changeset 27499:efb40ca43589

Debug output when changing group memberships. This would have helped debugging #7008.
author Paul Aurich <paul@darkrain42.org>
date Wed, 10 Jun 2009 04:22:21 +0000
parents ff640fedbfde
children b9da56683499
files libpurple/protocols/jabber/roster.c
diffstat 1 files changed, 38 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/roster.c	Wed Jun 10 03:58:11 2009 +0000
+++ b/libpurple/protocols/jabber/roster.c	Wed Jun 10 04:22:21 2009 +0000
@@ -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 @@
 		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 @@
 			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 @@
 		 */
 		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 @@
 	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 @@
 		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 @@
 			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");