pidgin: 5c6d1dbe: I've always wondered why the SB layer wa...
qulogic at pidgin.im
qulogic at pidgin.im
Tue May 10 00:16:24 EDT 2011
----------------------------------------------------------------------
Revision: 5c6d1dbe2fefcab5469ede503da2c2dba1f85df7
Parent: fdb174f23d34033c1e5b7b9258f93d7b0928ba90
Author: qulogic at pidgin.im
Date: 05/09/11 18:17:03
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5c6d1dbe2fefcab5469ede503da2c2dba1f85df7
Changelog:
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.
Changes against parent fdb174f23d34033c1e5b7b9258f93d7b0928ba90
patched libpurple/protocols/msn/msg.c
patched libpurple/protocols/msn/msg.h
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msg.c a86dff02297539c7bc975b356fe6b26468c72abc
+++ libpurple/protocols/msn/msg.c bffee978b412fada3f1ba0b68b32115fc895f9f6
@@ -135,8 +135,6 @@ msn_message_new_msnslp(void)
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 @@ msn_message_parse_payload(MsnMessage *ms
/* 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,27 +335,12 @@ msn_message_gen_payload(MsnMessage *msg,
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);
+ memcpy(n, body, body_len);
+ n += body_len;
+ *n = '\0';
}
- else
- {
- if (body != NULL)
- {
- memcpy(n, body, body_len);
- n += body_len;
- *n = '\0';
- }
- }
if (ret_size != NULL)
{
@@ -613,46 +588,25 @@ msn_message_show_readable(MsnMessage *ms
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 (msg->type == MSN_MSG_TEXT)
{
- if (text_body)
+ 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_len(str, body, body_len);
- if (body[body_len - 1] == '\0')
- {
- str->len--;
- g_string_append(str, " 0x00");
- }
- g_string_append(str, "\r\n");
+ g_string_append_printf(str, "%02x ", (unsigned char)*body);
+ if (i % 16 == 0 && i != 0)
+ g_string_append_c(str, '\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");
- }
+ g_string_append_c(str, '\n');
}
}
- else
- {
- if (body != NULL)
- {
- g_string_append_len(str, body, body_len);
- g_string_append(str, "\r\n");
- }
- }
purple_debug_info("msn", "Message %s:\n{%s}\n", info, str->str);
@@ -887,6 +841,7 @@ msn_p2p_msg(MsnCmdProc *cmdproc, MsnMess
{
MsnSession *session;
MsnSlpLink *slplink;
+ MsnP2PVersion p2p;
session = cmdproc->servconn->session;
slplink = msn_session_get_slplink(session, msg->remote_user);
@@ -909,11 +864,13 @@ msn_p2p_msg(MsnCmdProc *cmdproc, MsnMess
}
}
- 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
============================================================
--- libpurple/protocols/msn/msg.h 2215e85c82c0585509c3e23456b1ee90015e1fe7
+++ libpurple/protocols/msn/msg.h f45ce743ac28e25396d073dfecd443398cef4f1c
@@ -78,7 +78,6 @@ struct _MsnMessage
MsnMsgType type;
- gboolean msnslp_message;
MsnSlpMessagePart *part;
char *remote_user;
More information about the Commits
mailing list