Mercurial > pidgin.yaz
changeset 31274:237e2c2874e6
Add a function that will help debug of SlpMessages.
author | masca@cpw.pidgin.im |
---|---|
date | Wed, 30 Jun 2010 20:41:58 +0000 |
parents | 56ef12440d52 |
children | f13f06f1f515 |
files | libpurple/protocols/msn/slpmsg.c libpurple/protocols/msn/slpmsg.h |
diffstat | 2 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/slpmsg.c Tue Jun 29 23:33:52 2010 +0000 +++ b/libpurple/protocols/msn/slpmsg.c Wed Jun 30 20:41:58 2010 +0000 @@ -327,3 +327,35 @@ return base; } + +void msn_slpmsg_show_readable(MsnSlpMessage *slpmsg) +{ + GString *str; + + str = g_string_new(NULL); + + g_string_append_printf(str, "Session ID: %u\r\n", slpmsg->header->session_id); + g_string_append_printf(str, "ID: %u\r\n", slpmsg->header->id); + g_string_append_printf(str, "Offset: %" G_GUINT64_FORMAT "\r\n", slpmsg->header->offset); + g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", slpmsg->header->total_size); + g_string_append_printf(str, "Length: %u\r\n", slpmsg->header->length); + g_string_append_printf(str, "Flags: 0x%x\r\n", slpmsg->header->flags); + g_string_append_printf(str, "ACK ID: %u\r\n", slpmsg->header->ack_id); + g_string_append_printf(str, "SUB ID: %u\r\n", slpmsg->header->ack_sub_id); + g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", slpmsg->header->ack_size); + + if (purple_debug_is_verbose() && slpmsg->buffer != NULL) { + g_string_append_len(str, slpmsg->buffer, slpmsg->size); + + if (slpmsg->buffer[slpmsg->size - 1] == '\0') { + str->len--; + g_string_append(str, " 0x00"); + } + g_string_append(str, "\r\n"); + + } + + g_string_append_printf(str, "Footer: %u\r\n", slpmsg->footer->value); + + purple_debug_info("msn", "SlpMessage %s:\n{%s}\n", slpmsg->info, str->str); +}
--- a/libpurple/protocols/msn/slpmsg.h Tue Jun 29 23:33:52 2010 +0000 +++ b/libpurple/protocols/msn/slpmsg.h Wed Jun 30 20:41:58 2010 +0000 @@ -172,4 +172,6 @@ */ char *msn_slpmsg_serialize(MsnSlpMessage *slpmsg, size_t *ret_size); +void msn_slpmsg_show_readable(MsnSlpMessage *slpmsg); + #endif /* _MSN_SLPMSG_H_ */