comparison libpurple/protocols/msn/soap2.c @ 23506:d756a0477c06

propagate from branch 'im.pidgin.pidgin' (head e1c49c9ec5c6869ed9813feccd8ee41d2ca40f35) to branch 'im.pidgin.pidgin.khc.msnp15' (head cee4156a103d7f7b90a8d4e3a3ebf10950baf0aa)
author Ka-Hing Cheung <khc@hxbc.us>
date Wed, 14 May 2008 04:38:26 +0000
parents bca58b00afab 84807b5e60fa
children 0a762c2271ac
comparison
equal deleted inserted replaced
23505:a1652ea8f252 23506:d756a0477c06
31 31
32 #include "debug.h" 32 #include "debug.h"
33 #include "xmlnode.h" 33 #include "xmlnode.h"
34 34
35 #include <glib.h> 35 #include <glib.h>
36 #if !defined(_WIN32) || !defined(_WINERROR_)
36 #include <error.h> 37 #include <error.h>
38 #endif
37 39
38 #define SOAP_TIMEOUT (5 * 60) 40 #define SOAP_TIMEOUT (5 * 60)
39 41
40 typedef struct _MsnSoapRequest { 42 typedef struct _MsnSoapRequest {
41 char *path; 43 char *path;
262 } 264 }
263 265
264 static void 266 static void
265 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond) 267 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond)
266 { 268 {
267 MsnSoapConnection *conn = data; 269 MsnSoapConnection *conn = data;
268 int count = 0, cnt; 270 int count = 0, cnt;
269 char buf[8192]; 271 char buf[8192];
270 char *linebreak; 272 char *linebreak;
271 char *cursor; 273 char *cursor;
272 gboolean handled = FALSE; 274 gboolean handled = FALSE;
383 cursor = conn->buf->str + conn->handled_len; 385 cursor = conn->buf->str + conn->handled_len;
384 } 386 }
385 } 387 }
386 388
387 if (!handled && conn->headers_done) { 389 if (!handled && conn->headers_done) {
388 if (conn->buf->len - conn->handled_len >= 390 if (conn->buf->len - conn->handled_len >=
389 conn->body_len) { 391 conn->body_len) {
390 xmlnode *node = xmlnode_from_str(cursor, conn->body_len); 392 xmlnode *node = xmlnode_from_str(cursor, conn->body_len);
391 393
392 if (node == NULL) { 394 if (node == NULL) {
393 purple_debug_info("soap", "Malformed SOAP response: %s\n", 395 purple_debug_info("soap", "Malformed SOAP response: %s\n",
395 } else { 397 } else {
396 MsnSoapMessage *message = conn->message; 398 MsnSoapMessage *message = conn->message;
397 conn->message = NULL; 399 conn->message = NULL;
398 message->xml = node; 400 message->xml = node;
399 401
400 if (!msn_soap_handle_body(conn, message)) 402 if (!msn_soap_handle_body(conn, message)) {
403 msn_soap_message_destroy(message);
401 return; 404 return;
405 }
406 msn_soap_message_destroy(message);
402 } 407 }
403 408
404 msn_soap_connection_handle_next(conn); 409 msn_soap_connection_handle_next(conn);
405 } 410 }
406 411
501 conn->event_handle = purple_input_add(conn->ssl->fd, 506 conn->event_handle = purple_input_add(conn->ssl->fd,
502 PURPLE_INPUT_WRITE, msn_soap_write_cb, conn); 507 PURPLE_INPUT_WRITE, msn_soap_write_cb, conn);
503 msn_soap_write_cb(conn, conn->ssl->fd, PURPLE_INPUT_WRITE); 508 msn_soap_write_cb(conn, conn->ssl->fd, PURPLE_INPUT_WRITE);
504 509
505 g_free(body); 510 g_free(body);
506 } 511 }
507 } 512 }
508 513
509 return FALSE; 514 return FALSE;
510 } 515 }
511 516
636 g_free(message); 641 g_free(message);
637 } 642 }
638 } 643 }
639 644
640 void 645 void
641 msn_soap_message_add_header(MsnSoapMessage *req, 646 msn_soap_message_add_header(MsnSoapMessage *message,
642 const char *name, const char *value) 647 const char *name, const char *value)
643 { 648 {
644 char *header = g_strdup_printf("%s: %s\r\n", name, value); 649 char *header = g_strdup_printf("%s: %s\r\n", name, value);
645 650
646 req->headers = g_slist_prepend(req->headers, header); 651 message->headers = g_slist_prepend(message->headers, header);
647 } 652 }
648 653
649 static void 654 static void
650 msn_soap_request_destroy(MsnSoapRequest *req) 655 msn_soap_request_destroy(MsnSoapRequest *req)
651 { 656 {