cpw.darkrain42.roster: 0a50fd4c: Debug output when changing group members...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Jun 21 18:20:34 EDT 2009


-----------------------------------------------------------------
Revision: 0a50fd4c5f86432fdee427858cd39dcfffb8c466
Ancestor: 31cd08b695486b425c3178512fe9474a4bf53943
Author: darkrain42 at pidgin.im
Date: 2009-06-10T04:22:21
Branch: im.pidgin.cpw.darkrain42.roster
URL: http://d.pidgin.im/viewmtn/revision/info/0a50fd4c5f86432fdee427858cd39dcfffb8c466

Modified files:
        libpurple/protocols/jabber/roster.c

ChangeLog: 

Debug output when changing group memberships.

This would have helped debugging #7008.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/roster.c	becd141095c32132af66d96f091a57c959223b83
+++ libpurple/protocols/jabber/roster.c	63120e244700f7b4c8a393238047e6816da91add
@@ -31,6 +31,19 @@
 
 #include <string.h>
 
+/* Take a list of strings and join them with a ", " separator */
+static gchar *roster_groups_join(GSList *list)
+{
+	GString *out = g_string_new(NULL);
+	for ( ; list; list = list->next) {
+		out = g_string_append(out, (const char *)list->data);
+		if (list->next)
+			out = g_string_append(out, ", ");
+	}
+
+	return g_string_free(out, FALSE);
+}
+
 void jabber_roster_request(JabberStream *js)
 {
 	JabberIq *iq;
@@ -56,7 +69,7 @@ static void add_purple_buddy_to_groups(J
 		const char *alias, GSList *groups, const char *own_jid)
 {
 	GSList *buddies, *l;
-	GList *pool = NULL;
+	GSList *pool = NULL;
 
 	buddies = purple_find_buddies(js->gc->account, jid);
 
@@ -100,10 +113,24 @@ static void add_purple_buddy_to_groups(J
 			groups = g_slist_delete_link(groups, l);
 		} else {
 			/* This buddy isn't in the group on the server anymore */
-			pool = g_list_prepend(pool, b);
+			pool = g_slist_prepend(pool, b);
 		}
 	}
 
+	if (pool) {
+		char *tmp = roster_groups_join(pool);
+		purple_debug_info("jabber", "jabber_roster_parse(): Removing %s from "
+		                  "groups: %s\n", jid, tmp);
+		g_free(tmp);
+	}
+
+	if (groups) {
+		char *tmp = roster_groups_join(groups);
+		purple_debug_info("jabber", "jabber_roster_parse(): Adding %s to "
+		                  "groups: %s\n", jid, tmp);
+		g_free(tmp);
+	}
+
 	while(groups) {
 		PurpleGroup *g = purple_find_group(groups->data);
 		PurpleBuddy *b = NULL;
@@ -113,7 +140,7 @@ static void add_purple_buddy_to_groups(J
 		 */
 		if (pool) {
 			b = pool->data;
-			pool = g_list_delete_link(pool, pool);
+			pool = g_slist_delete_link(pool, pool);
 		} else {
 			b = purple_buddy_new(js->gc->account, jid, alias);
 		}
@@ -141,7 +168,7 @@ static void add_purple_buddy_to_groups(J
 	while (pool) {
 		PurpleBuddy *b = pool->data;
 		purple_blist_remove_buddy(b);
-		pool = g_list_delete_link(pool, pool);
+		pool = g_slist_delete_link(pool, pool);
 	}
 
 	g_slist_free(buddies);
@@ -255,22 +282,15 @@ static void jabber_roster_update(JabberS
 		return;
 
 	if(grps) {
-		GString *out = g_string_new(NULL);
+		char *tmp = roster_groups_join(groups);
 		groups = grps;
 
-		for (l = groups; l; l = l->next) {
-			out = g_string_append(out, (const char *)l->data);
-			if (l->next)
-				out = g_string_append(out, ", ");
-		}
-
 		purple_debug_info("jabber", "jabber_roster_update(%s): [Source: grps]: groups: %s\n",
-		                  name, out->str);
-		g_string_free(out, TRUE);
-
+		                  name, tmp);
+		g_free(tmp);
 	} else {
 		GSList *buddies = purple_find_buddies(js->gc->account, name);
-		GString *out = g_string_new(NULL);
+		char *tmp;
 
 		if(!buddies)
 			return;
@@ -280,15 +300,11 @@ static void jabber_roster_update(JabberS
 			groups = g_slist_append(groups, (char *)purple_group_get_name(g));
 			buddies = g_slist_remove(buddies, b);
 		}
-		for (l = groups; l; l = l->next) {
-			out = g_string_append(out, (const char *)l->data);
-			if (l->next)
-				out = g_string_append(out, ", ");
-		}
 
+		tmp = roster_groups_join(groups);
 		purple_debug_info("jabber", "jabber_roster_update(%s): [Source: local blist]: groups: %s\n",
-		                  name, out->str);
-		g_string_free(out, TRUE);
+		                  name, tmp);
+		g_free(tmp);
 	}
 
 	iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");


More information about the Commits mailing list