im.pidgin.pidgin: 7683bc9cb2ac8831a96194c68fa781cdbaa8a6fe

datallah at pidgin.im datallah at pidgin.im
Wed Oct 3 21:21:59 EDT 2007


revision:            7683bc9cb2ac8831a96194c68fa781cdbaa8a6fe
date:                2007-10-04T01:12:08
author:              datallah at pidgin.im
branch:              im.pidgin.pidgin
changelog:
Cleanup the SOAP SSL flag to be a gboolean for clarity.  Various sanity checks, sanity checking and I think a couple leak fixes too for the offline IM code.

manifest:
format_version "1"

new_manifest [33b53359423b75091509fb8c845d101ee5edabf6]

old_revision [cbefbdeb71c4fe12f131d0932abeaf81bea091cb]

patch "libpurple/protocols/msn/contact.c"
 from [237bd2df0ea6cfdc4751fed4cc3ef2bd54db66db]
   to [a7a995a283fd788e18d72038b7749da91114b3fe]

patch "libpurple/protocols/msn/nexus.c"
 from [d9fa147a49267475bbbcfad3e859b02cc8f1d8bf]
   to [9bd63395fda2ec18e2fcbcfed61c1376c3d22903]

patch "libpurple/protocols/msn/oim.c"
 from [193865c5c46e2ba14f09d1addfd247c04ded2386]
   to [f9e705bd719c70b2aed9fa8f6644f64a1d417874]

patch "libpurple/protocols/msn/soap.c"
 from [8a27072e32a3cb6052fcaafc1dcd0d1abb6b65d7]
   to [f5a701f14faa491e9afd7c79615398e113d610e7]

patch "libpurple/protocols/msn/soap.h"
 from [77457a117e8c85f3cfa8930c8d4581a3ba586ca7]
   to [9557b05bcf075239f98d97a1a90d2c7469967bd2]
