pidgin: 590cde6d: another patch from Maiku, this time hand...

khc at pidgin.im khc at pidgin.im
Fri Mar 21 01:30:38 EDT 2008


-----------------------------------------------------------------
Revision: 590cde6df3f1b6328a6941c0e74e9dc683313e00
Ancestor: 45158d4d440a4f35058bdddaf71fb7b8a3b6ad14
Author: khc at pidgin.im
Date: 2008-03-21T05:24:21
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/590cde6df3f1b6328a6941c0e74e9dc683313e00

Modified files:
        libpurple/protocols/msn/notification.c
        libpurple/protocols/msn/userlist.c
        libpurple/protocols/msn/userlist.h

ChangeLog: 

another patch from Maiku, this time handling IPG so we can receive paging.

I am not sure why anyone would ever want to use this, but apparently some
people find it helpful.

Blame me if it doesn't work

Fixes #5232


-------------- next part --------------
============================================================
--- libpurple/protocols/msn/notification.c	357d2a294b38728b6ddff119553d82fe155acaa7
+++ libpurple/protocols/msn/notification.c	64fd0c99502de78f5dcf67ade272a372af3520bd
@@ -1071,9 +1071,61 @@ ipg_cmd_post(MsnCmdProc *cmdproc, MsnCom
 static void
 ipg_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, size_t len)
 {
-#if 0
+	PurpleConnection *gc;
+	MsnUserList *userlist;
+	char *who = NULL, *text = NULL;
+	xmlnode *payloadNode, *from, *textNode;
+
 	purple_debug_misc("msn", "Incoming Page: {%s}\n", payload);
-#endif
+
+	userlist = cmdproc->session->userlist;
+	gc = purple_account_get_connection(cmdproc->session->account);
+
+	/* payload looks like this:
+	   <?xml version="1.0"?>
+	   <NOTIFICATION id="0" siteid="111100400" siteurl="http://mobile.msn.com/">
+	     <TO name="passport at example.com">
+	       <VIA agent="mobile"/>
+	     </TO>
+	     <FROM name="tel:+XXXXXXXXXXX"/>
+		 <MSG pri="1" id="1">
+		   <CAT Id="110110001"/>
+		   <ACTION url="2wayIM.asp"/>
+		   <SUBSCR url="2wayIM.asp"/>
+		   <BODY lcid="1033">
+		     <TEXT>Message was here</TEXT>
+		   </BODY>
+		 </MSG>
+	   </NOTIFICATION>
+	*/
+
+	if (!(payloadNode = xmlnode_from_str(payload, len)) ||
+		!(from = xmlnode_get_child(payloadNode, "FROM")) ||
+		!(textNode = xmlnode_get_child(payloadNode, "MSG/BODY/TEXT")))
+		return;
+
+	who = g_strdup(xmlnode_get_attrib(from, "name"));
+	if (!who) return;
+
+	text = xmlnode_get_data(textNode);
+
+	/* Match number to user's mobile number, FROM is a phone number if the
+	   other side page you using your phone number */
+	if(!strncmp(who, "tel:+", 5)) {
+		MsnUser *user =
+			msn_userlist_find_user_with_mobile_phone(userlist, who + 4);
+
+		if(user && user->passport) {
+			g_free(who);
+			who = g_strdup(user->passport);
+		}
+	}
+
+	serv_got_im(gc, who, text, 0, time(NULL));
+
+	g_free(text);
+	g_free(who);
+	xmlnode_free(payloadNode);
 }
 
 static void
============================================================
--- libpurple/protocols/msn/userlist.c	1e3596b48bf1a9a10d0f469d835c49e85e6627ba
+++ libpurple/protocols/msn/userlist.c	d18986f0d21aaa45d0a54f74f0b2f573da398150
@@ -518,6 +518,28 @@ msn_userlist_find_user_with_id(MsnUserLi
 	return NULL;
 }
 
+MsnUser *
+msn_userlist_find_user_with_mobile_phone(MsnUserList *userlist, const char *number)
+{
+	GList *l;
+
+	g_return_val_if_fail(number != NULL, NULL);
+
+	for (l = userlist->users; l != NULL; l = l->next) {
+		MsnUser *user = (MsnUser *)l->data;
+
+		if (user->phone.mobile == NULL) {
+			continue;
+		}
+
+		if (!g_strcasecmp(number, user->phone.mobile)) {
+			return user;
+		}
+	}
+
+	return NULL;
+}
+
 void
 msn_userlist_add_group(MsnUserList *userlist, MsnGroup *group)
 {
============================================================
--- libpurple/protocols/msn/userlist.h	86686c7beb731366308a0829fefbcc994b6a632c
+++ libpurple/protocols/msn/userlist.h	c6a065dc3475d3fbef37308e266025fafc09b4f4
@@ -80,6 +80,7 @@ MsnUser * msn_userlist_find_user_with_id
 MsnUser * msn_userlist_find_add_user(MsnUserList *userlist,
 				const char *passport, const char *userName);
 MsnUser * msn_userlist_find_user_with_id(MsnUserList *userlist, const char *uid);
+MsnUser * msn_userlist_find_user_with_mobile_phone(MsnUserList *userlist, const char *number);
 
 void msn_userlist_add_group(MsnUserList *userlist, MsnGroup *group);
 void msn_userlist_remove_group(MsnUserList *userlist, MsnGroup *group);


More information about the Commits mailing list