changeset 19762:75ecc42d3e8d

[gaim-migrate @ 16882] a version can work with windows Not stable committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Sat, 19 Aug 2006 11:46:33 +0000
parents 74334aadd843
children b488205ad0bc
files src/protocols/msn/contact.c src/protocols/msn/msg.c src/protocols/msn/nexus.c src/protocols/msn/nexus.h src/protocols/msn/notification.c src/protocols/msn/soap.c src/protocols/msn/switchboard.c
diffstat 7 files changed, 52 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/contact.c	Sat Aug 19 07:02:12 2006 +0000
+++ b/src/protocols/msn/contact.c	Sat Aug 19 11:46:33 2006 +0000
@@ -326,6 +326,9 @@
 			for(contactEmailNode = xmlnode_get_child(emailsNode,"ContactEmail");contactEmailNode;
 					contactEmailNode = xmlnode_get_next_twin(contactEmailNode) ){
 				messengerEnabledNode = xmlnode_get_child(contactEmailNode,"isMessengerEnabled");
+				if(messengerEnabledNode == NULL){
+					break;
+				}
 				msnEnabled = xmlnode_get_data(messengerEnabledNode);
 				if(!strcmp(msnEnabled,"true")){
 					emailNode = xmlnode_get_child(contactEmailNode,"email");
@@ -339,7 +342,10 @@
 		}
 
 		displayName = xmlnode_get_child(contactInfo,"displayName");
-		Name =xmlnode_get_data(displayName);
+		if(displayName == NULL)
+			Name = "";
+		else
+			Name =xmlnode_get_data(displayName);	
 
 		gaim_debug_misc("contact","name:%s,Id:{%s},display:{%s}\n",
 						passport,
--- a/src/protocols/msn/msg.c	Sat Aug 19 07:02:12 2006 +0000
+++ b/src/protocols/msn/msg.c	Sat Aug 19 11:46:33 2006 +0000
@@ -104,8 +104,7 @@
 	gaim_debug_info("msn", "message unref (%p)[%d]\n", msg, msg->ref_count);
 #endif
 
-	if (msg->ref_count == 0)
-	{
+	if (msg->ref_count == 0){
 		msn_message_destroy(msg);
 
 		return NULL;
@@ -121,15 +120,15 @@
 	char *message_cr;
 
 	msg = msn_message_new(MSN_MSG_TEXT);
-	msn_message_set_attr(msg, "User-Agent", "Gaim/" VERSION);
+//	msn_message_set_attr(msg, "User-Agent", "Gaim/" VERSION);
 	msn_message_set_content_type(msg, "text/plain");
 	msn_message_set_charset(msg, "UTF-8");
-	msn_message_set_flag(msg, 'A');
+	msn_message_set_flag(msg, 'N');
 	msn_message_set_attr(msg, "X-MMS-IM-Format",
-						 "FN=MS%20Sans%20Serif; EF=; CO=0; PF=0");
+						 "FN=MS%20Sans%20Serif; EF=; CO=0; CS=86;PF=0");
 
 	message_cr = gaim_str_add_cr(message);
-	msn_message_set_bin_data(msg, message_cr, strlen(message_cr));
+	msn_message_set_bin_data(msg, message_cr, strlen(message_cr)+1);
 	g_free(message_cr);
 
 	return msg;
@@ -471,7 +470,7 @@
 		{
 			memcpy(n, body, body_len);
 			n += body_len;
-			n = "\0";
+//			n = '\0';
 		}
 	}
 
--- a/src/protocols/msn/nexus.c	Sat Aug 19 07:02:12 2006 +0000
+++ b/src/protocols/msn/nexus.c	Sat Aug 19 11:46:33 2006 +0000
@@ -163,6 +163,7 @@
 	MsnSoapConn *soapconn;
 	MsnNexus * nexus;
 	MsnSession *session;
+	char *ru,*lc,*id,*tw,*ct,*kpp,*kv,*ver,*rn,*tpf;
 	char *username, *password;
 	char *request_str, *head, *tail,*challenge_str;
 
@@ -183,19 +184,31 @@
 	username = g_strdup(gaim_account_get_username(session->account));
 	password = g_strdup(gaim_connection_get_password(session->account->gc));
 
+	lc =	(char *)g_hash_table_lookup(nexus->challenge_data, "lc");
+	id =	(char *)g_hash_table_lookup(nexus->challenge_data, "id");
+	tw =	(char *)g_hash_table_lookup(nexus->challenge_data, "tw");
+	ru =	(char *)g_hash_table_lookup(nexus->challenge_data, "ru");
+	ct =	(char *)g_hash_table_lookup(nexus->challenge_data, "ct");
+	kpp=	(char *)g_hash_table_lookup(nexus->challenge_data, "kpp");
+	kv =	(char *)g_hash_table_lookup(nexus->challenge_data, "kv");
+	ver= (char *)g_hash_table_lookup(nexus->challenge_data, "ver");
+	rn = (char *)g_hash_table_lookup(nexus->challenge_data, "rn");
+	tpf=	(char *)g_hash_table_lookup(nexus->challenge_data, "tpf");
+
+	if(!(lc && id && tw && ru && ct && kpp && kv && ver && tpf)){
+		gaim_debug_error("MaYuan","WLM Authenticate Key Error!\n");
+		msn_session_set_error(session, MSN_ERROR_AUTH, _("Windows Live ID authentication Failed"));
+		g_free(username);
+		g_free(password);
+		gaim_ssl_close(gsc);
+		msn_nexus_destroy(nexus);
+		session->nexus = NULL;
+		return;
+	}
+
 	challenge_str = g_strdup_printf(
-		"lc=%s&amp;id=%s&amp;tw=%s&amp;fs=%s&amp;ru=%s&amp;ct=%s&amp;kpp=%s&amp;kv=%s&amp;ver=%s&amp;rn=%s&amp;tpf=%s\r\n",
-		(char *)g_hash_table_lookup(nexus->challenge_data, "lc"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "id"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "tw"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "fs"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "ru"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "ct"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "kpp"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "kv"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "ver"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "rn"),
-		(char *)g_hash_table_lookup(nexus->challenge_data, "tpf")
+		"lc=%s&amp;id=%s&amp;tw=%s&amp;fs=1&amp;ru=%s&amp;ct=%s&amp;kpp=%s&amp;kv=%s&amp;ver=%s&amp;rn=%s&amp;tpf=%s\r\n",
+		lc,id,tw,ru,ct,kpp,kv,ver,rn,tpf
 		);
 
 	/*build the SOAP windows Live ID XML body */
--- a/src/protocols/msn/nexus.h	Sat Aug 19 07:02:12 2006 +0000
+++ b/src/protocols/msn/nexus.h	Sat Aug 19 11:46:33 2006 +0000
@@ -77,7 +77,8 @@
 struct _MsnNexus
 {
 	MsnSession *session;
-	MsnSoapConn *soapconn;	
+	MsnSoapConn *soapconn;
+	char * challenge_data_str;
 	GHashTable *challenge_data;
 };
 
--- a/src/protocols/msn/notification.c	Sat Aug 19 07:02:12 2006 +0000
+++ b/src/protocols/msn/notification.c	Sat Aug 19 11:46:33 2006 +0000
@@ -248,15 +248,16 @@
 		session->nexus = msn_nexus_new(session);
 
 		/* Parse the challenge data. */
-
+		session->nexus->challenge_data_str = g_strdup(cmd->params[3]);
 		elems = g_strsplit(cmd->params[3], ",", 0);
 
 		for (cur = elems; *cur != NULL; cur++){
 			tokens = g_strsplit(*cur, "=", 2);
-//			gaim_debug_info("MaYuan","challenge %p,key:%s,value:%s\n",
-//								session->nexus->challenge_data,tokens[0],tokens[1]);
-			if(tokens[0]&&tokens[1])
+			if(tokens[0]&&tokens[1]){
+				gaim_debug_info("MaYuan","challenge %p,key:%s,value:%s\n",
+									session->nexus->challenge_data,tokens[0],tokens[1]);
 				g_hash_table_insert(session->nexus->challenge_data, tokens[0], tokens[1]);
+			}
 			/* Don't free each of the tokens, only the array. */
 			g_free(tokens);
 		}
--- a/src/protocols/msn/soap.c	Sat Aug 19 07:02:12 2006 +0000
+++ b/src/protocols/msn/soap.c	Sat Aug 19 11:46:33 2006 +0000
@@ -101,10 +101,12 @@
 				GaimSslInputFunction	connect_cb,
 				GaimSslErrorFunction	error_cb)
 {
+	gaim_debug_info("MaYuan","msn_soap_init...\n");
 	soapconn->login_host = g_strdup(host);
 	soapconn->ssl_conn = ssl;
 	soapconn->connect_cb = connect_cb;
 	soapconn->error_cb = error_cb;
+	gaim_debug_info("MaYuan","msn_soap_init...done\n");
 }
 
 /*connect the soap connection*/
@@ -343,14 +345,13 @@
 			if(soapconn->read_cb != NULL){
 				soapconn->read_cb(soapconn,source,0);
 			}
+			/*clear the read buffer*/
+			msn_soap_free_read_buf(soapconn);
 
 			/*Process the next queued SOAP request*/
 			msn_soap_post_head_request(soapconn);
 
 #if 0
-	/*clear the read buffer*/
-	msn_soap_free_read_buf(soapconn);
-
 	/*remove the read handler*/
 	gaim_input_remove(soapconn->input_handler);
 	soapconn->input_handler = -1;
--- a/src/protocols/msn/switchboard.c	Sat Aug 19 07:02:12 2006 +0000
+++ b/src/protocols/msn/switchboard.c	Sat Aug 19 11:46:33 2006 +0000
@@ -530,6 +530,7 @@
 	payload = msn_message_gen_payload(msg, &payload_len);
 
 #ifdef MSN_DEBUG_SB
+	gaim_debug_info("MaYuan","SB length:{%d}",payload_len);
 	msn_message_show_readable(msg, "SB SEND", FALSE);
 #endif
 
@@ -706,8 +707,8 @@
 
 	process_queue(swboard);
 
-	if (!session->http_method)
-		send_clientcaps(swboard);
+//	if (!session->http_method)
+//		send_clientcaps(swboard);
 
 	if (swboard->closed)
 		msn_switchboard_close(swboard);