cpw.qulogic.msnp16: 5ea4e913: Fix MSN protocol version detection to us...

qulogic at pidgin.im qulogic at pidgin.im
Mon Dec 14 02:27:37 EST 2009


-----------------------------------------------------------------
Revision: 5ea4e913663e67ac8f47d220af8939e542c269d6
Ancestor: f88709dd4ccfa38136f3c8eb5575251494fa4aac
Author: qulogic at pidgin.im
Date: 2009-12-02T02:46:59
Branch: im.pidgin.cpw.qulogic.msnp16
URL: http://d.pidgin.im/viewmtn/revision/info/5ea4e913663e67ac8f47d220af8939e542c269d6

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

ChangeLog: 

Fix MSN protocol version detection to use the best version returned by the
server.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/notification.c	c6716a6eb10c255c1ddfc82e5507624e9d9b6837
+++ libpurple/protocols/msn/notification.c	dad27928edec2678ad2f127147bde8f3f866cba5
@@ -236,20 +236,22 @@ ver_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	MsnSession *session;
 	PurpleAccount *account;
 	gboolean protocol_supported = FALSE;
-	char proto_str[8];
+	int proto_ver;
 	size_t i;
 
 	session = cmdproc->session;
 	account = session->account;
 
-	g_snprintf(proto_str, sizeof(proto_str), "MSNP%d", session->protocol_ver);
-
+	session->protocol_ver = 0;
 	for (i = 1; i < cmd->param_count; i++)
 	{
-		if (!strcmp(cmd->params[i], proto_str))
-		{
-			protocol_supported = TRUE;
-			break;
+		if (sscanf(cmd->params[i], "MSNP%d", &proto_ver) == 1) {
+			if (proto_ver >= WLM_MIN_PROTOCOL
+			 && proto_ver <= WLM_MAX_PROTOCOL
+			 && proto_ver > session->protocol_ver) {
+				protocol_supported = TRUE;
+				session->protocol_ver = proto_ver;
+			}
 		}
 	}
 
@@ -260,6 +262,8 @@ ver_cmd(MsnCmdProc *cmdproc, MsnCommand 
 		return;
 	}
 
+	purple_debug_info("msn", "Negotiated protocol version %d with the server.\n", session->protocol_ver);
+
 	/*
 	 * Windows Live Messenger 8.5
 	 * Notice :CVR String discriminate!
============================================================
--- libpurple/protocols/msn/session.c	79b8c6f9e0afb00ed089b6891500ed83046ffc28
+++ libpurple/protocols/msn/session.c	6be2f0aee5e57b86f9c8c32448ddda3fd4efb176
@@ -46,7 +46,7 @@ msn_session_new(PurpleAccount *account)
 								 purple_account_get_username(account), NULL);
 	session->oim = msn_oim_new(session);
 
-	session->protocol_ver = WLM_PROT_VER;
+	session->protocol_ver = 0;
 
 	session->guid = rand_guid();
 


More information about the Commits mailing list