Mercurial > pidgin
annotate libpurple/protocols/msn/soap.c @ 23713:92d0151e907b
Relegate XML dumped by msn's SOAP code to MISC from INFO.
If anyone objects wildly to this, feel free to disapprove, but it makes wading
through debug output a pain (when I otherwise want >=INFO-level debugging
output).
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Wed, 13 Aug 2008 15:25:51 +0000 |
parents | 96e78c0fa32b |
children | 29180633f672 |
rev | line source |
---|---|
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
1 /** |
23298
5cdd93dac7a2
Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
22822
diff
changeset
|
2 * @file soap.c |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
3 * C file for SOAP connection related process |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
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 |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
24 */ |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
25 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
26 #include "internal.h" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
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 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
30 #include "session.h" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
31 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
32 #include "debug.h" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
33 #include "xmlnode.h" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
34 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
35 #include <glib.h> |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
36 #if !defined(_WIN32) || !defined(_WINERROR_) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
37 #include <error.h> |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
38 #endif |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
39 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
40 #define SOAP_TIMEOUT (5 * 60) |
23626
96e78c0fa32b
Get rid of MsnSlpSession entirely. It only seems to link to MsnSlpCall
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23613
diff
changeset
|
41 #define MSN_UNSAFE_DEBUG 1 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
42 typedef struct _MsnSoapRequest { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
43 char *path; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
44 MsnSoapMessage *message; |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
45 gboolean secure; |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
46 MsnSoapCallback cb; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
47 gpointer cb_data; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
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 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
50 typedef struct _MsnSoapConnection { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
51 MsnSession *session; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
52 char *host; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
53 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
54 time_t last_used; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
55 PurpleSslConnection *ssl; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
56 gboolean connected; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
57 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
58 guint event_handle; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
59 GString *buf; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
60 gsize handled_len; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
61 gsize body_len; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
62 int response_code; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
63 gboolean headers_done; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
64 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
|
65 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
66 MsnSoapMessage *message; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
67 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
68 GQueue *queue; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
69 MsnSoapRequest *current_request; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
70 } MsnSoapConnection; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
71 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
72 static void msn_soap_connection_destroy_foreach_cb(gpointer item, gpointer data); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
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 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
75 static MsnSoapConnection *msn_soap_connection_new(MsnSession *session, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
76 const char *host); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
77 static void msn_soap_connection_handle_next(MsnSoapConnection *conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
78 static void msn_soap_connection_destroy(MsnSoapConnection *conn); |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
79 |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
80 static void msn_soap_message_send_internal(MsnSession *session, MsnSoapMessage *message, |
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
81 const char *host, const char *path, gboolean secure, |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
82 MsnSoapCallback cb, gpointer cb_data, gboolean first); |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
83 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
84 static void msn_soap_request_destroy(MsnSoapRequest *req, gboolean keep_message); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
85 static void msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
86 static gboolean msn_soap_write_cb_internal(gpointer data, gint fd, PurpleInputCondition cond, gboolean initial); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
87 static void msn_soap_process(MsnSoapConnection *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
|
88 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
89 static gboolean |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
90 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:
23464
diff
changeset
|
91 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
92 MsnSoapConnection *conn = value; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
93 time_t *t = data; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
94 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
95 if ((*t - conn->last_used) > SOAP_TIMEOUT * 2) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
96 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:
23464
diff
changeset
|
97 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
|
98 } |
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
|
99 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
100 return FALSE; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
101 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
102 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
103 static gboolean |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
104 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
|
105 { |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
106 MsnSession *sess = data; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
107 time_t t = time(NULL); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
108 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
109 purple_debug_info("soap", "session cleanup timeout\n"); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
110 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
111 if (sess->soap_table) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
112 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:
23464
diff
changeset
|
113 &t); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
114 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
115 if (g_hash_table_size(sess->soap_table) == 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
116 purple_timeout_remove(sess->soap_cleanup_handle); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
117 sess->soap_cleanup_handle = 0; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
118 } |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
119 } |
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
|
120 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
121 return TRUE; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
122 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
123 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
124 static MsnSoapConnection * |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
125 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
|
126 { |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
127 MsnSoapConnection *conn = NULL; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
128 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
129 if (session->soap_table) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
130 conn = g_hash_table_lookup(session->soap_table, host); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
131 } else { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
132 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:
23464
diff
changeset
|
133 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
|
134 } |
9a2a4a0c0003
Add the possibility to create an Address Book, useful for newly registered MSN users.
Carlos Silva <typ0@pidgin.im>
parents:
20471
diff
changeset
|
135 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
136 if (session->soap_cleanup_handle == 0) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
137 session->soap_cleanup_handle = purple_timeout_add(SOAP_TIMEOUT * 1000, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
138 msn_soap_cleanup_for_session, session); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
139 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
140 if (conn == NULL) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
141 conn = msn_soap_connection_new(session, host); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
142 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
|
143 } |
9a2a4a0c0003
Add the possibility to create an Address Book, useful for newly registered MSN users.
Carlos Silva <typ0@pidgin.im>
parents:
20471
diff
changeset
|
144 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
145 conn->last_used = time(NULL); |
23298
5cdd93dac7a2
Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
22822
diff
changeset
|
146 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
147 return conn; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
148 } |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
149 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
150 static MsnSoapConnection * |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
151 msn_soap_connection_new(MsnSession *session, const char *host) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
152 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
153 MsnSoapConnection *conn = g_new0(MsnSoapConnection, 1); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
154 conn->session = session; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
155 conn->host = g_strdup(host); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
156 conn->queue = g_queue_new(); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
157 return conn; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
158 } |
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
|
159 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
160 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
161 msn_soap_connected_cb(gpointer data, PurpleSslConnection *ssl, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
162 PurpleInputCondition cond) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
163 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
164 MsnSoapConnection *conn = data; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
165 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
166 conn->connected = TRUE; |
23298
5cdd93dac7a2
Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
22822
diff
changeset
|
167 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
168 if (conn->event_handle == 0) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
169 conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
170 } |
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
|
171 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
172 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
173 msn_soap_error_cb(PurpleSslConnection *ssl, PurpleSslErrorType error, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
174 gpointer data) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
175 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
176 MsnSoapConnection *conn = data; |
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
|
177 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
178 /* sslconn already frees the connection in case of error */ |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
179 conn->ssl = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
180 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
181 g_hash_table_remove(conn->session->soap_table, conn->host); |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
182 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
183 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
184 static gboolean |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
185 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
|
186 { |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
187 char *host; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
188 char *path; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
189 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
190 if (purple_url_parse(url, &host, NULL, &path, NULL, NULL)) { |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
191 msn_soap_message_send_internal(conn->session, conn->current_request->message, |
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
192 host, path, conn->current_request->secure, |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
193 conn->current_request->cb, conn->current_request->cb_data, TRUE); |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
194 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
195 msn_soap_request_destroy(conn->current_request, TRUE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
196 conn->current_request = NULL; |
23298
5cdd93dac7a2
Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
22822
diff
changeset
|
197 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
198 g_free(host); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
199 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
|
200 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
201 return TRUE; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
202 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
203 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
204 return FALSE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
205 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
206 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
207 static gboolean |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
208 msn_soap_handle_body(MsnSoapConnection *conn, MsnSoapMessage *response) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
209 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
210 xmlnode *body = xmlnode_get_child(response->xml, "Body"); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
211 xmlnode *fault = xmlnode_get_child(response->xml, "Fault"); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
212 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
213 if (fault) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
214 xmlnode *faultcode = xmlnode_get_child(fault, "faultcode"); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
215 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
216 if (faultcode != NULL) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
217 char *faultdata = xmlnode_get_data(faultcode); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
218 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
219 if (g_str_equal(faultdata, "psf:Redirect")) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
220 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
|
221 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
222 if (url) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
223 char *urldata = xmlnode_get_data(url); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
224 msn_soap_handle_redirect(conn, urldata); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
225 g_free(urldata); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
226 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
227 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
228 g_free(faultdata); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
229 msn_soap_message_destroy(response); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
230 return TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
231 } else if (g_str_equal(faultdata, "wsse:FailedAuthentication")) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
232 xmlnode *reason = xmlnode_get_child(fault, "faultstring"); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
233 char *reasondata = xmlnode_get_data(reason); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
234 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
235 msn_soap_connection_sanitize(conn, TRUE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
236 msn_session_set_error(conn->session, MSN_ERROR_AUTH, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
237 reasondata); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
238 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
239 g_free(reasondata); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
240 g_free(faultdata); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
241 msn_soap_message_destroy(response); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
242 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
|
243 } |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
244 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
245 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
|
246 } |
20416
4c5d68e93ef8
Handles SOAP redirects, thanks Sebasti«¡n E. Peyrott
Ka-Hing Cheung <khc@hxbc.us>
parents:
20404
diff
changeset
|
247 } |
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
|
248 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
249 if (fault || body) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
250 MsnSoapRequest *request = conn->current_request; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
251 conn->current_request = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
252 request->cb(request->message, response, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
253 request->cb_data); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
254 msn_soap_message_destroy(response); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
255 msn_soap_request_destroy(request, FALSE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
256 } |
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
|
257 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
258 return TRUE; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
259 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
260 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
261 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
262 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond) |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
263 { |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
264 MsnSoapConnection *conn = data; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
265 int count = 0, cnt, perrno; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
266 /* This buffer needs to be larger than any packets received from |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
267 login.live.com or Adium will fail to receive the packet |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
268 (something weird with the login.live.com server). With NSS it works |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
269 fine, so I believe it's some bug with OS X */ |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
270 char buf[16 * 1024]; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
271 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
272 if (conn->message == NULL) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
273 conn->message = msn_soap_message_new(NULL, NULL); |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
274 } |
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
|
275 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
276 if (conn->buf == NULL) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
277 conn->buf = g_string_new_len(buf, 0); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
278 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
279 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
280 while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
281 purple_debug_info("soap", "read %d bytes\n", cnt); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
282 count += cnt; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
283 g_string_append_len(conn->buf, buf, cnt); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
284 } |
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
|
285 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
286 /* && count is necessary for Adium, on OS X the last read always |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
287 return an error, so we want to proceed anyway. See #5212 for |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
288 discussion on this and the above buffer size issues */ |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
289 if(cnt < 0 && errno == EAGAIN && count == 0) |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
290 return; |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
291 |
23521
a0e957b7b923
Take care of more cleanup in the MSN code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23507
diff
changeset
|
292 /* msn_soap_process could alter errno */ |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
293 perrno = errno; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
294 msn_soap_process(conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
295 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
296 if (cnt < 0 && perrno != EAGAIN) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
297 purple_debug_info("soap", "read: %s\n", g_strerror(perrno)); |
23521
a0e957b7b923
Take care of more cleanup in the MSN code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23507
diff
changeset
|
298 /* It's possible msn_soap_process closed the ssl connection */ |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
299 if (conn->ssl) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
300 purple_ssl_close(conn->ssl); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
301 conn->ssl = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
302 msn_soap_connection_handle_next(conn); |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
303 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
304 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
305 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
306 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
307 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
308 msn_soap_process(MsnSoapConnection *conn) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
309 gboolean handled = FALSE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
310 char *cursor; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
311 char *linebreak; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
312 |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
313 #ifndef MSN_UNSAFE_DEBUG |
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
314 if (conn->current_request->secure) |
23713
92d0151e907b
Relegate XML dumped by msn's SOAP code to MISC from INFO.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23626
diff
changeset
|
315 purple_debug_misc("soap", "Received secure request.\n"); |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
316 else |
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
317 #endif |
23713
92d0151e907b
Relegate XML dumped by msn's SOAP code to MISC from INFO.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23626
diff
changeset
|
318 purple_debug_misc("soap", "current %s\n", conn->buf->str); |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
319 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
320 cursor = conn->buf->str + conn->handled_len; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
321 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
322 if (!conn->headers_done) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
323 while ((linebreak = strstr(cursor, "\r\n")) != NULL) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
324 conn->handled_len = linebreak - conn->buf->str + 2; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
325 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
326 if (conn->response_code == 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
327 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:
23464
diff
changeset
|
328 /* something horribly wrong */ |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
329 purple_ssl_close(conn->ssl); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
330 conn->ssl = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
331 msn_soap_connection_handle_next(conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
332 handled = TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
333 break; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
334 } else if (conn->response_code == 503) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
335 msn_soap_connection_sanitize(conn, TRUE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
336 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:
23464
diff
changeset
|
337 return; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
338 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
339 } else if (cursor == linebreak) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
340 /* blank line */ |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
341 conn->headers_done = TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
342 cursor = conn->buf->str + conn->handled_len; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
343 break; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
344 } else { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
345 char *line = g_strndup(cursor, linebreak - cursor); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
346 char *sep = strstr(line, ": "); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
347 char *key = line; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
348 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
|
349 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
350 if (sep == NULL) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
351 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:
23464
diff
changeset
|
352 g_free(line); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
353 goto loop_end; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
354 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
355 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
356 value = sep + 2; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
357 *sep = '\0'; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
358 msn_soap_message_add_header(conn->message, key, value); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
359 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
360 if ((conn->response_code == 301 || conn->response_code == 300) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
361 && strcmp(key, "Location") == 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
362 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
363 msn_soap_handle_redirect(conn, value); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
364 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
365 handled = TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
366 g_free(line); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
367 break; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
368 } else if (conn->response_code == 401 && |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
369 strcmp(key, "WWW-Authenticate") == 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
370 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
|
371 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
372 if (error) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
373 error += strlen("cbtxt="); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
374 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
375 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
376 msn_soap_connection_sanitize(conn, TRUE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
377 msn_session_set_error(conn->session, MSN_ERROR_AUTH, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
378 error ? purple_url_decode(error) : NULL); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
379 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
380 g_free(line); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
381 return; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
382 } else if (strcmp(key, "Content-Length") == 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
383 conn->body_len = atoi(value); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
384 } else if (strcmp(key, "Connection") == 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
385 if (strcmp(value, "close") == 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
386 conn->close_when_done = TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
387 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
388 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
389 g_free(line); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
390 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
391 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
392 loop_end: |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
393 cursor = conn->buf->str + conn->handled_len; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
394 } |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
395 } |
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
|
396 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
397 if (!handled && conn->headers_done) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
398 if (conn->buf->len - conn->handled_len >= |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
399 conn->body_len) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
400 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
|
401 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
402 if (node == NULL) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
403 purple_debug_info("soap", "Malformed SOAP response: %s\n", |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
404 cursor); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
405 } else { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
406 MsnSoapMessage *message = conn->message; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
407 conn->message = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
408 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
|
409 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
410 if (!msn_soap_handle_body(conn, message)) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
411 return; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
412 } |
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
|
413 } |
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
|
414 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
415 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
|
416 } |
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 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
418 return; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
419 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
420 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
421 if (handled) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
422 msn_soap_connection_handle_next(conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
423 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
424 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
425 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
426 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
427 msn_soap_write_cb(gpointer data, gint fd, PurpleInputCondition cond) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
428 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
429 msn_soap_write_cb_internal(data, fd, cond, FALSE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
430 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
431 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
432 static gboolean |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
433 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:
23464
diff
changeset
|
434 gboolean initial) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
435 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
436 MsnSoapConnection *conn = data; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
437 int written; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
438 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
439 if (cond != PURPLE_INPUT_WRITE) return TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
440 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
441 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:
23464
diff
changeset
|
442 conn->buf->len - conn->handled_len); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
443 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
444 if (written < 0 && errno == EAGAIN) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
445 return TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
446 else if (written <= 0) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
447 purple_ssl_close(conn->ssl); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
448 conn->ssl = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
449 if (!initial) msn_soap_connection_handle_next(conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
450 return FALSE; |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
451 } |
20770
58ce69a8582d
Correctly remove a buddy from the Pending list after it is accepted.
Carlos Silva <typ0@pidgin.im>
parents:
20759
diff
changeset
|
452 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
453 conn->handled_len += written; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
454 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
455 if (conn->handled_len < conn->buf->len) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
456 return TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
457 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
458 /* we are done! */ |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
459 g_string_free(conn->buf, TRUE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
460 conn->buf = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
461 conn->handled_len = 0; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
462 conn->body_len = 0; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
463 conn->response_code = 0; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
464 conn->headers_done = FALSE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
465 conn->close_when_done = FALSE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
466 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
467 purple_input_remove(conn->event_handle); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
468 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:
23464
diff
changeset
|
469 msn_soap_read_cb, conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
470 return TRUE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
471 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
472 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
473 static gboolean |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
474 msn_soap_connection_run(gpointer data) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
475 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
476 MsnSoapConnection *conn = data; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
477 MsnSoapRequest *req = g_queue_peek_head(conn->queue); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
478 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
479 conn->event_handle = 0; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
480 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
481 if (req) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
482 if (conn->ssl == NULL) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
483 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:
23464
diff
changeset
|
484 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:
23464
diff
changeset
|
485 } else if (conn->connected) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
486 int len = -1; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
487 char *body = xmlnode_to_str(req->message->xml, &len); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
488 GSList *iter; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
489 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
490 g_queue_pop_head(conn->queue); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
491 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
492 conn->buf = g_string_new(""); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
493 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
494 g_string_append_printf(conn->buf, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
495 "POST /%s HTTP/1.1\r\n" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
496 "SOAPAction: %s\r\n" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
497 "Content-Type:text/xml; charset=utf-8\r\n" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
498 "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:
23464
diff
changeset
|
499 "Accept: */*\r\n" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
500 "Host: %s\r\n" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
501 "Content-Length: %d\r\n" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
502 "Connection: Keep-Alive\r\n" |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
503 "Cache-Control: no-cache\r\n", |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
504 req->path, req->message->action ? req->message->action : "", |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
505 conn->host, len); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
506 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
507 for (iter = req->message->headers; iter; iter = iter->next) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
508 g_string_append(conn->buf, (char *)iter->data); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
509 g_string_append(conn->buf, "\r\n"); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
510 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
511 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
512 g_string_append(conn->buf, "\r\n"); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
513 g_string_append(conn->buf, body); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
514 |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
515 #ifndef MSN_UNSAFE_DEBUG |
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
516 if (req->secure) |
23713
92d0151e907b
Relegate XML dumped by msn's SOAP code to MISC from INFO.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23626
diff
changeset
|
517 purple_debug_misc("soap", "Sending secure request.\n"); |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
518 else |
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
519 #endif |
23713
92d0151e907b
Relegate XML dumped by msn's SOAP code to MISC from INFO.
Will Thompson <will.thompson@collabora.co.uk>
parents:
23626
diff
changeset
|
520 purple_debug_misc("soap", "%s\n", conn->buf->str); |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
521 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
522 conn->handled_len = 0; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
523 conn->current_request = req; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
524 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
525 conn->event_handle = purple_input_add(conn->ssl->fd, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
526 PURPLE_INPUT_WRITE, msn_soap_write_cb, conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
527 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:
23464
diff
changeset
|
528 /* Not connected => reconnect and retry */ |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
529 purple_debug_info("soap", "not connected, reconnecting\n"); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
530 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
531 conn->connected = FALSE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
532 conn->current_request = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
533 msn_soap_connection_sanitize(conn, FALSE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
534 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
535 g_queue_push_head(conn->queue, req); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
536 conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
537 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
538 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
539 g_free(body); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
540 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
541 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
542 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
543 return FALSE; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
544 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
545 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
546 void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
547 msn_soap_message_send(MsnSession *session, MsnSoapMessage *message, |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
548 const char *host, const char *path, gboolean secure, |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
549 MsnSoapCallback cb, gpointer cb_data) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
550 { |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
551 msn_soap_message_send_internal(session, message, host, path, secure, |
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
552 cb, cb_data, FALSE); |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
553 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
554 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
555 static void |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
556 msn_soap_message_send_internal(MsnSession *session, MsnSoapMessage *message, |
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
557 const char *host, const char *path, gboolean secure, |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
558 MsnSoapCallback cb, gpointer cb_data, gboolean first) |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
559 { |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
560 MsnSoapConnection *conn = msn_soap_get_connection(session, host); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
561 MsnSoapRequest *req = g_new0(MsnSoapRequest, 1); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
562 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
563 req->path = g_strdup(path); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
564 req->message = message; |
23613
860e5e210fc9
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23521
diff
changeset
|
565 req->secure = secure; |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
566 req->cb = cb; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
567 req->cb_data = cb_data; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
568 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
569 if (first) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
570 g_queue_push_head(conn->queue, req); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
571 } else { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
572 g_queue_push_tail(conn->queue, req); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
573 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
574 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
575 if (conn->event_handle == 0) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
576 conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
577 conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
578 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
579 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
580 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
581 msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
582 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
583 if (conn->event_handle) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
584 purple_input_remove(conn->event_handle); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
585 conn->event_handle = 0; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
586 } |
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
|
587 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
588 if (conn->message) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
589 msn_soap_message_destroy(conn->message); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
590 conn->message = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
591 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
592 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
593 if (conn->buf) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
594 g_string_free(conn->buf, TRUE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
595 conn->buf = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
596 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
597 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
598 if (conn->ssl && (disconnect || conn->close_when_done)) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
599 purple_ssl_close(conn->ssl); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
600 conn->ssl = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
601 } |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
602 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
603 if (conn->current_request) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
604 msn_soap_request_destroy(conn->current_request, FALSE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
605 conn->current_request = NULL; |
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
|
606 } |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
607 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
608 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
609 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
610 msn_soap_connection_handle_next(MsnSoapConnection *conn) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
611 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
612 msn_soap_connection_sanitize(conn, FALSE); |
23298
5cdd93dac7a2
Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
22822
diff
changeset
|
613 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
614 conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
615 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
616 if (conn->current_request) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
617 MsnSoapRequest *req = conn->current_request; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
618 conn->current_request = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
619 msn_soap_connection_destroy_foreach_cb(req, conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
620 } |
20394
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
621 } |
4a099e4d0d09
propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents:
diff
changeset
|
622 |
23507
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
623 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
624 msn_soap_connection_destroy_foreach_cb(gpointer item, gpointer data) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
625 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
626 MsnSoapRequest *req = item; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
627 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
628 if (req->cb) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
629 req->cb(req->message, NULL, req->cb_data); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
630 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
631 msn_soap_request_destroy(req, FALSE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
632 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
633 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
634 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
635 msn_soap_connection_destroy(MsnSoapConnection *conn) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
636 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
637 if (conn->current_request) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
638 MsnSoapRequest *req = conn->current_request; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
639 conn->current_request = NULL; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
640 msn_soap_connection_destroy_foreach_cb(req, conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
641 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
642 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
643 msn_soap_connection_sanitize(conn, TRUE); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
644 g_queue_foreach(conn->queue, msn_soap_connection_destroy_foreach_cb, conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
645 g_queue_free(conn->queue); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
646 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
647 g_free(conn->host); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
648 g_free(conn); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
649 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
650 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
651 MsnSoapMessage * |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
652 msn_soap_message_new(const char *action, xmlnode *xml) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
653 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
654 MsnSoapMessage *message = g_new0(MsnSoapMessage, 1); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
655 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
656 message->action = g_strdup(action); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
657 message->xml = xml; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
658 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
659 return message; |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
660 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
661 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
662 void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
663 msn_soap_message_destroy(MsnSoapMessage *message) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
664 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
665 if (message) { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
666 g_slist_foreach(message->headers, (GFunc)g_free, NULL); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
667 g_slist_free(message->headers); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
668 g_free(message->action); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
669 if (message->xml) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
670 xmlnode_free(message->xml); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
671 g_free(message); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
672 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
673 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
674 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
675 void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
676 msn_soap_message_add_header(MsnSoapMessage *message, |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
677 const char *name, const char *value) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
678 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
679 char *header = g_strdup_printf("%s: %s\r\n", name, value); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
680 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
681 message->headers = g_slist_prepend(message->headers, header); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
682 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
683 |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
684 static void |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
685 msn_soap_request_destroy(MsnSoapRequest *req, gboolean keep_message) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
686 { |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
687 g_free(req->path); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
688 if (!keep_message) |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
689 msn_soap_message_destroy(req->message); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
690 g_free(req); |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
691 } |
711773577380
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23464
diff
changeset
|
692 |