pidgin.2.x.y: 2f0f6854: Pluck all MSNP18 changes. This is pretty...

qulogic at pidgin.im qulogic at pidgin.im
Wed Feb 22 01:01:46 EST 2012


----------------------------------------------------------------------
Revision: 2f0f6854241b2f975d10b73095bf46d5e9a8eb01
Parent:   395c14cb9ec6322fae27e85095ab2f640fa7c00a
Author:   qulogic at pidgin.im
Date:     02/22/12 00:52:30
Branch:   im.pidgin.pidgin.2.x.y
URL: http://d.pidgin.im/viewmtn/revision/info/2f0f6854241b2f975d10b73095bf46d5e9a8eb01

Changelog: 

Pluck all MSNP18 changes. This is pretty much to fix sending OIMs.

*** Plucked rev b8b574c4d6f6c05105b372191ca5259b4ae0ad41 (qulogic at pidgin.im):
Add a function for parsing a network:username for MSNP18.

*** Plucked rev 86bb401efa33f02ca5d28fea216a39a3cf29b5b4 (qulogic at pidgin.im):
Fix UBX on MSNP18.

*** Plucked rev ba2513694e6abcbdfddc66820f1df20540a36847 (qulogic at pidgin.im):
Fix NLN on MSNP18.

*** Plucked rev 83a617670da618f4dbdeeebbdb5e2813a4ad2c0c (qulogic at pidgin.im):
Switch to ABFindContactsPaged instead of ABFindAll.

*** Plucked rev b6bd214d29db885c6d28628c163fa144bdf4a76d (qulogic at pidgin.im):
Send circle authentication on the notification server on MSNP18.

*** Plucked rev 2ca50146aa67469313579cea414e4a2b660939aa (qulogic at pidgin.im):
Make a small name change.

*** Plucked rev 2c13bf358104060d6713317e18e03b434862cb38 (qulogic at pidgin.im):
Add a missing function.

*** Plucked rev a8deb3f73726f4148e8f36f317a88fedcb051c34 (qulogic at pidgin.im):
Update UUM to allow sending to users on any network.

*** Plucked rev dddff988e830a7a2fa0e40aad200f0e908b9231e (qulogic at pidgin.im):
Switch to MSNP18.

*** Plucked rev 9fe45819000c530c509c07b7feb29ce9d4ea13b0 (qulogic at pidgin.im):
Send offline messages using UUM.

*** Plucked rev c1584182b85f99fa3507ea3f76b07865ee7e43f7 (qulogic at pidgin.im):
Drop support for protocols below 18.

*** Plucked rev f0388e54998489dbe4b6133796f77459f20fe884 (qulogic at pidgin.im):
Fix indices for client capabilities and display pics.

