changeset 19763:b488205ad0bc

[gaim-migrate @ 16884] chat function ok debugging the multiple soap request in one ssl connection not stable. comitted by MaYuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Sat, 19 Aug 2006 14:12:41 +0000
parents 75ecc42d3e8d
children da1075366756
files src/protocols/msn/README src/protocols/msn/msg.c src/protocols/msn/oim.c src/protocols/msn/oim.h src/protocols/msn/soap.c src/protocols/msn/soap.h src/protocols/msn/transaction.c
diffstat 7 files changed, 31 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/README	Sat Aug 19 11:46:33 2006 +0000
+++ b/src/protocols/msn/README	Sat Aug 19 14:12:41 2006 +0000
@@ -37,3 +37,11 @@
 
 4. Reference
 The very useful sites of MSN Protocol:
+MSNpiki site:
+reverse engineer of MSN Protocol.up to dated.
+http://msnpiki.msnfanatic.com/index.php/MSN_Protocol_Version_13
+
+hypothetic site:
+old MSN Protocol Introduction,but very useful for basic idea of MSN protocol
+http://www.hypothetic.org/docs/msn/index.php
+
--- a/src/protocols/msn/msg.c	Sat Aug 19 11:46:33 2006 +0000
+++ b/src/protocols/msn/msg.c	Sat Aug 19 14:12:41 2006 +0000
@@ -23,6 +23,7 @@
  */
 #include "msn.h"
 #include "msg.h"
+#define MSN_DEBUG_MSG
 
 MsnMessage *
 msn_message_new(MsnMsgType type)
@@ -123,12 +124,12 @@
 //	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, 'N');
