From 9a58dec61023dd6d97d1b7ee17dab923c33ca63b Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@msavard.(none)>
Date: Tue, 21 Jun 2011 15:51:12 -0400
Subject: [PATCH] #6233: Fix history

---
 sflphone-client-gnome/src/contacts/calllist.c |  6 ++--
 sflphone-client-gnome/src/contacts/calltree.c | 11 +++++---
 .../src/contacts/conferencelist.c             | 28 +++++++++++++++++--
 .../src/contacts/conferencelist.h             |  4 +++
 sflphone-client-gnome/src/uimanager.c         |  4 +++
 5 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/sflphone-client-gnome/src/contacts/calllist.c b/sflphone-client-gnome/src/contacts/calllist.c
index ab95bd03c6..986ff5a651 100644
--- a/sflphone-client-gnome/src/contacts/calllist.c
+++ b/sflphone-client-gnome/src/contacts/calllist.c
@@ -154,13 +154,13 @@ calllist_add_call (calltab_t* tab, callable_obj_t * c)
     g_queue_push_tail (tab->callQueue, (gpointer *) element);
 }
 
-// TODO : sflphoneGTK : try to do this more generic
 void
 calllist_clean_history (void)
 {
-    unsigned int i;
+    guint i;
     guint size = calllist_get_size (history);
-    DEBUG ("CallList: History list size = %i", calllist_get_size (history));
+
+    DEBUG ("CallList: History list size %d", size);
 
     for (i = 0 ; i < size; i++) {
         QueueElement* c = calllist_get_nth (history , i);
diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c
index c7f7a9ad1e..bc38ed0f30 100644
--- a/sflphone-client-gnome/src/contacts/calltree.c
+++ b/sflphone-client-gnome/src/contacts/calltree.c
@@ -1360,7 +1360,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf)
 
 void calltree_update_conference (calltab_t* tab, const conference_obj_t* conf)
 {
-    DEBUG ("CallTree: Update conference %s\n", conf->_confID);
+    DEBUG ("CallTree: Update conference %s", conf->_confID);
 
     calltree_remove_conference(tab, conf, NULL);
     calltree_add_conference (tab, (conference_obj_t *)conf);
@@ -1379,7 +1379,7 @@ void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, G
     int nbParticipant;
     int i, j;
    	
-    DEBUG ("CallTree: Remove conference %s\n", conf->_confID);
+    DEBUG ("CallTree: Remove conference %s", conf->_confID);
 
     int nbChild = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), parent);
 
@@ -1414,8 +1414,11 @@ void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, G
                             g_value_unset (&callval);
 
                             if (call) {
-                                calltree_add_call (tab, call, NULL);
-                            }
+				// do not add back call in history calltree when cleaning it
+				if(tab != history) {
+                                    calltree_add_call (tab, call, NULL);
+                                }
+			    }
                         }
 
                     }
diff --git a/sflphone-client-gnome/src/contacts/conferencelist.c b/sflphone-client-gnome/src/contacts/conferencelist.c
index 399cee58aa..fd70311994 100644
--- a/sflphone-client-gnome/src/contacts/conferencelist.c
+++ b/sflphone-client-gnome/src/contacts/conferencelist.c
@@ -28,8 +28,8 @@
  *  as that of the covered work.
  */
 
-#include <conferencelist.h>
-
+#include "calltree.h"
+#include "conferencelist.h"
 #include "logger.h"
 
 static gint is_confID_confstruct(gconstpointer, gconstpointer);
@@ -78,6 +78,30 @@ void conferencelist_clean(calltab_t *tab)
     g_queue_free (tab->conferenceQueue);
 }
 
+void
+conferencelist_clean_history(void)
+{
+    conference_obj_t *conf;
+    guint size = conferencelist_get_size(history);
+    guint i;
+
+    DEBUG("ConferenceList: clean history");
+
+    while(size > 0) {
+        conf = conferencelist_pop_head(history);
+	if(conf) {
+	    calltree_remove_conference(history, conf, NULL);
+	}
+	else {
+	    ERROR("ConferenceList: Conference pointer is NULL");
+        }
+	size = conferencelist_get_size(history);
+    }
+
+    // g_queue_free(history->conferenceQueue); 
+
+}
+
 
 void conferencelist_reset(calltab_t *tab)
 {
diff --git a/sflphone-client-gnome/src/contacts/conferencelist.h b/sflphone-client-gnome/src/contacts/conferencelist.h
index f09060b850..1fb288e45f 100644
--- a/sflphone-client-gnome/src/contacts/conferencelist.h
+++ b/sflphone-client-gnome/src/contacts/conferencelist.h
@@ -50,6 +50,10 @@ conferencelist_init (calltab_t *);
 void
 conferencelist_clean (calltab_t *);
 
+/** This function empty and free the history conference list */
+void
+conferencelist_clean_history (void);
+
 /** This function empty, free the conference list and allocate a new one. */
 void
 conferencelist_reset (calltab_t *);
diff --git a/sflphone-client-gnome/src/uimanager.c b/sflphone-client-gnome/src/uimanager.c
index 6d0817b9b1..832e72726e 100644
--- a/sflphone-client-gnome/src/uimanager.c
+++ b/sflphone-client-gnome/src/uimanager.c
@@ -875,6 +875,10 @@ edit_paste (void * foo UNUSED)
 static void
 clear_history (void)
 {
+    if(conferencelist_get_size(history) != 0) {
+	conferencelist_clean_history();
+    }
+
     if (calllist_get_size (history) != 0) {
         calllist_clean_history();
     }
-- 
GitLab