changeset 19455:6950ffd2291f

Update the buddylist if a buddy is moved to another group from a different simultaneous login.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 26 Aug 2007 20:35:40 +0000
parents a650c8294bd2
children f2a193f3bc90
files libpurple/protocols/jabber/roster.c
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/roster.c	Sun Aug 26 19:08:29 2007 +0000
+++ b/libpurple/protocols/jabber/roster.c	Sun Aug 26 20:35:40 2007 +0000
@@ -58,6 +58,7 @@
 {
 	GSList *buddies, *g2, *l;
 	gchar *my_bare_jid;
+	GList *pool = NULL;
 
 	buddies = purple_find_buddies(js->gc->account, jid);
 
@@ -89,13 +90,20 @@
 			g_free(l->data);
 			g2 = g_slist_delete_link(g2, l);
 		} else {
-			purple_blist_remove_buddy(b);
+			pool = g_list_prepend(pool, b);
 		}
 	}
 
 	while(g2) {
-		PurpleBuddy *b = purple_buddy_new(js->gc->account, jid, alias);
 		PurpleGroup *g = purple_find_group(g2->data);
+		PurpleBuddy *b = NULL;
+
+		if (pool) {
+			b = pool->data;
+			pool = g_list_delete_link(pool, pool);
+		} else {			
+			b = purple_buddy_new(js->gc->account, jid, alias);
+		}
 
 		if(!g) {
 			g = purple_group_new(g2->data);
@@ -121,6 +129,12 @@
 		g2 = g_slist_delete_link(g2, g2);
 	}
 
+	while (pool) {
+		PurpleBuddy *b = pool->data;
+		purple_blist_remove_buddy(b);
+		pool = g_list_delete_link(pool, pool);
+	}
+
 	g_free(my_bare_jid);
 	g_slist_free(buddies);
 }