+	msn_message_set_flag(msg, 'A');
 	msn_message_set_attr(msg, "X-MMS-IM-Format",
 						 "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)+1);
+	msn_message_set_bin_data(msg, message_cr, strlen(message_cr));
 	g_free(message_cr);
 
 	return msg;
@@ -514,14 +515,11 @@
 	if (msg->body != NULL)
 		g_free(msg->body);
 
-	if (data != NULL && len > 0)
-	{
+	if (data != NULL && len > 0){
 		msg->body = g_malloc0(len + 1);
 		memcpy(msg->body, data, len);
 		msg->body_len = len;
-	}
-	else
-	{
+	}else{
 		msg->body = NULL;
 		msg->body_len = 0;
 	}
--- a/src/protocols/msn/oim.c	Sat Aug 19 11:46:33 2006 +0000
+++ b/src/protocols/msn/oim.c	Sat Aug 19 14:12:41 2006 +0000
@@ -238,8 +238,6 @@
 	const char *soap_body,*t,*p;
 
 	gaim_debug_info("MaYuan","Get single OIM Message\n");
-	oim->retrieveconn->login_path = g_strdup(MSN_OIM_RETRIEVE__URL);
-	oim->retrieveconn->soap_action = g_strdup(MSN_OIM_GET_SOAP_ACTION);
 	t = oim->session->passport_info.t;
 	p = oim->session->passport_info.p;
 
@@ -248,8 +246,8 @@
 					p,
 					msgid
 					);
-	soap_request = msn_soap_request_new(MSN_OIM_SEND_HOST,
-					MSN_OIM_SEND_URL,MSN_OIM_SEND_SOAP_ACTION,
+	soap_request = msn_soap_request_new(MSN_OIM_RETRIEVE_HOST,
+					MSN_OIM_RETRIEVE_URL,MSN_OIM_GET_SOAP_ACTION,
 					soap_body,
 					msn_oim_get_read_cb,
 					msn_oim_get_written_cb);
@@ -261,22 +259,17 @@
 msn_oim_retrieve_connect_init(MsnSoapConn *soapconn)
 {
 	gaim_debug_info("MaYuan","msn_oim_connect...\n");
-
-	if(msn_soap_connected(soapconn) == -1){
-		msn_soap_init(soapconn,MSN_OIM_RETRIEVE_HOST,1,
+	msn_soap_init(soapconn,MSN_OIM_RETRIEVE_HOST,1,
 					msn_oim_get_connect_cb,
 					msn_oim_get_error_cb);
-	}
 }
 
 void msn_oim_send_connect_init(MsnSoapConn *sendconn)
 {
 	gaim_debug_info("MaYuan","msn oim send connect init...\n");
-	if(msn_soap_connected(sendconn) == -1){
-		msn_soap_init(sendconn,MSN_OIM_SEND_HOST,1,
+	msn_soap_init(sendconn,MSN_OIM_SEND_HOST,1,
 					msn_oim_send_connect_cb,
 					msn_oim_send_error_cb);
-	}
 }
 
 /*endof oim.c*/
--- a/src/protocols/msn/oim.h	Sat Aug 19 11:46:33 2006 +0000
+++ b/src/protocols/msn/oim.h	Sat Aug 19 14:12:41 2006 +0000
@@ -26,7 +26,7 @@
 #define _MSN_OIM_H_
 
 #define MSN_OIM_RETRIEVE_HOST	"rsi.hotmail.com"
-#define MSN_OIM_RETRIEVE__URL	"/rsi/rsi.asmx"
+#define MSN_OIM_RETRIEVE_URL	"/rsi/rsi.asmx"
 #define MSN_OIM_GET_SOAP_ACTION	"http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
 #define MSN_OIM_DEL_SOAP_ACTION	"http://www.hotmail.msn.com/ws/2004/09/oim/rsi/DeleteMessages"
 
--- a/src/protocols/msn/soap.c	Sat Aug 19 11:46:33 2006 +0000
+++ b/src/protocols/msn/soap.c	Sat Aug 19 14:12:41 2006 +0000
@@ -119,6 +119,7 @@
 				soapconn);
 	}else{
 	}
+	msn_soap_set_process_step(soapconn,MSN_SOAP_CONNECTING);
 }
 
 /*close the soap connection*/
@@ -185,14 +186,16 @@
 static gssize
 msn_soap_read(MsnSoapConn *soapconn)
 {
-	gssize len;
+	gssize len,requested_len;
 	gssize total_len = 0;
 	char temp_buf[MSN_SOAP_READ_BUFF_SIZE];
 
+//	requested_len = (soapconn->need_to_read > 0) ? soapconn->need_to_read : MSN_SOAP_READ_BUFF_SIZE;
+	requested_len = MSN_SOAP_READ_BUFF_SIZE;
 	if(soapconn->ssl_conn){
-		len = gaim_ssl_read(soapconn->gsc, temp_buf,MSN_SOAP_READ_BUFF_SIZE);
+		len = gaim_ssl_read(soapconn->gsc, temp_buf,requested_len);
 	}else{
-		len = read(soapconn->fd, temp_buf,MSN_SOAP_READ_BUFF_SIZE);
+		len = read(soapconn->fd, temp_buf,requested_len);
 	}
 	if(len >0){
 		total_len += len;
@@ -330,7 +333,9 @@
 			soapconn->body_len	= atoi(body_len);
 			gaim_debug_misc("MaYuan","SOAP Read length :%d,body len:%d\n",soapconn->read_len,soapconn->body_len);
 
+			soapconn->need_to_read = (body_start - soapconn->read_buf +soapconn->body_len) - soapconn->read_len;
 			if(soapconn->read_len < body_start - soapconn->read_buf + soapconn->body_len){
+//			if(soapconn->need_to_read >0){
 				return;
 			}
 			g_free(body_len);
@@ -370,6 +375,7 @@
 	}
 	soapconn->read_buf = NULL;
 	soapconn->read_len = 0;
+	soapconn->need_to_read = 0;
 }
 
 void
@@ -506,7 +512,7 @@
 				MsnSoapConnectInitFunction msn_soap_init_func)
 {
 	g_queue_push_tail(soapconn->soap_queue, request);
-	if(!msn_soap_connected(soapconn)){
+	if(!msn_soap_connected(soapconn)&&(soapconn->step == MSN_SOAP_UNCONNECTED)){
 		/*not connected?connect it first*/
 		gaim_debug_info("Ma Yuan","soap is not connected!\n");
 		msn_soap_init_func(soapconn);
--- a/src/protocols/msn/soap.h	Sat Aug 19 11:46:33 2006 +0000
+++ b/src/protocols/msn/soap.h	Sat Aug 19 14:12:41 2006 +0000
@@ -31,6 +31,7 @@
 typedef enum
 {
 	MSN_SOAP_UNCONNECTED,
+	MSN_SOAP_CONNECTING,
 	MSN_SOAP_CONNECTED,
 	MSN_SOAP_PROCESSING,
 	MSN_SOAP_CONNECTED_IDLE
@@ -95,6 +96,7 @@
 	/*read buffer*/
 	char *read_buf;
 	gsize read_len;
+	gsize need_to_read;
 	GaimInputFunction read_cb;
 
 	/*HTTP reply body part*/
--- a/src/protocols/msn/transaction.c	Sat Aug 19 11:46:33 2006 +0000
+++ b/src/protocols/msn/transaction.c	Sat Aug 19 14:12:41 2006 +0000
@@ -205,8 +205,7 @@
 void
 msn_transaction_set_timeout_cb(MsnTransaction *trans, MsnTimeoutCb cb)
 {
-	if (trans->timer)
-	{
+	if (trans->timer){
 		gaim_debug_error("msn", "This shouldn't be happening\n");
 		gaim_timeout_remove(trans->timer);
 	}