Mercurial > pidgin.yaz
changeset 32033:a406398412ee
I've always wondered why the SB layer was parsing the P2P stuff, when
it never really needed to do it. We have a P2P-specific handler for
receival that should do it instead. And for sending, it's already
serialized before getting to this layer, so that part is redundant.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Mon, 09 May 2011 22:17:03 +0000 |
parents | 1bc846bf4200 |
children | 02d9a66656cb |
files | libpurple/protocols/msn/msg.c libpurple/protocols/msn/msg.h |
diffstat | 2 files changed, 24 insertions(+), 68 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c Mon May 09 08:48:25 2011 +0000 +++ b/libpurple/protocols/msn/msg.c Mon May 09 22:17:03 2011 +0000 @@ -135,8 +135,6 @@ msn_message_set_header(msg, "User-Agent", NULL); - msg->msnslp_message = TRUE; - msn_message_set_flag(msg, 'D'); msn_message_set_content_type(msg, "application/x-msnmsgrp2p"); @@ -251,14 +249,6 @@ /* Now we *should* be at the body. */ content_type = msn_message_get_content_type(msg); - if (content_type != NULL && - !strcmp(content_type, "application/x-msnmsgrp2p")) { - MsnP2PVersion p2p; - msg->msnslp_message = TRUE; - p2p = msn_p2p_get_user_support(msg->remote_user); - msg->part = msn_slpmsgpart_new_from_data(p2p, tmp, payload_len - (tmp - tmp_base)); - } - if (payload_len - (tmp - tmp_base) > 0) { msg->body_len = payload_len - (tmp - tmp_base); g_free(msg->body); @@ -345,26 +335,11 @@ body = msn_message_get_bin_data(msg, &body_len); - if (msg->msnslp_message) + if (body != NULL) { - size_t siz; - char *body; - - body = msn_slpmsgpart_serialize(msg->part, &siz); - - memcpy(n, body, siz); - n += siz; - - g_free(body); - } - else - { - if (body != NULL) - { - memcpy(n, body, body_len); - n += body_len; - *n = '\0'; - } + memcpy(n, body, body_len); + n += body_len; + *n = '\0'; } if (ret_size != NULL) @@ -613,45 +588,24 @@ body = msn_message_get_bin_data(msg, &body_len); - if (msg->msnslp_message) + if (body != NULL) { - if (msg->part) - msn_slpmsgpart_to_string(msg->part, str); - - if (purple_debug_is_verbose() && body != NULL) - { - if (text_body) - { - g_string_append_len(str, body, body_len); - if (body[body_len - 1] == '\0') - { - str->len--; - g_string_append(str, " 0x00"); - } - g_string_append(str, "\r\n"); - } - else - { - int i; - - for (i = 0; i < body_len; i++) - { - g_string_append_printf(str, "%.2hhX ", body[i]); - if ((i % 16) == 15) - g_string_append(str, "\r\n"); - } - - g_string_append(str, "\r\n"); - } - } - } - else - { - if (body != NULL) + if (msg->type == MSN_MSG_TEXT) { g_string_append_len(str, body, body_len); g_string_append(str, "\r\n"); } + else + { + size_t i; + for (i = 0; i < body_len; i++, body++) + { + g_string_append_printf(str, "%02x ", (unsigned char)*body); + if (i % 16 == 0 && i != 0) + g_string_append_c(str, '\n'); + } + g_string_append_c(str, '\n'); + } } purple_debug_info("msn", "Message %s:\n{%s}\n", info, str->str); @@ -887,6 +841,7 @@ { MsnSession *session; MsnSlpLink *slplink; + MsnP2PVersion p2p; session = cmdproc->servconn->session; slplink = msn_session_get_slplink(session, msg->remote_user); @@ -909,11 +864,13 @@ } } - if (msg->part) { + p2p = msn_p2p_get_user_support(msg->remote_user); + msg->part = msn_slpmsgpart_new_from_data(p2p, msg->body, msg->body_len); + + if (msg->part) msn_slplink_process_msg(slplink, msg->part); - } - else /* This should never happen. */ - purple_debug_fatal("msn", "P2P message without a Part.\n"); + else + purple_debug_warning("msn", "P2P message failed to parse.\n"); } static void