Mercurial > pidgin
annotate plugins/yay/rxhandlers.c @ 1566:e9faf5dfdba0
[gaim-migrate @ 1576]
if not connected and disconnect remove WRITE instead of READ
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 13 Mar 2001 11:05:13 +0000 |
parents | 2c66d386be90 |
children | 4a47a459cc98 |
rev | line source |
---|---|
1546 | 1 /* |
2 * libyay | |
3 * | |
4 * Copyright (C) 2001 Eric Warmenhoven <warmenhoven@yahoo.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 #include "internal.h" | |
23 #include <string.h> | |
24 #include <stdlib.h> | |
25 #include <ctype.h> | |
26 | |
27 static int yahoo_parse_config(struct yahoo_session *session, struct yahoo_conn *conn, char *buf) | |
28 { | |
29 char **str_array = g_strsplit(buf, "\n", 1024); | |
30 char **it; | |
31 int state = 0; | |
32 | |
33 for (it = str_array; *it; it++) { | |
34 if (!strncmp(*it, "ERROR", strlen("ERROR"))) { | |
35 yahoo_close(session, conn); | |
36 CALLBACK(session, YAHOO_HANDLE_BADPASSWORD); | |
37 return 1; | |
38 } else if (!strncmp(*it, "Set-Cookie: ", strlen("Set-Cookie: "))) { | |
39 char **sa; | |
40 char **m; | |
41 | |
42 char *end = strchr(*it, ';'); | |
43 if (session->cookie) | |
44 g_free(session->cookie); | |
45 session->cookie = g_strndup(*it + strlen("Set-Cookie: "), | |
46 end - *it - strlen("Set-Cookie: ")); | |
47 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, session->cookie); | |
48 if (!session->cookie) { | |
49 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
50 YAHOO_PRINT(session, YAHOO_LOG_ERROR, "did not get cookie"); |
1546 | 51 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
52 return 1; | |
53 } | |
54 | |
55 sa = g_strsplit(session->cookie, "&", 8); | |
56 for (m = sa; *m; m++) { | |
57 if (!strncmp(*m, "n=", 2)) { | |
58 if (session->login_cookie) | |
59 g_free(session->login_cookie); | |
60 session->login_cookie = g_strdup(*m + 2); | |
61 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, session->login_cookie); | |
62 } | |
63 } | |
64 g_strfreev(sa); | |
65 } else if (!strncmp(*it, "BEGIN BUDDYLIST", strlen("BEGIN BUDDYLIST"))) { | |
66 state = 1; | |
67 } else if (!strncmp(*it, "END BUDDYLIST", strlen("END BUDDYLIST"))) { | |
68 state = 0; | |
69 } else if (!strncmp(*it, "BEGIN IGNORELIST", strlen("BEGIN IGNORELIST"))) { | |
70 state = 2; | |
71 } else if (!strncmp(*it, "END IGNORELIST", strlen("END IGNORELIST"))) { | |
72 state = 0; | |
73 } else if (!strncmp(*it, "BEGIN IDENTITIES", strlen("BEGIN IDENTITIES"))) { | |
74 state = 3; | |
75 } else if (!strncmp(*it, "END IDENTITIES", strlen("END IDENTITIES"))) { | |
76 state = 0; | |
77 } else if (!strncmp(*it, "Mail=", strlen("Mail="))) { | |
78 session->mail = atoi(*it + strlen("Mail=")); | |
79 } else if (!strncmp(*it, "Login=", strlen("Login="))) { | |
80 if (session->login) | |
81 g_free(session->login); | |
82 session->login = g_strdup(*it + strlen("Login=")); | |
83 } else { | |
84 if (state == 1) { | |
85 struct yahoo_group *grp = g_new0(struct yahoo_group, 1); | |
86 char *end = strchr(*it, ':'); | |
87 grp->name = g_strndup(*it, end - *it); | |
88 end++; | |
89 grp->buddies = g_strsplit(end, ",", 1024); | |
90 session->groups = g_list_append(session->groups, grp); | |
91 } else if (state == 2) { | |
92 session->ignored = g_list_append(session->ignored, g_strdup(*it)); | |
93 } else if (state == 3) { | |
94 session->identities = g_strsplit(*it, ",", 6); | |
95 } | |
96 } | |
97 } | |
98 | |
99 g_strfreev(str_array); | |
100 yahoo_close(session, conn); | |
101 CALLBACK(session, YAHOO_HANDLE_LOGINCOOKIE); | |
102 return 0; | |
103 } | |
104 | |
105 static void yahoo_parse_status(struct yahoo_session *sess, struct yahoo_packet *pkt) | |
106 { | |
107 char *tmp = pkt->content; | |
108 int count = 0; | |
109 char **strs; | |
110 int i; | |
111 | |
112 YAHOO_PRINT(sess, YAHOO_LOG_DEBUG, pkt->content); | |
113 | |
114 if (strstr(pkt->content, "was not AWAY")) | |
115 return; | |
116 | |
117 while (*tmp && isdigit((int)*tmp)) | |
118 count = count * 10 + *tmp++ - '0'; | |
119 if (*tmp == ',') | |
120 tmp++; | |
121 count = count ? count : 1; | |
122 | |
123 if (count > 1) | |
124 strs = g_strsplit(tmp, "),", count); | |
125 else | |
126 strs = g_strsplit(tmp, ")", count); | |
127 | |
128 for (i = 0; i < count && strs[i]; i++) { | |
129 char **vals; | |
130 char *end, *who; | |
131 char **it; | |
132 int c, j; | |
133 | |
134 who = strs[i]; | |
135 end = strchr(who, '('); | |
136 *end++ = '\0'; | |
137 | |
138 vals = g_strsplit(end, ",", 1024); | |
139 | |
140 for (it = vals, c = 0; *it; it++, c++); | |
141 if (c > 6) | |
142 end = g_strdup(vals[1]); | |
143 for (j = 2; j < c - 5; j++) { | |
144 char *x = end; | |
145 end = g_strconcat(end, ",", vals[j], NULL); | |
146 g_free(x); | |
147 } | |
148 | |
149 CALLBACK(sess, YAHOO_HANDLE_STATUS, who, atoi(vals[0]), end, | |
150 atoi(vals[c - 3]), atoi(vals[c - 2]), atoi(vals[c - 1])); | |
151 | |
152 if (c > 6) | |
153 g_free(end); | |
154 g_strfreev(vals); | |
155 } | |
156 | |
157 g_strfreev(strs); | |
158 } | |
159 | |
160 static void yahoo_parse_message(struct yahoo_session *sess, struct yahoo_packet *pkt) | |
161 { | |
162 char buf[256]; | |
163 int type = yahoo_makeint(pkt->msgtype); | |
164 char **str_array; | |
165 switch(type) { | |
166 case YAHOO_MESSAGE_NORMAL: | |
167 str_array = g_strsplit(pkt->content, ",,", 2); | |
168 CALLBACK(sess, YAHOO_HANDLE_MESSAGE, pkt->nick2, str_array[0], str_array[1]); | |
169 g_strfreev(str_array); | |
170 break; | |
1562
12f16a852540
[gaim-migrate @ 1572]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1561
diff
changeset
|
171 case YAHOO_MESSAGE_BOUNCE: |
12f16a852540
[gaim-migrate @ 1572]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1561
diff
changeset
|
172 CALLBACK(sess, YAHOO_HANDLE_BOUNCE); |
12f16a852540
[gaim-migrate @ 1572]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1561
diff
changeset
|
173 break; |
1546 | 174 default: |
175 g_snprintf(buf, sizeof(buf), "unhandled message type %d: %s", type, pkt->content); | |
176 YAHOO_PRINT(sess, YAHOO_LOG_WARNING, buf); | |
177 break; | |
178 } | |
179 } | |
180 | |
181 static void yahoo_parse_packet(struct yahoo_session *sess, | |
182 struct yahoo_conn *conn, struct yahoo_packet *pkt) | |
183 { | |
184 char buf[256]; | |
185 int service = yahoo_makeint(pkt->service); | |
186 conn->magic_id = yahoo_makeint(pkt->magic_id); | |
187 g_snprintf(buf, sizeof(buf), "Service %d (msgtype %d)", service, yahoo_makeint(pkt->msgtype)); | |
188 YAHOO_PRINT(sess, YAHOO_LOG_DEBUG, buf); | |
189 switch(service) { | |
190 case YAHOO_SERVICE_LOGON: | |
191 if (yahoo_makeint(pkt->msgtype) == 0) | |
192 CALLBACK(sess, YAHOO_HANDLE_ONLINE); | |
193 case YAHOO_SERVICE_LOGOFF: | |
194 case YAHOO_SERVICE_ISAWAY: | |
195 case YAHOO_SERVICE_ISBACK: | |
1561
9fe7b059d2a5
[gaim-migrate @ 1571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
196 yahoo_parse_status(sess, pkt); |
9fe7b059d2a5
[gaim-migrate @ 1571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
197 break; |
1557
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
198 case YAHOO_SERVICE_NEWCONTACT: |
1563
393b23c8f494
[gaim-migrate @ 1573]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1562
diff
changeset
|
199 if (yahoo_makeint(pkt->msgtype) == 3) { |
393b23c8f494
[gaim-migrate @ 1573]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1562
diff
changeset
|
200 char **str_array = g_strsplit(pkt->content, ",,", 2); |
393b23c8f494
[gaim-migrate @ 1573]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1562
diff
changeset
|
201 CALLBACK(sess, YAHOO_HANDLE_BUDDYADDED, pkt->nick2, str_array[0], str_array[1]); |
393b23c8f494
[gaim-migrate @ 1573]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1562
diff
changeset
|
202 g_strfreev(str_array); |
393b23c8f494
[gaim-migrate @ 1573]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1562
diff
changeset
|
203 } else |
1561
9fe7b059d2a5
[gaim-migrate @ 1571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1557
diff
changeset
|
204 yahoo_parse_status(sess, pkt); |
1546 | 205 break; |
206 case YAHOO_SERVICE_IDACT: | |
207 CALLBACK(sess, YAHOO_HANDLE_ACTIVATE, pkt->content); | |
208 break; | |
209 case YAHOO_SERVICE_MESSAGE: | |
210 yahoo_parse_message(sess, pkt); | |
211 break; | |
212 case YAHOO_SERVICE_NEWMAIL: | |
213 CALLBACK(sess, YAHOO_HANDLE_NEWMAIL, strlen(pkt->content) ? atoi(pkt->content) : 0); | |
214 break; | |
215 default: | |
216 g_snprintf(buf, sizeof(buf), "unhandled service type %d: %s", service, pkt->content); | |
217 YAHOO_PRINT(sess, YAHOO_LOG_WARNING, buf); | |
218 break; | |
219 } | |
220 } | |
221 | |
222 void yahoo_socket_handler(struct yahoo_session *session, int socket, int type) | |
223 { | |
224 int pos = 0; | |
225 struct yahoo_conn *conn; | |
226 | |
227 if (!session) | |
228 return; | |
229 | |
230 if (!(conn = yahoo_find_conn(session, socket))) | |
231 return; | |
232 | |
233 if (type == YAHOO_SOCKET_WRITE) { | |
234 int error = ETIMEDOUT, len = sizeof(error); | |
235 | |
236 if (getsockopt(socket, SOL_SOCKET, SO_ERROR, &error, &len) < 0) | |
237 error = errno; | |
238 if (error) { | |
239 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
240 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "unable to connect"); |
1546 | 241 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
242 return; | |
243 } | |
244 | |
245 fcntl(socket, F_SETFL, 0); | |
246 | |
247 YAHOO_PRINT(session, YAHOO_LOG_NOTICE, "connected"); | |
248 | |
1566
e9faf5dfdba0
[gaim-migrate @ 1576]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1565
diff
changeset
|
249 conn->connected = TRUE; |
1546 | 250 if (yahoo_socket_notify) |
251 (*yahoo_socket_notify)(session, socket, YAHOO_SOCKET_WRITE, FALSE); | |
252 if (yahoo_socket_notify) | |
253 (*yahoo_socket_notify)(session, socket, YAHOO_SOCKET_READ, TRUE); | |
254 | |
255 if (conn->type == YAHOO_CONN_TYPE_AUTH) { | |
256 CALLBACK(session, YAHOO_HANDLE_AUTHCONNECT); | |
257 } else if (conn->type == YAHOO_CONN_TYPE_MAIN) { | |
258 CALLBACK(session, YAHOO_HANDLE_MAINCONNECT); | |
259 } else if (conn->type == YAHOO_CONN_TYPE_DUMB) { | |
260 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "sending to buddy list host"); | |
261 yahoo_write(session, conn, conn->txqueue, strlen(conn->txqueue)); | |
262 g_free(conn->txqueue); | |
263 conn->txqueue = NULL; | |
1565
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
264 } else if (conn->type == YAHOO_CONN_TYPE_PROXY) { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
265 char buf[1024]; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
266 g_snprintf(buf, sizeof(buf), "CONNECT %s:%d HTTP/1.1\r\n\r\n", |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
267 YAHOO_PAGER_HOST, YAHOO_PAGER_PORT); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
268 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
269 yahoo_write(session, conn, buf, strlen(buf)); |
1546 | 270 } |
271 | |
272 return; | |
273 } | |
274 | |
275 if (conn->type == YAHOO_CONN_TYPE_AUTH) { | |
276 char *buf = g_malloc0(5000); | |
277 while (read(socket, &buf[pos++], 1) == 1); | |
278 if (pos == 1) { | |
279 g_free(buf); | |
280 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
281 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "could not read auth response"); |
1546 | 282 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
283 return; | |
284 } | |
285 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
286 if (yahoo_parse_config(session, conn, buf)) { |
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
287 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "could not parse auth response"); |
1546 | 288 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
289 } |
1546 | 290 g_free(buf); |
291 } else if (conn->type == YAHOO_CONN_TYPE_MAIN) { | |
292 struct yahoo_packet pkt; | |
293 int len; | |
294 | |
295 if ((read(socket, &pkt, 8) != 8) || strcmp(pkt.version, "YHOO1.0")) { | |
296 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
297 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "invalid version type"); |
1546 | 298 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
299 return; | |
300 } | |
301 | |
302 if (read(socket, &pkt.len, 4) != 4) { | |
303 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
304 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "could not read length"); |
1546 | 305 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
306 return; | |
307 } | |
308 len = yahoo_makeint(pkt.len); | |
309 | |
310 if (read(socket, &pkt.service, len - 12) != len - 12) { | |
311 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
312 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "could not read data"); |
1546 | 313 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
314 return; | |
315 } | |
316 yahoo_parse_packet(session, conn, &pkt); | |
317 } else if (conn->type == YAHOO_CONN_TYPE_DUMB) { | |
1557
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
318 char *buf = g_malloc0(5000); |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
319 while (read(socket, &buf[pos++], 1) == 1); |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
320 if (pos == 1) { |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
321 g_free(buf); |
1565
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
322 yahoo_close(session, conn); |
1557
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
323 YAHOO_PRINT(session, YAHOO_LOG_WARNING, "error reading from listserv"); |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
324 return; |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
325 } |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
326 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf); |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
327 YAHOO_PRINT(session, YAHOO_LOG_NOTICE, "closing buddy list host connnection"); |
1546 | 328 yahoo_close(session, conn); |
1565
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
329 g_free(buf); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
330 } else if (conn->type == YAHOO_CONN_TYPE_PROXY) { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
331 char *buf = g_malloc0(5000); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
332 int nlc = 0; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
333 while ((nlc != 2) && (read(socket, &buf[pos++], 1) == 1)) |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
334 if (buf[pos-1] == '\n') |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
335 nlc++; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
336 if (pos == 1) { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
337 g_free(buf); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
338 yahoo_close(session, conn); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
339 YAHOO_PRINT(session, YAHOO_LOG_ERROR, "error reading from proxy"); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
340 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
341 return; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
342 } |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
343 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
344 if (!strncasecmp(buf, HTTP_GOODSTRING1, strlen(HTTP_GOODSTRING1)) || |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
345 !strncasecmp(buf, HTTP_GOODSTRING2, strlen(HTTP_GOODSTRING2))) { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
346 conn->type = YAHOO_CONN_TYPE_MAIN; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
347 YAHOO_PRINT(session, YAHOO_LOG_NOTICE, "proxy connected successfully"); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
348 CALLBACK(session, YAHOO_HANDLE_MAINCONNECT); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
349 } else { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
350 yahoo_close(session, conn); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
351 YAHOO_PRINT(session, YAHOO_LOG_ERROR, "proxy could not connect"); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
352 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
353 } |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
354 g_free(buf); |
1546 | 355 } |
356 } | |
357 | |
358 void yahoo_add_handler(struct yahoo_session *session, int type, yahoo_callback function) | |
359 { | |
360 if (!session) | |
361 return; | |
362 | |
363 session->callbacks[type].function = function; | |
364 } |