Mercurial > pidgin.yaz
changeset 17355:9c5b1dc7404f
Change msim_msg_debug_string() to msim_msg_dump(), which prints the string
using purple_debug_info() using a given formatting string. Simplifies usage.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Mon, 04 Jun 2007 01:59:20 +0000 |
parents | c2208b64bffb |
children | c6305f8845d8 |
files | libpurple/protocols/myspace/message.c libpurple/protocols/myspace/message.h libpurple/protocols/myspace/myspace.c |
diffstat | 3 files changed, 19 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c Sun Jun 03 05:50:11 2007 +0000 +++ b/libpurple/protocols/myspace/message.c Mon Jun 04 01:59:20 2007 +0000 @@ -291,7 +291,7 @@ } /** Pack a string using the given GFunc and seperator. - * Used by msim_msg_debug_string() and msim_msg_pack(). + * Used by msim_msg_dump() and msim_msg_pack(). */ static gchar *msim_msg_pack_using(MsimMessage *msg, GFunc gf, gchar *sep, gchar *begin, gchar *end) { @@ -384,18 +384,25 @@ ++(*items); } -/** Return a human-readable string of the message. +/** Print a human-readable string of the message to Purple's debug log. * - * @return A string. Caller must g_free(). + * @param fmt_string A static string, in which '%s' will be replaced. */ -gchar *msim_msg_debug_string(MsimMessage *msg) +void msim_msg_dump(gchar *fmt_string, MsimMessage *msg) { + gchar *debug_str; + if (!msg) { - return g_strdup("<MsimMessage: empty>"); + debug_str = g_strdup("<MsimMessage: empty>"); + } else { + debug_str = msim_msg_pack_using(msg, msim_msg_debug_string_element, + "\n", "<MsimMessage: \n", "\n/MsimMessage>"); } - return msim_msg_pack_using(msg, msim_msg_debug_string_element, "\n", "<MsimMessage: \n", "\n/MsimMessage>"); + purple_debug_info("msim", fmt_string, debug_str); + + g_free(debug_str); } /** Return a message element data as a new string for a raw protocol message, converting from other types (integer, etc.) if necessary.
--- a/libpurple/protocols/myspace/message.h Sun Jun 03 05:50:11 2007 +0000 +++ b/libpurple/protocols/myspace/message.h Mon Jun 04 01:59:20 2007 +0000 @@ -48,7 +48,7 @@ MsimMessage *msim_msg_clone(MsimMessage *old); void msim_msg_free(MsimMessage *msg); MsimMessage *msim_msg_append(MsimMessage *msg, gchar *name, MsimMessageType type, gpointer data); -gchar *msim_msg_debug_string(MsimMessage *msg); +void msim_msg_dump(char *fmt_string, MsimMessage *msg); gchar *msim_msg_pack(MsimMessage *msg); /* Defined in myspace.h */
--- a/libpurple/protocols/myspace/myspace.c Sun Jun 03 05:50:11 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.c Mon Jun 04 01:59:20 2007 +0000 @@ -830,11 +830,7 @@ #ifdef MSIM_DEBUG_MSG { - gchar *debug_msg; - - debug_msg = msim_msg_debug_string(msg); - purple_debug_info("msim", "%s\n", debug_msg); - g_free(debug_msg); + msim_msg_dump("ready to process: %s\n", msg); } #endif @@ -1087,6 +1083,8 @@ /* TODO: sometimes (when click on it), buddy list disappears. Fix. */ purple_blist_add_buddy(buddy, NULL, NULL, NULL); + //purple_blist_set_int(&buddy->node, "uid", XYZ); + exit(0); } else { purple_debug_info("msim", "msim_status: found buddy %s\n", username); } @@ -1364,12 +1362,7 @@ * clone message if it wants to keep it afterwards.) */ if (!msim_process(gc, msg)) { - gchar *dbs; - - dbs = msim_msg_debug_string(msg); - purple_debug_info("msim", "msim_input_cb: processing message failed on msg: %s\n", - dbs); - g_free(dbs); + msim_msg_dump("msim_input_cb: processing message failed on msg: %s\n", msg); } msim_msg_free(msg); } @@ -1789,6 +1782,7 @@ msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); purple_debug_info("msim", "msg debug str=%s\n", msim_msg_debug_string(msg)); + msim_msg_debug_dump("msg debug str=%s\n", msg); purple_debug_info("msim", "msg packed=%s\n", msim_msg_pack(msg)); purple_debug_info("msim", "msg cloned=%s\n", msim_msg_pack(msim_msg_clone(msg))); msim_msg_free(msg);