Mercurial > pidgin.yaz
annotate src/protocols/msn/servconn.c @ 8808:bbd8cdaf0ad5
[gaim-migrate @ 9570]
A massive patch by shx to reorganize MSN some more and add command
processor support. This allows us to do cool things like produce more
detailed error messages. For example, the Invalid Username dialog now
shows the username of the invalid user.
I modified the aforementioned dialog so it'll look a little nicer looking,
and also mention the account this happened on. It also removes the user
from your blist, as there's no point to keeping the user on there.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 25 Apr 2004 22:02:06 +0000 |
parents | c47a90a0a3b1 |
children | ffecda0c1f45 |
rev | line source |
---|---|
5309 | 1 /** |
2 * @file servconn.c Server connection functions | |
3 * | |
4 * gaim | |
5 * | |
8475
06f57183e29f
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
8299
diff
changeset
|
6 * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6122
diff
changeset
|
7 * |
5309 | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
22 #include "msn.h" | |
23 #include "servconn.h" | |
8569
ee13d1befabe
[gaim-migrate @ 9317]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
24 #include "error.h" |
5309 | 25 |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
26 static void read_cb(gpointer data, gint source, GaimInputCondition cond); |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
27 |
5309 | 28 static void |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
29 connect_cb(gpointer data, gint source, GaimInputCondition cond) |
5309 | 30 { |
31 MsnServConn *servconn = data; | |
32 | |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
33 gaim_debug_info("msn", "In servconn's connect_cb\n"); |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
34 |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
35 servconn->fd = source; |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
36 |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
37 if (source > 0) |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
38 { |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
39 /* Someone wants to know we connected. */ |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
40 servconn->connect_cb(servconn); |
5309 | 41 servconn->inpa = gaim_input_add(servconn->fd, GAIM_INPUT_READ, |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
42 read_cb, data); |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
43 } |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
44 else |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
45 { |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
46 GaimConnection *gc = servconn->session->account->gc; |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
47 gaim_connection_error(gc, _("Unable to connect.")); |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
48 } |
5309 | 49 } |
50 | |
51 MsnServConn * | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
52 msn_servconn_new(MsnSession *session, MsnServerType type) |
5309 | 53 { |
54 MsnServConn *servconn; | |
55 | |
56 g_return_val_if_fail(session != NULL, NULL); | |
57 | |
58 servconn = g_new0(MsnServConn, 1); | |
59 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
60 servconn->type = type; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
61 |
5309 | 62 servconn->session = session; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
63 servconn->cmdproc = msn_cmdproc_new(session); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
64 servconn->cmdproc->servconn = servconn; |
5309 | 65 |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
66 if (session->http_method) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
67 { |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
68 servconn->http_data = g_new0(MsnHttpMethodData, 1); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
69 servconn->http_data->virgin = TRUE; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
70 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
71 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
72 servconn->num = session->servconns_count++; |
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
73 session->servconns = g_list_append(session->servconns, servconn); |
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
74 |
5309 | 75 return servconn; |
76 } | |
77 | |
78 gboolean | |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
79 msn_servconn_connect(MsnServConn *servconn, const char *host, int port) |
5309 | 80 { |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
81 MsnSession *session; |
5309 | 82 int i; |
83 | |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
84 g_return_val_if_fail(servconn != NULL, FALSE); |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
85 g_return_val_if_fail(host != NULL, FALSE); |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
86 g_return_val_if_fail(port > 0, FALSE); |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
87 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
88 session = servconn->session; |
5309 | 89 |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
90 if (servconn->connected) |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
91 msn_servconn_disconnect(servconn); |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
92 |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
93 if (session->http_method) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
94 { |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
95 servconn->http_data->gateway_ip = g_strdup(host); |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
96 host = "gateway.messenger.hotmail.com"; |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
97 port = 80; |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
98 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
99 |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
100 i = gaim_proxy_connect(session->account, host, port, connect_cb, |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
101 servconn); |
5309 | 102 |
103 if (i == 0) | |
104 servconn->connected = TRUE; | |
105 | |
106 return servconn->connected; | |
107 } | |
108 | |
109 void | |
110 msn_servconn_disconnect(MsnServConn *servconn) | |
111 { | |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
112 MsnSession *session; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
113 |
5309 | 114 g_return_if_fail(servconn != NULL); |
115 g_return_if_fail(servconn->connected); | |
116 | |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
117 session = servconn->session; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
118 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
119 if (servconn->inpa > 0) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
120 { |
5309 | 121 gaim_input_remove(servconn->inpa); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
122 servconn->inpa = 0; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
123 } |
5309 | 124 |
5744
6b87c127fe7b
[gaim-migrate @ 6168]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
125 close(servconn->fd); |
6b87c127fe7b
[gaim-migrate @ 6168]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
126 |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
127 if (servconn->http_data != NULL) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
128 { |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
129 if (servconn->http_data->session_id != NULL) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
130 g_free(servconn->http_data->session_id); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
131 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
132 if (servconn->http_data->old_gateway_ip != NULL) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
133 g_free(servconn->http_data->old_gateway_ip); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
134 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
135 if (servconn->http_data->gateway_ip != NULL) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
136 g_free(servconn->http_data->gateway_ip); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
137 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
138 if (servconn->http_data->timer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
7938
diff
changeset
|
139 gaim_timeout_remove(servconn->http_data->timer); |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
140 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
141 g_free(servconn->http_data); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
142 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
143 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
144 servconn->rx_len = 0; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
145 servconn->payload_len = 0; |
5309 | 146 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
147 if (servconn->disconnect_cb != NULL) |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
148 servconn->disconnect_cb(servconn); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
149 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
150 servconn->connected = FALSE; |
5309 | 151 } |
152 | |
153 void | |
154 msn_servconn_destroy(MsnServConn *servconn) | |
155 { | |
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
156 MsnSession *session; |
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
157 |
5309 | 158 g_return_if_fail(servconn != NULL); |
159 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
160 if (servconn->processing) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
161 { |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
162 servconn->wasted = TRUE; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
163 return; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
164 } |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
165 |
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
166 session = servconn->session; |
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
167 |
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
168 session->servconns = g_list_remove(session->servconns, servconn); |
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
169 |
5309 | 170 if (servconn->connected) |
171 msn_servconn_disconnect(servconn); | |
172 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
173 msn_cmdproc_destroy(servconn->cmdproc); |
5309 | 174 g_free(servconn); |
175 } | |
176 | |
177 void | |
178 msn_servconn_set_connect_cb(MsnServConn *servconn, | |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
179 gboolean (*connect_cb)(MsnServConn *servconn)) |
5309 | 180 { |
181 g_return_if_fail(servconn != NULL); | |
182 | |
183 servconn->connect_cb = connect_cb; | |
184 } | |
185 | |
186 void | |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
187 msn_servconn_set_disconnect_cb(MsnServConn *servconn, |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
188 void (*disconnect_cb)(MsnServConn |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
189 *servconn)) |
5309 | 190 { |
191 g_return_if_fail(servconn != NULL); | |
192 | |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
193 servconn->disconnect_cb = disconnect_cb; |
5309 | 194 } |
195 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
196 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
197 show_error(MsnServConn *servconn) |
5309 | 198 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
199 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
200 char *tmp; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
201 char *cmd; |
5309 | 202 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
203 const char *names[] = { "Notification", "Switchboard" }; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
204 const char *name; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
205 |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
206 gc = gaim_account_get_connection(servconn->session->account); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
207 name = names[servconn->type]; |
5309 | 208 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
209 switch (servconn->cmdproc->error) |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
210 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
211 case MSN_ERROR_CONNECT: |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
212 tmp = g_strdup_printf(_("Unable to connect to %s server"), |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
213 name); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
214 break; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
215 case MSN_ERROR_WRITE: |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
216 tmp = g_strdup_printf(_("Error writing to %s server"), name); |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
217 break; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
218 case MSN_ERROR_READ: |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
219 cmd = servconn->cmdproc->last_trans; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
220 tmp = g_strdup_printf(_("Error reading from %s server. Last" |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
221 "command was:\n %s"), name, cmd); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
222 break; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
223 default: |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
224 tmp = g_strdup_printf(_("Unknown error from %s server"), name); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
225 break; |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
226 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
227 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
228 gaim_connection_error(gc, tmp); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
229 |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
230 g_free(tmp); |
5309 | 231 } |
232 | |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
233 static void |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
234 failed_io(MsnServConn *servconn) |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
235 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
236 show_error(servconn); |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
237 |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
238 msn_servconn_disconnect(servconn); |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
239 } |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
240 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
241 size_t |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
242 msn_servconn_write(MsnServConn *servconn, const char *buf, size_t size) |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
243 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
244 size_t ret = FALSE; |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
245 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
246 g_return_val_if_fail(servconn != NULL, 0); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
247 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
248 if (servconn->session->http_method) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
249 { |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
250 ret = msn_http_servconn_write(servconn, buf, size, |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
251 servconn->http_data->server_type); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
252 } |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
253 else |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
254 { |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
255 ret = write(servconn->fd, buf, size); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
256 } |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
257 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
258 if (ret < 0) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
259 { |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
260 servconn->cmdproc->error = MSN_ERROR_WRITE; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
261 failed_io(servconn); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
262 } |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
263 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
264 return ret; |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
265 } |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
266 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
267 static void |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
268 read_cb(gpointer data, gint source, GaimInputCondition cond) |
5309 | 269 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
270 MsnServConn *servconn; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
271 MsnSession *session; |
5309 | 272 char buf[MSN_BUF_LEN]; |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
273 char *cur, *end, *old_rx_buf; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
274 int len, cur_len; |
5309 | 275 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
276 servconn = data; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
277 session = servconn->session; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
278 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
279 len = read(servconn->fd, buf, sizeof(buf) - 1); |
5309 | 280 |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
281 if (len <= 0) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
282 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
283 servconn->cmdproc->error = MSN_ERROR_READ; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
284 |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
285 failed_io(servconn); |
5309 | 286 |
287 return; | |
288 } | |
289 | |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
290 servconn->rx_buf = g_realloc(servconn->rx_buf, len + servconn->rx_len); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
291 memcpy(servconn->rx_buf + servconn->rx_len, buf, len); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
292 servconn->rx_len += len; |
5309 | 293 |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
294 if (session->http_method) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
295 { |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
296 char *result_msg = NULL; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
297 size_t result_len = 0; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
298 gboolean error; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
299 char *tmp; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
300 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
301 tmp = g_strndup(servconn->rx_buf, servconn->rx_len); |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
302 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
303 if (!msn_http_servconn_parse_data(servconn, tmp, |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
304 servconn->rx_len, &result_msg, |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
305 &result_len, &error)) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
306 { |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
307 g_free(tmp); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
308 return; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
309 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
310 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
311 g_free(tmp); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
312 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
313 if (error) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
314 { |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
315 gaim_connection_error( |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
316 gaim_account_get_connection(session->account), |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
317 _("Received HTTP error. Please report this.")); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
318 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
319 return; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
320 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
321 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
322 if (servconn->http_data->session_id != NULL && |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
323 !strcmp(servconn->http_data->session_id, "close")) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
324 { |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
325 msn_servconn_destroy(servconn); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
326 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
327 return; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
328 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
329 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
330 #if 0 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
331 if (strcmp(servconn->http_data->gateway_ip, |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
332 msn_servconn_get_server(servconn)) != 0) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
333 { |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
334 int i; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
335 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
336 /* Evil hackery. I promise to remove it, even though I can't. */ |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
337 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
338 servconn->connected = FALSE; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
339 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
340 if (servconn->inpa) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
341 gaim_input_remove(servconn->inpa); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
342 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
343 close(servconn->fd); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
344 |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
345 i = gaim_proxy_connect(session->account, servconn->host, |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
346 servconn->port, servconn->login_cb, |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
347 servconn); |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
348 |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
349 if (i == 0) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
350 servconn->connected = TRUE; |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
351 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
352 #endif |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
353 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
354 g_free(servconn->rx_buf); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
355 servconn->rx_buf = result_msg; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
356 servconn->rx_len = result_len; |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
357 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
358 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
359 end = old_rx_buf = servconn->rx_buf; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
360 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
361 servconn->processing = TRUE; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
362 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
363 do |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
364 { |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
365 cur = end; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
366 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
367 if (servconn->payload_len) |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
368 { |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
369 if (servconn->payload_len > servconn->rx_len) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
370 /* The payload is still not complete. */ |
5309 | 371 break; |
372 | |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
373 cur_len = servconn->payload_len; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
374 end += cur_len; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
375 } |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
376 else |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
377 { |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
378 end = strstr(cur, "\r\n"); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
379 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
380 if (!end) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
381 /* The command is still not complete. */ |
5309 | 382 break; |
383 | |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
384 *end = '\0'; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
385 cur_len = end - cur + 2; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
386 end += 2; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
387 } |
5309 | 388 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
389 servconn->rx_len -= cur_len; |
5899
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
390 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
391 if (servconn->payload_len) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
392 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
393 msn_cmdproc_process_payload(servconn->cmdproc, cur, cur_len); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
394 servconn->payload_len = 0; |
5309 | 395 } |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
396 else |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
397 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
398 msn_cmdproc_process_cmd_text(servconn->cmdproc, cur); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
399 } |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
400 } while (servconn->connected && servconn->rx_len); |
5309 | 401 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
402 if (servconn->connected) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
403 { |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
404 if (servconn->rx_len) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
405 servconn->rx_buf = g_memdup(cur, servconn->rx_len); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
406 else |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
407 servconn->rx_buf = NULL; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
408 } |
5309 | 409 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
410 servconn->processing = FALSE; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
411 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
412 if (servconn->wasted) |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
413 msn_servconn_destroy(servconn); |
5309 | 414 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
415 g_free(old_rx_buf); |
5309 | 416 } |