empathy r2580 - trunk/libempathy



Author: xclaesse
Date: Fri Mar  6 11:51:25 2009
New Revision: 2580
URL: http://svn.gnome.org/viewvc/empathy?rev=2580&view=rev

Log:
Make get_dates check whether a date is already in the GList before adding it now in order. (Jonny Lamb)

Signed-off-by: Jonny Lamb <jonny lamb collabora co uk>

Modified:
   trunk/libempathy/empathy-log-manager.c

Modified: trunk/libempathy/empathy-log-manager.c
==============================================================================
--- trunk/libempathy/empathy-log-manager.c	(original)
+++ trunk/libempathy/empathy-log-manager.c	Fri Mar  6 11:51:25 2009
@@ -173,6 +173,17 @@
   return FALSE;
 }
 
+static void
+log_manager_get_dates_foreach (gpointer data,
+                               gpointer user_data)
+{
+  /* g_list_first is needed in case an older date was last inserted */
+  GList *orig = g_list_first (user_data);
+
+  if (g_list_find_custom (orig, data, (GCompareFunc) strcmp))
+    orig = g_list_insert_sorted (orig, g_strdup (data), (GCompareFunc) strcmp);
+}
+
 GList *
 empathy_log_manager_get_dates (EmpathyLogManager *manager,
                                McAccount *account,
@@ -198,9 +209,16 @@
       if (!out)
         out = source->get_dates (manager, account, chat_id, chatroom);
       else
-        /* TODO fix this */
-        out = g_list_concat (out, source->get_dates (manager, account,
-              chat_id, chatroom));
+        {
+          GList *new = source->get_dates (manager, account, chat_id, chatroom);
+          g_list_foreach (new, log_manager_get_dates_foreach, out);
+
+          g_list_foreach (new, (GFunc) g_free, NULL);
+          g_list_free (new);
+
+          /* Similar reason for using g_list_first here as before */
+          out = g_list_first (out);
+        }
     }
 
   return out;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]