diff libpurple/protocols/msn/soap.c @ 20481:eb93710aec4d

Make buddy and group management actually work, add some SOAP templates, redesign some parts of code and separate some bigger functions into its smaller tasks which are completely unrelated to each other
author Carlos Silva <typ0@pidgin.im>
date Tue, 28 Aug 2007 03:54:18 +0000
parents 6a8463be5b23
children 321d25932f5e
line wrap: on
line diff
--- a/libpurple/protocols/msn/soap.c	Wed Aug 08 23:04:44 2007 +0000
+++ b/libpurple/protocols/msn/soap.c	Tue Aug 28 03:54:18 2007 +0000
@@ -486,6 +486,8 @@
 void 
 msn_soap_free_read_buf(MsnSoapConn *soapconn)
 {
+	g_return_if_fail(soapconn != NULL);
+	
 	if (soapconn->read_buf) {
 		g_free(soapconn->read_buf);
 	}
@@ -497,13 +499,23 @@
 void
 msn_soap_free_write_buf(MsnSoapConn *soapconn)
 {
-	if(soapconn->write_buf){
+	g_return_if_fail(soapconn != NULL);
+
+	if (soapconn->write_buf) {
 		g_free(soapconn->write_buf);
 	}
 	soapconn->write_buf = NULL;
 	soapconn->written_len = 0;
 }
 
+void
+msn_soap_free_data_cb(MsnSoapConn *soapconn)
+{
+	if (soapconn->data_cb) {
+		g_free(soapconn->data_cb);
+	}
+}
+
 /*Soap write process func*/
 static void
 msn_soap_write_cb(gpointer data, gint source, PurpleInputCondition cond)
@@ -582,7 +594,7 @@
 /* New a soap request*/
 MsnSoapReq *
 msn_soap_request_new(const char *host,const char *post_url,const char *soap_action,
-				const char *body,
+				const char *body, const gpointer data_cb,
 				PurpleInputFunction read_cb,PurpleInputFunction written_cb)
 {
 	MsnSoapReq *request;
@@ -594,6 +606,7 @@
 	request->login_path = g_strdup(post_url);
 	request->soap_action		= g_strdup(soap_action);
 	request->body		= g_strdup(body);
+	request->data_cb 	= data_cb;
 	request->read_cb	= read_cb;
 	request->written_cb	= written_cb;
 
@@ -610,6 +623,7 @@
 	g_free(request->login_path);
 	g_free(request->soap_action);
 	g_free(request->body);
+	g_free(request->data_cb);
 	request->read_cb	= NULL;
 	request->written_cb	= NULL;
 
@@ -649,7 +663,7 @@
 		msn_soap_connect(soapconn);
 		return;
 	}
-	purple_debug_misc("MSN SOAP","Connected to SOAP server!\n");
+	purple_debug_misc("MSN SOAP","Connected to SOAP server\n");
 
 	/*if connected, what we only needed to do is to queue the request, 
 	 * when SOAP request in the queue processed done, will do this command.
@@ -710,8 +724,9 @@
 	
 	g_free(soap_head);
 	/*free read buffer*/
-	msn_soap_free_read_buf(soapconn);
+	// msn_soap_free_read_buf(soapconn);
 	/*post it to server*/
-	msn_soap_write(soapconn,request_str,request->written_cb);
+	soapconn->data_cb = request->data_cb;
+	msn_soap_write(soapconn, request_str, request->written_cb);
 }