changeset 24739:773662f77be7

merge of '16c1dbfe5a0090d97df6477c7f8235365d07090c' and 'dbad9300b40f03937a5bed27529b9c1445d02322'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 15 Dec 2008 01:53:50 +0000
parents e88d205cb4da (diff) e268ad14e693 (current diff)
children 7b6037f09baf ba8a5fded83c ca01403251f1
files
diffstat 3 files changed, 97 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Dec 15 01:16:59 2008 +0000
+++ b/ChangeLog	Mon Dec 15 01:53:50 2008 +0000
@@ -2,11 +2,6 @@
 
 version 2.5.3 (??/??/????):
 	libpurple:
-	* Fix an error with MSN offline messages by shipping the *new*
-	  "Microsoft Secure Server Authority" and the
-	  "Microsoft Internet Authority" certificates.  People that use
-	  --with-system-ssl-certs and GnuTLS need to include these in the
-	  system certs directory.
 	* Corrected maximum message lengths for Yahoo!
 	* The Buddy State Notification plugin no longer prints duplicate
 	  notifications when the same buddy is in multiple groups (Florian Quèze)
@@ -20,9 +15,6 @@
 	  connected (Paul Aurich)
 	* Fix a crash in purple_accounts_delete that happens when this function is
 	  called before the buddy list is initialized (Florian Quèze)
-	* On MSN, the Games and Office media can now be set and displayed (in
-	  addition to the previous Music media). The Media status text now shows
-	  the album, if possible.
 	* Fix use of av_len in perl bindings to fix some off-by-one bugs (Paul
 	  Aurich)
 	* On ICQ, advertise the ICQ 6 typing capability.  This should fix the
@@ -35,6 +27,17 @@
 	* Gadu-Gadu now does proper charset translations where needed (Adam
 	  Strzelecki)
 
+	MSN:
+	* Fix an error with offline messages by shipping the *new* "Microsoft
+	  Secure Server Authority" and the "Microsoft Internet Authority"
+	  certificates. These are now always installed even when using
+	  --with-system-ssl-certs because most system certs are not up to date.
+	* The Games and Office media can now be set and displayed (in addition
+	  to the previous Music media). The Media status text now shows the
+	  album, if possible.
+	* Messages sent from a mobile device while you were offline are now
+	  correctly received.
+
 	XMPP:
 	* Fix the namespace URL we look for in PEP reply stanzas to match the URL
 	  used in the 'get' requests (Paul Aurich)
--- a/libpurple/protocols/msn/msg.c	Mon Dec 15 01:16:59 2008 +0000
+++ b/libpurple/protocols/msn/msg.c	Mon Dec 15 01:53:50 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 01:16:59 2008 +0000
+++ b/libpurple/protocols/msn/oim.c	Mon Dec 15 01:53:50 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