pidgin: 237ac12c: Add support for receiving MSN offline me...
qulogic at pidgin.im
qulogic at pidgin.im
Sun Dec 14 20:55:39 EST 2008
-----------------------------------------------------------------
Revision: 237ac12c436b96cd8e5959a16892ab9dcba4c5da
Ancestor: 45e2b34d6c6f6f79d9d0dd8a29091fdbbde20cf4
Author: qulogic at pidgin.im
Date: 2008-12-15T01:40:52
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/237ac12c436b96cd8e5959a16892ab9dcba4c5da
Modified files:
ChangeLog libpurple/protocols/msn/oim.c
ChangeLog:
Add support for receiving MSN offline messages that were sent from a mobile
device. Based on a patch from Maiku.
-------------- next part --------------
============================================================
--- ChangeLog 1a00be6ef6009d4ef94200de27157899fb4e24b5
+++ ChangeLog fd8e9795e0952a39aca16a057f2009ce1eb6cc36
@@ -28,6 +28,8 @@ version 2.5.3 (??/??/????):
* On ICQ, advertise the ICQ 6 typing capability. This should fix the
reports of typing notifications not working with third-party clients
(Jarom?r Karmaz?n)
+ * On MSN, messages sent from a mobile device while you were offline are
+ now correctly received.
Gadu-Gadu:
* Fix some problems with Gadu-Gadu buddy icons (Adam Strzelecki)
============================================================
--- libpurple/protocols/msn/oim.c c61006adfd7592becf71453c5f6040dff51a5c97
+++ libpurple/protocols/msn/oim.c b74447968f8afd0c7765796d1ed7e0d2cca9bb50
@@ -596,11 +596,10 @@ msn_oim_report_to_user(MsnOimRecvData *r
MsnMessage *message;
const char *date;
const char *from;
- char *decode_msg;
+ char *decode_msg = NULL;
gsize body_len;
char **tokens;
- char *start, *end;
- char *passport;
+ char *passport = NULL;
time_t stamp;
message = msn_message_new(MSN_MSG_UNKNOWN);
@@ -608,21 +607,72 @@ msn_oim_report_to_user(MsnOimRecvData *r
msn_message_parse_payload(message, msg_str, strlen(msg_str),
MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM);
purple_debug_info("msn", "oim body:{%s}\n", message->body);
- decode_msg = (char *)purple_base64_decode(message->body, &body_len);
- date = msn_message_get_attr(message, "Date");
- from = msn_message_get_attr(message, "From");
- tokens = g_strsplit(from, " ", 2);
- if (tokens[1] != NULL)
- from = (const char *)tokens[1];
+ if (!strcmp(msn_message_get_attr(message, "X-OIMProxy"), "MOSMS")) {
+ char *boundary;
+ char **part;
- start = strchr(from, '<') + 1;
- end = strchr(from, '>');
- passport = g_strndup(start, end - start);
- purple_debug_info("msn", "oim Date:{%s},passport{%s},tokens[0]:{%s}\n",
- date, passport, tokens[0]);
+ from = msn_message_get_attr(message, "X-OIM-originatingSource");
+ /* Match number to user's mobile number, FROM is a phone number
+ if the other side pages you using your phone number */
+ if (!strncmp(passport, "tel:+", 5)) {
+ MsnUser *user = msn_userlist_find_user_with_mobile_phone(
+ rdata->oim->session->userlist, from + 4);
+
+ if (user && user->passport)
+ passport = g_strdup(user->passport);
+ }
+ if (passport == NULL)
+ passport = g_strdup(from);
+
+ boundary = g_strdup_printf("--%s" MSG_OIM_LINE_DEM,
+ msn_message_get_attr(message, "boundary"));
+ tokens = g_strsplit(message->body, boundary, 0);
+
+ for (part = tokens; *part != NULL; part++) {
+ MsnMessage *multipart;
+ multipart = msn_message_new(MSN_MSG_UNKNOWN);
+ msn_message_parse_payload(multipart, *part, strlen(*part),
+ MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM);
+
+ if (!strcmp(msn_message_get_content_type(multipart), "text/plain")) {
+ decode_msg = (char *)purple_base64_decode(multipart->body, &body_len);
+ msn_message_destroy(multipart);
+ break;
+ }
+ msn_message_destroy(multipart);
+ }
+
+ g_strfreev(tokens);
+ g_free(boundary);
+
+ if (decode_msg == NULL) {
+ purple_debug_error("msn", "Couldn't find text/plain OIM message.\n");
+ g_free(passport);
+ return;
+ }
+ } else {
+ char *start, *end;
+
+ from = msn_message_get_attr(message, "From");
+ decode_msg = (char *)purple_base64_decode(message->body, &body_len);
+
+ tokens = g_strsplit(from, " ", 2);
+ if (tokens[1] != NULL)
+ from = (const char *)tokens[1];
+
+ start = strchr(from, '<') + 1;
+ end = strchr(from, '>');
+ passport = g_strndup(start, end - start);
+
+ g_strfreev(tokens);
+ }
+
+ date = msn_message_get_attr(message, "Date");
stamp = msn_oim_parse_timestamp(date);
+ purple_debug_info("msn", "oim Date:{%s},passport{%s}\n",
+ date, passport);
serv_got_im(rdata->oim->session->account->gc, passport, decode_msg, 0,
stamp);
@@ -632,7 +682,6 @@ msn_oim_report_to_user(MsnOimRecvData *r
*/
msn_oim_post_delete_msg(rdata);
- g_strfreev(tokens);
g_free(passport);
g_free(decode_msg);
}
More information about the Commits
mailing list