comparison libpurple/protocols/msn/soap2.c @ 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 4ea59c6e57cd
children fc060adb7178 b70f30dd4753
comparison
equal deleted inserted replaced
21583:21cbdaf265f6 21585:8fcd795f627e
206 206
207 static gboolean 207 static gboolean
208 msn_soap_handle_body(MsnSoapConnection *conn, MsnSoapMessage *response) 208 msn_soap_handle_body(MsnSoapConnection *conn, MsnSoapMessage *response)
209 { 209 {
210 xmlnode *body = xmlnode_get_child(response->xml, "Body"); 210 xmlnode *body = xmlnode_get_child(response->xml, "Body");
211 211 xmlnode *fault = xmlnode_get_child(response->xml, "Fault");
212 if (body) { 212
213 MsnSoapRequest *request; 213 if (fault) {
214 214 xmlnode *faultcode = xmlnode_get_child(fault, "faultcode");
215 if (strcmp(body->name, "Fault") == 0) { 215
216 xmlnode *fault = xmlnode_get_child(body, "faultcode"); 216 if (faultcode != NULL) {
217 217 char *faultdata = xmlnode_get_data(faultcode);
218 if (fault != NULL) { 218
219 char *faultdata = xmlnode_get_data(fault); 219 if (g_str_equal(faultdata, "psf:Redirect")) {
220 220 xmlnode *url = xmlnode_get_child(body, "redirectUrl");
221 if (strcmp(faultdata, "psf:Redirect") == 0) { 221
222 xmlnode *url = xmlnode_get_child(body, "redirectUrl"); 222 if (url) {
223 223 char *urldata = xmlnode_get_data(url);
224 if (url) { 224 msn_soap_handle_redirect(conn, urldata);
225 char *urldata = xmlnode_get_data(url); 225 g_free(urldata);
226 msn_soap_handle_redirect(conn, urldata);
227 g_free(urldata);
228 }
229
230 g_free(faultdata);
231 return TRUE;
232 } else if (strcmp(faultdata, "wsse:FailedAuthentication") == 0) {
233 xmlnode *reason = xmlnode_get_child(body, "faultstring");
234 char *reasondata = xmlnode_get_data(reason);
235
236 msn_soap_connection_sanitize(conn, TRUE);
237 msn_session_set_error(conn->session, MSN_ERROR_AUTH,
238 reasondata);
239
240 g_free(reasondata);
241 g_free(faultdata);
242 return FALSE;
243 } 226 }
244 227
245 g_free(faultdata); 228 g_free(faultdata);
229 return TRUE;
230 } else if (g_str_equal(faultdata, "wsse:FailedAuthentication")) {
231 xmlnode *reason = xmlnode_get_child(body, "faultstring");
232 char *reasondata = xmlnode_get_data(reason);
233
234 msn_soap_connection_sanitize(conn, TRUE);
235 msn_session_set_error(conn->session, MSN_ERROR_AUTH,
236 reasondata);
237
238 g_free(reasondata);
239 g_free(faultdata);
240 return FALSE;
246 } 241 }
242
243 g_free(faultdata);
247 } 244 }
248 245 }
249 request = conn->current_request; 246
247 if (fault || body) {
248 MsnSoapRequest *request = conn->current_request;
250 conn->current_request = NULL; 249 conn->current_request = NULL;
251 request->cb(request->message, response, 250 request->cb(request->message, response,
252 request->cb_data); 251 request->cb_data);
253 msn_soap_request_destroy(request); 252 msn_soap_request_destroy(request);
254 } 253 }