annotate libpurple/protocols/msn/soap.c @ 32827:4a34689eeb33 default tip

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 19 Nov 2011 14:42:54 +0900
parents fe35df9a5af4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1 /**
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 22798
diff changeset
2 * @file soap.c
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
3 * Functions relating to SOAP connections.
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
4 *
20401
4ddc27c18781 Fix up some gaim -> purple issues.
Richard Laager <rlaager@wiktel.com>
parents: 20394
diff changeset
5 * purple
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
6 *
20401
4ddc27c18781 Fix up some gaim -> purple issues.
Richard Laager <rlaager@wiktel.com>
parents: 20394
diff changeset
7 * Purple is the legal property of its developers, whose names are too numerous
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
9 * source distribution.
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
10 *
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
14 * (at your option) any later version.
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
15 *
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
19 * GNU General Public License for more details.
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
20 *
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
28420
7921a53b94b3 Oops, Elliott correctly pointed out this was wrong...
Paul Aurich <paul@darkrain42.org>
parents: 28399
diff changeset
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
24 */
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
25
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
26 #include "internal.h"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
27
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
28 #include "soap.h"
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
29
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
30 #include "session.h"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
31
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
32 #include "debug.h"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
33 #include "xmlnode.h"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
34
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
35 #include <glib.h>
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
36 #if !defined(_WIN32) || !defined(_WINERROR_)
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
37 #include <error.h>
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
38 #endif
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
39
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
40 #define SOAP_TIMEOUT (5 * 60)
23805
29180633f672 I seem to have accidentally turned on those "unsafe" SOAP debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23775
diff changeset
41
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
42 typedef struct _MsnSoapRequest {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
43 char *path;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
44 MsnSoapMessage *message;
23658
860e5e210fc9 Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23566
diff changeset
45 gboolean secure;
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
46 MsnSoapCallback cb;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
47 gpointer cb_data;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
48 } MsnSoapRequest;
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
49
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
50 typedef struct _MsnSoapConnection {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
51 MsnSession *session;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
52 char *host;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
53
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
54 time_t last_used;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
55 PurpleSslConnection *ssl;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
56 gboolean connected;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
57
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
58 guint event_handle;
24477
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
59 guint run_timer;
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
60 GString *buf;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
61 gsize handled_len;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
62 gsize body_len;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
63 int response_code;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
64 gboolean headers_done;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
65 gboolean close_when_done;
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
66
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
67 MsnSoapMessage *message;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
68
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
69 GQueue *queue;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
70 MsnSoapRequest *current_request;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
71 } MsnSoapConnection;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
72
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
73 static gboolean msn_soap_connection_run(gpointer data);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
74
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
75 static MsnSoapConnection *
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
76 msn_soap_connection_new(MsnSession *session, const char *host)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
77 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
78 MsnSoapConnection *conn = g_new0(MsnSoapConnection, 1);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
79 conn->session = session;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
80 conn->host = g_strdup(host);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
81 conn->queue = g_queue_new();
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
82 return conn;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
83 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
84
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
85 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
86 msn_soap_message_destroy(MsnSoapMessage *message)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
87 {
24475
113e95371d3c I don't believe message should ever be null
Mark Doliner <mark@kingant.net>
parents: 24474
diff changeset
88 g_slist_foreach(message->headers, (GFunc)g_free, NULL);
113e95371d3c I don't believe message should ever be null
Mark Doliner <mark@kingant.net>
parents: 24474
diff changeset
89 g_slist_free(message->headers);
113e95371d3c I don't believe message should ever be null
Mark Doliner <mark@kingant.net>
parents: 24474
diff changeset
90 g_free(message->action);
113e95371d3c I don't believe message should ever be null
Mark Doliner <mark@kingant.net>
parents: 24474
diff changeset
91 if (message->xml)
113e95371d3c I don't believe message should ever be null
Mark Doliner <mark@kingant.net>
parents: 24474
diff changeset
92 xmlnode_free(message->xml);
113e95371d3c I don't believe message should ever be null
Mark Doliner <mark@kingant.net>
parents: 24474
diff changeset
93 g_free(message);
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
94 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
95
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
96 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
97 msn_soap_request_destroy(MsnSoapRequest *req, gboolean keep_message)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
98 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
99 g_free(req->path);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
100 if (!keep_message)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
101 msn_soap_message_destroy(req->message);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
102 g_free(req);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
103 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
104
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
105 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
106 msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
107 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
108 if (conn->event_handle) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
109 purple_input_remove(conn->event_handle);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
110 conn->event_handle = 0;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
111 }
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
112
24477
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
113 if (conn->run_timer) {
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
114 purple_timeout_remove(conn->run_timer);
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
115 conn->run_timer = 0;
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
116 }
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
117
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
118 if (conn->message) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
119 msn_soap_message_destroy(conn->message);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
120 conn->message = NULL;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
121 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
122
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
123 if (conn->buf) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
124 g_string_free(conn->buf, TRUE);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
125 conn->buf = NULL;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
126 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
127
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
128 if (conn->ssl && (disconnect || conn->close_when_done)) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
129 purple_ssl_close(conn->ssl);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
130 conn->ssl = NULL;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
131 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
132
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
133 if (conn->current_request) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
134 msn_soap_request_destroy(conn->current_request, FALSE);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
135 conn->current_request = NULL;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
136 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
137 }
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
138
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
139 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
140 msn_soap_connection_destroy_foreach_cb(gpointer item, gpointer data)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
141 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
142 MsnSoapRequest *req = item;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
143
31537
ce1bd217ce3d Everyone provides a callback here. Might as well make it required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30763
diff changeset
144 req->cb(req->message, NULL, req->cb_data);
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
145
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
146 msn_soap_request_destroy(req, FALSE);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
147 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
148
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
149 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
150 msn_soap_connection_destroy(MsnSoapConnection *conn)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
151 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
152 if (conn->current_request) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
153 MsnSoapRequest *req = conn->current_request;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
154 conn->current_request = NULL;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
155 msn_soap_connection_destroy_foreach_cb(req, conn);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
156 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
157
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
158 msn_soap_connection_sanitize(conn, TRUE);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
159 g_queue_foreach(conn->queue, msn_soap_connection_destroy_foreach_cb, conn);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
160 g_queue_free(conn->queue);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
161
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
162 g_free(conn->host);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
163 g_free(conn);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
164 }
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
165
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
166 static gboolean
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
167 msn_soap_cleanup_each(gpointer key, gpointer value, gpointer data)
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
168 {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
169 MsnSoapConnection *conn = value;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
170 time_t *t = data;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
171
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
172 if ((*t - conn->last_used) > SOAP_TIMEOUT * 2) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
173 purple_debug_info("soap", "cleaning up soap conn %p\n", conn);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
174 return TRUE;
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
175 }
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
176
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
177 return FALSE;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
178 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
179
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
180 static gboolean
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
181 msn_soap_cleanup_for_session(gpointer data)
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
182 {
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
183 MsnSession *sess = data;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
184 time_t t = time(NULL);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
185
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
186 purple_debug_info("soap", "session cleanup timeout\n");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
187
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
188 if (sess->soap_table) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
189 g_hash_table_foreach_remove(sess->soap_table, msn_soap_cleanup_each,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
190 &t);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
191
24480
a9fdc17304d9 Remove the timer if sess->soap_table is NULL. I don't think this ever
Mark Doliner <mark@kingant.net>
parents: 24477
diff changeset
192 if (g_hash_table_size(sess->soap_table) != 0)
a9fdc17304d9 Remove the timer if sess->soap_table is NULL. I don't think this ever
Mark Doliner <mark@kingant.net>
parents: 24477
diff changeset
193 return TRUE;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
194 }
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
195
24480
a9fdc17304d9 Remove the timer if sess->soap_table is NULL. I don't think this ever
Mark Doliner <mark@kingant.net>
parents: 24477
diff changeset
196 sess->soap_cleanup_handle = 0;
a9fdc17304d9 Remove the timer if sess->soap_table is NULL. I don't think this ever
Mark Doliner <mark@kingant.net>
parents: 24477
diff changeset
197 return FALSE;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
198 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
199
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
200 static MsnSoapConnection *
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
201 msn_soap_get_connection(MsnSession *session, const char *host)
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
202 {
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
203 MsnSoapConnection *conn = NULL;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
204
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
205 if (session->soap_table) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
206 conn = g_hash_table_lookup(session->soap_table, host);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
207 } else {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
208 session->soap_table = g_hash_table_new_full(g_str_hash, g_str_equal,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
209 NULL, (GDestroyNotify)msn_soap_connection_destroy);
20477
9a2a4a0c0003 Add the possibility to create an Address Book, useful for newly registered MSN users.
Carlos Silva <typ0@pidgin.im>
parents: 20471
diff changeset
210 }
9a2a4a0c0003 Add the possibility to create an Address Book, useful for newly registered MSN users.
Carlos Silva <typ0@pidgin.im>
parents: 20471
diff changeset
211
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
212 if (session->soap_cleanup_handle == 0)
24342
9bdaf273c0ff Use purple_timeout_add_seconds() instead of purple_timeout_add() in a
Mark Doliner <mark@kingant.net>
parents: 24018
diff changeset
213 session->soap_cleanup_handle = purple_timeout_add_seconds(SOAP_TIMEOUT,
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
214 msn_soap_cleanup_for_session, session);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
215
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
216 if (conn == NULL) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
217 conn = msn_soap_connection_new(session, host);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
218 g_hash_table_insert(session->soap_table, conn->host, conn);
20477
9a2a4a0c0003 Add the possibility to create an Address Book, useful for newly registered MSN users.
Carlos Silva <typ0@pidgin.im>
parents: 20471
diff changeset
219 }
9a2a4a0c0003 Add the possibility to create an Address Book, useful for newly registered MSN users.
Carlos Silva <typ0@pidgin.im>
parents: 20471
diff changeset
220
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
221 conn->last_used = time(NULL);
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 22798
diff changeset
222
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
223 return conn;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
224 }
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
225
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
226 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
227 msn_soap_connection_handle_next(MsnSoapConnection *conn)
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
228 {
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
229 msn_soap_connection_sanitize(conn, FALSE);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
230
24477
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
231 conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn);
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
232 }
20479
6a8463be5b23 Improve MSN_SOAP_DEBUG and workaround a Win32 bug which would case Pidgin to consume insane amounts of memory when printing a large string to the Debug Window.
Carlos Silva <typ0@pidgin.im>
parents: 20478
diff changeset
233
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
234 static void
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
235 msn_soap_message_send_internal(MsnSession *session, MsnSoapMessage *message,
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
236 const char *host, const char *path, gboolean secure,
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
237 MsnSoapCallback cb, gpointer cb_data, gboolean first)
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
238 {
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
239 MsnSoapConnection *conn = msn_soap_get_connection(session, host);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
240 MsnSoapRequest *req = g_new0(MsnSoapRequest, 1);
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
241
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
242 req->path = g_strdup(path);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
243 req->message = message;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
244 req->secure = secure;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
245 req->cb = cb;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
246 req->cb_data = cb_data;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
247
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
248 if (first) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
249 g_queue_push_head(conn->queue, req);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
250 } else {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
251 g_queue_push_tail(conn->queue, req);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
252 }
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 22798
diff changeset
253
24477
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
254 if (conn->run_timer == 0)
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
255 conn->run_timer = purple_timeout_add(0, msn_soap_connection_run,
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
256 conn);
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
257 }
20477
9a2a4a0c0003 Add the possibility to create an Address Book, useful for newly registered MSN users.
Carlos Silva <typ0@pidgin.im>
parents: 20471
diff changeset
258
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
259 void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
260 msn_soap_message_send(MsnSession *session, MsnSoapMessage *message,
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
261 const char *host, const char *path, gboolean secure,
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
262 MsnSoapCallback cb, gpointer cb_data)
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
263 {
24475
113e95371d3c I don't believe message should ever be null
Mark Doliner <mark@kingant.net>
parents: 24474
diff changeset
264 g_return_if_fail(message != NULL);
31537
ce1bd217ce3d Everyone provides a callback here. Might as well make it required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30763
diff changeset
265 g_return_if_fail(cb != NULL);
24475
113e95371d3c I don't believe message should ever be null
Mark Doliner <mark@kingant.net>
parents: 24474
diff changeset
266
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
267 msn_soap_message_send_internal(session, message, host, path, secure,
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
268 cb, cb_data, FALSE);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
269 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
270
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
271 static gboolean
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
272 msn_soap_handle_redirect(MsnSoapConnection *conn, const char *url)
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
273 {
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
274 char *host;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
275 char *path;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
276
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
277 if (purple_url_parse(url, &host, NULL, &path, NULL, NULL)) {
31538
b3a54678e51a Using conn->current_request looks a bit iffy here. And even if it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31537
diff changeset
278 MsnSoapRequest *req = conn->current_request;
b3a54678e51a Using conn->current_request looks a bit iffy here. And even if it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31537
diff changeset
279 conn->current_request = NULL;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
280
31538
b3a54678e51a Using conn->current_request looks a bit iffy here. And even if it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31537
diff changeset
281 msn_soap_message_send_internal(conn->session, req->message, host, path,
b3a54678e51a Using conn->current_request looks a bit iffy here. And even if it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31537
diff changeset
282 req->secure, req->cb, req->cb_data, TRUE);
b3a54678e51a Using conn->current_request looks a bit iffy here. And even if it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31537
diff changeset
283
b3a54678e51a Using conn->current_request looks a bit iffy here. And even if it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31537
diff changeset
284 msn_soap_request_destroy(req, TRUE);
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 22798
diff changeset
285
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
286 g_free(host);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
287 g_free(path);
20477
9a2a4a0c0003 Add the possibility to create an Address Book, useful for newly registered MSN users.
Carlos Silva <typ0@pidgin.im>
parents: 20471
diff changeset
288
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
289 return TRUE;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
290 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
291
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
292 return FALSE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
293 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
294
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
295 static gboolean
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
296 msn_soap_handle_body(MsnSoapConnection *conn, MsnSoapMessage *response)
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
297 {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
298 xmlnode *body = xmlnode_get_child(response->xml, "Body");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
299 xmlnode *fault = xmlnode_get_child(response->xml, "Fault");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
300
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
301 if (fault) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
302 xmlnode *faultcode = xmlnode_get_child(fault, "faultcode");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
303
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
304 if (faultcode != NULL) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
305 char *faultdata = xmlnode_get_data(faultcode);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
306
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
307 if (g_str_equal(faultdata, "psf:Redirect")) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
308 xmlnode *url = xmlnode_get_child(fault, "redirectUrl");
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
309
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
310 if (url) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
311 char *urldata = xmlnode_get_data(url);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
312 msn_soap_handle_redirect(conn, urldata);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
313 g_free(urldata);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
314 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
315
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
316 g_free(faultdata);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
317 msn_soap_message_destroy(response);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
318 return TRUE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
319 } else if (g_str_equal(faultdata, "wsse:FailedAuthentication")) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
320 xmlnode *reason = xmlnode_get_child(fault, "faultstring");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
321 char *reasondata = xmlnode_get_data(reason);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
322
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
323 msn_soap_connection_sanitize(conn, TRUE);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
324 msn_session_set_error(conn->session, MSN_ERROR_AUTH,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
325 reasondata);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
326
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
327 g_free(reasondata);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
328 g_free(faultdata);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
329 msn_soap_message_destroy(response);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
330 return FALSE;
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
331 }
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
332
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
333 g_free(faultdata);
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
334 }
20416
4c5d68e93ef8 Handles SOAP redirects, thanks Sebasti«¡n E. Peyrott
Ka-Hing Cheung <khc@hxbc.us>
parents: 20404
diff changeset
335 }
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
336
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
337 if (fault || body) {
25045
651cdeab9b99 conn->current_request can be NULL here.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24944
diff changeset
338 if (conn->current_request) {
651cdeab9b99 conn->current_request can be NULL here.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24944
diff changeset
339 MsnSoapRequest *request = conn->current_request;
651cdeab9b99 conn->current_request can be NULL here.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24944
diff changeset
340 conn->current_request = NULL;
651cdeab9b99 conn->current_request can be NULL here.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24944
diff changeset
341 request->cb(request->message, response,
651cdeab9b99 conn->current_request can be NULL here.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24944
diff changeset
342 request->cb_data);
651cdeab9b99 conn->current_request can be NULL here.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24944
diff changeset
343 msn_soap_request_destroy(request, FALSE);
651cdeab9b99 conn->current_request can be NULL here.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24944
diff changeset
344 }
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
345 msn_soap_message_destroy(response);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
346 }
20479
6a8463be5b23 Improve MSN_SOAP_DEBUG and workaround a Win32 bug which would case Pidgin to consume insane amounts of memory when printing a large string to the Debug Window.
Carlos Silva <typ0@pidgin.im>
parents: 20478
diff changeset
347
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
348 return TRUE;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
349 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
350
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
351 static void
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
352 msn_soap_message_add_header(MsnSoapMessage *message,
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
353 const char *name, const char *value)
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
354 {
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
355 char *header = g_strdup_printf("%s: %s\r\n", name, value);
24018
40a4e02027f4 shuffle some code around to make sure are using the right errno,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23949
diff changeset
356
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
357 message->headers = g_slist_prepend(message->headers, header);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
358 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
359
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
360 static void
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
361 msn_soap_process(MsnSoapConnection *conn)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
362 {
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
363 gboolean handled = FALSE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
364 char *cursor;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
365 char *linebreak;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
366
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
367 cursor = conn->buf->str + conn->handled_len;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
368
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
369 if (!conn->headers_done) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
370 while ((linebreak = strstr(cursor, "\r\n")) != NULL) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
371 conn->handled_len = linebreak - conn->buf->str + 2;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
372
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
373 if (conn->response_code == 0) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
374 if (sscanf(cursor, "HTTP/1.1 %d", &conn->response_code) != 1) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
375 /* something horribly wrong */
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
376 purple_ssl_close(conn->ssl);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
377 conn->ssl = NULL;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
378 handled = TRUE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
379 break;
28062
a9594824b8a3 If the SOAP server returns a 503 AND we haven't yet authenticated, then
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27380
diff changeset
380 } else if (conn->response_code == 503 && conn->session->login_step < MSN_LOGIN_STEP_END) {
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
381 msn_soap_connection_sanitize(conn, TRUE);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
382 msn_session_set_error(conn->session, MSN_ERROR_SERV_UNAVAILABLE, NULL);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
383 return;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
384 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
385 } else if (cursor == linebreak) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
386 /* blank line */
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
387 conn->headers_done = TRUE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
388 cursor = conn->buf->str + conn->handled_len;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
389 break;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
390 } else {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
391 char *line = g_strndup(cursor, linebreak - cursor);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
392 char *sep = strstr(line, ": ");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
393 char *key = line;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
394 char *value;
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
395
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
396 if (sep == NULL) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
397 purple_debug_info("soap", "ignoring malformed line: %s\n", line);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
398 g_free(line);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
399 goto loop_end;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
400 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
401
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
402 value = sep + 2;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
403 *sep = '\0';
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
404 msn_soap_message_add_header(conn->message, key, value);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
405
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
406 if ((conn->response_code == 301 || conn->response_code == 300)
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
407 && strcmp(key, "Location") == 0) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
408
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
409 msn_soap_handle_redirect(conn, value);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
410
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
411 handled = TRUE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
412 g_free(line);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
413 break;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
414 } else if (conn->response_code == 401 &&
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
415 strcmp(key, "WWW-Authenticate") == 0) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
416 char *error = strstr(value, "cbtxt=");
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
417
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
418 if (error) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
419 error += strlen("cbtxt=");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
420 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
421
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
422 msn_soap_connection_sanitize(conn, TRUE);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
423 msn_session_set_error(conn->session, MSN_ERROR_AUTH,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
424 error ? purple_url_decode(error) : NULL);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
425
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
426 g_free(line);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
427 return;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
428 } else if (strcmp(key, "Content-Length") == 0) {
25840
62e619e4957e Use sscanf to parse to parse the Content-Length to ensure consistent parsing for the target variable type. This comes out of the Veracode analysis.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 25045
diff changeset
429 sscanf(value, "%" G_GSIZE_FORMAT, &(conn->body_len));
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
430 } else if (strcmp(key, "Connection") == 0) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
431 if (strcmp(value, "close") == 0) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
432 conn->close_when_done = TRUE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
433 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
434 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
435 g_free(line);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
436 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
437
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
438 loop_end:
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
439 cursor = conn->buf->str + conn->handled_len;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
440 }
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
441 }
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
442
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
443 if (!handled && conn->headers_done) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
444 if (conn->buf->len - conn->handled_len >=
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
445 conn->body_len) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
446 xmlnode *node = xmlnode_from_str(cursor, conn->body_len);
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
447
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
448 if (node == NULL) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
449 purple_debug_info("soap", "Malformed SOAP response: %s\n",
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
450 cursor);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
451 } else {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
452 MsnSoapMessage *message = conn->message;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
453 conn->message = NULL;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
454 message->xml = node;
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
455
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
456 if (!msn_soap_handle_body(conn, message)) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
457 return;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
458 }
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
459 }
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
460
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
461 msn_soap_connection_handle_next(conn);
20539
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
462 }
2c8c6d77f12c Make use of the GQueue in MsnSoapConn to manage the SOAP requests, allowing them to work perfectly even when dispatching multiple requests at once.
Carlos Silva <typ0@pidgin.im>
parents: 20501
diff changeset
463
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
464 return;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
465 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
466
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
467 if (handled) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
468 msn_soap_connection_handle_next(conn);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
469 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
470 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
471
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
472 static void
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
473 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond)
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
474 {
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
475 MsnSoapConnection *conn = data;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
476 int count = 0, cnt, perrno;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
477 /* This buffer needs to be larger than any packets received from
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
478 login.live.com or Adium will fail to receive the packet
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
479 (something weird with the login.live.com server). With NSS it works
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
480 fine, so I believe it's some bug with OS X */
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
481 char buf[16 * 1024];
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
482 gsize cursor;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
483
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
484 if (conn->message == NULL) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
485 conn->message = msn_soap_message_new(NULL, NULL);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
486 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
487
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
488 if (conn->buf == NULL) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
489 conn->buf = g_string_new_len(buf, 0);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
490 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
491
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
492 cursor = conn->buf->len;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
493 while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
494 purple_debug_info("soap", "read %d bytes\n", cnt);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
495 count += cnt;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
496 g_string_append_len(conn->buf, buf, cnt);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
497 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
498
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
499 perrno = errno;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
500 if (cnt < 0 && perrno != EAGAIN)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
501 purple_debug_info("soap", "read: %s\n", g_strerror(perrno));
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
502
24944
b474cd321e88 make this toggleable via env instead of #define
Ka-Hing Cheung <khc@hxbc.us>
parents: 24943
diff changeset
503 if (conn->current_request && conn->current_request->secure &&
30763
9e71e7ddfebc There's no reason to cache this value, right?
Mark Doliner <mark@kingant.net>
parents: 28420
diff changeset
504 !purple_debug_is_unsafe())
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
505 purple_debug_misc("soap", "Received secure request.\n");
24944
b474cd321e88 make this toggleable via env instead of #define
Ka-Hing Cheung <khc@hxbc.us>
parents: 24943
diff changeset
506 else if (count != 0)
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
507 purple_debug_misc("soap", "current %s\n", conn->buf->str + cursor);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
508
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
509 /* && count is necessary for Adium, on OS X the last read always
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
510 return an error, so we want to proceed anyway. See #5212 for
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
511 discussion on this and the above buffer size issues */
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
512 if(cnt < 0 && errno == EAGAIN && count == 0)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
513 return;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
514
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
515 /* msn_soap_process could alter errno */
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
516 msn_soap_process(conn);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
517
24789
222265ec3044 I'm guessing this is what was intended here?
Mark Doliner <mark@kingant.net>
parents: 24773
diff changeset
518 if ((cnt < 0 && perrno != EAGAIN) || cnt == 0) {
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
519 /* It's possible msn_soap_process closed the ssl connection */
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
520 if (conn->ssl) {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
521 purple_ssl_close(conn->ssl);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
522 conn->ssl = NULL;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
523 msn_soap_connection_handle_next(conn);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
524 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
525 }
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
526 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
527
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
528 static gboolean
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
529 msn_soap_write_cb_internal(gpointer data, gint fd, PurpleInputCondition cond,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
530 gboolean initial)
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
531 {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
532 MsnSoapConnection *conn = data;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
533 int written;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
534
24476
faff4870f99d Formatting change: Split these if statements on to two lines
Mark Doliner <mark@kingant.net>
parents: 24475
diff changeset
535 if (cond != PURPLE_INPUT_WRITE)
faff4870f99d Formatting change: Split these if statements on to two lines
Mark Doliner <mark@kingant.net>
parents: 24475
diff changeset
536 return TRUE;
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
537
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
538 written = purple_ssl_write(conn->ssl, conn->buf->str + conn->handled_len,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
539 conn->buf->len - conn->handled_len);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
540
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
541 if (written < 0 && errno == EAGAIN)
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
542 return TRUE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
543 else if (written <= 0) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
544 purple_ssl_close(conn->ssl);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
545 conn->ssl = NULL;
24476
faff4870f99d Formatting change: Split these if statements on to two lines
Mark Doliner <mark@kingant.net>
parents: 24475
diff changeset
546 if (!initial)
faff4870f99d Formatting change: Split these if statements on to two lines
Mark Doliner <mark@kingant.net>
parents: 24475
diff changeset
547 msn_soap_connection_handle_next(conn);
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
548 return FALSE;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
549 }
20770
58ce69a8582d Correctly remove a buddy from the Pending list after it is accepted.
Carlos Silva <typ0@pidgin.im>
parents: 20759
diff changeset
550
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
551 conn->handled_len += written;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
553 if (conn->handled_len < conn->buf->len)
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
554 return TRUE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
555
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
556 /* we are done! */
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
557 g_string_free(conn->buf, TRUE);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
558 conn->buf = NULL;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
559 conn->handled_len = 0;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
560 conn->body_len = 0;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
561 conn->response_code = 0;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
562 conn->headers_done = FALSE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
563 conn->close_when_done = FALSE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
564
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
565 purple_input_remove(conn->event_handle);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
566 conn->event_handle = purple_input_add(conn->ssl->fd, PURPLE_INPUT_READ,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
567 msn_soap_read_cb, conn);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
568 return TRUE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
569 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
570
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
571 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
572 msn_soap_write_cb(gpointer data, gint fd, PurpleInputCondition cond)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
573 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
574 msn_soap_write_cb_internal(data, fd, cond, FALSE);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
575 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
576
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
577 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
578 msn_soap_error_cb(PurpleSslConnection *ssl, PurpleSslErrorType error,
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
579 gpointer data)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
580 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
581 MsnSoapConnection *conn = data;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
582
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
583 /* sslconn already frees the connection in case of error */
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
584 conn->ssl = NULL;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
585
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
586 g_hash_table_remove(conn->session->soap_table, conn->host);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
587 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
588
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
589 static void
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
590 msn_soap_connected_cb(gpointer data, PurpleSslConnection *ssl,
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
591 PurpleInputCondition cond)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
592 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
593 MsnSoapConnection *conn = data;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
594
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
595 conn->connected = TRUE;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
596
24477
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
597 if (conn->run_timer == 0)
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
598 conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn);
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
599 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
600
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
601 MsnSoapMessage *
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
602 msn_soap_message_new(const char *action, xmlnode *xml)
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
603 {
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
604 MsnSoapMessage *message = g_new0(MsnSoapMessage, 1);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
605
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
606 message->action = g_strdup(action);
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
607 message->xml = xml;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
608
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
609 return message;
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
610 }
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
611
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
612 static gboolean
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
613 msn_soap_connection_run(gpointer data)
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
614 {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
615 MsnSoapConnection *conn = data;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
616 MsnSoapRequest *req = g_queue_peek_head(conn->queue);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
617
24477
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
618 conn->run_timer = 0;
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
619
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
620 if (req) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
621 if (conn->ssl == NULL) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
622 conn->ssl = purple_ssl_connect(conn->session->account, conn->host,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
623 443, msn_soap_connected_cb, msn_soap_error_cb, conn);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
624 } else if (conn->connected) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
625 int len = -1;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
626 char *body = xmlnode_to_str(req->message->xml, &len);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
627 GSList *iter;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
628
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
629 g_queue_pop_head(conn->queue);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
630
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
631 conn->buf = g_string_new("");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
632
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
633 g_string_append_printf(conn->buf,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
634 "POST /%s HTTP/1.1\r\n"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
635 "SOAPAction: %s\r\n"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
636 "Content-Type:text/xml; charset=utf-8\r\n"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
637 "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
638 "Accept: */*\r\n"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
639 "Host: %s\r\n"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
640 "Content-Length: %d\r\n"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
641 "Connection: Keep-Alive\r\n"
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
642 "Cache-Control: no-cache\r\n",
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
643 req->path, req->message->action ? req->message->action : "",
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
644 conn->host, len);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
645
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
646 for (iter = req->message->headers; iter; iter = iter->next) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
647 g_string_append(conn->buf, (char *)iter->data);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
648 g_string_append(conn->buf, "\r\n");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
649 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
650
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
651 g_string_append(conn->buf, "\r\n");
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
652 g_string_append(conn->buf, body);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
653
30763
9e71e7ddfebc There's no reason to cache this value, right?
Mark Doliner <mark@kingant.net>
parents: 28420
diff changeset
654 if (req->secure && !purple_debug_is_unsafe())
23775
92d0151e907b Relegate XML dumped by msn's SOAP code to MISC from INFO.
Will Thompson <will.thompson@collabora.co.uk>
parents: 23671
diff changeset
655 purple_debug_misc("soap", "Sending secure request.\n");
23658
860e5e210fc9 Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23566
diff changeset
656 else
24944
b474cd321e88 make this toggleable via env instead of #define
Ka-Hing Cheung <khc@hxbc.us>
parents: 24943
diff changeset
657 purple_debug_misc("soap", "%s\n", conn->buf->str);
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
658
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
659 conn->handled_len = 0;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
660 conn->current_request = req;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
661
26973
4bba5827b7fc Get rid of a runtime warning on connect.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25895
diff changeset
662 if (conn->event_handle)
4bba5827b7fc Get rid of a runtime warning on connect.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25895
diff changeset
663 purple_input_remove(conn->event_handle);
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
664 conn->event_handle = purple_input_add(conn->ssl->fd,
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
665 PURPLE_INPUT_WRITE, msn_soap_write_cb, conn);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
666 if (!msn_soap_write_cb_internal(conn, conn->ssl->fd, PURPLE_INPUT_WRITE, TRUE)) {
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
667 /* Not connected => reconnect and retry */
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
668 purple_debug_info("soap", "not connected, reconnecting\n");
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
669
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
670 conn->connected = FALSE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
671 conn->current_request = NULL;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
672 msn_soap_connection_sanitize(conn, FALSE);
24474
01e8334101df Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <mark@kingant.net>
parents: 24424
diff changeset
673
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
674 g_queue_push_head(conn->queue, req);
24477
d70eb6304eae Use separate variables to keep track of the timer and the watcher.
Mark Doliner <mark@kingant.net>
parents: 24476
diff changeset
675 conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn);
23552
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
676 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
677
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
678 g_free(body);
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
679 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
680 }
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
681
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
682 return FALSE;
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23509
diff changeset
683 }