Tue, 23 Jul 2013 14:10:34 +0200
HTTP: purify internal API for msn's SOAP handling
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
1 | /** |
|
23819
c3bbef4646b1
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23798
diff
changeset
|
2 | * @file soap.c |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
3 | * Functions relating to SOAP connections. |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
4 | * |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
5 | * purple |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
6 | * |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
7 | * Purple is the legal property of its developers, whose names are too numerous |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
8 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
9 | * source distribution. |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
10 | * |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
11 | * This program is free software; you can redistribute it and/or modify |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
12 | * it under the terms of the GNU General Public License as published by |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
13 | * the Free Software Foundation; either version 2 of the License, or |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
14 | * (at your option) any later version. |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
15 | * |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
16 | * This program is distributed in the hope that it will be useful, |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
19 | * GNU General Public License for more details. |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
20 | * |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
21 | * You should have received a copy of the GNU General Public License |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
22 | * along with this program; if not, write to the Free Software |
|
28345
57a838c454b0
Oops, Elliott correctly pointed out this was wrong...
Paul Aurich <darkrain42@pidgin.im>
parents:
28323
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
24 | */ |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
25 | |
|
23819
c3bbef4646b1
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23798
diff
changeset
|
26 | #include "soap.h" |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
27 | |
|
34264
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
28 | #include "internal.h" |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
29 | |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
30 | #include "debug.h" |
|
34264
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
31 | #include "http.h" |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
32 | |
|
21361
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
33 | #define SOAP_TIMEOUT (5 * 60) |
|
24075
7c07336ce376
I seem to have accidentally turned on those "unsafe" SOAP debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24045
diff
changeset
|
34 | |
|
34264
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
35 | struct _MsnSoapMessage { |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
36 | gchar *action; |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
37 | xmlnode *xml; |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
38 | GSList *headers; |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
39 | }; |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
40 | |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
41 | xmlnode * |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
42 | msn_soap_message_get_xml(MsnSoapMessage *message) |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
43 | { |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
44 | g_return_val_if_fail(message != NULL, NULL); |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
45 | |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
46 | return message->xml; |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
47 | } |
|
e531664a3ad1
HTTP: purify internal API for msn's SOAP handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
48 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
49 | typedef struct _MsnSoapRequest { |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
50 | char *path; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
51 | MsnSoapMessage *message; |
|
23925
aa38fbc30cfb
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23846
diff
changeset
|
52 | gboolean secure; |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
53 | MsnSoapCallback cb; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
54 | gpointer cb_data; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
55 | } MsnSoapRequest; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
56 | |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
57 | typedef struct _MsnSoapConnection { |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
58 | MsnSession *session; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
59 | char *host; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
60 | |
|
21360
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
61 | time_t last_used; |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
62 | PurpleSslConnection *ssl; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
63 | gboolean connected; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
64 | |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
65 | guint event_handle; |
|
24794
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
66 | guint run_timer; |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
67 | GString *buf; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
68 | gsize handled_len; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
69 | gsize body_len; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
70 | int response_code; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
71 | gboolean headers_done; |
| 21358 | 72 | gboolean close_when_done; |
| 73 | ||
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
74 | MsnSoapMessage *message; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
75 | |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
76 | GQueue *queue; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
77 | MsnSoapRequest *current_request; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
78 | } MsnSoapConnection; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
79 | |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
80 | static gboolean msn_soap_connection_run(gpointer data); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
81 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
82 | static MsnSoapConnection * |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
83 | msn_soap_connection_new(MsnSession *session, const char *host) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
84 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
85 | MsnSoapConnection *conn = g_new0(MsnSoapConnection, 1); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
86 | conn->session = session; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
87 | conn->host = g_strdup(host); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
88 | conn->queue = g_queue_new(); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
89 | return conn; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
90 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
91 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
92 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
93 | msn_soap_message_destroy(MsnSoapMessage *message) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
94 | { |
|
24792
22453f0066b4
I don't believe message should ever be null
Mark Doliner <markdoliner@pidgin.im>
parents:
24791
diff
changeset
|
95 | g_slist_foreach(message->headers, (GFunc)g_free, NULL); |
|
22453f0066b4
I don't believe message should ever be null
Mark Doliner <markdoliner@pidgin.im>
parents:
24791
diff
changeset
|
96 | g_slist_free(message->headers); |
|
22453f0066b4
I don't believe message should ever be null
Mark Doliner <markdoliner@pidgin.im>
parents:
24791
diff
changeset
|
97 | g_free(message->action); |
|
22453f0066b4
I don't believe message should ever be null
Mark Doliner <markdoliner@pidgin.im>
parents:
24791
diff
changeset
|
98 | if (message->xml) |
|
22453f0066b4
I don't believe message should ever be null
Mark Doliner <markdoliner@pidgin.im>
parents:
24791
diff
changeset
|
99 | xmlnode_free(message->xml); |
|
22453f0066b4
I don't believe message should ever be null
Mark Doliner <markdoliner@pidgin.im>
parents:
24791
diff
changeset
|
100 | g_free(message); |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
101 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
102 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
103 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
104 | msn_soap_request_destroy(MsnSoapRequest *req, gboolean keep_message) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
105 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
106 | g_free(req->path); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
107 | if (!keep_message) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
108 | msn_soap_message_destroy(req->message); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
109 | g_free(req); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
110 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
111 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
112 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
113 | msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
114 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
115 | if (conn->event_handle) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
116 | purple_input_remove(conn->event_handle); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
117 | conn->event_handle = 0; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
118 | } |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
119 | |
|
24794
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
120 | if (conn->run_timer) { |
|
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
121 | purple_timeout_remove(conn->run_timer); |
|
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
122 | conn->run_timer = 0; |
|
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
123 | } |
|
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
124 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
125 | if (conn->message) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
126 | msn_soap_message_destroy(conn->message); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
127 | conn->message = NULL; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
128 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
129 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
130 | if (conn->buf) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
131 | g_string_free(conn->buf, TRUE); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
132 | conn->buf = NULL; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
133 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
134 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
135 | if (conn->ssl && (disconnect || conn->close_when_done)) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
136 | purple_ssl_close(conn->ssl); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
137 | conn->ssl = NULL; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
138 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
139 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
140 | if (conn->current_request) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
141 | msn_soap_request_destroy(conn->current_request, FALSE); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
142 | conn->current_request = NULL; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
143 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
144 | } |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
145 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
146 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
147 | msn_soap_connection_destroy_foreach_cb(gpointer item, gpointer data) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
148 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
149 | MsnSoapRequest *req = item; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
150 | |
|
31297
3f3a8f0993e1
Everyone provides a callback here. Might as well make it required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30597
diff
changeset
|
151 | req->cb(req->message, NULL, req->cb_data); |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
152 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
153 | msn_soap_request_destroy(req, FALSE); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
154 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
155 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
156 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
157 | msn_soap_connection_destroy(MsnSoapConnection *conn) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
158 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
159 | if (conn->current_request) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
160 | MsnSoapRequest *req = conn->current_request; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
161 | conn->current_request = NULL; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
162 | msn_soap_connection_destroy_foreach_cb(req, conn); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
163 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
164 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
165 | msn_soap_connection_sanitize(conn, TRUE); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
166 | g_queue_foreach(conn->queue, msn_soap_connection_destroy_foreach_cb, conn); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
167 | g_queue_free(conn->queue); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
168 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
169 | g_free(conn->host); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
170 | g_free(conn); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
171 | } |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
172 | |
|
21360
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
173 | static gboolean |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
174 | msn_soap_cleanup_each(gpointer key, gpointer value, gpointer data) |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
175 | { |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
176 | MsnSoapConnection *conn = value; |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
177 | time_t *t = data; |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
178 | |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
179 | if ((*t - conn->last_used) > SOAP_TIMEOUT * 2) { |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
180 | purple_debug_info("soap", "cleaning up soap conn %p\n", conn); |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
181 | return TRUE; |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
182 | } |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
183 | |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
184 | return FALSE; |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
185 | } |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
186 | |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
187 | static gboolean |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
188 | msn_soap_cleanup_for_session(gpointer data) |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
189 | { |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
190 | MsnSession *sess = data; |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
191 | time_t t = time(NULL); |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
192 | |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
193 | purple_debug_info("soap", "session cleanup timeout\n"); |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
194 | |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
195 | if (sess->soap_table) { |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
196 | g_hash_table_foreach_remove(sess->soap_table, msn_soap_cleanup_each, |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
197 | &t); |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
198 | |
|
24797
5d78589aee74
Remove the timer if sess->soap_table is NULL. I don't think this ever
Mark Doliner <markdoliner@pidgin.im>
parents:
24794
diff
changeset
|
199 | if (g_hash_table_size(sess->soap_table) != 0) |
|
5d78589aee74
Remove the timer if sess->soap_table is NULL. I don't think this ever
Mark Doliner <markdoliner@pidgin.im>
parents:
24794
diff
changeset
|
200 | return TRUE; |
|
21360
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
201 | } |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
202 | |
|
24797
5d78589aee74
Remove the timer if sess->soap_table is NULL. I don't think this ever
Mark Doliner <markdoliner@pidgin.im>
parents:
24794
diff
changeset
|
203 | sess->soap_cleanup_handle = 0; |
|
5d78589aee74
Remove the timer if sess->soap_table is NULL. I don't think this ever
Mark Doliner <markdoliner@pidgin.im>
parents:
24794
diff
changeset
|
204 | return FALSE; |
|
21360
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
205 | } |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
206 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
207 | static MsnSoapConnection * |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
208 | msn_soap_get_connection(MsnSession *session, const char *host) |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
209 | { |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
210 | MsnSoapConnection *conn = NULL; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
211 | |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
212 | if (session->soap_table) { |
|
21361
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
213 | conn = g_hash_table_lookup(session->soap_table, host); |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
214 | } else { |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
215 | session->soap_table = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
216 | NULL, (GDestroyNotify)msn_soap_connection_destroy); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
217 | } |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
218 | |
|
21360
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
219 | if (session->soap_cleanup_handle == 0) |
|
24619
5ece4c87ea96
Use purple_timeout_add_seconds() instead of purple_timeout_add() in a
Mark Doliner <markdoliner@pidgin.im>
parents:
24289
diff
changeset
|
220 | session->soap_cleanup_handle = purple_timeout_add_seconds(SOAP_TIMEOUT, |
|
21360
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
221 | msn_soap_cleanup_for_session, session); |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
222 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
223 | if (conn == NULL) { |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
224 | conn = msn_soap_connection_new(session, host); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
225 | g_hash_table_insert(session->soap_table, conn->host, conn); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
226 | } |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
227 | |
|
21360
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
228 | conn->last_used = time(NULL); |
|
92d5c6c58c85
cleanup soap connection with a timeout
Ka-Hing Cheung <khc@pidgin.im>
parents:
21358
diff
changeset
|
229 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
230 | return conn; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
231 | } |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
232 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
233 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
234 | msn_soap_connection_handle_next(MsnSoapConnection *conn) |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
235 | { |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
236 | msn_soap_connection_sanitize(conn, FALSE); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
237 | |
|
24794
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
238 | conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
239 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
240 | |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
241 | static void |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
242 | msn_soap_message_send_internal(MsnSession *session, MsnSoapMessage *message, |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
243 | const char *host, const char *path, gboolean secure, |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
244 | MsnSoapCallback cb, gpointer cb_data, gboolean first) |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
245 | { |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
246 | MsnSoapConnection *conn = msn_soap_get_connection(session, host); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
247 | MsnSoapRequest *req = g_new0(MsnSoapRequest, 1); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
248 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
249 | req->path = g_strdup(path); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
250 | req->message = message; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
251 | req->secure = secure; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
252 | req->cb = cb; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
253 | req->cb_data = cb_data; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
254 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
255 | if (first) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
256 | g_queue_push_head(conn->queue, req); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
257 | } else { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
258 | g_queue_push_tail(conn->queue, req); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
259 | } |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
260 | |
|
24794
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
261 | if (conn->run_timer == 0) |
|
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
262 | conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
263 | conn); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
264 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
265 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
266 | void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
267 | msn_soap_message_send(MsnSession *session, MsnSoapMessage *message, |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
268 | const char *host, const char *path, gboolean secure, |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
269 | MsnSoapCallback cb, gpointer cb_data) |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
270 | { |
|
24792
22453f0066b4
I don't believe message should ever be null
Mark Doliner <markdoliner@pidgin.im>
parents:
24791
diff
changeset
|
271 | g_return_if_fail(message != NULL); |
|
31297
3f3a8f0993e1
Everyone provides a callback here. Might as well make it required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30597
diff
changeset
|
272 | g_return_if_fail(cb != NULL); |
|
24792
22453f0066b4
I don't believe message should ever be null
Mark Doliner <markdoliner@pidgin.im>
parents:
24791
diff
changeset
|
273 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
274 | msn_soap_message_send_internal(session, message, host, path, secure, |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
275 | cb, cb_data, FALSE); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
276 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
277 | |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
278 | static gboolean |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
279 | msn_soap_handle_redirect(MsnSoapConnection *conn, const char *url_raw) |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
280 | { |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
281 | MsnSoapRequest *req; |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
282 | PurpleHttpURL *url; |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
283 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
284 | url = purple_http_url_parse(url_raw); |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
285 | if (!url) |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
286 | return FALSE; |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
287 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
288 | req = conn->current_request; |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
289 | conn->current_request = NULL; |
|
31298
34249a2a55ae
Using conn->current_request looks a bit iffy here. And even if it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31297
diff
changeset
|
290 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
291 | msn_soap_message_send_internal(conn->session, req->message, |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
292 | purple_http_url_get_host(url), purple_http_url_get_path(url), |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
293 | req->secure, req->cb, req->cb_data, TRUE); |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
294 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
295 | msn_soap_request_destroy(req, TRUE); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
296 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
297 | purple_http_url_free(url); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
298 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
299 | return TRUE; |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
300 | |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
301 | } |
|
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
302 | |
|
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
303 | static gboolean |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
304 | msn_soap_handle_body(MsnSoapConnection *conn, MsnSoapMessage *response) |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
305 | { |
|
21361
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
306 | xmlnode *body = xmlnode_get_child(response->xml, "Body"); |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
307 | xmlnode *fault = xmlnode_get_child(response->xml, "Fault"); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
308 | |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
309 | if (fault) { |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
310 | xmlnode *faultcode = xmlnode_get_child(fault, "faultcode"); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
311 | |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
312 | if (faultcode != NULL) { |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
313 | char *faultdata = xmlnode_get_data(faultcode); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
314 | |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
315 | if (g_str_equal(faultdata, "psf:Redirect")) { |
|
23794
3175e940fa12
Use the correct xmlnode when processing SOAP Faults.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23787
diff
changeset
|
316 | xmlnode *url = xmlnode_get_child(fault, "redirectUrl"); |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
317 | |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
318 | if (url) { |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
319 | char *urldata = xmlnode_get_data(url); |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
320 | msn_soap_handle_redirect(conn, urldata); |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
321 | g_free(urldata); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
322 | } |
| 21358 | 323 | |
| 324 | g_free(faultdata); | |
|
23762
8bb3533742fd
fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@pidgin.im>
parents:
23760
diff
changeset
|
325 | msn_soap_message_destroy(response); |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
326 | return TRUE; |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
327 | } else if (g_str_equal(faultdata, "wsse:FailedAuthentication")) { |
|
23794
3175e940fa12
Use the correct xmlnode when processing SOAP Faults.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23787
diff
changeset
|
328 | xmlnode *reason = xmlnode_get_child(fault, "faultstring"); |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
329 | char *reasondata = xmlnode_get_data(reason); |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
330 | |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
331 | msn_soap_connection_sanitize(conn, TRUE); |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
332 | msn_session_set_error(conn->session, MSN_ERROR_AUTH, |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
333 | reasondata); |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
334 | |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
335 | g_free(reasondata); |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
336 | g_free(faultdata); |
|
23762
8bb3533742fd
fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@pidgin.im>
parents:
23760
diff
changeset
|
337 | msn_soap_message_destroy(response); |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
338 | return FALSE; |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
339 | } |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
340 | |
|
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
341 | g_free(faultdata); |
| 21358 | 342 | } |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
343 | } |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
344 | |
|
21672
cb25ada4f6a0
soap faults are now properly handled
Ka-Hing Cheung <khc@pidgin.im>
parents:
21398
diff
changeset
|
345 | if (fault || body) { |
|
25547
6f84a4a36cad
conn->current_request can be NULL here.
Daniel Atallah <datallah@pidgin.im>
parents:
25416
diff
changeset
|
346 | if (conn->current_request) { |
|
6f84a4a36cad
conn->current_request can be NULL here.
Daniel Atallah <datallah@pidgin.im>
parents:
25416
diff
changeset
|
347 | MsnSoapRequest *request = conn->current_request; |
|
6f84a4a36cad
conn->current_request can be NULL here.
Daniel Atallah <datallah@pidgin.im>
parents:
25416
diff
changeset
|
348 | conn->current_request = NULL; |
|
6f84a4a36cad
conn->current_request can be NULL here.
Daniel Atallah <datallah@pidgin.im>
parents:
25416
diff
changeset
|
349 | request->cb(request->message, response, |
|
6f84a4a36cad
conn->current_request can be NULL here.
Daniel Atallah <datallah@pidgin.im>
parents:
25416
diff
changeset
|
350 | request->cb_data); |
|
6f84a4a36cad
conn->current_request can be NULL here.
Daniel Atallah <datallah@pidgin.im>
parents:
25416
diff
changeset
|
351 | msn_soap_request_destroy(request, FALSE); |
|
6f84a4a36cad
conn->current_request can be NULL here.
Daniel Atallah <datallah@pidgin.im>
parents:
25416
diff
changeset
|
352 | } |
|
23762
8bb3533742fd
fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@pidgin.im>
parents:
23760
diff
changeset
|
353 | msn_soap_message_destroy(response); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
354 | } |
|
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
355 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
356 | return TRUE; |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
357 | } |
|
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
358 | |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
359 | static void |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
360 | msn_soap_message_add_header(MsnSoapMessage *message, |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
361 | const char *name, const char *value) |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
362 | { |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
363 | char *header = g_strdup_printf("%s: %s\r\n", name, value); |
|
24289
eee560dd9d2c
shuffle some code around to make sure are using the right errno,
Ka-Hing Cheung <khc@pidgin.im>
parents:
24216
diff
changeset
|
364 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
365 | message->headers = g_slist_prepend(message->headers, header); |
|
23469
74429b4ad296
Patch from tomgr and Maiku that workarounds some OS X issue,
Ka-Hing Cheung <khc@pidgin.im>
parents:
23078
diff
changeset
|
366 | } |
|
21398
a31c84608fcb
read as much from the fd as possible if we get a read event, hopefully will
Ka-Hing Cheung <khc@pidgin.im>
parents:
21391
diff
changeset
|
367 | |
|
23469
74429b4ad296
Patch from tomgr and Maiku that workarounds some OS X issue,
Ka-Hing Cheung <khc@pidgin.im>
parents:
23078
diff
changeset
|
368 | static void |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
369 | msn_soap_process(MsnSoapConnection *conn) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
370 | { |
|
23469
74429b4ad296
Patch from tomgr and Maiku that workarounds some OS X issue,
Ka-Hing Cheung <khc@pidgin.im>
parents:
23078
diff
changeset
|
371 | gboolean handled = FALSE; |
|
74429b4ad296
Patch from tomgr and Maiku that workarounds some OS X issue,
Ka-Hing Cheung <khc@pidgin.im>
parents:
23078
diff
changeset
|
372 | char *cursor; |
|
74429b4ad296
Patch from tomgr and Maiku that workarounds some OS X issue,
Ka-Hing Cheung <khc@pidgin.im>
parents:
23078
diff
changeset
|
373 | char *linebreak; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
374 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
375 | cursor = conn->buf->str + conn->handled_len; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
376 | |
|
21361
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
377 | if (!conn->headers_done) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
378 | while ((linebreak = strstr(cursor, "\r\n")) != NULL) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
379 | conn->handled_len = linebreak - conn->buf->str + 2; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
380 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
381 | if (conn->response_code == 0) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
382 | if (sscanf(cursor, "HTTP/1.1 %d", &conn->response_code) != 1) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
383 | /* something horribly wrong */ |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
384 | purple_ssl_close(conn->ssl); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
385 | conn->ssl = NULL; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
386 | handled = TRUE; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
387 | break; |
|
27996
25d2f18b9c67
If the SOAP server returns a 503 AND we haven't yet authenticated, then
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27543
diff
changeset
|
388 | } else if (conn->response_code == 503 && conn->session->login_step < MSN_LOGIN_STEP_END) { |
|
21361
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
389 | msn_soap_connection_sanitize(conn, TRUE); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
390 | msn_session_set_error(conn->session, MSN_ERROR_SERV_UNAVAILABLE, NULL); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
391 | return; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
392 | } |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
393 | } else if (cursor == linebreak) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
394 | /* blank line */ |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
395 | conn->headers_done = TRUE; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
396 | cursor = conn->buf->str + conn->handled_len; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
397 | break; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
398 | } else { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
399 | char *line = g_strndup(cursor, linebreak - cursor); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
400 | char *sep = strstr(line, ": "); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
401 | char *key = line; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
402 | char *value; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
403 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
404 | if (sep == NULL) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
405 | purple_debug_info("soap", "ignoring malformed line: %s\n", line); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
406 | g_free(line); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
407 | goto loop_end; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
408 | } |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
409 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
410 | value = sep + 2; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
411 | *sep = '\0'; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
412 | msn_soap_message_add_header(conn->message, key, value); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
413 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
414 | if ((conn->response_code == 301 || conn->response_code == 300) |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
415 | && strcmp(key, "Location") == 0) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
416 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
417 | msn_soap_handle_redirect(conn, value); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
418 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
419 | handled = TRUE; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
420 | g_free(line); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
421 | break; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
422 | } else if (conn->response_code == 401 && |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
423 | strcmp(key, "WWW-Authenticate") == 0) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
424 | char *error = strstr(value, "cbtxt="); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
425 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
426 | if (error) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
427 | error += strlen("cbtxt="); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
428 | } |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
429 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
430 | msn_soap_connection_sanitize(conn, TRUE); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
431 | msn_session_set_error(conn->session, MSN_ERROR_AUTH, |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
432 | error ? purple_url_decode(error) : NULL); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
433 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
434 | g_free(line); |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
435 | return; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
436 | } else if (strcmp(key, "Content-Length") == 0) { |
|
33809
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31300
diff
changeset
|
437 | if (sscanf(value, "%" G_GSIZE_FORMAT, &(conn->body_len)) != 1) |
|
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31300
diff
changeset
|
438 | purple_debug_error("soap", "Unable to parse Content-Length\n"); |
|
21361
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
439 | } else if (strcmp(key, "Connection") == 0) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
440 | if (strcmp(value, "close") == 0) { |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
441 | conn->close_when_done = TRUE; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
442 | } |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
443 | } |
| 21364 | 444 | g_free(line); |
|
21361
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
445 | } |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
446 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
447 | loop_end: |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
448 | cursor = conn->buf->str + conn->handled_len; |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
449 | } |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
450 | } |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
451 | |
|
f890366c8ec6
oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents:
21360
diff
changeset
|
452 | if (!handled && conn->headers_done) { |
|
22981
b83a23981419
Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents:
22060
diff
changeset
|
453 | if (conn->buf->len - conn->handled_len >= |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
454 | conn->body_len) { |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
455 | xmlnode *node = xmlnode_from_str(cursor, conn->body_len); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
456 | |
|
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
457 | if (node == NULL) { |
|
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
458 | purple_debug_info("soap", "Malformed SOAP response: %s\n", |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
459 | cursor); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
460 | } else { |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
461 | MsnSoapMessage *message = conn->message; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
462 | conn->message = NULL; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
463 | message->xml = node; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
464 | |
|
22981
b83a23981419
Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents:
22060
diff
changeset
|
465 | if (!msn_soap_handle_body(conn, message)) { |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
466 | return; |
|
22981
b83a23981419
Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents:
22060
diff
changeset
|
467 | } |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
468 | } |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
469 | |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
470 | msn_soap_connection_handle_next(conn); |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
471 | } |
|
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
472 | |
|
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
473 | return; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
474 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
475 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
476 | if (handled) { |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
477 | msn_soap_connection_handle_next(conn); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
478 | } |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
479 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
480 | |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
481 | static void |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
482 | msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond) |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
483 | { |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
484 | MsnSoapConnection *conn = data; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
485 | int count = 0, cnt, perrno; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
486 | /* This buffer needs to be larger than any packets received from |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
487 | login.live.com or Adium will fail to receive the packet |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
488 | (something weird with the login.live.com server). With NSS it works |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
489 | fine, so I believe it's some bug with OS X */ |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
490 | char buf[16 * 1024]; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
491 | gsize cursor; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
492 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
493 | if (conn->message == NULL) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
494 | conn->message = msn_soap_message_new(NULL, NULL); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
495 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
496 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
497 | if (conn->buf == NULL) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
498 | conn->buf = g_string_new_len(buf, 0); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
499 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
500 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
501 | cursor = conn->buf->len; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
502 | while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
503 | purple_debug_info("soap", "read %d bytes\n", cnt); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
504 | count += cnt; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
505 | g_string_append_len(conn->buf, buf, cnt); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
506 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
507 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
508 | perrno = errno; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
509 | if (cnt < 0 && perrno != EAGAIN) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
510 | purple_debug_info("soap", "read: %s\n", g_strerror(perrno)); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
511 | |
|
25416
08467e65ce8f
make this toggleable via env instead of #define
Ka-Hing Cheung <khc@pidgin.im>
parents:
25415
diff
changeset
|
512 | if (conn->current_request && conn->current_request->secure && |
|
30597
4454f3c6da08
There's no reason to cache this value, right?
Mark Doliner <markdoliner@pidgin.im>
parents:
28345
diff
changeset
|
513 | !purple_debug_is_unsafe()) |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
514 | purple_debug_misc("soap", "Received secure request.\n"); |
|
25416
08467e65ce8f
make this toggleable via env instead of #define
Ka-Hing Cheung <khc@pidgin.im>
parents:
25415
diff
changeset
|
515 | else if (count != 0) |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
516 | purple_debug_misc("soap", "current %s\n", conn->buf->str + cursor); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
517 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
518 | /* && count is necessary for Adium, on OS X the last read always |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
519 | return an error, so we want to proceed anyway. See #5212 for |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
520 | discussion on this and the above buffer size issues */ |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
521 | if(cnt < 0 && errno == EAGAIN && count == 0) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
522 | return; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
523 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
524 | /* msn_soap_process could alter errno */ |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
525 | msn_soap_process(conn); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
526 | |
|
25259
9e602f04ed84
I'm guessing this is what was intended here?
Mark Doliner <markdoliner@pidgin.im>
parents:
25243
diff
changeset
|
527 | if ((cnt < 0 && perrno != EAGAIN) || cnt == 0) { |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
528 | /* It's possible msn_soap_process closed the ssl connection */ |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
529 | if (conn->ssl) { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
530 | purple_ssl_close(conn->ssl); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
531 | conn->ssl = NULL; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
532 | msn_soap_connection_handle_next(conn); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
533 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
534 | } |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
535 | } |
|
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
536 | |
|
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
537 | static gboolean |
|
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
538 | msn_soap_write_cb_internal(gpointer data, gint fd, PurpleInputCondition cond, |
|
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
539 | gboolean initial) |
|
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
540 | { |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
541 | MsnSoapConnection *conn = data; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
542 | int written; |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
543 | |
|
24793
11fa724fee55
Formatting change: Split these if statements on to two lines
Mark Doliner <markdoliner@pidgin.im>
parents:
24792
diff
changeset
|
544 | if (cond != PURPLE_INPUT_WRITE) |
|
11fa724fee55
Formatting change: Split these if statements on to two lines
Mark Doliner <markdoliner@pidgin.im>
parents:
24792
diff
changeset
|
545 | return TRUE; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
546 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
547 | written = purple_ssl_write(conn->ssl, conn->buf->str + conn->handled_len, |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
548 | conn->buf->len - conn->handled_len); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
549 | |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
550 | if (written < 0 && errno == EAGAIN) |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
551 | return TRUE; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
552 | else if (written <= 0) { |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
553 | purple_ssl_close(conn->ssl); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
554 | conn->ssl = NULL; |
|
24793
11fa724fee55
Formatting change: Split these if statements on to two lines
Mark Doliner <markdoliner@pidgin.im>
parents:
24792
diff
changeset
|
555 | if (!initial) |
|
11fa724fee55
Formatting change: Split these if statements on to two lines
Mark Doliner <markdoliner@pidgin.im>
parents:
24792
diff
changeset
|
556 | msn_soap_connection_handle_next(conn); |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
557 | return FALSE; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
558 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
559 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
560 | conn->handled_len += written; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
561 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
562 | if (conn->handled_len < conn->buf->len) |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
563 | return TRUE; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
564 | |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
565 | /* we are done! */ |
| 21358 | 566 | g_string_free(conn->buf, TRUE); |
| 567 | conn->buf = NULL; | |
| 568 | conn->handled_len = 0; | |
| 569 | conn->body_len = 0; | |
| 570 | conn->response_code = 0; | |
| 571 | conn->headers_done = FALSE; | |
| 572 | conn->close_when_done = FALSE; | |
| 573 | ||
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
574 | purple_input_remove(conn->event_handle); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
575 | conn->event_handle = purple_input_add(conn->ssl->fd, PURPLE_INPUT_READ, |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
576 | msn_soap_read_cb, conn); |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
577 | return TRUE; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
578 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
579 | |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
580 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
581 | msn_soap_write_cb(gpointer data, gint fd, PurpleInputCondition cond) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
582 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
583 | msn_soap_write_cb_internal(data, fd, cond, FALSE); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
584 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
585 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
586 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
587 | msn_soap_error_cb(PurpleSslConnection *ssl, PurpleSslErrorType error, |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
588 | gpointer data) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
589 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
590 | MsnSoapConnection *conn = data; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
591 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
592 | /* sslconn already frees the connection in case of error */ |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
593 | conn->ssl = NULL; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
594 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
595 | g_hash_table_remove(conn->session->soap_table, conn->host); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
596 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
597 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
598 | static void |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
599 | msn_soap_connected_cb(gpointer data, PurpleSslConnection *ssl, |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
600 | PurpleInputCondition cond) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
601 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
602 | MsnSoapConnection *conn = data; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
603 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
604 | conn->connected = TRUE; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
605 | |
|
24794
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
606 | if (conn->run_timer == 0) |
|
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
607 | conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn); |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
608 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
609 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
610 | MsnSoapMessage * |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
611 | msn_soap_message_new(const char *action, xmlnode *xml) |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
612 | { |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
613 | MsnSoapMessage *message = g_new0(MsnSoapMessage, 1); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
614 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
615 | message->action = g_strdup(action); |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
616 | message->xml = xml; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
617 | |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
618 | return message; |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
619 | } |
|
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
620 | |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
621 | static gboolean |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
622 | msn_soap_connection_run(gpointer data) |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
623 | { |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
624 | MsnSoapConnection *conn = data; |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
625 | MsnSoapRequest *req = g_queue_peek_head(conn->queue); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
626 | |
|
24794
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
627 | conn->run_timer = 0; |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
628 | |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
629 | if (req) { |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
630 | if (conn->ssl == NULL) { |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
631 | conn->ssl = purple_ssl_connect(conn->session->account, conn->host, |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
632 | 443, msn_soap_connected_cb, msn_soap_error_cb, conn); |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
633 | } else if (conn->connected) { |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
634 | int len = -1; |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
635 | char *body = xmlnode_to_str(req->message->xml, &len); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
636 | GSList *iter; |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
637 | |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
638 | g_queue_pop_head(conn->queue); |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
639 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
640 | conn->buf = g_string_new(""); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
641 | |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
642 | g_string_append_printf(conn->buf, |
|
23798
604090d9bfb0
Don't free the SOAP message when we're still using it for a redirect.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23797
diff
changeset
|
643 | "POST /%s HTTP/1.1\r\n" |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
644 | "SOAPAction: %s\r\n" |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
645 | "Content-Type:text/xml; charset=utf-8\r\n" |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
646 | "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
647 | "Accept: */*\r\n" |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
648 | "Host: %s\r\n" |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
649 | "Content-Length: %d\r\n" |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
650 | "Connection: Keep-Alive\r\n" |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
651 | "Cache-Control: no-cache\r\n", |
|
21356
50afac513011
handle unauthenticated soap connection
Ka-Hing Cheung <khc@pidgin.im>
parents:
21355
diff
changeset
|
652 | req->path, req->message->action ? req->message->action : "", |
|
23757
bf5c8c3d6374
Patch 3 from Qulogic, this one updates contact list actions to use ticket
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21672
diff
changeset
|
653 | conn->host, len); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
654 | |
|
21354
5c6020f03f2d
mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@pidgin.im>
parents:
21353
diff
changeset
|
655 | for (iter = req->message->headers; iter; iter = iter->next) { |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
656 | g_string_append(conn->buf, (char *)iter->data); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
657 | g_string_append(conn->buf, "\r\n"); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
658 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
659 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
660 | g_string_append(conn->buf, "\r\n"); |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
661 | g_string_append(conn->buf, body); |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
662 | |
|
30597
4454f3c6da08
There's no reason to cache this value, right?
Mark Doliner <markdoliner@pidgin.im>
parents:
28345
diff
changeset
|
663 | if (req->secure && !purple_debug_is_unsafe()) |
|
24045
e0c6a01eca85
Relegate XML dumped by msn's SOAP code to MISC from INFO.
Will Thompson <resiak@pidgin.im>
parents:
23938
diff
changeset
|
664 | purple_debug_misc("soap", "Sending secure request.\n"); |
|
23925
aa38fbc30cfb
Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23846
diff
changeset
|
665 | else |
|
25416
08467e65ce8f
make this toggleable via env instead of #define
Ka-Hing Cheung <khc@pidgin.im>
parents:
25415
diff
changeset
|
666 | purple_debug_misc("soap", "%s\n", conn->buf->str); |
| 21358 | 667 | |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
668 | conn->handled_len = 0; |
|
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
669 | conn->current_request = req; |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
670 | |
|
27126
9cc2cee805c1
Get rid of a runtime warning on connect.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25749
diff
changeset
|
671 | if (conn->event_handle) |
|
9cc2cee805c1
Get rid of a runtime warning on connect.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25749
diff
changeset
|
672 | purple_input_remove(conn->event_handle); |
|
21355
500740852250
removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@pidgin.im>
parents:
21354
diff
changeset
|
673 | conn->event_handle = purple_input_add(conn->ssl->fd, |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
674 | PURPLE_INPUT_WRITE, msn_soap_write_cb, conn); |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
675 | if (!msn_soap_write_cb_internal(conn, conn->ssl->fd, PURPLE_INPUT_WRITE, TRUE)) { |
|
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
676 | /* Not connected => reconnect and retry */ |
|
23819
c3bbef4646b1
Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23798
diff
changeset
|
677 | purple_debug_info("soap", "not connected, reconnecting\n"); |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
678 | |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
679 | conn->connected = FALSE; |
|
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
680 | conn->current_request = NULL; |
|
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
681 | msn_soap_connection_sanitize(conn, FALSE); |
|
24791
6e1d82706043
Minor whitespace changes and shuffle functions around to be in a more
Mark Doliner <markdoliner@pidgin.im>
parents:
24713
diff
changeset
|
682 | |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
683 | g_queue_push_head(conn->queue, req); |
|
24794
1f4f77e2e111
Use separate variables to keep track of the timer and the watcher.
Mark Doliner <markdoliner@pidgin.im>
parents:
24793
diff
changeset
|
684 | conn->run_timer = purple_timeout_add(0, msn_soap_connection_run, conn); |
|
23774
032236e2eb9e
Patch from tomgr to resend once if the connection is down, fixes #5379
Ka-Hing Cheung <khc@pidgin.im>
parents:
23773
diff
changeset
|
685 | } |
|
21356
50afac513011
handle unauthenticated soap connection
Ka-Hing Cheung <khc@pidgin.im>
parents:
21355
diff
changeset
|
686 | |
| 21364 | 687 | g_free(body); |
|
22981
b83a23981419
Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents:
22060
diff
changeset
|
688 | } |
|
21353
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
689 | } |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
690 | |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
691 | return FALSE; |
|
a70d31127cb6
beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@pidgin.im>
parents:
diff
changeset
|
692 | } |