pidgin: a8840dd4: No need to clutter the debug log with do...

ivan.komarov at soc.pidgin.im ivan.komarov at soc.pidgin.im
Thu Nov 4 20:45:49 EDT 2010


----------------------------------------------------------------------
Revision: a8840dd42182ddf786129279eef4a242de2fcd7b
Parent:   ec80b5b661b01c9cd3e2666129b5472b8f261fe2
Author:   ivan.komarov at soc.pidgin.im
Date:     11/04/10 20:37:23
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a8840dd42182ddf786129279eef4a242de2fcd7b

Changelog: 

No need to clutter the debug log with dozens of lines when
the information can fit on one, increasing readability.

Changes against parent ec80b5b661b01c9cd3e2666129b5472b8f261fe2

  patched  libpurple/protocols/oscar/oscar.c
  patched  libpurple/protocols/oscar/oscar_data.c
  patched  libpurple/protocols/oscar/rxhandlers.c

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/oscar.c	4a37d1a1245efc957098fad392198614a4b3a6b8
+++ libpurple/protocols/oscar/oscar.c	ea3d3962582dd7fb3715e76a29d159bc59dbedd3
@@ -616,17 +616,37 @@ static const gchar *login_servers[] = {
 	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_login(PurpleAccount *account)
 	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 @@ static int purple_chatnav_info(OscarData
 
 	switch(type) {
 		case 0x0002: {
+			GString *msg = g_string_new("");
 			guint8 maxrooms;
 			struct aim_chat_exchangeinfo *exchanges;
 			int exchangecount, i;
@@ -2395,15 +2428,17 @@ static int purple_chatnav_info(OscarData
 			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",
============================================================
--- libpurple/protocols/oscar/rxhandlers.c	39fa235b8be986848882c0add9171ebc225f1e28
+++ libpurple/protocols/oscar/rxhandlers.c	1ec3dbfdcaac866e3be08e83d4ef93b1e479b710
@@ -69,8 +69,6 @@ int aim__registermodule(OscarData *od, i
 	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;
 }
 
============================================================
--- libpurple/protocols/oscar/oscar_data.c	2e5613370106f9c793078dfeb71aebacef90789f
+++ libpurple/protocols/oscar/oscar_data.c	9f8e42b1a0c7a2c694546009b916fff2c1339cd6
@@ -37,6 +37,8 @@ oscar_data_new(void)
 oscar_data_new(void)
 {
 	OscarData *od;
+	aim_module_t *cur;
+	GString *msg;
 
 	od = g_new0(OscarData, 1);
 
@@ -70,6 +72,20 @@ oscar_data_new(void)
 	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 @@ oscar_data_addhandler(OscarData *od, gui
 {
 	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;


More information about the Commits mailing list