pidgin: adc3176c: Send the SOAP faultcode to the callbacks...

qulogic at pidgin.im qulogic at pidgin.im
Wed Dec 10 01:56:32 EST 2008


-----------------------------------------------------------------
Revision: adc3176c376f3dfd332101e7c3da956646c3331d
Ancestor: 68a2ccd3df34ca17e6d788cfcbaf96a605bea2e5
Author: qulogic at pidgin.im
Date: 2008-12-01T05:53:40
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/adc3176c376f3dfd332101e7c3da956646c3331d

Modified files:
        libpurple/protocols/msn/contact.c

ChangeLog: 

Send the SOAP faultcode to the callbacks for each Contact operation. They all
just print a debug message like it did before, but this should allow for
specific error handling.

References #6755.

Comments: 

References #3322.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/contact.c	b53c798969772eb9c127c9486269abe695d92d3b
+++ libpurple/protocols/msn/contact.c	584d94d53431ccc90ca22ae1df807af2b8f3a8a0
@@ -903,12 +903,15 @@ msn_contact_request_cb(MsnSoapMessage *r
 	}
 	else
 	{
-		/* We don't know how to respond to this faultcode, so just log it */
-		/* XXX: Probably should notify the user or undo the change or something? */
-		char *str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
-		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
-		                   msn_contact_operation_str(state->action), str);
-		g_free(str);
+		if (state->cb) {
+			((MsnSoapCallback)state->cb)(req, resp, data);
+		} else {
+			/* We don't know how to respond to this faultcode, so log it */
+			char *str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+			purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+			                   msn_contact_operation_str(state->action), str);
+			g_free(str);
+		}
 		msn_callback_state_free(state);
 	}
 
@@ -943,6 +946,17 @@ msn_add_contact_read_cb(MsnSoapMessage *
 	MsnUser *user;
 	xmlnode *guid;
 
+	char *fault_str;
+
+	/* We don't know how to respond to this faultcode, so log it */
+	fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+	if (fault_str != NULL) {
+		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+		                   msn_contact_operation_str(state->action), fault_str);
+		g_free(fault_str);
+		return;
+	}
+
 	g_return_if_fail(session != NULL);
 
 	userlist = session->userlist;
@@ -1012,8 +1026,16 @@ msn_add_contact_to_group_read_cb(MsnSoap
 {
 	MsnCallbackState *state = data;
 	MsnUserList *userlist;
+	char *fault_str;
 
-	g_return_if_fail(data != NULL);
+	/* We don't know how to respond to this faultcode, so log it */
+	fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+	if (fault_str != NULL) {
+		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+		                   msn_contact_operation_str(state->action), fault_str);
+		g_free(fault_str);
+		return;
+	}
 
 	userlist = state->session->userlist;
 
@@ -1120,7 +1142,17 @@ msn_delete_contact_read_cb(MsnSoapMessag
 	MsnCallbackState *state = data;
 	MsnUserList *userlist = state->session->userlist;
 	MsnUser *user = msn_userlist_find_user_with_id(userlist, state->uid);
+	char *fault_str;
 
+	/* We don't know how to respond to this faultcode, so log it */
+	fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+	if (fault_str != NULL) {
+		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+		                   msn_contact_operation_str(state->action), fault_str);
+		g_free(fault_str);
+		return;
+	}
+
 	purple_debug_info("msn", "Delete contact successful\n");
 
 	if (user != NULL) {
@@ -1165,7 +1197,17 @@ msn_del_contact_from_group_read_cb(MsnSo
 	gpointer data)
 {
 	MsnCallbackState *state = data;
+	char *fault_str;
 
+	/* We don't know how to respond to this faultcode, so log it */
+	fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+	if (fault_str != NULL) {
+		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+		                   msn_contact_operation_str(state->action), fault_str);
+		g_free(fault_str);
+		return;
+	}
+
 	if (msn_userlist_rem_buddy_from_group(state->session->userlist,
 			state->who, state->old_group_name)) {
 		purple_debug_info("msn", "Contact %s deleted successfully from group %s\n", state->who, state->old_group_name);
@@ -1235,6 +1277,18 @@ msn_update_contact_read_cb(MsnSoapMessag
 msn_update_contact_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp,
 	gpointer data)
 {
+	MsnCallbackState *state = (MsnCallbackState *)data;
+	char *fault_str;
+
+	/* We don't know how to respond to this faultcode, so log it */
+	fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+	if (fault_str != NULL) {
+		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+		                   msn_contact_operation_str(state->action), fault_str);
+		g_free(fault_str);
+		return;
+	}
+
 	purple_debug_info("msn", "Contact updated successfully\n");
 }
 
@@ -1312,7 +1366,17 @@ msn_del_contact_from_list_read_cb(MsnSoa
 {
 	MsnCallbackState *state = data;
 	MsnSession *session = state->session;
+	char *fault_str;
 
+	/* We don't know how to respond to this faultcode, so log it */
+	fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+	if (fault_str != NULL) {
+		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+		                   msn_contact_operation_str(state->action), fault_str);
+		g_free(fault_str);
+		return;
+	}
+
 	purple_debug_info("msn", "Contact %s deleted successfully from %s list on server!\n", state->who, MsnMemberRole[state->list_id]);
 
 	if (state->list_id == MSN_LIST_PL) {
@@ -1387,8 +1451,17 @@ msn_add_contact_to_list_read_cb(MsnSoapM
 	gpointer data)
 {
 	MsnCallbackState *state = data;
+	char *fault_str;
 
-	g_return_if_fail(state != NULL);
+	/* We don't know how to respond to this faultcode, so log it */
+	fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+	if (fault_str != NULL) {
+		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+		                   msn_contact_operation_str(state->action), fault_str);
+		g_free(fault_str);
+		return;
+	}
+
 	g_return_if_fail(state->session != NULL);
 
 	purple_debug_info("msn", "Contact %s added successfully to %s list on server!\n", state->who, MsnMemberRole[state->list_id]);
@@ -1482,7 +1555,17 @@ msn_group_read_cb(MsnSoapMessage *req, M
 	MsnCallbackState *state = data;
 	MsnSession *session;
 	MsnUserList *userlist;
+	char *fault_str;
 
+	/* We don't know how to respond to this faultcode, so log it */
+	fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL);
+	if (fault_str != NULL) {
+		purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
+		                   msn_contact_operation_str(state->action), fault_str);
+		g_free(fault_str);
+		return;
+	}
+
 	purple_debug_info("msn", "Group request successful.\n");
 
 	g_return_if_fail(state->session != NULL);
@@ -1661,3 +1744,4 @@ msn_contact_rename_group(MsnSession *ses
 	g_free(escaped_group_name);
 	g_free(body);
 }
+


More information about the Commits mailing list