Mercurial > pidgin.yaz
changeset 27393:319b0f3dd2d0
merge of '034300b33708a7dbb7856d91c3098493b2dffa34'
and 'adf7d277ae63ff767e0db40965e3eee80cec5e46'
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sun, 05 Jul 2009 02:26:03 +0000 |
parents | 304fef974f28 (current diff) 377e063ecda5 (diff) |
children | 16ef6a9e7acd f92e2fdfeda4 |
files | ChangeLog |
diffstat | 12 files changed, 145 insertions(+), 67 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Jul 05 00:07:03 2009 +0000 +++ b/ChangeLog Sun Jul 05 02:26:03 2009 +0000 @@ -26,6 +26,10 @@ PURPLE_GNUTLS_DEBUG environment variable, which is an integer between 0 and 9 (higher is more verbose). Higher values may reveal sensitive information. + * PURPLE_VERBOSE_DEBUG environment variable. Currently this is an "on" or + "off" variable. Set it to any value to turn it on and unset it to turn + it off. This will optionally be used to only show less useful debug + information on an as-needed basis. Gadu-Gadu: * Accounts can specify a server to which to connect.
--- a/ChangeLog.API Sun Jul 05 00:07:03 2009 +0000 +++ b/ChangeLog.API Sun Jul 05 02:26:03 2009 +0000 @@ -30,6 +30,10 @@ * purple_connection_set_protocol_data * purple_contact_destroy * purple_conv_chat_invite_user + * purple_debug_is_unsafe + * purple_debug_is_verbose + * purple_debug_set_unsafe + * purple_debug_set_verbose * purple_global_proxy_set_info * purple_group_destroy * purple_log_get_activity_score
--- a/libpurple/debug.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/debug.c Sun Jul 05 02:26:03 2009 +0000 @@ -36,12 +36,20 @@ * * It doesn't make sense to make this a normal Purple preference * because it's a command line option. This will always be FALSE, - * unless the user explicitly started Purple with the -d flag. + * unless the user explicitly started the UI with the -d flag. * It doesn't matter what this value was the last time Purple was * started, so it doesn't make sense to save it in prefs. */ static gboolean debug_enabled = FALSE; +/* + * These determine whether verbose or unsafe debugging are desired. I + * don't want to make these purple preferences because their values should + * not be remembered across instances of the UI. + */ +static gboolean debug_verbose = FALSE; +static gboolean debug_unsafe = FALSE; + static void purple_debug_vargs(PurpleDebugLevel level, const char *category, const char *format, va_list args) @@ -175,6 +183,30 @@ debug_ui_ops = ops; } +gboolean +purple_debug_is_verbose() +{ + return debug_verbose; +} + +void +purple_debug_set_verbose(gboolean verbose) +{ + debug_verbose = verbose; +} + +gboolean +purple_debug_is_unsafe() +{ + return debug_unsafe; +} + +void +purple_debug_set_unsafe(gboolean unsafe) +{ + debug_unsafe = unsafe; +} + PurpleDebugUiOps * purple_debug_get_ui_ops(void) { @@ -184,6 +216,13 @@ void purple_debug_init(void) { + /* Read environment variables once per init */ + if(g_getenv("PURPLE_UNSAFE_DEBUG")) + purple_debug_set_unsafe(TRUE); + + if(g_getenv("PURPLE_VERBOSE_DEBUG")) + purple_debug_set_verbose(TRUE); + purple_prefs_add_none("/purple/debug"); /* @@ -193,3 +232,4 @@ */ purple_prefs_add_bool("/purple/debug/timestamps", TRUE); } +
--- a/libpurple/debug.h Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/debug.h Sun Jul 05 02:26:03 2009 +0000 @@ -151,10 +151,50 @@ /** * Check if console debug output is enabled. * - * @return TRUE if debuggin is enabled, FALSE if it is not. + * @return TRUE if debugging is enabled, FALSE if it is not. */ gboolean purple_debug_is_enabled(void); +/** + * Enable or disable verbose debugging. This ordinarily should only be called + * by #purple_debug_init, but there are cases where this can be useful for + * plugins. + * + * @param verbose TRUE to enable verbose debugging or FALSE to disable it. + * + * @since 2.6.0 + */ +void purple_debug_set_verbose(gboolean verbose); + +/** + * Check if verbose logging is enabled. + * + * @return TRUE if verbose debugging is enabled, FALSE if it is not. + * + * @since 2.6.0 + */ +gboolean purple_debug_is_verbose(void); + +/** + * Enable or disable verbose debugging. This ordinarily should only be called + * by #purple_debug_init, but there are cases where this can be useful for + * plugins. + * + * @param unsafe TRUE to enable verbose debugging or FALSE to disable it. + * + * @since 2.6.0 + */ +void purple_debug_set_unsafe(gboolean unsafe); + +/** + * Check if unsafe debugging is enabled. + * + * @return TRUE if verbose debugging is enabled, FALSE if it is not. + * + * @since 2.6.0 + */ +gboolean purple_debug_is_unsafe(void); + /*@}*/ /**************************************************************************/
--- a/libpurple/protocols/msn/soap.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/protocols/msn/soap.c Sun Jul 05 02:26:03 2009 +0000 @@ -80,7 +80,7 @@ conn->session = session; conn->host = g_strdup(host); conn->queue = g_queue_new(); - conn->unsafe_debug = g_getenv("PURPLE_UNSAFE_DEBUG") != NULL; + conn->unsafe_debug = purple_debug_is_unsafe(); return conn; }
--- a/libpurple/protocols/yahoo/util.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/protocols/yahoo/util.c Sun Jul 05 02:26:03 2009 +0000 @@ -354,7 +354,7 @@ else if ((match = (char *) g_hash_table_lookup(ht, tmp->str))) g_string_append(s, match); else { - purple_debug(PURPLE_DEBUG_ERROR, "yahoo", + purple_debug_error("yahoo", "Unknown ansi code 'ESC[%sm'.\n", tmp->str); g_string_free(tmp, TRUE); break; @@ -423,7 +423,7 @@ ret = s->str; g_string_free(s, FALSE); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", "yahoo_codes_to_html: Returning string: '%s'.\n", ret); + purple_debug_misc("yahoo", "yahoo_codes_to_html: Returning string: '%s'.\n", ret); return ret; } @@ -822,7 +822,7 @@ g_string_free(dest, FALSE); esc = g_strescape(ret, NULL); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", "yahoo_html_to_codes: Returning string: '%s'.\n", esc); + purple_debug_misc("yahoo", "yahoo_html_to_codes: Returning string: '%s'.\n", esc); g_free(esc); yahoo_htc_queue_cleanup(colors);
--- a/libpurple/protocols/yahoo/yahoo.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Sun Jul 05 02:26:03 2009 +0000 @@ -390,7 +390,7 @@ b = i->data; g = purple_buddy_get_group(b); if (!purple_utf8_strcasecmp(group, purple_group_get_name(g))) { - purple_debug(PURPLE_DEBUG_MISC, "yahoo", + purple_debug_misc("yahoo", "Oh good, %s is in the right group (%s).\n", name, group); list = g_slist_delete_link(list, i); onlist = 1; @@ -399,7 +399,7 @@ } if (!onlist) { - purple_debug(PURPLE_DEBUG_MISC, "yahoo", + purple_debug_misc("yahoo", "Uhoh, %s isn't on the list (or not in this group), adding him to group %s.\n", name, group); if (!(g = purple_find_group(group))) { g = purple_group_new(group); @@ -427,7 +427,7 @@ for (i = list; i; i = i->next) { b = i->data; g = purple_buddy_get_group(b); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, + purple_debug_misc("yahoo", "Deleting Buddy %s from group %s.\n", name, purple_group_get_name(g)); purple_blist_remove_buddy(b); } @@ -801,9 +801,8 @@ PurpleBuddy *bud = purple_find_buddy(account, from); if (!bud) { - purple_debug(PURPLE_DEBUG_WARNING, "yahoo", - "%s is playing a game, and doesn't want " - "you to know.\n", from); + purple_debug_warning("yahoo", + "%s is playing a game, and doesn't want you to know.\n", from); } f = yahoo_friend_find(gc, from); @@ -1943,8 +1942,7 @@ name = g_strdup(purple_buddy_get_name(buddy)); account = purple_buddy_get_account(buddy); - purple_debug(PURPLE_DEBUG_INFO, "blist", - "Removing '%s' from buddy list.\n", name); + purple_debug_info("yahoo", "blist: Removing '%s' from buddy list.\n", name); purple_account_remove_buddy(account, buddy, group); purple_blist_remove_buddy(buddy); @@ -2382,14 +2380,14 @@ pos += 2; pktlen = yahoo_get16(buf + pos); pos += 2; - purple_debug(PURPLE_DEBUG_MISC, "yahoo", "p2p: %d bytes to read\n", len); + purple_debug_misc("yahoo", "p2p: %d bytes to read\n", len); pkt = yahoo_packet_new(0, 0, 0); pkt->service = yahoo_get16(buf + pos); pos += 2; pkt->status = yahoo_get32(buf + pos); pos += 4; pkt->id = yahoo_get32(buf + pos); pos += 4; - purple_debug(PURPLE_DEBUG_MISC, "yahoo", "p2p: Yahoo Service: 0x%02x Status: %d\n",pkt->service, pkt->status); + purple_debug_misc("yahoo", "p2p: Yahoo Service: 0x%02x Status: %d\n",pkt->service, pkt->status); yahoo_packet_read(pkt, buf + pos, pktlen); /* packet processing */ @@ -2909,8 +2907,7 @@ break; default: - purple_debug(PURPLE_DEBUG_ERROR, "yahoo", - "Unhandled service 0x%02x\n", pkt->service); + purple_debug_error("yahoo", "Unhandled service 0x%02x\n", pkt->service); break; } } @@ -2979,8 +2976,7 @@ pos += 2; pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; - purple_debug(PURPLE_DEBUG_MISC, "yahoo", - "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); + purple_debug_misc("yahoo", "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) return; @@ -2991,8 +2987,7 @@ pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; - purple_debug(PURPLE_DEBUG_MISC, "yahoo", - "Yahoo Service: 0x%02x Status: %d\n", + purple_debug_misc("yahoo", "Yahoo Service: 0x%02x Status: %d\n", pkt->service, pkt->status); pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; @@ -4882,8 +4877,7 @@ gc = purple_conversation_get_gc(conv); yd = gc->proto_data; id = yd->conf_id; - purple_debug(PURPLE_DEBUG_INFO, "yahoo", - "Trying to join %s \n", args[0]); + purple_debug_info("yahoo", "Trying to join %s \n", args[0]); comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); g_hash_table_replace(comp, g_strdup("room"), g_ascii_strdown(args[0], -1)); @@ -4920,8 +4914,8 @@ g_return_val_if_fail(c != NULL, FALSE); - purple_debug(PURPLE_DEBUG_INFO, "yahoo", - "Sending <ding> on account %s to buddy %s.\n", username, c->name); + purple_debug_info("yahoo", "Sending <ding> on account %s to buddy %s.\n", + username, c->name); purple_conv_im_send_with_flags(PURPLE_CONV_IM(c), "<ding>", PURPLE_MESSAGE_INVISIBLE); return TRUE;
--- a/libpurple/protocols/yahoo/yahoo_filexfer.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/protocols/yahoo/yahoo_filexfer.c Sun Jul 05 02:26:03 2009 +0000 @@ -156,8 +156,8 @@ PurpleXfer *xfer; struct yahoo_xfer_data *xd; - purple_debug(PURPLE_DEBUG_INFO, "yahoo", - "AAA - in yahoo_receivefile_connected\n"); + purple_debug_info("yahoo", "in yahoo_receivefile_connected\n"); + if (!(xfer = data)) return; if (!(xd = xfer->data)) @@ -235,8 +235,8 @@ PurpleAccount *account; struct yahoo_data *yd; - purple_debug(PURPLE_DEBUG_INFO, "yahoo", - "AAA - in yahoo_sendfile_connected\n"); + purple_debug_info("yahoo", "in yahoo_sendfile_connected\n"); + if (!(xfer = data)) return; if (!(xd = xfer->data))
--- a/libpurple/protocols/yahoo/yahoo_packet.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/protocols/yahoo/yahoo_packet.c Sun Jul 05 02:26:03 2009 +0000 @@ -187,15 +187,12 @@ pos = x; pkt->hash = g_slist_prepend(pkt->hash, pair); -#ifdef DEBUG - { + if (purple_debug_is_verbose()) { char *esc; esc = g_strescape(pair->value, NULL); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", - "Key: %d \tValue: %s\n", pair->key, esc); + purple_debug_misc("yahoo", "Key: %d \tValue: %s\n", pair->key, esc); g_free(esc); } -#endif /* DEBUG */ } else { g_free(pair); } @@ -253,35 +250,35 @@ #ifdef YAHOO_DEBUG int i; - purple_debug(PURPLE_DEBUG_MISC, "yahoo", ""); + purple_debug_misc("yahoo", ""); for (i = 0; i + 1 < len; i += 2) { if ((i % 16 == 0) && i) { - purple_debug(PURPLE_DEBUG_MISC, NULL, "\n"); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", ""); + purple_debug_misc(NULL, "\n"); + purple_debug_misc("yahoo", ""); } - purple_debug(PURPLE_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]); + purple_debug_misc(NULL, "%02x%02x ", data[i], data[i + 1]); } if (i < len) - purple_debug(PURPLE_DEBUG_MISC, NULL, "%02x", data[i]); + purple_debug_misc(NULL, "%02x", data[i]); - purple_debug(PURPLE_DEBUG_MISC, NULL, "\n"); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", ""); + purple_debug_misc(NULL, "\n"); + purple_debug_misc("yahoo", ""); for (i = 0; i < len; i++) { if ((i % 16 == 0) && i) { - purple_debug(PURPLE_DEBUG_MISC, NULL, "\n"); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", ""); + purple_debug_misc(NULL, "\n"); + purple_debug_misc("yahoo", ""); } if (g_ascii_isprint(data[i])) - purple_debug(PURPLE_DEBUG_MISC, NULL, "%c ", data[i]); + purple_debug_misc(NULL, "%c ", data[i]); else - purple_debug(PURPLE_DEBUG_MISC, NULL, ". "); + purple_debug_misc(NULL, ". "); } - purple_debug(PURPLE_DEBUG_MISC, NULL, "\n"); + purple_debug_misc(NULL, "\n"); #endif /* YAHOO_DEBUG */ }
--- a/libpurple/protocols/yahoo/yahoochat.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/protocols/yahoo/yahoochat.c Sun Jul 05 02:26:03 2009 +0000 @@ -648,7 +648,7 @@ } if (!msg) { - purple_debug(PURPLE_DEBUG_MISC, "yahoo", "Got a message packet with no message.\nThis probably means something important, but we're ignoring it.\n"); + purple_debug_misc("yahoo", "Got a message packet with no message.\nThis probably means something important, but we're ignoring it.\n"); return; } msg2 = yahoo_string_decode(gc, msg, utf8);
--- a/libpurple/protocols/yahoo/ycht.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/protocols/yahoo/ycht.c Sun Jul 05 02:26:03 2009 +0000 @@ -196,35 +196,35 @@ #ifdef YAHOO_YCHT_DEBUG int i; - purple_debug(PURPLE_DEBUG_MISC, "yahoo", ""); + purple_debug_misc("yahoo", ""); for (i = 0; i + 1 < len; i += 2) { if ((i % 16 == 0) && i) { - purple_debug(PURPLE_DEBUG_MISC, NULL, "\n"); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", ""); + purple_debug_misc(NULL, "\n"); + purple_debug_misc("yahoo", ""); } - purple_debug(PURPLE_DEBUG_MISC, NULL, "%02hhx%02hhx ", data[i], data[i + 1]); + purple_debug_misc(NULL, "%02hhx%02hhx ", data[i], data[i + 1]); } if (i < len) - purple_debug(PURPLE_DEBUG_MISC, NULL, "%02hhx", data[i]); + purple_debug_misc(NULL, "%02hhx", data[i]); - purple_debug(PURPLE_DEBUG_MISC, NULL, "\n"); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", ""); + purple_debug_misc(NULL, "\n"); + purple_debug_misc("yahoo", ""); for (i = 0; i < len; i++) { if ((i % 16 == 0) && i) { - purple_debug(PURPLE_DEBUG_MISC, NULL, "\n"); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", ""); + purple_debug_misc(NULL, "\n"); + purple_debug_misc("yahoo", ""); } if (g_ascii_isprint(data[i])) - purple_debug(PURPLE_DEBUG_MISC, NULL, "%c ", data[i]); + purple_debug_misc(NULL, "%c ", data[i]); else - purple_debug(PURPLE_DEBUG_MISC, NULL, ". "); + purple_debug_misc(NULL, ". "); } - purple_debug(PURPLE_DEBUG_MISC, NULL, "\n"); + purple_debug_misc(NULL, "\n"); #endif /* YAHOO_YCHT_DEBUG */ } @@ -507,16 +507,15 @@ service = yahoo_get32(ycht->rxqueue + pos); pos += 4; status = yahoo_get16(ycht->rxqueue + pos); pos += 2; pktlen = yahoo_get16(ycht->rxqueue + pos); pos += 2; - purple_debug(PURPLE_DEBUG_MISC, "yahoo", - "ycht: %d bytes to read, rxlen is %d\n", pktlen, ycht->rxlen); + purple_debug_misc("yahoo", "ycht: %d bytes to read, rxlen is %d\n", + pktlen, ycht->rxlen); if (ycht->rxlen < (YCHT_HEADER_LEN + pktlen)) return; purple_debug_misc("yahoo", "--==Incoming YCHT packet==--\n"); - purple_debug(PURPLE_DEBUG_MISC, "yahoo", - "YCHT Service: 0x%02x Version: 0x%02x Status: 0x%02x\n", - service, version, status); + purple_debug_misc("yahoo", "YCHT Service: 0x%02x Version: 0x%02x Status: 0x%02x\n", + service, version, status); ycht_packet_dump(ycht->rxqueue, YCHT_HEADER_LEN + pktlen); pkt = ycht_packet_new(version, service, status);
--- a/libpurple/util.c Sun Jul 05 00:07:03 2009 +0000 +++ b/libpurple/util.c Sun Jul 05 02:26:03 2009 +0000 @@ -4042,7 +4042,7 @@ } } - if(g_getenv("PURPLE_UNSAFE_DEBUG")) + if(purple_debug_is_unsafe()) purple_debug_misc("util", "Request: '%s'\n", gfud->request); else purple_debug_misc("util", "request constructed\n"); @@ -4159,7 +4159,7 @@ g_return_val_if_fail(url != NULL, NULL); g_return_val_if_fail(callback != NULL, NULL); - if(g_getenv("PURPLE_UNSAFE_DEBUG")) + if(purple_debug_is_unsafe()) purple_debug_info("util", "requested to fetch (%s), full=%d, user_agent=(%s), http11=%d\n", url, full, user_agent?user_agent:"(null)", http11);