Mercurial > pidgin
annotate src/protocols/msn/servconn.c @ 9125:668ffb8fec00
[gaim-migrate @ 9902]
(12:53:05) nosnilmot: LSchiere: not majorly important, but the pref changes
listed in the ChangeLog are out of sync
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sun, 30 May 2004 16:54:40 +0000 |
| parents | 6dd02df922b4 |
| children | c30d81b4dd22 |
| 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 |
|
9092
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
29 show_error(MsnServConn *servconn) |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
30 { |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
31 GaimConnection *gc; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
32 char *tmp; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
33 char *cmd; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
34 |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
35 const char *names[] = { "Notification", "Switchboard" }; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
36 const char *name; |
|
9093
6dd02df922b4
[gaim-migrate @ 9870]
Christian Hammond <chipx86@chipx86.com>
parents:
9092
diff
changeset
|
37 |
|
9092
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
38 gc = gaim_account_get_connection(servconn->session->account); |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
39 name = names[servconn->type]; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
40 |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
41 switch (servconn->cmdproc->error) |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
42 { |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
43 case MSN_ERROR_CONNECT: |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
44 tmp = g_strdup_printf(_("Unable to connect to %s server"), |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
45 name); |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
46 break; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
47 case MSN_ERROR_WRITE: |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
48 tmp = g_strdup_printf(_("Error writing to %s server"), name); |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
49 break; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
50 case MSN_ERROR_READ: |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
51 cmd = servconn->cmdproc->last_trans; |
|
9093
6dd02df922b4
[gaim-migrate @ 9870]
Christian Hammond <chipx86@chipx86.com>
parents:
9092
diff
changeset
|
52 tmp = g_strdup_printf(_("Error reading from %s server. Last" |
|
6dd02df922b4
[gaim-migrate @ 9870]
Christian Hammond <chipx86@chipx86.com>
parents:
9092
diff
changeset
|
53 "command was:\n %s"), name, cmd); |
|
9092
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
54 gaim_debug_info("msn", "Last command was: %s\n", cmd); |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
55 break; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
56 default: |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
57 tmp = g_strdup_printf(_("Unknown error from %s server"), name); |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
58 break; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
59 } |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
60 |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
61 gaim_connection_error(gc, tmp); |
|
9093
6dd02df922b4
[gaim-migrate @ 9870]
Christian Hammond <chipx86@chipx86.com>
parents:
9092
diff
changeset
|
62 |
|
9092
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
63 g_free(tmp); |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
64 } |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
65 |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
66 static void |
|
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5785
diff
changeset
|
67 connect_cb(gpointer data, gint source, GaimInputCondition cond) |
| 5309 | 68 { |
| 69 MsnServConn *servconn = data; | |
| 70 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
71 gaim_debug_info("msn", "In servconn's connect_cb\n"); |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
72 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
73 servconn->fd = source; |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
74 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
75 if (source > 0) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
76 { |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
77 /* Someone wants to know we connected. */ |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
78 servconn->connect_cb(servconn); |
| 5309 | 79 servconn->inpa = gaim_input_add(servconn->fd, GAIM_INPUT_READ, |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
80 read_cb, data); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
81 } |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
82 else |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
83 { |
|
9092
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
84 servconn->cmdproc->error = MSN_ERROR_CONNECT; |
|
9e5a709c30a8
[gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents:
9088
diff
changeset
|
85 show_error(servconn); |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
86 } |
| 5309 | 87 } |
| 88 | |
| 89 MsnServConn * | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
90 msn_servconn_new(MsnSession *session, MsnServerType type) |
| 5309 | 91 { |
| 92 MsnServConn *servconn; | |
| 93 | |
| 94 g_return_val_if_fail(session != NULL, NULL); | |
| 95 | |
| 96 servconn = g_new0(MsnServConn, 1); | |
| 97 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
98 servconn->type = type; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
99 |
| 5309 | 100 servconn->session = session; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
101 servconn->cmdproc = msn_cmdproc_new(session); |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
102 servconn->cmdproc->servconn = servconn; |
| 5309 | 103 |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
104 if (session->http_method) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
105 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
106 servconn->http_data = g_new0(MsnHttpMethodData, 1); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
107 servconn->http_data->virgin = TRUE; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
108 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
109 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
110 servconn->num = session->servconns_count++; |
|
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
111 session->servconns = g_list_append(session->servconns, servconn); |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
112 |
| 5309 | 113 return servconn; |
| 114 } | |
| 115 | |
| 116 gboolean | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
117 msn_servconn_connect(MsnServConn *servconn, const char *host, int port) |
| 5309 | 118 { |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
119 MsnSession *session; |
| 5309 | 120 int i; |
| 121 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
122 g_return_val_if_fail(servconn != NULL, FALSE); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
123 g_return_val_if_fail(host != NULL, FALSE); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
124 g_return_val_if_fail(port > 0, FALSE); |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
125 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
126 session = servconn->session; |
| 5309 | 127 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
128 if (servconn->connected) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
129 msn_servconn_disconnect(servconn); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
130 |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
131 if (session->http_method) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
132 { |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
133 servconn->http_data->gateway_ip = g_strdup(host); |
|
7288
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 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
136 i = gaim_proxy_connect(session->account, host, port, connect_cb, |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
137 servconn); |
| 5309 | 138 |
| 139 if (i == 0) | |
| 140 servconn->connected = TRUE; | |
| 141 | |
| 142 return servconn->connected; | |
| 143 } | |
| 144 | |
| 145 void | |
| 146 msn_servconn_disconnect(MsnServConn *servconn) | |
| 147 { | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
148 MsnSession *session; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
149 |
| 5309 | 150 g_return_if_fail(servconn != NULL); |
| 151 g_return_if_fail(servconn->connected); | |
| 152 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
153 session = servconn->session; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
154 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
155 if (servconn->inpa > 0) |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
156 { |
| 5309 | 157 gaim_input_remove(servconn->inpa); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
158 servconn->inpa = 0; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
159 } |
| 5309 | 160 |
|
5744
6b87c127fe7b
[gaim-migrate @ 6168]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
161 close(servconn->fd); |
|
6b87c127fe7b
[gaim-migrate @ 6168]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
162 |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
163 if (servconn->http_data != NULL) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
164 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
165 if (servconn->http_data->session_id != NULL) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
166 g_free(servconn->http_data->session_id); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
167 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
168 if (servconn->http_data->old_gateway_ip != NULL) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
169 g_free(servconn->http_data->old_gateway_ip); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
170 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
171 if (servconn->http_data->gateway_ip != NULL) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
172 g_free(servconn->http_data->gateway_ip); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
173 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
174 if (servconn->http_data->timer) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
7938
diff
changeset
|
175 gaim_timeout_remove(servconn->http_data->timer); |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
176 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
177 g_free(servconn->http_data); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
178 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
179 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
180 servconn->rx_len = 0; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
181 servconn->payload_len = 0; |
| 5309 | 182 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
183 if (servconn->disconnect_cb != NULL) |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
184 servconn->disconnect_cb(servconn); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
185 |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
186 servconn->connected = FALSE; |
| 5309 | 187 } |
| 188 | |
| 189 void | |
| 190 msn_servconn_destroy(MsnServConn *servconn) | |
| 191 { | |
|
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
192 MsnSession *session; |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
193 |
| 5309 | 194 g_return_if_fail(servconn != NULL); |
| 195 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
196 if (servconn->processing) |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
197 { |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
198 servconn->wasted = TRUE; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
199 return; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
200 } |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
201 |
|
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
202 session = servconn->session; |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
203 |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
204 session->servconns = g_list_remove(session->servconns, servconn); |
|
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5897
diff
changeset
|
205 |
| 5309 | 206 if (servconn->connected) |
| 207 msn_servconn_disconnect(servconn); | |
| 208 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
209 msn_cmdproc_destroy(servconn->cmdproc); |
| 5309 | 210 g_free(servconn); |
| 211 } | |
| 212 | |
| 213 void | |
| 214 msn_servconn_set_connect_cb(MsnServConn *servconn, | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
215 gboolean (*connect_cb)(MsnServConn *servconn)) |
| 5309 | 216 { |
| 217 g_return_if_fail(servconn != NULL); | |
| 218 | |
| 219 servconn->connect_cb = connect_cb; | |
| 220 } | |
| 221 | |
| 222 void | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
223 msn_servconn_set_disconnect_cb(MsnServConn *servconn, |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
224 void (*disconnect_cb)(MsnServConn |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
225 *servconn)) |
| 5309 | 226 { |
| 227 g_return_if_fail(servconn != NULL); | |
| 228 | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
229 servconn->disconnect_cb = disconnect_cb; |
| 5309 | 230 } |
| 231 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
232 static void |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
233 failed_io(MsnServConn *servconn) |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
234 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
235 show_error(servconn); |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
236 |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
237 msn_servconn_disconnect(servconn); |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
238 } |
|
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
239 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
240 size_t |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
241 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
|
242 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
243 size_t ret = FALSE; |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
244 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
245 g_return_val_if_fail(servconn != NULL, 0); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
246 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
247 if (servconn->session->http_method) |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
248 { |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
249 ret = msn_http_servconn_write(servconn, buf, size, |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
250 servconn->http_data->server_type); |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
251 } |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
252 else |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
253 { |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
254 ret = write(servconn->fd, buf, size); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
255 } |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
256 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
257 if (ret < 0) |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
258 { |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
259 servconn->cmdproc->error = MSN_ERROR_WRITE; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
260 failed_io(servconn); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
261 } |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
262 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
263 return ret; |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
264 } |
|
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 static void |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
267 read_cb(gpointer data, gint source, GaimInputCondition cond) |
| 5309 | 268 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
269 MsnServConn *servconn; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
270 MsnSession *session; |
| 5309 | 271 char buf[MSN_BUF_LEN]; |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
272 char *cur, *end, *old_rx_buf; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
273 int len, cur_len; |
| 5309 | 274 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
275 servconn = data; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
276 session = servconn->session; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
277 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
278 len = read(servconn->fd, buf, sizeof(buf) - 1); |
| 5309 | 279 |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
280 if (len <= 0) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
281 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
282 servconn->cmdproc->error = MSN_ERROR_READ; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
283 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
284 failed_io(servconn); |
| 5309 | 285 |
| 286 return; | |
| 287 } | |
| 288 | |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
289 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
|
290 memcpy(servconn->rx_buf + servconn->rx_len, buf, len); |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
291 servconn->rx_len += len; |
| 5309 | 292 |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
293 if (session->http_method) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
294 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
295 char *result_msg = NULL; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
296 size_t result_len = 0; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
297 gboolean error; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
298 char *tmp; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
299 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
300 tmp = g_strndup(servconn->rx_buf, servconn->rx_len); |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
301 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
302 if (!msn_http_servconn_parse_data(servconn, tmp, |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
303 servconn->rx_len, &result_msg, |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
304 &result_len, &error)) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
305 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
306 g_free(tmp); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
307 return; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
308 } |
|
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 g_free(tmp); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
311 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
312 if (error) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
313 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
314 gaim_connection_error( |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
315 gaim_account_get_connection(session->account), |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
316 _("Received HTTP error. Please report this.")); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
317 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
318 return; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
319 } |
|
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 if (servconn->http_data->session_id != NULL && |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
322 !strcmp(servconn->http_data->session_id, "close")) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
323 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
324 msn_servconn_destroy(servconn); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
325 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
326 return; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
327 } |
|
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 #if 0 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
330 if (strcmp(servconn->http_data->gateway_ip, |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
331 msn_servconn_get_server(servconn)) != 0) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
332 { |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
333 int i; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
334 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
335 /* 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
|
336 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
337 servconn->connected = FALSE; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
338 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
339 if (servconn->inpa) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
340 gaim_input_remove(servconn->inpa); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
341 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
342 close(servconn->fd); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
343 |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8569
diff
changeset
|
344 i = gaim_proxy_connect(session->account, servconn->host, |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
345 servconn->port, servconn->login_cb, |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
346 servconn); |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
347 |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
348 if (i == 0) |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
349 servconn->connected = TRUE; |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
350 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
351 #endif |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
352 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
353 g_free(servconn->rx_buf); |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
354 servconn->rx_buf = result_msg; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
355 servconn->rx_len = result_len; |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
356 } |
|
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
357 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
358 end = old_rx_buf = servconn->rx_buf; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
359 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
360 servconn->processing = TRUE; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
361 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
362 do |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
363 { |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
364 cur = end; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
365 |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
366 if (servconn->payload_len) |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
367 { |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
368 if (servconn->payload_len > servconn->rx_len) |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
369 /* The payload is still not complete. */ |
| 5309 | 370 break; |
| 371 | |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
372 cur_len = servconn->payload_len; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
373 end += cur_len; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
374 } |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
375 else |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
376 { |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
377 end = strstr(cur, "\r\n"); |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
378 |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
379 if (!end) |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
380 /* The command is still not complete. */ |
| 5309 | 381 break; |
| 382 | |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
383 *end = '\0'; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
384 cur_len = end - cur + 2; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
385 end += 2; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
386 } |
| 5309 | 387 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
388 servconn->rx_len -= cur_len; |
|
5899
349204c9a709
[gaim-migrate @ 6331]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
389 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
390 if (servconn->payload_len) |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
391 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
392 msn_cmdproc_process_payload(servconn->cmdproc, cur, cur_len); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
393 servconn->payload_len = 0; |
| 5309 | 394 } |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
395 else |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
396 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
397 msn_cmdproc_process_cmd_text(servconn->cmdproc, cur); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
398 } |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
399 } while (servconn->connected && servconn->rx_len); |
| 5309 | 400 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
401 if (servconn->connected) |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
402 { |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
403 if (servconn->rx_len) |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
404 servconn->rx_buf = g_memdup(cur, servconn->rx_len); |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
405 else |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
406 servconn->rx_buf = NULL; |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
407 } |
| 5309 | 408 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
409 servconn->processing = FALSE; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8662
diff
changeset
|
410 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
411 if (servconn->wasted) |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
412 msn_servconn_destroy(servconn); |
| 5309 | 413 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
414 g_free(old_rx_buf); |
| 5309 | 415 } |
