Mercurial > pidgin.yaz
changeset 24686:ecbf95af2fa7
merge of '237ac12c436b96cd8e5959a16892ab9dcba4c5da'
and 'b91b112c0b3cd2cc014285d5dad8b6cb8973a22b'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Mon, 15 Dec 2008 01:42:24 +0000 |
parents | 34258af32335 (diff) bca23aa61d0f (current diff) |
children | e88d205cb4da |
files | |
diffstat | 3 files changed, 88 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Dec 15 00:40:36 2008 +0000 +++ b/ChangeLog Mon Dec 15 01:42:24 2008 +0000 @@ -28,6 +28,8 @@ * 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)
--- a/libpurple/protocols/msn/msg.c Mon Dec 15 00:40:36 2008 +0000 +++ b/libpurple/protocols/msn/msg.c Mon Dec 15 01:42:24 2008 +0000 @@ -231,6 +231,25 @@ { const char *key, *value; + /* If this line starts with whitespace, it's been folded from the + previous line and won't have ':'. */ + if ((**cur == ' ') || (**cur == '\t')) { + tokens = g_strsplit(g_strchug(*cur), "=\"", 2); + key = tokens[0]; + value = tokens[1]; + + /* The only one I care about is 'boundary' (which is folded from + the key 'Content-Type'), so only process that. */ + if (!strcmp(key, "boundary")) { + char *end = strchr(value, '\"'); + *end = '\0'; + msn_message_set_attr(msg, key, value); + } + + g_strfreev(tokens); + continue; + } + tokens = g_strsplit(*cur, ": ", 2); key = tokens[0];
--- a/libpurple/protocols/msn/oim.c Mon Dec 15 00:40:36 2008 +0000 +++ b/libpurple/protocols/msn/oim.c Mon Dec 15 01:42:24 2008 +0000 @@ -594,47 +594,88 @@ msn_oim_report_to_user(MsnOimRecvData *rdata, const char *msg_str) { MsnMessage *message; - char *date,*from,*decode_msg; + const char *date; + const char *from; + char *decode_msg = NULL; gsize body_len; char **tokens; - char *start,*end; - int has_nick = 0; - char *passport_str, *passport; + char *passport = NULL; time_t stamp; message = msn_message_new(MSN_MSG_UNKNOWN); msn_message_parse_payload(message, msg_str, strlen(msg_str), - MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM); + 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 = (char *)g_hash_table_lookup(message->attr_table, "Date"); - from = (char *)g_hash_table_lookup(message->attr_table, "From"); - if (strstr(from," ")) { - has_nick = 1; - } - if (has_nick) { - tokens = g_strsplit(from , " " , 2); - passport_str = g_strdup(tokens[1]); - purple_debug_info("msn", "oim Date:{%s},nickname:{%s},tokens[1]:{%s} passport{%s}\n", - date, tokens[0], tokens[1], passport_str); + + if (!strcmp(msn_message_get_attr(message, "X-OIMProxy"), "MOSMS")) { + char *boundary; + char **part; + + 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 { - passport_str = g_strdup(from); - purple_debug_info("msn", "oim Date:{%s},passport{%s}\n", - date, passport_str); + 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); } - start = strstr(passport_str,"<"); - start += 1; - end = strstr(passport_str,">"); - passport = g_strndup(start,end - start); - g_free(passport_str); - purple_debug_info("msn", "oim Date:{%s},passport{%s}\n", date, passport); + 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); + stamp); /*Now get the oim message ID from the oim_list. * and append to read list to prepare for deleting the Offline Message when sign out