Changes against parent 395c14cb9ec6322fae27e85095ab2f640fa7c00a

  patched  libpurple/protocols/msn/contact.c
  patched  libpurple/protocols/msn/contact.h
  patched  libpurple/protocols/msn/msn.c
  patched  libpurple/protocols/msn/msn.h
  patched  libpurple/protocols/msn/msnutils.c
  patched  libpurple/protocols/msn/msnutils.h
  patched  libpurple/protocols/msn/notification.c
  patched  libpurple/protocols/msn/notification.h
  patched  libpurple/protocols/msn/session.c
  patched  libpurple/protocols/msn/state.c
  patched  libpurple/protocols/msn/switchboard.c
  patched  libpurple/protocols/msn/user.c

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.c	bb50121259b8427e3b569b7e588392a4c4d377c1
+++ libpurple/protocols/msn/msn.c	8bb2b91a43bb1511fd78968ff2bc08564e069202
@@ -1220,7 +1220,7 @@ msn_actions(PurplePlugin *plugin, gpoint
 	m = g_list_append(m, act);
 	m = g_list_append(m, NULL);
 
-	if (session->enable_mpop && session->protocol_ver >= 16)
+	if (session->enable_mpop)
 	{
 		act = purple_plugin_action_new(_("View Locations..."),
 		                               msn_show_locations);
@@ -1567,90 +1567,69 @@ msn_send_im(PurpleConnection *gc, const 
 		return 0;
 	}
 
-	if (msn_user_is_online(account, who) ||
-		msn_user_is_yahoo(account, who) ||
-		swboard != NULL) {
-		/*User online or have a swboard open because it's invisible
-		 * and sent us a message,then send Online Instant Message*/
+	if (msglen + strlen(msgformat) + strlen(VERSION) > 1564)
+	{
+		g_free(msgformat);
+		g_free(msgtext);
 
-		if (msglen + strlen(msgformat) + strlen(VERSION) > 1564)
-		{
-			g_free(msgformat);
-			g_free(msgtext);
+		return -E2BIG;
+	}
 
-			return -E2BIG;
-		}
+	msg = msn_message_new_plain(msgtext);
+	msg->remote_user = g_strdup(who);
+	msn_message_set_header(msg, "X-MMS-IM-Format", msgformat);
 
-		msg = msn_message_new_plain(msgtext);
-		msg->remote_user = g_strdup(who);
-		msn_message_set_header(msg, "X-MMS-IM-Format", msgformat);
+	g_free(msgformat);
+	g_free(msgtext);
 
-		g_free(msgformat);
-		g_free(msgtext);
-
-		purple_debug_info("msn", "prepare to send online Message\n");
-		if (g_ascii_strcasecmp(who, username))
-		{
-			if (flags & PURPLE_MESSAGE_AUTO_RESP) {
-				msn_message_set_flag(msg, 'U');
-			}
-			if (msn_user_is_yahoo(account, who)) {
-				/*we send the online and offline Message to Yahoo User via UBM*/
-				purple_debug_info("msn", "send to Yahoo User\n");
-				uum_send_msg(session, msg);
-			} else {
-				purple_debug_info("msn", "send via switchboard\n");
-				msn_send_im_message(session, msg);
-			}
+	purple_debug_info("msn", "prepare to send online Message\n");
+	if (g_ascii_strcasecmp(who, username))
+	{
+		if (flags & PURPLE_MESSAGE_AUTO_RESP) {
+			msn_message_set_flag(msg, 'U');
 		}
-		else
-		{
-			char *body_str, *body_enc, *pre, *post;
-			const char *format;
-			MsnIMData *imdata = g_new0(MsnIMData, 1);
-			/*
-			 * In MSN, you can't send messages to yourself, so
-			 * we'll fake like we received it ;)
-			 */
-			body_str = msn_message_to_string(msg);
-			body_enc = g_markup_escape_text(body_str, -1);
-			g_free(body_str);
 
-			format = msn_message_get_header_value(msg, "X-MMS-IM-Format");
-			msn_parse_format(format, &pre, &post);
-			body_str = g_strdup_printf("%s%s%s", pre ? pre :  "",
-									   body_enc ? body_enc : "", post ? post : "");
-			g_free(body_enc);
-			g_free(pre);
-			g_free(post);
-
-			serv_got_typing_stopped(gc, who);
-			imdata->gc = gc;
-			imdata->who = who;
-			imdata->msg = body_str;
-			imdata->flags = flags & ~PURPLE_MESSAGE_SEND;
-			imdata->when = time(NULL);
-			purple_timeout_add(0, msn_send_me_im, imdata);
+		if (msn_user_is_yahoo(account, who) || !(msn_user_is_online(account, who) || swboard != NULL)) {
+			/*we send the online and offline Message to Yahoo User via UBM*/
+			purple_debug_info("msn", "send to Yahoo User\n");
+			msn_notification_send_uum(session, msg);
+		} else {
+			purple_debug_info("msn", "send via switchboard\n");
+			msn_send_im_message(session, msg);
 		}
+	}
+	else
+	{
+		char *body_str, *body_enc, *pre, *post;
+		const char *format;
+		MsnIMData *imdata = g_new0(MsnIMData, 1);
+		/*
+		 * In MSN, you can't send messages to yourself, so
+		 * we'll fake like we received it ;)
+		 */
+		body_str = msn_message_to_string(msg);
+		body_enc = g_markup_escape_text(body_str, -1);
+		g_free(body_str);
 
-		msn_message_unref(msg);
-	} else {
-		/*send Offline Instant Message,only to MSN Passport User*/
-		char *friendname;
+		format = msn_message_get_header_value(msg, "X-MMS-IM-Format");
+		msn_parse_format(format, &pre, &post);
+		body_str = g_strdup_printf("%s%s%s", pre ? pre :  "",
+								   body_enc ? body_enc : "", post ? post : "");
+		g_free(body_enc);
+		g_free(pre);
+		g_free(post);
 
-		purple_debug_info("msn", "prepare to send offline Message\n");
-
-		friendname = msn_encode_mime(account->username);
-		msn_oim_prep_send_msg_info(session->oim,
-			purple_account_get_username(account),
-			friendname, who, msgtext);
-		msn_oim_send_msg(session->oim);
-
-		g_free(msgformat);
-		g_free(msgtext);
-		g_free(friendname);
+		serv_got_typing_stopped(gc, who);
+		imdata->gc = gc;
+		imdata->who = who;
+		imdata->msg = body_str;
+		imdata->flags = flags & ~PURPLE_MESSAGE_SEND;
+		imdata->when = time(NULL);
+		purple_timeout_add(0, msn_send_me_im, imdata);
 	}
 
+	msn_message_unref(msg);
+
 	return 1;
 }
 
============================================================
--- libpurple/protocols/msn/msn.h	2b9dc0da233cb36c2afcfef9465d20c7810cd17e
+++ libpurple/protocols/msn/msn.h	599b85bae484702b59e5383a9aa56a31b3642587
@@ -115,10 +115,10 @@ typedef enum
 #define MSN_SERVER "messenger.hotmail.com"
 #define MSN_HTTPCONN_SERVER "gateway.messenger.hotmail.com"
 #define MSN_PORT 1863
-#define WLM_PROT_VER		16
+#define WLM_PROT_VER		18
 
-#define WLM_MAX_PROTOCOL	16
-#define WLM_MIN_PROTOCOL	15
+#define WLM_MAX_PROTOCOL	18
+#define WLM_MIN_PROTOCOL	18
 
 #define MSN_TYPING_RECV_TIMEOUT 6
 #define MSN_TYPING_SEND_TIMEOUT	4
============================================================
--- libpurple/protocols/msn/switchboard.c	5da66f3d15024b12f90845eb547015040c81c219
+++ libpurple/protocols/msn/switchboard.c	a78b20826f417873811507b305dddad0d753d2d2
@@ -707,10 +707,7 @@ ubm_cmd(MsnCmdProc *cmdproc, MsnCommand 
 ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
 {
 	purple_debug_misc("msn", "get UBM...\n");
-	if (cmdproc->session->protocol_ver >= 16)
-		cmd->payload_len = atoi(cmd->params[5]);
-	else
-		cmd->payload_len = atoi(cmd->params[3]);
+	cmd->payload_len = atoi(cmd->params[5]);
 	cmdproc->last_cmd->payload_cb = msg_cmd_post;
 }
 
@@ -867,12 +864,9 @@ connect_cb(MsnServConn *servconn)
 	swboard = cmdproc->data;
 	g_return_if_fail(swboard != NULL);
 
-	if (servconn->session->protocol_ver >= 16)
-		username = g_strdup_printf("%s;{%s}",
-		                           purple_account_get_username(account),
-		                           servconn->session->guid);
-	else
-		username = g_strdup(purple_account_get_username(account));
+	username = g_strdup_printf("%s;{%s}",
+	                           purple_account_get_username(account),
+	                           servconn->session->guid);
 
 	if (msn_switchboard_is_invited(swboard))
 	{
============================================================
--- libpurple/protocols/msn/notification.c	d568c550413334155dfcabc1b8673c1316437b12
+++ libpurple/protocols/msn/notification.c	4e3baf26c8a5012bfc27354756504a5a84fae254
@@ -164,10 +164,7 @@ msn_got_login_params(MsnSession *session
 
 	msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END);
 
-	if (session->protocol_ver >= 16)
-		trans = msn_transaction_new(cmdproc, "USR", "SSO S %s %s %s", ticket, response, session->guid);
-	else
-		trans = msn_transaction_new(cmdproc, "USR", "SSO S %s %s", ticket, response);
+	trans = msn_transaction_new(cmdproc, "USR", "SSO S %s %s %s", ticket, response, session->guid);
 
 	msn_cmdproc_send_trans(cmdproc, trans);
 }
@@ -359,23 +356,34 @@ void
 
 /*send Message to Yahoo Messenger*/
 void
-uum_send_msg(MsnSession *session,MsnMessage *msg)
+msn_notification_send_uum(MsnSession *session, MsnMessage *msg)
 {
 	MsnCmdProc *cmdproc;
 	MsnTransaction *trans;
 	char *payload;
 	gsize payload_len;
 	int type;
+	MsnUser *user;
+	int network;
 
+	g_return_if_fail(msg != NULL);
+
 	cmdproc = session->notification->cmdproc;
-	g_return_if_fail(msg     != NULL);
+
 	payload = msn_message_gen_payload(msg, &payload_len);
+	type = msg->type;
+	user = msn_userlist_find_user(session->userlist, msg->remote_user);
+	if (user)
+		network = msn_user_get_network(user);
+	else
+		network = MSN_NETWORK_PASSPORT;
+
 	purple_debug_info("msn",
 		"send UUM, payload{%s}, strlen:%" G_GSIZE_FORMAT ", len:%" G_GSIZE_FORMAT "\n",
 		payload, strlen(payload), payload_len);
-	type = msg->type;
-	trans = msn_transaction_new(cmdproc, "UUM", "%s 32 %d %" G_GSIZE_FORMAT,
-		msg->remote_user, type, payload_len);
+
+	trans = msn_transaction_new(cmdproc, "UUM", "%s %d %d %" G_GSIZE_FORMAT,
+		msg->remote_user, network, type, payload_len);
 	msn_transaction_set_payload(trans, payload, strlen(payload));
 	msn_cmdproc_send_trans(cmdproc, trans);
 }
@@ -390,10 +398,7 @@ ubm_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	 * command and we are processing it */
 	if (cmd->payload == NULL) {
 		cmdproc->last_cmd->payload_cb = msg_cmd_post;
-		if (cmdproc->session->protocol_ver >= 16)
-			cmd->payload_len = atoi(cmd->params[5]);
-		else
-			cmd->payload_len = atoi(cmd->params[3]);
+		cmd->payload_len = atoi(cmd->params[5]);
 	} else {
 		g_return_if_fail(cmd->payload_cb != NULL);
 
@@ -1042,7 +1047,7 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 		networkid = atoi(cmd->params[3]);
 		friendly = g_strdup(purple_url_decode(cmd->params[4]));
 		clientid = strtoul(cmd->params[5], &extcap_str, 10);
-		if (session->protocol_ver >= 16 && extcap_str && *extcap_str)
+		if (extcap_str && *extcap_str)
 			extcaps = strtoul(extcap_str+1, NULL, 10);
 		else
 			extcaps = 0;
@@ -1056,7 +1061,7 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 		networkid = atoi(cmd->params[3]);
 		friendly = g_strdup(purple_url_decode(cmd->params[4]));
 		clientid = strtoul(cmd->params[5], &extcap_str, 10);
-		if (session->protocol_ver >= 16 && extcap_str && *extcap_str)
+		if (extcap_str && *extcap_str)
 			extcaps = strtoul(extcap_str+1, NULL, 10);
 		else
 			extcaps = 0;
@@ -1069,7 +1074,7 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 			networkid = atoi(cmd->params[3]);
 			friendly = g_strdup(purple_url_decode(cmd->params[4]));
 			clientid = strtoul(cmd->params[5], &extcap_str, 10);
-			if (session->protocol_ver >= 16 && extcap_str && *extcap_str)
+			if (extcap_str && *extcap_str)
 				extcaps = strtoul(extcap_str+1, NULL, 10);
 			else
 				extcaps = 0;
@@ -1077,7 +1082,7 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 			/* MSNP8+ with Display Picture object */
 			friendly = g_strdup(purple_url_decode(cmd->params[3]));
 			clientid = strtoul(cmd->params[4], &extcap_str, 10);
-			if (session->protocol_ver >= 16 && extcap_str && *extcap_str)
+			if (extcap_str && *extcap_str)
 				extcaps = strtoul(extcap_str+1, NULL, 10);
 			else
 				extcaps = 0;
@@ -1087,7 +1092,7 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 		/* MSNP8+ without Display Picture object */
 		friendly = g_strdup(purple_url_decode(cmd->params[3]));
 		clientid = strtoul(cmd->params[4], &extcap_str, 10);
-		if (session->protocol_ver >= 16 && extcap_str && *extcap_str)
+		if (extcap_str && *extcap_str)
 			extcaps = strtoul(extcap_str+1, NULL, 10);
 		else
 			extcaps = 0;
@@ -1250,15 +1255,15 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	MsnObject *msnobj;
 	unsigned long clientid, extcaps;
 	char *extcap_str;
+	char *passport;
 	int networkid;
-	const char *state, *passport, *friendly;
+	const char *state, *friendly;
 
 	session = cmdproc->session;
 
-	state    = cmd->params[0];
-	passport = cmd->params[1];
-	networkid = atoi(cmd->params[2]);
-	friendly = purple_url_decode(cmd->params[3]);
+	state = cmd->params[0];
+	msn_parse_user(cmd->params[1], &passport, &networkid);
+	friendly = purple_url_decode(cmd->params[2]);
 
 	user = msn_userlist_find_user(session->userlist, passport);
 	if (user == NULL) return;
@@ -1268,9 +1273,9 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 		msn_update_contact(session, passport, MSN_UPDATE_DISPLAY, friendly);
 	}
 
-	if (cmd->param_count == 6)
+	if (cmd->param_count == 5)
 	{
-		msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[5]));
+		msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[4]));
 		msn_user_set_object(user, msnobj);
 	}
 	else
@@ -1278,8 +1283,8 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 		msn_user_set_object(user, NULL);
 	}
 
