/pidgin/main: e531664a3ad1: HTTP: purify internal API for msn's ...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Tue Jul 23 08:10:42 EDT 2013


Changeset: e531664a3ad1fa73eb575b768f5530b60f6c12d7
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-07-23 14:10 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/e531664a3ad1

Description:

HTTP: purify internal API for msn's SOAP handling

diffstat:

 libpurple/protocols/msn/contact.c |  36 ++++++++++++++++++------------------
 libpurple/protocols/msn/nexus.c   |   6 +++---
 libpurple/protocols/msn/oim.c     |  12 ++++++------
 libpurple/protocols/msn/soap.c    |  28 +++++++++++++++++-----------
 libpurple/protocols/msn/soap.h    |  27 +++++++++++----------------
 5 files changed, 55 insertions(+), 54 deletions(-)

diffs (truncated from 347 to 300 lines):

diff --git a/libpurple/protocols/msn/contact.c b/libpurple/protocols/msn/contact.c
--- a/libpurple/protocols/msn/contact.c
+++ b/libpurple/protocols/msn/contact.c
@@ -218,11 +218,11 @@ msn_contact_request_cb(MsnSoapMessage *r
 	}
 
  	/* Update CacheKey if necessary */
- 	cachekey = xmlnode_get_child(resp->xml, "Header/ServiceHeader/CacheKeyChanged");
+ 	cachekey = xmlnode_get_child(msn_soap_message_get_xml(resp), "Header/ServiceHeader/CacheKeyChanged");
  	if (cachekey != NULL) {
  		changed = xmlnode_get_data(cachekey);
  		if (changed && !strcmp(changed, "true")) {
- 			cachekey = xmlnode_get_child(resp->xml, "Header/ServiceHeader/CacheKey");
+ 			cachekey = xmlnode_get_child(msn_soap_message_get_xml(resp), "Header/ServiceHeader/CacheKey");
  			g_free(state->session->abch_cachekey);
  			state->session->abch_cachekey = xmlnode_get_data(cachekey);
  			purple_debug_info("msn", "Updated CacheKey for %s to '%s'.\n",
@@ -232,7 +232,7 @@ msn_contact_request_cb(MsnSoapMessage *r
  		g_free(changed);
  	}
 
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 
 	if (fault == NULL) {
 		/* No errors */
@@ -322,7 +322,7 @@ static void
 msn_create_address_cb(MsnSoapMessage *req, MsnSoapMessage *resp, gpointer data)
 {
 	MsnCallbackState *state = data;
-	if (resp && xmlnode_get_child(resp->xml, "Body/Fault") == NULL) {
+	if (resp && xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault") == NULL) {
 		purple_debug_info("msn", "Address Book successfully created!\n");
 		msn_get_address_book(state->session, MSN_PS_INITIAL, NULL, NULL);
 	} else {
@@ -536,7 +536,7 @@ msn_get_contact_list_cb(MsnSoapMessage *
 
 		purple_debug_misc("msn", "Got the contact list!\n");
 
-		if (msn_parse_contact_list(session, resp->xml)) {
+		if (msn_parse_contact_list(session, msn_soap_message_get_xml(resp))) {
 #ifdef MSN_PARTIAL_LISTS
 			abLastChange = purple_account_get_string(session->account,
 				"ablastChange", NULL);
@@ -992,7 +992,7 @@ msn_get_address_cb(MsnSoapMessage *req, 
 
 	purple_debug_misc("msn", "Got the Address Book!\n");
 
-	if (msn_parse_addressbook(session, resp->xml)) {
+	if (msn_parse_addressbook(session, msn_soap_message_get_xml(resp))) {
 		msn_send_privacy(purple_account_get_connection(session->account));
 		msn_notification_dump_contact(session);
 	} else {
@@ -1059,7 +1059,7 @@ msn_add_contact_read_cb(MsnSoapMessage *
 	g_return_if_fail(session != NULL);
 	userlist = session->userlist;
 
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *errorcode = xmlnode_get_data(xmlnode_get_child(fault, "detail/errorcode"));
 		if (errorcode && !strcmp(errorcode, "EmailDomainIsFederated")) {
@@ -1096,7 +1096,7 @@ msn_add_contact_read_cb(MsnSoapMessage *
 	user = msn_userlist_find_add_user(userlist, state->who, state->who);
 	msn_user_add_group_id(user, state->guid);
 
-	guid = xmlnode_get_child(resp->xml,
+	guid = xmlnode_get_child(msn_soap_message_get_xml(resp),
 		"Body/ABContactAddResponse/ABContactAddResult/guid");
 	if (guid != NULL) {
 		char *uid = xmlnode_get_data(guid);
@@ -1155,7 +1155,7 @@ msn_add_contact_to_group_read_cb(MsnSoap
 	g_return_if_fail(session != NULL);
 	userlist = session->userlist;
 
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *errorcode = xmlnode_get_data(xmlnode_get_child(fault, "detail/errorcode"));
 		if (errorcode && !strcmp(errorcode, "EmailDomainIsFederated")) {
@@ -1193,7 +1193,7 @@ msn_add_contact_to_group_read_cb(MsnSoap
 
 	if (state->action & MSN_ADD_BUDDY) {
 		MsnUser *user = msn_userlist_find_user(userlist, state->who);
-		xmlnode *guid = xmlnode_get_child(resp->xml,
+		xmlnode *guid = xmlnode_get_child(msn_soap_message_get_xml(resp),
 			"Body/ABGroupContactAddResponse/ABGroupContactAddResult/guid");
 
 		if (guid != NULL) {
@@ -1315,7 +1315,7 @@ msn_delete_contact_read_cb(MsnSoapMessag
 	xmlnode *fault;
 
 	/* We don't know how to respond to this faultcode, so log it */
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *fault_str = xmlnode_to_str(fault, NULL);
 		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
@@ -1371,7 +1371,7 @@ msn_del_contact_from_group_read_cb(MsnSo
 	xmlnode *fault;
 
 	/* We don't know how to respond to this faultcode, so log it */
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *fault_str = xmlnode_to_str(fault, NULL);
 		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
@@ -1453,7 +1453,7 @@ msn_update_contact_read_cb(MsnSoapMessag
 	xmlnode *fault;
 
 	/* We don't know how to respond to this faultcode, so log it */
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *fault_str = xmlnode_to_str(fault, NULL);
 		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
@@ -1551,7 +1551,7 @@ msn_annotate_contact_read_cb(MsnSoapMess
 	xmlnode *fault;
 
 	/* We don't know how to respond to this faultcode, so log it */
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *fault_str = xmlnode_to_str(fault, NULL);
 		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
@@ -1643,7 +1643,7 @@ msn_del_contact_from_list_read_cb(MsnSoa
 	xmlnode *fault;
 
 	/* We don't know how to respond to this faultcode, so log it */
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *fault_str = xmlnode_to_str(fault, NULL);
 		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
@@ -1741,7 +1741,7 @@ msn_add_contact_to_list_read_cb(MsnSoapM
 	xmlnode *fault;
 
 	/* We don't know how to respond to this faultcode, so log it */
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *fault_str = xmlnode_to_str(fault, NULL);
 		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
@@ -1855,7 +1855,7 @@ msn_group_read_cb(MsnSoapMessage *req, M
 	xmlnode *fault;
 
 	/* We don't know how to respond to this faultcode, so log it */
-	fault = xmlnode_get_child(resp->xml, "Body/Fault");
+	fault = xmlnode_get_child(msn_soap_message_get_xml(resp), "Body/Fault");
 	if (fault != NULL) {
 		char *fault_str = xmlnode_to_str(fault, NULL);
 		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
@@ -1882,7 +1882,7 @@ msn_group_read_cb(MsnSoapMessage *req, M
 		/* the response is taken from
 		   http://telepathy.freedesktop.org/wiki/Pymsn/MSNP/ContactListActions
 		   should copy it to msnpiki some day */
-		xmlnode *guid_node = xmlnode_get_child(resp->xml,
+		xmlnode *guid_node = xmlnode_get_child(msn_soap_message_get_xml(resp),
 			"Body/ABGroupAddResponse/ABGroupAddResult/guid");
 
 		if (guid_node) {
diff --git a/libpurple/protocols/msn/nexus.c b/libpurple/protocols/msn/nexus.c
--- a/libpurple/protocols/msn/nexus.c
+++ b/libpurple/protocols/msn/nexus.c
@@ -352,7 +352,7 @@ nexus_got_response_cb(MsnSoapMessage *re
 	}
 
 	if (!nexus_parse_collection(nexus, -1,
-	                            xmlnode_get_child(resp->xml,
+	                            xmlnode_get_child(msn_soap_message_get_xml(resp),
 	                                              "Body/RequestSecurityTokenResponseCollection"))) {
 		msn_session_set_error(session, MSN_ERROR_SERVCONN, _("Windows Live ID authentication:Invalid response"));
 		return;
@@ -438,7 +438,7 @@ nexus_got_update_cb(MsnSoapMessage *req,
 
 	purple_debug_info("msn", "Got Update Response for %s.\n", ticket_domains[ud->id][SSO_VALID_TICKET_DOMAIN]);
 
-	enckey = xmlnode_get_child(resp->xml, "Header/Security/DerivedKeyToken");
+	enckey = xmlnode_get_child(msn_soap_message_get_xml(resp), "Header/Security/DerivedKeyToken");
 	while (enckey) {
 		if (g_str_equal(xmlnode_get_attrib(enckey, "Id"), "EncKey"))
 			break;
@@ -467,7 +467,7 @@ nexus_got_update_cb(MsnSoapMessage *req,
 	}
 #endif
 
-	tmp = xmlnode_get_data(xmlnode_get_child(resp->xml,
+	tmp = xmlnode_get_data(xmlnode_get_child(msn_soap_message_get_xml(resp),
 		"Body/EncryptedData/CipherData/CipherValue"));
 	if (tmp) {
 		char *unescaped;
diff --git a/libpurple/protocols/msn/oim.c b/libpurple/protocols/msn/oim.c
--- a/libpurple/protocols/msn/oim.c
+++ b/libpurple/protocols/msn/oim.c
@@ -167,7 +167,7 @@ msn_oim_request_cb(MsnSoapMessage *reque
 	xmlnode *faultcode = NULL;
 
 	if (response != NULL)
-		fault = xmlnode_get_child(response->xml, "Body/Fault");
+		fault = xmlnode_get_child(msn_soap_message_get_xml(response), "Body/Fault");
 
 	if (fault && (faultcode = xmlnode_get_child(fault, "faultcode"))) {
 		gchar *faultcode_str = xmlnode_get_data(faultcode);
@@ -282,7 +282,7 @@ msn_oim_get_metadata_cb(MsnSoapMessage *
 
 	if (response) {
 		msn_parse_oim_xml(oim,
-			xmlnode_get_child(response->xml, "Body/GetMetadataResponse/MD"));
+			xmlnode_get_child(msn_soap_message_get_xml(response), "Body/GetMetadataResponse/MD"));
 	}
 }
 
@@ -351,7 +351,7 @@ msn_oim_send_read_cb(MsnSoapMessage *req
 	if (response == NULL) {
 		purple_debug_info("msn", "cannot send OIM: %s\n", msg->oim_msg);
 	} else {
-		xmlnode	*faultNode = xmlnode_get_child(response->xml, "Body/Fault");
+		xmlnode	*faultNode = xmlnode_get_child(msn_soap_message_get_xml(response), "Body/Fault");
 
 		if (faultNode == NULL) {
 			/*Send OK! return*/
@@ -499,7 +499,7 @@ msn_oim_delete_read_cb(MsnSoapMessage *r
 {
 	MsnOimRecvData *rdata = data;
 
-	if (response && xmlnode_get_child(response->xml, "Body/Fault") == NULL)
+	if (response && xmlnode_get_child(msn_soap_message_get_xml(response), "Body/Fault") == NULL)
 		purple_debug_info("msn", "Delete OIM success\n");
 	else
 		purple_debug_info("msn", "Delete OIM failed\n");
@@ -761,7 +761,7 @@ msn_oim_get_read_cb(MsnSoapMessage *requ
 	MsnOimRecvData *rdata = data;
 
 	if (response != NULL) {
-		xmlnode *msg_node = xmlnode_get_child(response->xml,
+		xmlnode *msg_node = xmlnode_get_child(msn_soap_message_get_xml(response),
 			"Body/GetMessageResponse/GetMessageResult");
 
 		if (msg_node) {
@@ -769,7 +769,7 @@ msn_oim_get_read_cb(MsnSoapMessage *requ
 			msn_oim_report_to_user(rdata, msg_str);
 			g_free(msg_str);
 		} else {
-			char *str = xmlnode_to_str(response->xml, NULL);
+			char *str = xmlnode_to_str(msn_soap_message_get_xml(response), NULL);
 			purple_debug_info("msn", "Unknown OIM response: %s\n", str);
 			g_free(str);
 			msn_oim_recv_data_free(rdata);
diff --git a/libpurple/protocols/msn/soap.c b/libpurple/protocols/msn/soap.c
--- a/libpurple/protocols/msn/soap.c
+++ b/libpurple/protocols/msn/soap.c
@@ -23,23 +23,29 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,  USA
  */
 
+#include "soap.h"
+
 #include "internal.h"
 
-#include "soap.h"
-
+#include "debug.h"
 #include "http.h"
-#include "session.h"
-
-#include "debug.h"
-#include "xmlnode.h"
-
-#include <glib.h>
-#if !defined(_WIN32) || !defined(_WINERROR_)
-#include <error.h>
-#endif
 
 #define SOAP_TIMEOUT (5 * 60)
 
+struct _MsnSoapMessage {
+	gchar *action;
+	xmlnode *xml;
+	GSList *headers;
+};
+
+xmlnode *
+msn_soap_message_get_xml(MsnSoapMessage *message)
+{
+	g_return_val_if_fail(message != NULL, NULL);
+
+	return message->xml;
+}
+
 typedef struct _MsnSoapRequest {
 	char *path;
 	MsnSoapMessage *message;
diff --git a/libpurple/protocols/msn/soap.h b/libpurple/protocols/msn/soap.h
--- a/libpurple/protocols/msn/soap.h
+++ b/libpurple/protocols/msn/soap.h
@@ -1,6 +1,5 @@
 /**
- * @file soap.h
- * 	header file for SOAP connection related process
+ * @file soap.h SOAP handling



More information about the Commits mailing list