changeset 31096:ed838ad00173

Fix MSN protocol version detection to use the best version returned by the server.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 02 Dec 2009 02:46:59 +0000
parents e30865b62859
children 88c48bcb5455
files libpurple/protocols/msn/notification.c libpurple/protocols/msn/session.c
diffstat 2 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/notification.c	Tue Dec 01 22:13:30 2009 +0000
+++ b/libpurple/protocols/msn/notification.c	Wed Dec 02 02:46:59 2009 +0000
@@ -236,20 +236,22 @@
 	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 @@
 		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!
--- a/libpurple/protocols/msn/session.c	Tue Dec 01 22:13:30 2009 +0000
+++ b/libpurple/protocols/msn/session.c	Wed Dec 02 02:46:59 2009 +0000
@@ -46,7 +46,7 @@
 								 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();