-	clientid = strtoul(cmd->params[4], &extcap_str, 10);
-	if (session->protocol_ver >= 16 && extcap_str && *extcap_str)
+	clientid = strtoul(cmd->params[3], &extcap_str, 10);
+	if (extcap_str && *extcap_str)
 		extcaps = strtoul(extcap_str+1, NULL, 10);
 	else
 		extcaps = 0;
@@ -1292,6 +1297,8 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 
 	msn_user_set_state(user, state);
 	msn_user_update(user);
+
+	g_free(passport);
 }
 
 #if 0
@@ -1705,22 +1712,27 @@ ubx_cmd_post(MsnCmdProc *cmdproc, MsnCom
 {
 	MsnSession *session;
 	MsnUser *user;
-	const char *passport;
+	char *passport;
+	int network;
 	xmlnode *payloadNode;
 	char *psm_str, *str;
 
 	session = cmdproc->session;
 
-	passport = cmd->params[0];
+	msn_parse_user(cmd->params[0], &passport, &network);
 	user = msn_userlist_find_user(session->userlist, passport);
+
 	if (user == NULL) {
-		char *str = g_strndup(payload, len);
+		str = g_strndup(payload, len);
 		purple_debug_info("msn", "unknown user %s, payload is %s\n",
 			passport, str);
+		g_free(passport);
 		g_free(str);
 		return;
 	}
 
+	g_free(passport);
+
 	/* Free any existing media info for this user */
 	if (user->extinfo) {
 		g_free(user->extinfo->media_album);
@@ -1767,7 +1779,7 @@ ubx_cmd(MsnCmdProc *cmdproc, MsnCommand 
 {
 	purple_debug_misc("msn", "UBX received.\n");
 	cmdproc->last_cmd->payload_cb  = ubx_cmd_post;
-	cmd->payload_len = atoi(cmd->params[2]);
+	cmd->payload_len = atoi(cmd->params[1]);
 }
 
 static void
@@ -1812,10 +1824,7 @@ void msn_notification_send_uux_endpointd
 	epDataNode = xmlnode_new("EndpointData");
 
 	capNode = xmlnode_new_child(epDataNode, "Capabilities");
-	if (session->protocol_ver >= 16)
-		caps = g_strdup_printf("%d:%02d", MSN_CLIENT_ID_CAPABILITIES, MSN_CLIENT_ID_EXT_CAPS);
-	else
-		caps = g_strdup_printf("%d", MSN_CLIENT_ID_CAPABILITIES);
+	caps = g_strdup_printf("%d:%02d", MSN_CLIENT_ID_CAPABILITIES, MSN_CLIENT_ID_EXT_CAPS);
 	xmlnode_insert_data(capNode, caps, -1);
 	g_free(caps);
 
@@ -1942,6 +1951,22 @@ msn_notification_send_uun(MsnSession *se
 	msn_cmdproc_send_trans(cmdproc, trans);
 }
 
+void
+msn_notification_send_circle_auth(MsnSession *session, const char *ticket)
+{
+	MsnTransaction *trans;
+	MsnCmdProc *cmdproc;
+	char *encoded;
+
+	cmdproc = session->notification->cmdproc;
+
+	encoded = purple_base64_encode((guchar *)ticket, strlen(ticket));
+	trans = msn_transaction_new(cmdproc, "USR", "SHA A %s", encoded);
+	msn_cmdproc_send_trans(cmdproc, trans);
+
+	g_free(encoded);
+}
+
 /**************************************************************************
  * Message Types
  **************************************************************************/
============================================================
--- libpurple/protocols/msn/notification.h	646dbe9cdb9300871764ead11e1b441cc69ac5b1
+++ libpurple/protocols/msn/notification.h	04329004236cce0993aea4cd6274a986546d0375
@@ -76,8 +76,6 @@ typedef enum {
 
 } MsnUnifiedNotificationType;
 
-void uum_send_msg(MsnSession *session, MsnMessage *msg);
-
 void msn_notification_end(void);
 void msn_notification_init(void);
 
@@ -97,6 +95,8 @@ void msn_notification_dump_contact(MsnSe
 void msn_notification_disconnect(MsnNotification *notification);
 void msn_notification_dump_contact(MsnSession *session);
 
+void msn_notification_send_uum(MsnSession *session, MsnMessage *msg);
+
 void msn_notification_send_uux(MsnSession *session, const char *payload);
 
 void msn_notification_send_uux_endpointdata(MsnSession *session);
@@ -108,6 +108,8 @@ void msn_notification_send_uun(MsnSessio
                                MsnUnifiedNotificationType type,
                                const char *payload);
 
+void msn_notification_send_circle_auth(MsnSession *session, const char *ticket);
+
 /**
  * Closes a notification.
  *
============================================================
--- libpurple/protocols/msn/session.c	e026000c2dd603d8e5e15eafdb5210751fce66c2
+++ libpurple/protocols/msn/session.c	0bf7f66d5fbd13f86c9ace6635799c1a9b2e98d1
@@ -491,11 +491,10 @@ msn_session_finish_login(MsnSession *ses
 		msn_session_sync_users(session);
 	}
 
-	if (session->protocol_ver >= 16) {
-		/* TODO: Send this when updating status instead? */
-		msn_notification_send_uux_endpointdata(session);
-		msn_notification_send_uux_private_endpointdata(session);
-	}
+	/* TODO: Send this when updating status instead? */
+	msn_notification_send_uux_endpointdata(session);
+	msn_notification_send_uux_private_endpointdata(session);
+
 	msn_change_status(session);
 }
 
============================================================
--- libpurple/protocols/msn/user.c	8c7e757f6b615aee9dce7caf348ea1ce6770fafe
+++ libpurple/protocols/msn/user.c	d49f24735675d82fbecfe0494bfcd2033ed80ef0
@@ -699,6 +699,14 @@ msn_user_get_endpoint_data(MsnUser *user
 	return NULL;
 }
 
+MsnNetwork
+msn_user_get_network(const MsnUser *user)
+{
+	g_return_val_if_fail(user != NULL, MSN_NETWORK_UNKNOWN);
+
+	return user->networkid;
+}
+
 MsnObject *
 msn_user_get_object(const MsnUser *user)
 {
============================================================
--- libpurple/protocols/msn/msnutils.c	d930db8b663626b67201f669623431b6756f0c42
+++ libpurple/protocols/msn/msnutils.c	a50eee65336eb7bf849196ac32f9c892099e18f5
@@ -490,6 +490,21 @@ msn_parse_socket(const char *str, char *
 	*ret_port = port;
 }
 
+void
+msn_parse_user(const char *str, char **ret_user, int *ret_network)
+{
+	char **tokens;
+
+	tokens = g_strsplit(str, ":", 2);
+
+	*ret_network = atoi(tokens[0]);
+	*ret_user = tokens[1];
+
+	g_free(tokens[0]);
+	/* tokens[1] is returned */
+	g_free(tokens);
+}
+
 gboolean
 msn_email_is_valid(const char *passport)
 {
============================================================
--- libpurple/protocols/msn/msnutils.h	9722d3b7268666bc496e626d06cf10faa29f1548
+++ libpurple/protocols/msn/msnutils.h	eaf4392070d1bc1d9f759c6f64cc43da9a21374c
@@ -76,6 +76,15 @@ void msn_parse_socket(const char *str, c
 void msn_parse_socket(const char *str, char **ret_host, int *ret_port);
 
 /**
+ * Parses a user name
+ *
+ * @param str         A network:username string.
+ * @param ret_user    Return of the user's passport.
+ * @param ret_network Return of the user's network.
+ */
+void msn_parse_user(const char *str, char **ret_user, int *ret_network);
+
+/**
  * Verify if the email is a vaild passport.
  *
  * @param passport 	The email
============================================================
--- libpurple/protocols/msn/state.c	32d23c9160735eaf6c155cb31718afac858ebfeb
+++ libpurple/protocols/msn/state.c	728f3eeddfee4a1c2b392edeaca80a355145c3c8
@@ -186,7 +186,7 @@ msn_set_psm(MsnSession *session)
 	statusline_stripped = purple_markup_strip_html(statusline);
 	media = create_media_string(presence);
 	g_free(session->psm);
-	session->psm = msn_build_psm(statusline_stripped, media, session->protocol_ver >= 16 ? session->guid : NULL, session->protocol_ver);
+	session->psm = msn_build_psm(statusline_stripped, media, session->guid, session->protocol_ver);
 
 	payload = session->psm;
 
@@ -245,10 +245,8 @@ msn_change_status(MsnSession *session)
 
 	if (msnobj == NULL)
 	{
-		if (session->protocol_ver >= 16)
-			trans = msn_transaction_new(cmdproc, "CHG", "%s %u:%02u 0", state_text, caps, MSN_CLIENT_ID_EXT_CAPS);
-		else
-			trans = msn_transaction_new(cmdproc, "CHG", "%s %u", state_text, caps);
+		trans = msn_transaction_new(cmdproc, "CHG", "%s %u:%02u 0", state_text,
+		                            caps, MSN_CLIENT_ID_EXT_CAPS);
 	}
 	else
 	{
@@ -256,12 +254,9 @@ msn_change_status(MsnSession *session)
 
 		msnobj_str = msn_object_to_string(msnobj);
 
-		if (session->protocol_ver >= 16)
-			trans = msn_transaction_new(cmdproc, "CHG", "%s %u:%02u %s", state_text,
-							 caps, MSN_CLIENT_ID_EXT_CAPS, purple_url_encode(msnobj_str));
-		else
-			trans = msn_transaction_new(cmdproc, "CHG", "%s %u %s", state_text,
-							 caps, purple_url_encode(msnobj_str));
+		trans = msn_transaction_new(cmdproc, "CHG", "%s %u:%02u %s", state_text,
+		                            caps, MSN_CLIENT_ID_EXT_CAPS,
+		                            purple_url_encode(msnobj_str));
 
 		g_free(msnobj_str);
 	}
============================================================
--- libpurple/protocols/msn/contact.c	b4c18ff4aab916791e4dbd4f2424f0a9d6dfac2f
+++ libpurple/protocols/msn/contact.c	d37e996d9ddfa2d77c62a7099cd94c5ef5acb2a2
@@ -864,6 +864,21 @@ msn_parse_addressbook_contacts(MsnSessio
 	g_free(alias);
 }
 
+static void
+msn_parse_addressbook_circles(MsnSession *session, xmlnode *node)
+{
+	xmlnode *ticket;
+
+	/* TODO: Parse groups */
+
+	ticket = xmlnode_get_child(node, "CircleTicket");
+	if (ticket) {
+		char *data = xmlnode_get_data(ticket);
+		msn_notification_send_circle_auth(session, data);
+		g_free(data);
+	}
+}
+
 static gboolean
 msn_parse_addressbook(MsnSession *session, xmlnode *node)
 {
@@ -871,6 +886,7 @@ msn_parse_addressbook(MsnSession *sessio
 	xmlnode *groups;
 	xmlnode *contacts;
 	xmlnode *abNode;
+	xmlnode *circleNode;
 	xmlnode *fault;
 
 	if ((fault = xmlnode_get_child(node, "Body/Fault"))) {
@@ -897,7 +913,7 @@ msn_parse_addressbook(MsnSession *sessio
 		return FALSE;
 	}
 
-	result = xmlnode_get_child(node, "Body/ABFindAllResponse/ABFindAllResult");
+	result = xmlnode_get_child(node, "Body/ABFindContactsPagedResponse/ABFindContactsPagedResult");
 	if (result == NULL) {
 		purple_debug_misc("msn", "Received no address book update\n");
 		return TRUE;
@@ -906,7 +922,7 @@ msn_parse_addressbook(MsnSession *sessio
 	/* I don't see this "groups" tag documented on msnpiki, need to find out
 	   if they are really there, and update msnpiki */
 	/*Process Group List*/
-	groups = xmlnode_get_child(result, "groups");
+	groups = xmlnode_get_child(result, "Groups");
 	if (groups != NULL) {
 		msn_parse_addressbook_groups(session, groups);
 	}
@@ -931,12 +947,12 @@ msn_parse_addressbook(MsnSession *sessio
 
 	/*Process contact List*/
 	purple_debug_info("msn", "Process contact list...\n");
-	contacts = xmlnode_get_child(result, "contacts");
+	contacts = xmlnode_get_child(result, "Contacts");
 	if (contacts != NULL) {
 		msn_parse_addressbook_contacts(session, contacts);
 	}
 
-	abNode = xmlnode_get_child(result, "ab");
+	abNode = xmlnode_get_child(result, "Ab");
 	if (abNode != NULL) {
 		xmlnode *node2;
 		char *tmp = NULL;
@@ -954,6 +970,11 @@ msn_parse_addressbook(MsnSession *sessio
 		g_free(tmp);
 	}
 
+	circleNode = xmlnode_get_child(result, "CircleResult");
+	if (circleNode != NULL) {
+		msn_parse_addressbook_circles(session, circleNode);
+	}
+
 	return TRUE;
 }
 
============================================================
--- libpurple/protocols/msn/contact.h	0cecd5282ca125e3cbd4a1439dcd40d12723f10e
+++ libpurple/protocols/msn/contact.h	6a1fc7bc0f9045975abd8095187568a95951cff9
@@ -142,11 +142,13 @@ typedef enum
 "</soap:Envelope>"
 
 /* Get AddressBook */
-#define MSN_GET_ADDRESS_SOAP_ACTION	"http://www.msn.com/webservices/AddressBook/ABFindAll"
+#define MSN_GET_ADDRESS_SOAP_ACTION	"http://www.msn.com/webservices/AddressBook/ABFindContactsPaged"
 #define MSN_GET_ADDRESS_FULL_TIME	"0001-01-01T00:00:00.0000000-08:00"
 #define MSN_GET_ADDRESS_UPDATE_XML \
-	"<deltasOnly>true</deltasOnly>"\
-	"<lastChange>%s</lastChange>"
+	"<filterOptions>"\
+		"<deltasOnly>true</deltasOnly>"\
+		"<lastChange>%s</lastChange>"\
+	"</filterOptions>"
 
 #define MSN_GET_GLEAM_UPDATE_XML \
 	"%s"\
@@ -171,11 +173,11 @@ typedef enum
 		"</ABAuthHeader>"\
 	"</soap:Header>"\
 	"<soap:Body>"\
-		"<ABFindAll xmlns=\"http://www.msn.com/webservices/AddressBook\">"\
-			"<abId>00000000-0000-0000-0000-000000000000</abId>"\
+		"<ABFindContactsPaged xmlns=\"http://www.msn.com/webservices/AddressBook\">"\
 			"<abView>Full</abView>"\
+			"<extendedContent>AB AllGroups CircleResult</extendedContent>"\
 			"%s"\
-		"</ABFindAll>"\
+		"</ABFindContactsPaged>"\
 	"</soap:Body>"\
 "</soap:Envelope>"
 


More information about the Commits mailing list