-------------- next part --------------
#
#
# patch "libpurple/protocols/msn/contact.c"
#  from [237bd2df0ea6cfdc4751fed4cc3ef2bd54db66db]
#    to [a7a995a283fd788e18d72038b7749da91114b3fe]
# 
# patch "libpurple/protocols/msn/nexus.c"
#  from [d9fa147a49267475bbbcfad3e859b02cc8f1d8bf]
#    to [9bd63395fda2ec18e2fcbcfed61c1376c3d22903]
# 
# patch "libpurple/protocols/msn/oim.c"
#  from [193865c5c46e2ba14f09d1addfd247c04ded2386]
#    to [f9e705bd719c70b2aed9fa8f6644f64a1d417874]
# 
# patch "libpurple/protocols/msn/soap.c"
#  from [8a27072e32a3cb6052fcaafc1dcd0d1abb6b65d7]
#    to [f5a701f14faa491e9afd7c79615398e113d610e7]
# 
# patch "libpurple/protocols/msn/soap.h"
#  from [77457a117e8c85f3cfa8930c8d4581a3ba586ca7]
#    to [9557b05bcf075239f98d97a1a90d2c7469967bd2]
#
============================================================
--- libpurple/protocols/msn/contact.c	237bd2df0ea6cfdc4751fed4cc3ef2bd54db66db
+++ libpurple/protocols/msn/contact.c	a7a995a283fd788e18d72038b7749da91114b3fe
@@ -1891,7 +1891,7 @@ msn_contact_connect_init(MsnSoapConn *so
 void
 msn_contact_connect_init(MsnSoapConn *soapconn)
 {
-	msn_soap_init(soapconn, MSN_CONTACT_SERVER, 1,
+	msn_soap_init(soapconn, MSN_CONTACT_SERVER, TRUE,
 		      msn_contact_login_connect_cb,
 		      msn_contact_login_error_cb);
 }
============================================================
--- libpurple/protocols/msn/nexus.c	d9fa147a49267475bbbcfad3e859b02cc8f1d8bf
+++ libpurple/protocols/msn/nexus.c	9bd63395fda2ec18e2fcbcfed61c1376c3d22903
@@ -463,6 +463,6 @@ msn_nexus_connect(MsnNexus *nexus)
 msn_nexus_connect(MsnNexus *nexus)
 {
 	/*  Authenticate via Windows Live ID. */
-	msn_soap_init(nexus->soapconn, MSN_TWN_SERVER, 1, nexus_login_connect_cb, nexus_login_error_cb);
+	msn_soap_init(nexus->soapconn, MSN_TWN_SERVER, TRUE, nexus_login_connect_cb, nexus_login_error_cb);
 	msn_soap_connect(nexus->soapconn);
 }
============================================================
--- libpurple/protocols/msn/oim.c	193865c5c46e2ba14f09d1addfd247c04ded2386
+++ libpurple/protocols/msn/oim.c	f9e705bd719c70b2aed9fa8f6644f64a1d417874
@@ -51,10 +51,10 @@ msn_oim_new(MsnSession *session)
 
 	oim = g_new0(MsnOim, 1);
 	oim->session = session;
-	oim->retrieveconn = msn_soap_new(session,oim,1);
+	oim->retrieveconn = msn_soap_new(session, oim, TRUE);
 	
-	oim->oim_list	= NULL;
-	oim->sendconn = msn_soap_new(session,oim,1);
+	oim->oim_list = NULL;
+	oim->sendconn = msn_soap_new(session, oim, TRUE);
 	oim->run_id = rand_guid();
 	oim->challenge = NULL;
 	oim->send_queue = g_queue_new();
@@ -165,70 +165,73 @@ msn_oim_send_process(MsnOim *oim, const 
 msn_oim_send_process(MsnOim *oim, const char *body, int len)
 {
 	xmlnode *responseNode, *bodyNode;
-	xmlnode	*faultNode, *faultCodeNode, *faultstringNode;
+	xmlnode *faultNode = NULL, *faultCodeNode, *faultstringNode;
 	xmlnode *detailNode, *challengeNode;
-	char *faultCodeStr = NULL, *faultstring = NULL;
+	char *fault_code, *fault_text;
 
 	responseNode = xmlnode_from_str(body,len);
+
 	g_return_if_fail(responseNode != NULL);
-	bodyNode = xmlnode_get_child(responseNode,"Body");
-	faultNode = xmlnode_get_child(bodyNode,"Fault");
-	if(faultNode == NULL){
+
+	if ((bodyNode = xmlnode_get_child(responseNode, "Body")))
+		faultNode = xmlnode_get_child(bodyNode, "Fault");
+
+	if (faultNode == NULL) {
 		/*Send OK! return*/
 		MsnOimSendReq *request;
-		
-		purple_debug_info("MSN OIM","send OIM OK!");
+
 		xmlnode_free(responseNode);
 		request = g_queue_pop_head(oim->send_queue);
 		msn_oim_free_send_req(request);
 		/*send next buffered Offline Message*/
 		msn_soap_post(oim->sendconn, NULL);
+
 		return;
 	}
+
 	/*get the challenge,and repost it*/
-	faultCodeNode = xmlnode_get_child(faultNode,"faultcode");
+	if (faultNode)
+		faultCodeNode = xmlnode_get_child(faultNode, "faultcode");
+
 	if(faultCodeNode == NULL){
-		purple_debug_info("MSN OIM","faultcode Node is NULL\n");
-		goto oim_send_process_fail;
+		purple_debug_info("MSN OIM", "No faultcode for failed Offline Message.\n");
+		xmlnode_free(responseNode);
+		return;
 	}
-	faultCodeStr = xmlnode_get_data(faultCodeNode);
-	purple_debug_info("MSN OIM","fault code:{%s}\n",faultCodeStr);
+
+	fault_code = xmlnode_get_data(faultCodeNode);
 #if 0
-	if(!strcmp(faultCodeStr,"q0:AuthenticationFailed")){
+	if(!strcmp(fault_code,"q0:AuthenticationFailed")){
 		/*other Fault Reason?*/
 		goto oim_send_process_fail;
 	}
 #endif
 
-	faultstringNode = xmlnode_get_child(faultNode,"faultstring");
-	faultstring = xmlnode_get_data(faultstringNode);
-	purple_debug_info("MSN OIM","fault string :{%s}\n",faultstring);
+	faultstringNode = xmlnode_get_child(faultNode, "faultstring");
+	fault_text = xmlnode_get_data(faultstringNode);
+	purple_debug_info("MSN OIM", "Error sending Offline Message: %s (%s)\n",
+		fault_text ? fault_text : "(null)", fault_code ? fault_code : "(null)");
 
 	/* lock key fault reason,
 	 * compute the challenge and resend it
 	 */
-	detailNode = xmlnode_get_child(faultNode, "detail");
-	if(detailNode == NULL){
-		goto oim_send_process_fail;
-	}
-	challengeNode = xmlnode_get_child(detailNode,"LockKeyChallenge");
-	if (challengeNode == NULL) {
-		goto oim_send_process_fail;
-	}
+	if ((detailNode = xmlnode_get_child(faultNode, "detail"))
+			&& (challengeNode = xmlnode_get_child(detailNode, "LockKeyChallenge"))) {
+		g_free(oim->challenge);
+		oim->challenge = xmlnode_get_data(challengeNode);
 
-	g_free(oim->challenge);
-	oim->challenge = xmlnode_get_data(challengeNode);
-	purple_debug_info("MSN OIM","lockkey:{%s}\n",oim->challenge);
+		purple_debug_info("MSN OIM", "Retrying Offline IM with lockkey:{%s}\n",
+			oim->challenge ? oim->challenge : "(null)");
 
-	/*repost the send*/
-	purple_debug_info("MSN OIM","prepare to repost the send...\n");
-	msn_oim_send_msg(oim);
+		/*repost the send*/
+		msn_oim_send_msg(oim);
 
-oim_send_process_fail:
-	g_free(faultstring);
-	g_free(faultCodeStr);
+		/* XXX: This needs to give up eventually (1 retry, maybe?) */
+	}
+
+	g_free(fault_text);
+	g_free(fault_code);
 	xmlnode_free(responseNode);
-	return ;
 }
 
 static gboolean
@@ -300,7 +303,7 @@ msn_oim_send_msg(MsnOim *oim)
 		purple_debug_info("MSN OIM","no lock key challenge,wait for SOAP Fault and Resend\n");
 		buf[0]='\0';
 	}
-	purple_debug_info("MSN OIM","get the lock key challenge {%s}\n",buf);	
+	purple_debug_info("MSN OIM","get the lock key challenge {%s}\n",buf);
 
 	msg_body = msn_oim_msg_to_str(oim, oim_request->oim_msg);
 	soap_body = g_strdup_printf(MSN_OIM_SEND_TEMPLATE,
@@ -311,8 +314,8 @@ msn_oim_send_msg(MsnOim *oim)
 					MSNP13_WLM_PRODUCT_ID,
 					buf,
 					oim_request->send_seq,
-					msg_body
-					);
+					msg_body);
+
 	soap_request = msn_soap_request_new(MSN_OIM_SEND_HOST,
 					MSN_OIM_SEND_URL,
 					MSN_OIM_SEND_SOAP_ACTION,
@@ -644,10 +647,8 @@ msn_parse_oim_msg(MsnOim *oim,const char
 		nickname = xmlnode_get_data(nNode);
 		/*receive time*/
 		rtNode = xmlnode_get_child(mNode,"RT");
-		if(rtNode != NULL) {
+		if(rtNode != NULL)
 			rTime = xmlnode_get_data(rtNode);
-			rtNode = NULL;
-		}
 /*		purple_debug_info("MSN OIM","E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime); */
 
 		oim->oim_list = g_list_append(oim->oim_list,strdup(msgid));
@@ -694,7 +695,7 @@ msn_oim_retrieve_connect_init(MsnSoapCon
 msn_oim_retrieve_connect_init(MsnSoapConn *soapconn)
 {
 	purple_debug_info("MSN OIM","Initializing OIM retrieve connection\n");
-	msn_soap_init(soapconn, MSN_OIM_RETRIEVE_HOST, 1,
+	msn_soap_init(soapconn, MSN_OIM_RETRIEVE_HOST, TRUE,
 		      msn_oim_get_connect_cb,
 		      msn_oim_get_error_cb);
 }
@@ -704,7 +705,7 @@ msn_oim_send_connect_init(MsnSoapConn *s
 msn_oim_send_connect_init(MsnSoapConn *sendconn)
 {
 	purple_debug_info("MSN OIM","Initializing OIM send connection\n");
-	msn_soap_init(sendconn, MSN_OIM_SEND_HOST, 1,
+	msn_soap_init(sendconn, MSN_OIM_SEND_HOST, TRUE,
 		      msn_oim_send_connect_cb,
 		      msn_oim_send_error_cb);
 }
============================================================
--- libpurple/protocols/msn/soap.c	8a27072e32a3cb6052fcaafc1dcd0d1abb6b65d7
+++ libpurple/protocols/msn/soap.c	f5a701f14faa491e9afd7c79615398e113d610e7
@@ -49,17 +49,16 @@ msn_soap_set_process_step(MsnSoapConn *s
 	soapconn->step = step;
 }
 
-//msn_soap_new(MsnSession *session,gpointer data,int sslconn)
 /*new a soap connection*/
 MsnSoapConn *
-msn_soap_new(MsnSession *session,gpointer data,int sslconn)
+msn_soap_new(MsnSession *session,gpointer data, gboolean ssl)
 {
 	MsnSoapConn *soapconn;
 
 	soapconn = g_new0(MsnSoapConn, 1);
 	soapconn->session = session;
 	soapconn->parent = data;
-	soapconn->ssl_conn = sslconn;
+	soapconn->ssl_conn = ssl;
 
 	soapconn->gsc = NULL;
 	soapconn->input_handler = 0;
@@ -127,7 +126,7 @@ void
 
 /*init the soap connection*/
 void
-msn_soap_init(MsnSoapConn *soapconn,char * host,int ssl,
+msn_soap_init(MsnSoapConn *soapconn,char * host, gboolean ssl,
 				MsnSoapSslConnectCbFunction connect_cb,
 				MsnSoapSslErrorCbFunction error_cb)
 {
============================================================
--- libpurple/protocols/msn/soap.h	77457a117e8c85f3cfa8930c8d4581a3ba586ca7
+++ libpurple/protocols/msn/soap.h	9557b05bcf075239f98d97a1a90d2c7469967bd2
@@ -83,9 +83,9 @@ struct _MsnSoapConn{
 
 	MsnSoapStep step;
 	/*ssl connection?*/
-	guint	ssl_conn;
+	gboolean ssl_conn;
 	/*normal connection*/
-	guint	fd;
+	guint fd;
 	/*SSL connection*/
 	PurpleSslConnection *gsc;
 	/*ssl connection callback*/
@@ -135,13 +135,13 @@ void msn_soap_post_head_request(MsnSoapC
 void msn_soap_post_head_request(MsnSoapConn *soapconn);
 
 /*new a soap conneciton */
-MsnSoapConn *msn_soap_new(MsnSession *session,gpointer data,int sslconn);
+MsnSoapConn *msn_soap_new(MsnSession *session, gpointer data, gboolean ssl);
 
 /*destroy */
 void msn_soap_destroy(MsnSoapConn *soapconn);
 
 /*init a soap conneciton */
-void msn_soap_init(MsnSoapConn *soapconn, char * host, int ssl,
+void msn_soap_init(MsnSoapConn *soapconn, char * host, gboolean ssl,
 		   MsnSoapSslConnectCbFunction connect_cb,
 		   MsnSoapSslErrorCbFunction error_cb);
 void msn_soap_connect(MsnSoapConn *soapconn);


More information about the Commits mailing list