comparison libpurple/protocols/myspace/message.c @ 17298: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 437381cd780a
children 641c96277fa6
comparison
equal deleted inserted replaced
17297:c2208b64bffb 17298:9c5b1dc7404f
289 289
290 return g_list_append(msg, elem); 290 return g_list_append(msg, elem);
291 } 291 }
292 292
293 /** Pack a string using the given GFunc and seperator. 293 /** Pack a string using the given GFunc and seperator.
294 * Used by msim_msg_debug_string() and msim_msg_pack(). 294 * Used by msim_msg_dump() and msim_msg_pack().
295 */ 295 */
296 static gchar *msim_msg_pack_using(MsimMessage *msg, GFunc gf, gchar *sep, gchar *begin, gchar *end) 296 static gchar *msim_msg_pack_using(MsimMessage *msg, GFunc gf, gchar *sep, gchar *begin, gchar *end)
297 { 297 {
298 gchar **strings; 298 gchar **strings;
299 gchar **strings_tmp; 299 gchar **strings_tmp;
382 382
383 **items = string; 383 **items = string;
384 ++(*items); 384 ++(*items);
385 } 385 }
386 386
387 /** Return a human-readable string of the message. 387 /** Print a human-readable string of the message to Purple's debug log.
388 * 388 *
389 * @return A string. Caller must g_free(). 389 * @param fmt_string A static string, in which '%s' will be replaced.
390 */ 390 */
391 gchar *msim_msg_debug_string(MsimMessage *msg) 391 void msim_msg_dump(gchar *fmt_string, MsimMessage *msg)
392 { 392 {
393 gchar *debug_str;
394
393 if (!msg) 395 if (!msg)
394 { 396 {
395 return g_strdup("<MsimMessage: empty>"); 397 debug_str = g_strdup("<MsimMessage: empty>");
396 } 398 } else {
397 399 debug_str = msim_msg_pack_using(msg, msim_msg_debug_string_element,
398 return msim_msg_pack_using(msg, msim_msg_debug_string_element, "\n", "<MsimMessage: \n", "\n/MsimMessage>"); 400 "\n", "<MsimMessage: \n", "\n/MsimMessage>");
401 }
402
403 purple_debug_info("msim", fmt_string, debug_str);
404
405 g_free(debug_str);
399 } 406 }
400 407
401 /** Return a message element data as a new string for a raw protocol message, converting from other types (integer, etc.) if necessary. 408 /** Return a message element data as a new string for a raw protocol message, converting from other types (integer, etc.) if necessary.
402 * 409 *
403 * @return gchar * The data as a string, or NULL. Caller must g_free(). 410 * @return gchar * The data as a string, or NULL. Caller must g_free().