pidgin: 9aeabc80: Support some older versions of the ILN c...

qulogic at pidgin.im qulogic at pidgin.im
Thu Aug 21 02:50:49 EDT 2008


-----------------------------------------------------------------
Revision: 9aeabc8056bc8b61f63881f3f6af2b2fcbd8b99c
Ancestor: c3270f154f1777243d7c71b4e7eaa86bb417d93a
Author: qulogic at pidgin.im
Date: 2008-08-21T06:40:00
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/9aeabc8056bc8b61f63881f3f6af2b2fcbd8b99c

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

ChangeLog: 

Support some older versions of the ILN command. Apparently some IM 
monitoring software inserts these, even though it's invalid on MSNP15.
Also, quit processing the ILN command if the user is not known to us.

Fixes #6656.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/notification.c	9b40a962bb89ad9d54a28bb9c2fef0e818cc9620
+++ libpurple/protocols/msn/notification.c	20c04cf6e7290488baf9c0e236654a7b996917d2
@@ -950,10 +950,11 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	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;
@@ -961,23 +962,47 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 
 	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;
 
-	serv_got_alias(gc, passport, friendly);
+	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);


More information about the Commits mailing list