changeset 23875:60de5d1ee482

merge of '038d9d36d640ed83f9df5333d57dc0cd8b9ae847' and '9aeabc8056bc8b61f63881f3f6af2b2fcbd8b99c'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Thu, 21 Aug 2008 06:46:19 +0000
parents 7cb7bc8865af (current diff) 54432ea0a5ab (diff)
children 169c1451b7e5 0943e9c59a18 5b60f32bf547
files
diffstat 1 files changed, 42 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/notification.c	Wed Aug 20 21:20:03 2008 +0000
+++ b/libpurple/protocols/msn/notification.c	Thu Aug 21 06:46:19 2008 +0000
@@ -613,13 +613,16 @@
 	xmlnode_set_attrib(adl_node, "l", "1");
 
 	/*get the userlist*/
-	for (l = session->userlist->users; l != NULL; l = l->next){
+	for (l = session->userlist->users; l != NULL; l = l->next) {
 		user = l->data;
 
 		/* skip RL & PL during initial dump */
 		if (!(user->list_op & MSN_LIST_OP_MASK))
 			continue;
 
+		if (!strcmp(user->passport, "messenger@microsoft.com"))
+			continue;
+
 		msn_add_contact_xml(session, adl_node, user->passport,
 			user->list_op & MSN_LIST_OP_MASK, user->networkid);
 
@@ -947,10 +950,11 @@
 	PurpleAccount *account;
 	PurpleConnection *gc;
 	MsnUser *user;
-	MsnObject *msnobj;
+	MsnObject *msnobj = NULL;
 	unsigned long clientid;
-	int networkid;
-	const char *state, *passport, *friendly;
+	int networkid = 0;
+	const char *state, *passport;
+	char *friendly;
 
 	session = cmdproc->session;
 	account = session->account;
@@ -958,23 +962,47 @@
 
 	state    = cmd->params[1];
 	passport = cmd->params[2];
-	/*if a contact is actually on the WLM part or the yahoo part*/
-	networkid = atoi(cmd->params[3]);
-	friendly = purple_url_decode(cmd->params[4]);
 
 	user = msn_userlist_find_user(session->userlist, passport);
+	if (user == NULL)
+		/* Where'd this come from? */
+		return;
+
+	if (cmd->param_count == 7) {
+		/* MSNP14+ with Display Picture object */
+		networkid = atoi(cmd->params[3]);
+		friendly = g_strdup(purple_url_decode(cmd->params[4]));
+		clientid = strtoul(cmd->params[5], NULL, 10);
+		msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[6]));
+	} else if (cmd->param_count == 6) {
+		/* Yes, this is 5. The friendly name could start with a number,
+		   but the display picture object can't... */
+		if (isdigit(cmd->params[5][0])) {
+			/* MSNP14 without Display Picture object */
+			networkid = atoi(cmd->params[3]);
+			friendly = g_strdup(purple_url_decode(cmd->params[4]));
+			clientid = strtoul(cmd->params[5], NULL, 10);
+		} else {
+			/* MSNP8+ with Display Picture object */
+			friendly = g_strdup(purple_url_decode(cmd->params[3]));
+			clientid = strtoul(cmd->params[4], NULL, 10);
+			msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[5]));
+		}
+	} else if (cmd->param_count == 5) {
+		/* MSNP8+ without Display Picture object */
+		friendly = g_strdup(purple_url_decode(cmd->params[3]));
+		clientid = strtoul(cmd->params[4], NULL, 10);
+	} else {
+		purple_debug_warning("msn", "Received ILN with unknown number of parameters.\n");
+		return;
+	}
 
 	serv_got_alias(gc, passport, friendly);
-
 	msn_user_set_friendly_name(user, friendly);
+	g_free(friendly);
 
-	if (cmd->param_count == 7)
-	{
-		msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[6]));
-		msn_user_set_object(user, msnobj);
-	}
+	msn_user_set_object(user, msnobj);
 
-	clientid = strtoul(cmd->params[5], NULL, 10);
 	user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone.mobile && user->phone.mobile[0] == '+');
 	msn_user_set_clientid(user, clientid);
 	msn_user_set_network(user, networkid);