changeset 30904:91d3b40a2f70

No need to clutter the debug log with dozens of lines when the information can fit on one, increasing readability.
author ivan.komarov@soc.pidgin.im
date Fri, 05 Nov 2010 00:37:23 +0000
parents f8f853ab3aba
children 58b013a3a2d4
files libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscar_data.c libpurple/protocols/oscar/rxhandlers.c
diffstat 3 files changed, 61 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Thu Nov 04 23:38:20 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Fri Nov 05 00:37:23 2010 +0000
@@ -616,17 +616,37 @@
 	ICQ_DEFAULT_SSL_LOGIN_SERVER,
 };
 
-static const gchar *get_login_server(gboolean is_icq, gboolean use_ssl)
+static const gchar *
+get_login_server(gboolean is_icq, gboolean use_ssl)
 {
 	return login_servers[(is_icq ? 2 : 0) + (use_ssl ? 1 : 0)];
 }
 
+static gint
+compare_handlers(gconstpointer a, gconstpointer b)
+{
+	guint aa = GPOINTER_TO_UINT(a);
+	guint bb = GPOINTER_TO_UINT(b);
+	guint family1 = aa >> 16;
+	guint family2 = bb >> 16;
+	guint subtype1 = aa & 0xFFFF;
+	guint subtype2 = bb & 0xFFFF;
+	if (family1 != family2) {
+		return family1 - family2;
+	}
+	return subtype1 - subtype2;
+}
+
 void
 oscar_login(PurpleAccount *account)
 {
 	PurpleConnection *gc;
 	OscarData *od;
 	const gchar *encryption_type;
+	GList *handlers;
+	GList *sorted_handlers;
+	GList *cur;
+	GString *msg = g_string_new("");
 
 	gc = purple_account_get_connection(account);
 	od = oscar_data_new();
@@ -685,6 +705,18 @@
 	oscar_data_addhandler(od, SNAC_FAMILY_USERLOOKUP, SNAC_SUBTYPE_USERLOOKUP_ERROR, purple_parse_searcherror, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_USERLOOKUP, 0x0003, purple_parse_searchreply, 0);
 
+	g_string_append(msg, "Registered handlers: ");
+	handlers = g_hash_table_get_keys(od->handlerlist);
+	sorted_handlers = g_list_sort(g_list_copy(handlers), compare_handlers);
+	for (cur = sorted_handlers; cur; cur = cur->next) {
+		guint x = GPOINTER_TO_UINT(cur->data);
+		g_string_append_printf(msg, "%04x/%04x, ", x >> 16, x & 0xFFFF);
+	}
+	g_list_free(sorted_handlers);
+	g_list_free(handlers);
+	purple_debug_misc("oscar", "%s\n", msg->str);
+	g_string_free(msg, TRUE);
+
 	purple_debug_misc("oscar", "oscar_login: gc = %p\n", gc);
 
 	if (!oscar_util_valid_name(purple_account_get_username(account))) {
@@ -2387,6 +2419,7 @@
 
 	switch(type) {
 		case 0x0002: {
+			GString *msg = g_string_new("");
 			guint8 maxrooms;
 			struct aim_chat_exchangeinfo *exchanges;
 			int exchangecount, i;
@@ -2395,15 +2428,17 @@
 			exchangecount = va_arg(ap, int);
 			exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
 
-			purple_debug_misc("oscar", "chat info: Chat Rights:\n");
-			purple_debug_misc("oscar",
-					   "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms);
-			purple_debug_misc("oscar",
-					   "chat info: \tExchange List: (%d total)\n", exchangecount);
-			for (i = 0; i < exchangecount; i++)
-				purple_debug_misc("oscar",
-						   "chat info: \t\t%hu    %s\n",
-						   exchanges[i].number, exchanges[i].name ? exchanges[i].name : "");
+			g_string_append_printf(msg, "chat info: Max Concurrent Rooms: %hhd, Exchange List (%d total): ", maxrooms, exchangecount);
+			for (i = 0; i < exchangecount; i++) {
+				g_string_append_printf(msg, "%hu", exchanges[i].number);
+				if (exchanges[i].name) {
+					g_string_append_printf(msg, " %s", exchanges[i].name);
+				}
+				g_string_append(msg, ", ");
+			}
+			purple_debug_misc("oscar", "%s\n", msg->str);
+			g_string_free(msg, TRUE);
+
 			while (od->create_rooms) {
 				struct create_room *cr = od->create_rooms->data;
 				purple_debug_info("oscar",
--- a/libpurple/protocols/oscar/oscar_data.c	Thu Nov 04 23:38:20 2010 +0000
+++ b/libpurple/protocols/oscar/oscar_data.c	Fri Nov 05 00:37:23 2010 +0000
@@ -37,6 +37,8 @@
 oscar_data_new(void)
 {
 	OscarData *od;
+	aim_module_t *cur;
+	GString *msg;
 
 	od = g_new0(OscarData, 1);
 
@@ -70,6 +72,20 @@
 	aim__registermodule(od, auth_modfirst);
 	aim__registermodule(od, email_modfirst);
 
+	msg = g_string_new("Registered modules: ");
+	for (cur = od->modlistv; cur; cur = cur->next) {
+		g_string_append_printf(
+			msg,
+			"%s (family=0x%04x, version=0x%04x, toolid=0x%04x, toolversion=0x%04x), ",
+			cur->name,
+			cur->family,
+			cur->version,
+			cur->toolid,
+			cur->toolversion);
+	}
+	purple_debug_misc("oscar", "%s\n", msg->str);
+	g_string_free(msg, TRUE);
+
 	return od;
 }
 
@@ -118,8 +134,6 @@
 {
 	SnacHandler *snac_handler;
 
-	purple_debug_misc("oscar", "Adding handler for %04x/%04x\n", family, subtype);
-
 	snac_handler = g_new0(SnacHandler, 1);
 
 	snac_handler->family = family;
--- a/libpurple/protocols/oscar/rxhandlers.c	Thu Nov 04 23:38:20 2010 +0000
+++ b/libpurple/protocols/oscar/rxhandlers.c	Fri Nov 05 00:37:23 2010 +0000
@@ -69,8 +69,6 @@
 	mod->next = (aim_module_t *)od->modlistv;
 	od->modlistv = mod;
 
-	purple_debug_misc("oscar", "registered module %s (family 0x%04x, version = 0x%04x, tool 0x%04x, tool version 0x%04x)\n", mod->name, mod->family, mod->version, mod->toolid, mod->toolversion);
-
 	return 0;
 }