annotate libpurple/protocols/msn/soap2.c @ 20534:7e69275a4eef

oim migrated to new soap code, quadruply duplicated message! the timestamp seems to be off too, but I didn't change that part at all, I need to sleep now though
author Ka-Hing Cheung <khc@hxbc.us>
date Mon, 01 Oct 2007 07:20:35 +0000
parents 66921a5c9ae9
children c49b886231d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
1 /**
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
2 * @file soap2.c
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
3 * C file for SOAP connection related process
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
4 *
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
5 * purple
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
6 *
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
7 * Purple is the legal property of its developers, whose names are too numerous
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
9 * source distribution.
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
10 *
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
14 * (at your option) any later version.
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
15 *
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
19 * GNU General Public License for more details.
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
20 *
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
24 */
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
25
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
26 #include "soap2.h"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
27
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
28 #include "session.h"
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
29
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
30 #include "debug.h"
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
31 #include "xmlnode.h"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
32
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
33 #include <glib.h>
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
34 #include <error.h>
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
35
20534
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
36 #define SOAP_TIMEOUT (5 * 60)
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
37
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
38 typedef struct _MsnSoapRequest {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
39 char *path;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
40 MsnSoapMessage *message;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
41 MsnSoapCallback cb;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
42 gpointer cb_data;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
43 } MsnSoapRequest;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
44
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
45 typedef struct _MsnSoapConnection {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
46 MsnSession *session;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
47 char *host;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
48
20533
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
49 time_t last_used;
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
50 PurpleSslConnection *ssl;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
51 gboolean connected;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
52
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
53 guint event_handle;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
54 GString *buf;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
55 gsize handled_len;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
56 gsize body_len;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
57 int response_code;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
58 gboolean headers_done;
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
59 gboolean close_when_done;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
60
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
61 MsnSoapMessage *message;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
62
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
63 GQueue *queue;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
64 MsnSoapRequest *current_request;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
65 } MsnSoapConnection;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
66
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
67 static void msn_soap_connection_destroy_foreach_cb(gpointer item, gpointer data);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
68 static gboolean msn_soap_connection_run(gpointer data);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
69
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
70 static MsnSoapConnection *msn_soap_connection_new(MsnSession *session,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
71 const char *host);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
72 static void msn_soap_connection_handle_next(MsnSoapConnection *conn);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
73 static void msn_soap_connection_destroy(MsnSoapConnection *conn);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
74
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
75 static void msn_soap_message_send_internal(MsnSession *session,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
76 MsnSoapMessage *message, const char *host, const char *path,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
77 MsnSoapCallback cb, gpointer cb_data, gboolean first);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
78
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
79 static void msn_soap_request_destroy(MsnSoapRequest *req);
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
80 static void msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
81
20533
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
82 static gboolean
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
83 msn_soap_cleanup_each(gpointer key, gpointer value, gpointer data)
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
84 {
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
85 MsnSoapConnection *conn = value;
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
86 time_t *t = data;
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
87
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
88 if ((*t - conn->last_used) > SOAP_TIMEOUT * 2) {
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
89 purple_debug_info("soap", "cleaning up soap conn %p\n", conn);
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
90 return TRUE;
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
91 }
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
92
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
93 return FALSE;
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
94 }
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
95
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
96 static gboolean
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
97 msn_soap_cleanup_for_session(gpointer data)
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
98 {
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
99 MsnSession *sess = data;
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
100 time_t t = time(NULL);
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
101
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
102 purple_debug_info("soap", "session cleanup timeout\n");
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
103
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
104 if (sess->soap_table) {
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
105 g_hash_table_foreach_remove(sess->soap_table, msn_soap_cleanup_each,
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
106 &t);
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
107
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
108 if (g_hash_table_size(sess->soap_table) == 0) {
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
109 purple_timeout_remove(sess->soap_cleanup_handle);
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
110 sess->soap_cleanup_handle = 0;
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
111 }
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
112 }
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
113
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
114 return TRUE;
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
115 }
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
116
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
117 static MsnSoapConnection *
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
118 msn_soap_get_connection(MsnSession *session, const char *host)
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
119 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
120 MsnSoapConnection *conn = NULL;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
121
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
122 if (session->soap_table) {
20534
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
123 conn = g_hash_table_lookup(session->soap_table, host);
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
124 } else {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
125 session->soap_table = g_hash_table_new_full(g_str_hash, g_str_equal,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
126 NULL, (GDestroyNotify)msn_soap_connection_destroy);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
127 }
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
128
20533
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
129 if (session->soap_cleanup_handle == 0)
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
130 session->soap_cleanup_handle = purple_timeout_add(SOAP_TIMEOUT * 1000,
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
131 msn_soap_cleanup_for_session, session);
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
132
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
133 if (conn == NULL) {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
134 conn = msn_soap_connection_new(session, host);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
135 g_hash_table_insert(session->soap_table, conn->host, conn);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
136 }
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
137
20533
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
138 conn->last_used = time(NULL);
66921a5c9ae9 cleanup soap connection with a timeout
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
139
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
140 return conn;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
141 }
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
142
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
143 static MsnSoapConnection *
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
144 msn_soap_connection_new(MsnSession *session, const char *host)
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
145 {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
146 MsnSoapConnection *conn = g_new0(MsnSoapConnection, 1);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
147 conn->session = session;
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
148 conn->host = g_strdup(host);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
149 conn->queue = g_queue_new();
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
150 return conn;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
151 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
152
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
153 static void
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
154 msn_soap_connected_cb(gpointer data, PurpleSslConnection *ssl,
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
155 PurpleInputCondition cond)
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
156 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
157 MsnSoapConnection *conn = data;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
158
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
159 conn->connected = TRUE;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
160
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
161 if (conn->event_handle == 0)
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
162 conn->event_handle = g_idle_add(msn_soap_connection_run, conn);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
163 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
164
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
165 static void
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
166 msn_soap_error_cb(PurpleSslConnection *ssl, PurpleSslErrorType error,
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
167 gpointer data)
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
168 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
169 MsnSoapConnection *conn = data;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
170
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
171 g_hash_table_remove(conn->session->soap_table, conn->host);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
172 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
173
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
174 static gboolean
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
175 msn_soap_handle_redirect(MsnSoapConnection *conn, const char *url)
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
176 {
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
177 char *c;
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
178
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
179 /* Skip the http:// */
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
180 if ((c = strchr(url, '/')) != NULL)
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
181 url += 2;
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
182
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
183 if ((c = strchr(url, '/')) != NULL) {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
184 char *host, *path;
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
185
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
186 host = g_strndup(url, c - url);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
187 path = g_strdup(c);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
188
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
189 msn_soap_message_send_internal(conn->session,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
190 conn->current_request->message, host, path,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
191 conn->current_request->cb, conn->current_request->cb_data, TRUE);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
192
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
193 msn_soap_request_destroy(conn->current_request);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
194 conn->current_request = NULL;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
195
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
196 g_free(host);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
197 g_free(path);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
198
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
199 return TRUE;
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
200 }
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
201
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
202 return FALSE;
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
203 }
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
204
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
205 static gboolean
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
206 msn_soap_handle_body(MsnSoapConnection *conn, MsnSoapMessage *response)
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
207 {
20534
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
208 xmlnode *body = xmlnode_get_child(response->xml, "Body");
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
209
20534
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
210 if (body) {
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
211 MsnSoapRequest *request;
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
212
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
213 if (strcmp(body->name, "Fault") == 0) {
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
214 xmlnode *fault = xmlnode_get_child(body, "faultcode");
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
215
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
216 if (fault != NULL) {
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
217 char *faultdata = xmlnode_get_data(fault);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
218
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
219 if (strcmp(faultdata, "psf:Redirect") == 0) {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
220 xmlnode *url = xmlnode_get_child(body, "redirectUrl");
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
221
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
222 if (url) {
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
223 char *urldata = xmlnode_get_data(url);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
224 msn_soap_handle_redirect(conn, urldata);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
225 g_free(urldata);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
226 }
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
227
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
228 g_free(faultdata);
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
229 return TRUE;
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
230 } else if (strcmp(faultdata, "wsse:FailedAuthentication") == 0) {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
231 xmlnode *reason = xmlnode_get_child(body, "faultstring");
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
232 char *reasondata = xmlnode_get_data(reason);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
233
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
234 msn_soap_connection_sanitize(conn, TRUE);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
235 msn_session_set_error(conn->session, MSN_ERROR_AUTH,
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
236 reasondata);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
237
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
238 g_free(reasondata);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
239 g_free(faultdata);
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
240 return FALSE;
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
241 }
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
242
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
243 g_free(faultdata);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
244 }
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
245 }
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
246
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
247 request = conn->current_request;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
248 conn->current_request = NULL;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
249 request->cb(request->message, response,
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
250 request->cb_data);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
251 msn_soap_request_destroy(request);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
252 }
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
253
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
254 return TRUE;
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
255 }
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
256
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
257 static void
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
258 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond)
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
259 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
260 MsnSoapConnection *conn = data;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
261 int count;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
262 char buf[8192];
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
263 char *linebreak;
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
264 char *cursor;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
265 gboolean handled = FALSE;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
266
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
267 g_return_if_fail(cond == PURPLE_INPUT_READ);
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
268
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
269 count = purple_ssl_read(conn->ssl, buf, sizeof(buf));
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
270 purple_debug_info("soap", "read %d bytes\n", count);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
271 if (count < 0 && errno == EAGAIN)
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
272 return;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
273 else if (count <= 0) {
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
274 purple_debug_info("soap", "read: %s\n", strerror(errno));
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
275 purple_ssl_close(conn->ssl);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
276 conn->ssl = NULL;
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
277 msn_soap_connection_handle_next(conn);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
278 return;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
279 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
280
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
281 if (conn->message == NULL) {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
282 conn->message = msn_soap_message_new(NULL, NULL);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
283 }
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
284
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
285 if (conn->buf == NULL) {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
286 conn->buf = g_string_new_len(buf, count);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
287 } else {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
288 g_string_append_len(conn->buf, buf, count);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
289 }
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
290
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
291 purple_debug_info("soap", "current %s\n", conn->buf->str);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
292
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
293 cursor = conn->buf->str + conn->handled_len;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
294
20534
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
295 if (!conn->headers_done) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
296 while ((linebreak = strstr(cursor, "\r\n")) != NULL) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
297 conn->handled_len = linebreak - conn->buf->str + 2;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
298
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
299 if (conn->response_code == 0) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
300 if (sscanf(cursor, "HTTP/1.1 %d", &conn->response_code) != 1) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
301 /* something horribly wrong */
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
302 purple_ssl_close(conn->ssl);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
303 conn->ssl = NULL;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
304 msn_soap_connection_handle_next(conn);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
305 handled = TRUE;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
306 break;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
307 } else if (conn->response_code == 503) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
308 msn_soap_connection_sanitize(conn, TRUE);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
309 msn_session_set_error(conn->session, MSN_ERROR_SERV_UNAVAILABLE, NULL);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
310 return;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
311 }
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
312 } else if (cursor == linebreak) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
313 /* blank line */
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
314 conn->headers_done = TRUE;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
315 cursor = conn->buf->str + conn->handled_len;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
316 break;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
317 } else {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
318 char *line = g_strndup(cursor, linebreak - cursor);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
319 char *sep = strstr(line, ": ");
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
320 char *key = line;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
321 char *value;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
322
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
323 if (sep == NULL) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
324 purple_debug_info("soap", "ignoring malformed line: %s\n", line);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
325 g_free(line);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
326 goto loop_end;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
327 }
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
328
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
329 value = sep + 2;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
330 *sep = '\0';
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
331 msn_soap_message_add_header(conn->message, key, value);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
332 purple_debug_info("soap", "header %s: %s\n", key, value);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
333
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
334 if ((conn->response_code == 301 || conn->response_code == 300)
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
335 && strcmp(key, "Location") == 0) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
336
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
337 msn_soap_handle_redirect(conn, value);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
338
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
339 handled = TRUE;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
340 g_free(line);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
341 break;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
342 } else if (conn->response_code == 401 &&
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
343 strcmp(key, "WWW-Authenticate") == 0) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
344 char *error = strstr(value, "cbtxt=");
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
345
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
346 if (error) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
347 error += strlen("cbtxt=");
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
348 }
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
349
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
350 msn_soap_connection_sanitize(conn, TRUE);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
351 msn_session_set_error(conn->session, MSN_ERROR_AUTH,
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
352 error ? purple_url_decode(error) : NULL);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
353
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
354 g_free(line);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
355 return;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
356 } else if (strcmp(key, "Content-Length") == 0) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
357 conn->body_len = atoi(value);
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
358 } else if (strcmp(key, "Connection") == 0) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
359 if (strcmp(value, "close") == 0) {
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
360 conn->close_when_done = TRUE;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
361 }
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
362 }
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
363 }
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
364
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
365 loop_end:
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
366 cursor = conn->buf->str + conn->handled_len;
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
367 }
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
368 }
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
369
7e69275a4eef oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20533
diff changeset
370 if (!handled && conn->headers_done) {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
371 if (conn->buf->len - conn->handled_len >=
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
372 conn->body_len) {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
373 xmlnode *node = xmlnode_from_str(cursor, conn->body_len);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
374
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
375 if (node == NULL) {
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
376 purple_debug_info("soap", "Malformed SOAP response: %s\n",
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
377 cursor);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
378 } else {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
379 MsnSoapMessage *message = conn->message;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
380 conn->message = NULL;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
381 message->xml = node;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
382
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
383 if (!msn_soap_handle_body(conn, message))
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
384 return;
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
385 }
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
386
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
387 msn_soap_connection_handle_next(conn);
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
388 }
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
389
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
390 return;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
391 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
392
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
393 if (handled) {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
394 msn_soap_connection_handle_next(conn);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
395 }
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
396 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
397
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
398 static void
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
399 msn_soap_write_cb(gpointer data, gint fd, PurpleInputCondition cond)
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
400 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
401 MsnSoapConnection *conn = data;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
402 int written;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
403
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
404 g_return_if_fail(cond == PURPLE_INPUT_WRITE);
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
405
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
406 written = purple_ssl_write(conn->ssl, conn->buf->str + conn->handled_len,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
407 conn->buf->len - conn->handled_len);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
408
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
409 if (written < 0 && errno == EAGAIN)
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
410 return;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
411 else if (written <= 0) {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
412 purple_ssl_close(conn->ssl);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
413 conn->ssl = NULL;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
414 msn_soap_connection_handle_next(conn);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
415 return;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
416 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
417
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
418 conn->handled_len += written;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
419
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
420 if (conn->handled_len < conn->buf->len)
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
421 return;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
422
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
423 /* we are done! */
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
424 g_string_free(conn->buf, TRUE);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
425 conn->buf = NULL;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
426 conn->handled_len = 0;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
427 conn->body_len = 0;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
428 conn->response_code = 0;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
429 conn->headers_done = FALSE;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
430 conn->close_when_done = FALSE;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
431
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
432 purple_input_remove(conn->event_handle);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
433 conn->event_handle = purple_input_add(conn->ssl->fd, PURPLE_INPUT_READ,
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
434 msn_soap_read_cb, conn);
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
435 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
436
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
437 static gboolean
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
438 msn_soap_connection_run(gpointer data)
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
439 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
440 MsnSoapConnection *conn = data;
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
441 MsnSoapRequest *req = g_queue_peek_head(conn->queue);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
442
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
443 conn->event_handle = 0;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
444
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
445 if (req) {
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
446 if (conn->ssl == NULL) {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
447 conn->ssl = purple_ssl_connect(conn->session->account, conn->host,
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
448 443, msn_soap_connected_cb, msn_soap_error_cb, conn);
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
449 } else if (conn->connected) {
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
450 int len = -1;
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
451 char *body = xmlnode_to_str(req->message->xml, &len);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
452 GSList *iter;
20529
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
453 char *authstr = NULL;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
454
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
455 g_queue_pop_head(conn->queue);
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
456
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
457 conn->buf = g_string_new("");
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
458
20529
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
459 if (conn->session->passport_info.mspauth)
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
460 authstr = g_strdup_printf("Cookie: MSPAuth=%s\r\n",
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
461 conn->session->passport_info.mspauth);
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
462
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
463
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
464 g_string_append_printf(conn->buf,
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
465 "POST %s HTTP/1.1\r\n"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
466 "SOAPAction: %s\r\n"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
467 "Content-Type:text/xml; charset=utf-8\r\n"
20529
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
468 "%s"
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
469 "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
470 "Accept: */*\r\n"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
471 "Host: %s\r\n"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
472 "Content-Length: %d\r\n"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
473 "Connection: Keep-Alive\r\n"
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
474 "Cache-Control: no-cache\r\n",
20529
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
475 req->path, req->message->action ? req->message->action : "",
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
476 authstr ? authstr : "", conn->host, len);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
477
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
478 for (iter = req->message->headers; iter; iter = iter->next) {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
479 g_string_append(conn->buf, (char *)iter->data);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
480 g_string_append(conn->buf, "\r\n");
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
481 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
482
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
483 g_string_append(conn->buf, "\r\n");
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
484 g_string_append(conn->buf, body);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
485
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
486 purple_debug_info("soap", "%s\n", conn->buf->str);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
487
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
488 conn->handled_len = 0;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
489 conn->current_request = req;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
490
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
491 conn->event_handle = purple_input_add(conn->ssl->fd,
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
492 PURPLE_INPUT_WRITE, msn_soap_write_cb, conn);
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
493 msn_soap_write_cb(conn, conn->ssl->fd, PURPLE_INPUT_WRITE);
20529
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
494
1180920ffcec handle unauthenticated soap connection
Ka-Hing Cheung <khc@hxbc.us>
parents: 20528
diff changeset
495 g_free(authstr);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
496 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
497 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
498
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
499 return FALSE;
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
500 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
501
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
502 void
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
503 msn_soap_message_send(MsnSession *session, MsnSoapMessage *message,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
504 const char *host, const char *path,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
505 MsnSoapCallback cb, gpointer cb_data)
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
506 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
507 msn_soap_message_send_internal(session, message, host, path, cb, cb_data,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
508 FALSE);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
509 }
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
510
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
511 static void
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
512 msn_soap_message_send_internal(MsnSession *session,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
513 MsnSoapMessage *message, const char *host, const char *path,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
514 MsnSoapCallback cb, gpointer cb_data, gboolean first)
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
515 {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
516 MsnSoapConnection *conn = msn_soap_get_connection(session, host);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
517 MsnSoapRequest *req = g_new0(MsnSoapRequest, 1);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
518
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
519 req->path = g_strdup(path);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
520 req->message = message;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
521 req->cb = cb;
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
522 req->cb_data = cb_data;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
523
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
524 if (first) {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
525 g_queue_push_head(conn->queue, req);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
526 } else {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
527 g_queue_push_tail(conn->queue, req);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
528 }
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
529
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
530 if (conn->event_handle == 0)
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
531 conn->event_handle = purple_timeout_add(0, msn_soap_connection_run,
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
532 conn);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
533 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
534
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
535 static void
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
536 msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect)
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
537 {
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
538 if (conn->event_handle) {
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
539 purple_input_remove(conn->event_handle);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
540 conn->event_handle = 0;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
541 }
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
542
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
543 if (conn->message) {
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
544 msn_soap_message_destroy(conn->message);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
545 conn->message = NULL;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
546 }
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
547
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
548 if (conn->buf) {
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
549 g_string_free(conn->buf, TRUE);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
550 conn->buf = NULL;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
551 }
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
552
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
553 if (conn->ssl && (disconnect || conn->close_when_done)) {
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
554 purple_ssl_close(conn->ssl);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
555 conn->ssl = NULL;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
556 }
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
557
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
558 if (conn->current_request) {
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
559 msn_soap_request_destroy(conn->current_request);
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
560 conn->current_request = NULL;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
561 }
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
562 }
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
563
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
564 static void
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
565 msn_soap_connection_handle_next(MsnSoapConnection *conn)
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
566 {
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
567 msn_soap_connection_sanitize(conn, FALSE);
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
568
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
569 conn->event_handle = purple_timeout_add(0, msn_soap_connection_run, conn);
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
570
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
571 if (conn->current_request) {
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
572 MsnSoapRequest *req = conn->current_request;
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
573 conn->current_request = NULL;
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
574 msn_soap_connection_destroy_foreach_cb(req, conn);
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
575 }
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
576 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
577
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
578 static void
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
579 msn_soap_connection_destroy_foreach_cb(gpointer item, gpointer data)
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
580 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
581 MsnSoapRequest *req = item;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
582
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
583 if (req->cb)
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
584 req->cb(req->message, NULL, req->cb_data);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
585
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
586 msn_soap_request_destroy(req);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
587 }
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
588
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
589 static void
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
590 msn_soap_connection_destroy(MsnSoapConnection *conn)
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
591 {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
592 if (conn->current_request) {
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
593 MsnSoapRequest *req = conn->current_request;
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
594 conn->current_request = NULL;
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
595 msn_soap_connection_destroy_foreach_cb(req, conn);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
596 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
597
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
598 msn_soap_connection_sanitize(conn, TRUE);
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
599 g_queue_foreach(conn->queue, msn_soap_connection_destroy_foreach_cb, conn);
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
600 g_queue_free(conn->queue);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
601
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
602 g_free(conn->host);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
603 g_free(conn);
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
604 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
605
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
606 MsnSoapMessage *
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
607 msn_soap_message_new(const char *action, xmlnode *xml)
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
608 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
609 MsnSoapMessage *message = g_new0(MsnSoapMessage, 1);
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
610
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
611 message->action = g_strdup(action);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
612 message->xml = xml;
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
613
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
614 return message;
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
615 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
616
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
617 void
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
618 msn_soap_message_destroy(MsnSoapMessage *message)
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
619 {
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
620 if (message) {
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
621 g_slist_foreach(message->headers, (GFunc)g_free, NULL);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
622 g_slist_free(message->headers);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
623 g_free(message->action);
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
624 if (message->xml)
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
625 xmlnode_free(message->xml);
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
626 g_free(message);
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
627 }
20526
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
628 }
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
629
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
630 void
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
631 msn_soap_message_add_header(MsnSoapMessage *req,
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
632 const char *name, const char *value)
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
633 {
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
634 char *header = g_strdup_printf("%s: %s\r\n", name, value);
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
635
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
636 req->headers = g_slist_prepend(req->headers, header);
915e11fbaeb0 beginning of soap layer rewrite, does that even compile?
Ka-Hing Cheung <khc@hxbc.us>
parents:
diff changeset
637 }
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
638
20528
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
639 static void
06527cc0f79b removes public handle to soap connection, instead a connection is looked up
Ka-Hing Cheung <khc@hxbc.us>
parents: 20527
diff changeset
640 msn_soap_request_destroy(MsnSoapRequest *req)
20527
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
641 {
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
642 g_free(req->path);
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
643 msn_soap_message_destroy(req->message);
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
644 g_free(req);
0034d7e89032 mostly done with soap level parsing, compiles
Ka-Hing Cheung <khc@hxbc.us>
parents: 20526
diff changeset
645 }
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
646
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
647 xmlnode *
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
648 msn_soap_xml_get(xmlnode *parent, const char *node)
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
649 {
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
650 xmlnode *ret;
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
651 char **tokens = g_strsplit(node, "/", -1);
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
652 int i;
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
653
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
654 for (i = 0; tokens[i]; i++) {
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
655 if ((ret = xmlnode_get_child(parent, tokens[i])) != NULL)
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
656 parent = ret;
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
657 else
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
658 break;
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
659 }
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
660
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
661 g_strfreev(tokens);
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
662 return ret;
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
663 }
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20529
diff changeset
664