diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-03-06 19:51:25 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-03-06 19:51:25 +0800 |
commit | 997336d0f9c77afa7bd229d96e60979fb4eaf23c (patch) | |
tree | 15ce1910f550b60ed920271644598be24c482501 | |
parent | d78ab99f9c8eb7952f502cfb81a9bb0274b210df (diff) | |
download | gsoc2013-empathy-997336d0f9c77afa7bd229d96e60979fb4eaf23c.tar gsoc2013-empathy-997336d0f9c77afa7bd229d96e60979fb4eaf23c.tar.gz gsoc2013-empathy-997336d0f9c77afa7bd229d96e60979fb4eaf23c.tar.bz2 gsoc2013-empathy-997336d0f9c77afa7bd229d96e60979fb4eaf23c.tar.lz gsoc2013-empathy-997336d0f9c77afa7bd229d96e60979fb4eaf23c.tar.xz gsoc2013-empathy-997336d0f9c77afa7bd229d96e60979fb4eaf23c.tar.zst gsoc2013-empathy-997336d0f9c77afa7bd229d96e60979fb4eaf23c.zip |
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>
svn path=/trunk/; revision=2580
-rw-r--r-- | libempathy/empathy-log-manager.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c index f734a184d..54e9a62f3 100644 --- a/libempathy/empathy-log-manager.c +++ b/libempathy/empathy-log-manager.c @@ -173,6 +173,17 @@ empathy_log_manager_exists (EmpathyLogManager *manager, 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 @@ empathy_log_manager_get_dates (EmpathyLogManager *manager, 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; |