Mercurial > pidgin.yaz
changeset 31223:64e2fe53acc2
Use slp parse code that was just moved to SlpMessage since it belongs there
instead of the one in MsnMessage (the code was just moved).
Also, a little bit more drop of MsnMessage header and footer
(this is in the same commit because It's not possible to split changes in
the same file).
author | masca@cpw.pidgin.im |
---|---|
date | Tue, 08 Jun 2010 21:32:12 +0000 |
parents | 320c0852b5cc |
children | fb7897d40ca6 |
files | libpurple/protocols/msn/msg.c |
diffstat | 1 files changed, 37 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c Tue Jun 08 21:26:39 2010 +0000 +++ b/libpurple/protocols/msn/msg.c Tue Jun 08 21:32:12 2010 +0000 @@ -28,7 +28,7 @@ #include "msn.h" #include "msg.h" #include "msnutils.h" -#include "p2p.h" +#include "slpmsg.h" MsnMessage * msn_message_new(MsnMsgType type) @@ -161,6 +161,7 @@ return msg; } +#if 0 void msn_message_parse_slp_body(MsnMessage *msg, const char *body, size_t len) { @@ -197,6 +198,7 @@ tmp += body_len; } } +#endif void msn_message_parse_payload(MsnMessage *msg, @@ -294,7 +296,12 @@ content_type = msn_message_get_content_type(msg); if (content_type != NULL && - !strcmp(content_type, "application/x-msnmsgrp2p")) + !strcmp(content_type, "application/x-msnmsgrp2p")) { + msg->msnslp_message = TRUE; + msg->slpmsg = msn_slpmsg_new_from_data(tmp, payload_len - (tmp - tmp_base)); + } + +#if 0 { MsnP2PHeader *header; MsnP2PHeader wire; @@ -339,6 +346,7 @@ } else { +#endif if (payload_len - (tmp - tmp_base) > 0) { msg->body_len = payload_len - (tmp - tmp_base); g_free(msg->body); @@ -355,7 +363,9 @@ msg->body = body; msg->charset = g_strdup("UTF-8"); } +#if 0 } +#endif g_free(tmp_base); } @@ -379,6 +389,7 @@ char * msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size) { +#if 0 MsnP2PHeader *header; char *tmp, *base; @@ -410,6 +421,11 @@ *ret_size = tmp - base; return base; +#endif + char *tmp; + + tmp = msn_slpmsg_serialize(msg->slpmsg, ret_size); + return tmp; } char * @@ -464,6 +480,14 @@ if (msg->msnslp_message) { + size_t siz; + char *body; + + body = msn_slpmsg_serialize(msg->slpmsg, &siz); + + memcpy(n, body, siz); + n += siz; +#if 0 MsnP2PHeader *header; MsnP2PFooter footer; @@ -485,6 +509,7 @@ memcpy(n, &footer, 4); n += 4; +#endif } else { @@ -744,15 +769,15 @@ if (msg->msnslp_message) { - g_string_append_printf(str, "Session ID: %u\r\n", msg->msnslp_header.session_id); - g_string_append_printf(str, "ID: %u\r\n", msg->msnslp_header.id); - g_string_append_printf(str, "Offset: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.offset); - g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.total_size); - g_string_append_printf(str, "Length: %u\r\n", msg->msnslp_header.length); - g_string_append_printf(str, "Flags: 0x%x\r\n", msg->msnslp_header.flags); - g_string_append_printf(str, "ACK ID: %u\r\n", msg->msnslp_header.ack_id); - g_string_append_printf(str, "SUB ID: %u\r\n", msg->msnslp_header.ack_sub_id); - g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.ack_size); + g_string_append_printf(str, "Session ID: %u\r\n", msg->slpmsg->header->session_id); + g_string_append_printf(str, "ID: %u\r\n", msg->slpmsg->header->id); + g_string_append_printf(str, "Offset: %" G_GUINT64_FORMAT "\r\n", msg->slpmsg->header->offset); + g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", msg->slpmsg->header->total_size); + g_string_append_printf(str, "Length: %u\r\n", msg->slpmsg->header->length); + g_string_append_printf(str, "Flags: 0x%x\r\n", msg->slpmsg->header->flags); + g_string_append_printf(str, "ACK ID: %u\r\n", msg->slpmsg->header->ack_id); + g_string_append_printf(str, "SUB ID: %u\r\n", msg->slpmsg->header->ack_sub_id); + g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", msg->slpmsg->header->ack_size); if (purple_debug_is_verbose() && body != NULL) { @@ -779,7 +804,7 @@ } } - g_string_append_printf(str, "Footer: %u\r\n", msg->msnslp_footer.value); + g_string_append_printf(str, "Footer: %u\r\n", msg->slpmsg->footer->value); } else {