Mercurial > pidgin
diff libpurple/protocols/msn/soap2.c @ 20530:719ce4acfcb9
the new soap code finally doesn't crash on startup, still can't
authenticate though
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Fri, 28 Sep 2007 05:51:49 +0000 |
parents | 1180920ffcec |
children | a96b5015395a |
line wrap: on
line diff
--- a/libpurple/protocols/msn/soap2.c Mon Sep 24 06:04:54 2007 +0000 +++ b/libpurple/protocols/msn/soap2.c Fri Sep 28 05:51:49 2007 +0000 @@ -170,6 +170,7 @@ if (strcmp(body->name, "Fault")) { xmlnode *fault = xmlnode_get_child(body, "faultcode"); + MsnSoapRequest *request; if (fault != NULL) { if (strcmp(fault->data, "psf:Redirect") == 0) { @@ -190,10 +191,11 @@ } } - conn->current_request->cb(conn->current_request->message, response, - conn->current_request->cb_data); - msn_soap_request_destroy(conn->current_request); + request = conn->current_request; conn->current_request = NULL; + conn->current_request->cb(request->message, response, + request->cb_data); + msn_soap_request_destroy(request); } } @@ -216,9 +218,9 @@ if (count < 0 && errno == EAGAIN) return; else if (count <= 0) { - msn_soap_connection_handle_next(conn); purple_ssl_close(conn->ssl); conn->ssl = NULL; + msn_soap_connection_handle_next(conn); return; } @@ -287,11 +289,7 @@ if ((conn->response_code == 301 || conn->response_code == 300) && strcmp(key, "Location") == 0) { - if (!msn_soap_handle_redirect(conn, value) && - conn->current_request->cb) { - conn->current_request->cb(conn->current_request->message, - NULL, conn->current_request->cb_data); - } + msn_soap_handle_redirect(conn, value); handled = TRUE; break; @@ -448,18 +446,21 @@ static void msn_soap_connection_handle_next(MsnSoapConnection *conn) { - if (conn->current_request) { - msn_soap_connection_destroy_foreach_cb(conn->current_request, conn); - conn->current_request = NULL; - } - purple_input_remove(conn->event_handle); conn->event_handle = 0; msn_soap_message_destroy(conn->message); + conn->message = NULL; g_string_free(conn->buf, TRUE); + conn->buf = NULL; conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, conn); + + if (conn->current_request) { + MsnSoapRequest *req = conn->current_request; + conn->current_request = NULL; + msn_soap_connection_destroy_foreach_cb(req, conn); + } } static void @@ -477,8 +478,9 @@ msn_soap_connection_destroy(MsnSoapConnection *conn) { if (conn->current_request) { - msn_soap_connection_destroy_foreach_cb(conn->current_request, conn); + MsnSoapRequest *req = conn->current_request; conn->current_request = NULL; + msn_soap_connection_destroy_foreach_cb(req, conn); } g_queue_foreach(conn->queue, msn_soap_connection_destroy_foreach_cb, conn); @@ -516,7 +518,8 @@ g_slist_foreach(message->headers, (GFunc)g_free, NULL); g_slist_free(message->headers); g_free(message->action); - xmlnode_free(message->xml); + if (message->xml) + xmlnode_free(message->xml); g_free(message); } } @@ -537,3 +540,22 @@ msn_soap_message_destroy(req->message); g_free(req); } + +xmlnode * +msn_soap_xml_get(xmlnode *parent, const char *node) +{ + xmlnode *ret; + char **tokens = g_strsplit(node, "/", -1); + int i; + + for (i = 0; tokens[i]; i++) { + if ((ret = xmlnode_get_child(parent, tokens[i])) != NULL) + parent = ret; + else + break; + } + + g_strfreev(tokens); + return ret; +} +