changeset 19824:a8d00b8dae40

[gaim-migrate @ 17040] send OIM middle version. Now can send to server, but need to encode the friend name to MIME format committed by MaYuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Sat, 26 Aug 2006 08:07:08 +0000
parents 1b6c631012d9
children 9cc3a3407816
files src/protocols/msn/contact.c src/protocols/msn/msn-utils.c src/protocols/msn/msn-utils.h src/protocols/msn/msn.c src/protocols/msn/oim.c src/protocols/msn/slpcall.c src/protocols/msn/user.h src/protocols/msn/userlist.c
diffstat 8 files changed, 65 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/contact.c	Sat Aug 26 03:25:00 2006 +0000
+++ b/src/protocols/msn/contact.c	Sat Aug 26 08:07:08 2006 +0000
@@ -384,11 +384,11 @@
 				g_free(group_id);
 			}
 		}else{
+			/*not in any group,Then set default group*/
 			group_id = g_strdup(MSN_INDIVIDUALS_GROUP_ID);
 			msn_user_add_group_id(user,group_id);
 			g_free(group_id);
 #if 0
-			/*not in any group,Then set default group*/
 			char *name,*group_id;
 
 			name = g_strdup(MSN_INDIVIDUALS_GROUP_NAME);
--- a/src/protocols/msn/msn-utils.c	Sat Aug 26 03:25:00 2006 +0000
+++ b/src/protocols/msn/msn-utils.c	Sat Aug 26 08:07:08 2006 +0000
@@ -26,6 +26,23 @@
 #include "time.h"
 //#include <openssl/md5.h>
 
+/**************************************************************************
+ * Util
+ **************************************************************************/
+char *
+rand_guid()
+{
+	return g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X",
+			rand() % 0xAAFF + 0x1111,
+			rand() % 0xAAFF + 0x1111,
+			rand() % 0xAAFF + 0x1111,
+			rand() % 0xAAFF + 0x1111,
+			rand() % 0xAAFF + 0x1111,
+			rand() % 0xAAFF + 0x1111,
+			rand() % 0xAAFF + 0x1111,
+			rand() % 0xAAFF + 0x1111);
+}
+
 void
 msn_parse_format(const char *mime, char **pre_ret, char **post_ret)
 {
--- a/src/protocols/msn/msn-utils.h	Sat Aug 26 03:25:00 2006 +0000
+++ b/src/protocols/msn/msn-utils.h	Sat Aug 26 08:07:08 2006 +0000
@@ -25,6 +25,11 @@
 #define _MSN_UTILS_H_
 
 /**
+ * Generate the Random GUID
+ */
+char * rand_guid();
+
+/**
  * Parses the MSN message formatting into a format compatible with Gaim.
  *
  * @param mime     The mime header with the formatting.
--- a/src/protocols/msn/msn.c	Sat Aug 26 03:25:00 2006 +0000
+++ b/src/protocols/msn/msn.c	Sat Aug 26 08:07:08 2006 +0000
@@ -896,7 +896,7 @@
 		friendname = g_strdup_printf("=?utf-8?B?Y2xpZW50?=");
 		msn_oim_prep_send_msg_info(oim,
 			gaim_account_get_username(account),friendname,who,
-			msg);
+			message);
 		msn_oim_send_msg(oim);
 	}
 	return 1;
--- a/src/protocols/msn/oim.c	Sat Aug 26 03:25:00 2006 +0000
+++ b/src/protocols/msn/oim.c	Sat Aug 26 08:07:08 2006 +0000
@@ -59,6 +59,7 @@
 {
 	MsnOimSendReq *request;
 	
+	gaim_debug_info("OIM","destroy the OIM \n");
 	msn_soap_destroy(oim->retrieveconn);
 	msn_soap_destroy(oim->sendconn);
 	g_free(oim->run_id);
@@ -81,17 +82,19 @@
 	MsnOimSendReq *request;
 	
 	request = g_new0(MsnOimSendReq, 1);
-	request->from_member =g_strdup(from_member);
-	request->friendname = g_strdup(friendname);
-	request->to_member = g_strdup(to_member);
-	request->send_seq = send_seq;
-	request->oim_msg= g_strdup(msg);
+	request->from_member	=g_strdup(from_member);
+	request->friendname		= g_strdup(friendname);
+	request->to_member		= g_strdup(to_member);
+	request->send_seq		= send_seq;
+	request->oim_msg		= g_strdup(msg);
 	return request;
 }
 
 void
 msn_oim_free_send_req(MsnOimSendReq *req)
 {
+	g_return_if_fail(req != NULL);
+
 	g_free(req->from_member);
 	g_free(req->friendname);
 	g_free(req->to_member);
@@ -107,20 +110,14 @@
 char * 
 msn_oim_msg_to_str(MsnOim *oim,char *body)
 {
-	char *oim_body;
-	char *oim_base64,*oim_base16;
+	char *oim_body,*oim_base64;
 	
 	gaim_debug_info("MaYuan","encode OIM Message...\n");	
-	gaim_debug_info("MaYuan","runid:{%s}\n",oim->run_id);	
-	gaim_debug_info("MaYuan","body:{%s}\n",body);	
 	oim_base64 = gaim_base64_encode((const guchar *)body, strlen(body));
-	gaim_debug_info("MaYuan","encode body:{%s}\n",oim_base64);	
-	oim_base16 = gaim_base16_encode((const guchar *)body, strlen(body));
-	gaim_debug_info("MaYuan","encode body:{%s}\n",oim_base16);	
+	gaim_debug_info("MaYuan","encoded base64 body:{%s}\n",oim_base64);	
 
 	oim_body = g_strdup_printf(MSN_OIM_MSG_TEMPLATE,
 				oim->run_id,oim->send_seq,oim_base64);
-	gaim_debug_info("MaYuan","start base64 encode\n",body);	
 
 	return oim_body;
 }
@@ -154,6 +151,10 @@
 	g_return_if_fail(session != NULL);
 }
 
+/*
+ * Process the send return SOAP string
+ * If got SOAP Fault,get the lock key,and resend it.
+ */
 void
 msn_oim_send_process(MsnOim *oim,char *body,int len)
 {
@@ -169,6 +170,7 @@
 		/*Send OK! return*/
 		MsnOimSendReq *request;
 		
+		gaim_debug_info("MaYuan","send OIM OK!");
 		xmlnode_free(responseNode);
 		request = g_queue_pop_head(oim->send_queue);
 		msn_oim_free_send_req(request);
@@ -179,9 +181,7 @@
 	/*get the challenge,and repost it*/
 	detailNode = xmlnode_get_child(faultNode, "detail");
 	challengeNode = xmlnode_get_child(detailNode,"LockKeyChallenge");
-//	gaim_debug_info("MaYuan","challenge:{%s}\n",challenge);
 
-	gaim_debug_info("MaYuan","prepare to dup the challenge\n");
 	g_free(oim->challenge);
 	oim->challenge = xmlnode_get_data(challengeNode);
 	gaim_debug_info("MaYuan","lockkey:{%s}\n",oim->challenge);
@@ -197,9 +197,14 @@
 msn_oim_send_read_cb(gpointer data, GaimSslConnection *gsc,
 				 GaimInputCondition cond)
 {
-	MsnSoapConn * soapconn = data;	
+	MsnSoapConn * soapconn = data;
+	MsnSession 	*session = soapconn->session;
 	MsnOim * oim;
 
+	g_return_if_fail(session != NULL);
+	oim = soapconn->session->oim;
+	g_return_if_fail(oim != NULL);
+
 	gaim_debug_info("MaYuan","read buffer:{%s}\n",soapconn->body);
 	msn_oim_send_process(oim,soapconn->body,soapconn->body_len);
 }
@@ -233,7 +238,9 @@
 	char *soap_body,*mspauth;
 	char *msg_body;
 	char buf[33];
-	
+
+	g_return_if_fail(oim != NULL);
+	gaim_debug_info("MaYuan","queue:{%p}\n",oim->send_queue);
 	oim_request = g_queue_pop_head(oim->send_queue);
 	if(oim_request == NULL){
 		return;
@@ -243,17 +250,21 @@
 		oim->session->passport_info.t,
 		oim->session->passport_info.p
 		);
-	gaim_debug_info("MaYuan","get mspauth...\n");	
+	g_queue_push_head(oim->send_queue,oim_request);
+
+	/* if we got the challenge lock key, we compute it
+	 * else we go for the SOAP fault and resend it.
+	 */
 	if(oim->challenge != NULL){
 		msn_handle_chl(oim->challenge, buf);
+		oim_request->send_seq++;
 	}else{
-		g_queue_push_head(oim->send_queue,oim_request);
+		gaim_debug_info("MaYuan","no lock key challenge,wait for SOAP Fault and Resend\n");
 		buf[0]='\0';
 	}
-	gaim_debug_info("MaYuan","get challenge...\n");	
+	gaim_debug_info("MaYuan","get the lock key challenge {%s}\n",buf);	
 
 	msg_body = msn_oim_msg_to_str(oim, oim_request->oim_msg);
-	gaim_debug_info("MaYuan","get body...\n");	
 	soap_body = g_strdup_printf(MSN_OIM_SEND_TEMPLATE,
 					oim_request->from_member,
 					oim_request->friendname,
@@ -264,7 +275,6 @@
 					oim_request->send_seq,
 					msg_body
 					);
-	gaim_debug_info("MaYuan","post body...\n");
 	soap_request = msn_soap_request_new(MSN_OIM_SEND_HOST,
 					MSN_OIM_SEND_URL,MSN_OIM_SEND_SOAP_ACTION,
 					soap_body,
--- a/src/protocols/msn/slpcall.c	Sat Aug 26 03:25:00 2006 +0000
+++ b/src/protocols/msn/slpcall.c	Sat Aug 26 08:07:08 2006 +0000
@@ -22,6 +22,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "msn.h"
+#include "msn-utils.h"
 #include "slpcall.h"
 #include "slpsession.h"
 
@@ -30,24 +31,6 @@
 /* #define MSN_DEBUG_SLPCALL */
 
 /**************************************************************************
- * Util
- **************************************************************************/
-
-char *
-rand_guid()
-{
-	return g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X",
-			rand() % 0xAAFF + 0x1111,
-			rand() % 0xAAFF + 0x1111,
-			rand() % 0xAAFF + 0x1111,
-			rand() % 0xAAFF + 0x1111,
-			rand() % 0xAAFF + 0x1111,
-			rand() % 0xAAFF + 0x1111,
-			rand() % 0xAAFF + 0x1111,
-			rand() % 0xAAFF + 0x1111);
-}
-
-/**************************************************************************
  * Main
  **************************************************************************/
 
--- a/src/protocols/msn/user.h	Sat Aug 26 03:25:00 2006 +0000
+++ b/src/protocols/msn/user.h	Sat Aug 26 08:07:08 2006 +0000
@@ -295,6 +295,12 @@
  */
 GHashTable *msn_user_get_client_caps(const MsnUser *user);
 
+/**
+ * check to see if user is online
+ */
+gboolean
+msn_user_is_online(GaimAccount *account, const char *name);
+
 /*@}*/
 
 #endif /* _MSN_USER_H_ */
--- a/src/protocols/msn/userlist.c	Sat Aug 26 03:25:00 2006 +0000
+++ b/src/protocols/msn/userlist.c	Sat Aug 26 08:07:08 2006 +0000
@@ -279,7 +279,7 @@
 			 *       looked at this.  Maybe we should use the store
 			 *       name instead? --KingAnt
 			 */
-			got_new_entry(gc, passport, friendly);
+//			got_new_entry(gc, passport, friendly);
 		}
 	}
 
@@ -391,7 +391,7 @@
 		 */
 
 		if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))){
-			got_new_entry(gc, passport, store);
+//			got_new_entry(gc, passport, store);
 		}
 	}