changeset 21585:8fcd795f627e

soap faults are now properly handled
author Ka-Hing Cheung <khc@hxbc.us>
date Mon, 19 Nov 2007 02:45:41 +0000
parents 21cbdaf265f6
children 948e5c7a558f 837c382af6a4
files libpurple/protocols/msn/soap2.c
diffstat 1 files changed, 28 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/soap2.c	Sun Nov 18 21:03:29 2007 +0000
+++ b/libpurple/protocols/msn/soap2.c	Mon Nov 19 02:45:41 2007 +0000
@@ -208,45 +208,44 @@
 msn_soap_handle_body(MsnSoapConnection *conn, MsnSoapMessage *response)
 {
 	xmlnode *body = xmlnode_get_child(response->xml, "Body");
-
-	if (body) {
-		MsnSoapRequest *request;
+	xmlnode *fault = xmlnode_get_child(response->xml, "Fault");
 
-		if (strcmp(body->name, "Fault") == 0) {
-			xmlnode *fault = xmlnode_get_child(body, "faultcode");
+	if (fault) {
+		xmlnode *faultcode = xmlnode_get_child(fault, "faultcode");
 
-			if (fault != NULL) {
-				char *faultdata = xmlnode_get_data(fault);
-
-				if (strcmp(faultdata, "psf:Redirect") == 0) {
-					xmlnode *url = xmlnode_get_child(body, "redirectUrl");
+		if (faultcode != NULL) {
+			char *faultdata = xmlnode_get_data(faultcode);
 
-					if (url) {
-						char *urldata = xmlnode_get_data(url);
-						msn_soap_handle_redirect(conn, urldata);
-						g_free(urldata);
-					}
+			if (g_str_equal(faultdata, "psf:Redirect")) {
+				xmlnode *url = xmlnode_get_child(body, "redirectUrl");
 
-					g_free(faultdata);
-					return TRUE;
-				} else if (strcmp(faultdata, "wsse:FailedAuthentication") == 0) {
-					xmlnode *reason = xmlnode_get_child(body, "faultstring");
-					char *reasondata = xmlnode_get_data(reason);
-
-					msn_soap_connection_sanitize(conn, TRUE);
-					msn_session_set_error(conn->session, MSN_ERROR_AUTH,
-						reasondata);
-
-					g_free(reasondata);
-					g_free(faultdata);
-					return FALSE;
+				if (url) {
+					char *urldata = xmlnode_get_data(url);
+					msn_soap_handle_redirect(conn, urldata);
+					g_free(urldata);
 				}
 
 				g_free(faultdata);
+				return TRUE;
+			} else if (g_str_equal(faultdata, "wsse:FailedAuthentication")) {
+				xmlnode *reason = xmlnode_get_child(body, "faultstring");
+				char *reasondata = xmlnode_get_data(reason);
+
+				msn_soap_connection_sanitize(conn, TRUE);
+				msn_session_set_error(conn->session, MSN_ERROR_AUTH,
+					reasondata);
+
+				g_free(reasondata);
+				g_free(faultdata);
+				return FALSE;
 			}
+
+			g_free(faultdata);
 		}
+	}
 
-		request = conn->current_request;
+	if (fault || body) {
+		MsnSoapRequest *request = conn->current_request;
 		conn->current_request = NULL;
 		request->cb(request->message, response,
 			request->cb_data);