Mercurial > pidgin.yaz
annotate plugins/yay/rxhandlers.c @ 1565:2c66d386be90
[gaim-migrate @ 1575]
http proxy for libyay. yay.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 13 Mar 2001 10:05:45 +0000 |
parents | 393b23c8f494 |
children | e9faf5dfdba0 |
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 | |
249 if (yahoo_socket_notify) | |
250 (*yahoo_socket_notify)(session, socket, YAHOO_SOCKET_WRITE, FALSE); | |
251 if (yahoo_socket_notify) | |
252 (*yahoo_socket_notify)(session, socket, YAHOO_SOCKET_READ, TRUE); | |
253 | |
254 if (conn->type == YAHOO_CONN_TYPE_AUTH) { | |
255 CALLBACK(session, YAHOO_HANDLE_AUTHCONNECT); | |
256 } else if (conn->type == YAHOO_CONN_TYPE_MAIN) { | |
257 CALLBACK(session, YAHOO_HANDLE_MAINCONNECT); | |
258 } else if (conn->type == YAHOO_CONN_TYPE_DUMB) { | |
259 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "sending to buddy list host"); | |
260 yahoo_write(session, conn, conn->txqueue, strlen(conn->txqueue)); | |
261 g_free(conn->txqueue); | |
262 conn->txqueue = NULL; | |
1565
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
263 } else if (conn->type == YAHOO_CONN_TYPE_PROXY) { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
264 char buf[1024]; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
265 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
|
266 YAHOO_PAGER_HOST, YAHOO_PAGER_PORT); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
267 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
268 yahoo_write(session, conn, buf, strlen(buf)); |
1546 | 269 } |
270 | |
271 return; | |
272 } | |
273 | |
274 if (conn->type == YAHOO_CONN_TYPE_AUTH) { | |
275 char *buf = g_malloc0(5000); | |
276 while (read(socket, &buf[pos++], 1) == 1); | |
277 if (pos == 1) { | |
278 g_free(buf); | |
279 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
280 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "could not read auth response"); |
1546 | 281 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
282 return; | |
283 } | |
284 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
285 if (yahoo_parse_config(session, conn, buf)) { |
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
286 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "could not parse auth response"); |
1546 | 287 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
288 } |
1546 | 289 g_free(buf); |
290 } else if (conn->type == YAHOO_CONN_TYPE_MAIN) { | |
291 struct yahoo_packet pkt; | |
292 int len; | |
293 | |
294 if ((read(socket, &pkt, 8) != 8) || strcmp(pkt.version, "YHOO1.0")) { | |
295 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
296 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "invalid version type"); |
1546 | 297 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
298 return; | |
299 } | |
300 | |
301 if (read(socket, &pkt.len, 4) != 4) { | |
302 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
303 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "could not read length"); |
1546 | 304 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
305 return; | |
306 } | |
307 len = yahoo_makeint(pkt.len); | |
308 | |
309 if (read(socket, &pkt.service, len - 12) != len - 12) { | |
310 yahoo_close(session, conn); | |
1554
c3afde736a8a
[gaim-migrate @ 1564]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1553
diff
changeset
|
311 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "could not read data"); |
1546 | 312 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
313 return; | |
314 } | |
315 yahoo_parse_packet(session, conn, &pkt); | |
316 } else if (conn->type == YAHOO_CONN_TYPE_DUMB) { | |
1557
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
317 char *buf = g_malloc0(5000); |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
318 while (read(socket, &buf[pos++], 1) == 1); |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
319 if (pos == 1) { |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
320 g_free(buf); |
1565
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
321 yahoo_close(session, conn); |
1557
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
322 YAHOO_PRINT(session, YAHOO_LOG_WARNING, "error reading from listserv"); |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
323 return; |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
324 } |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
325 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf); |
1ca5f5fcd483
[gaim-migrate @ 1567]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1554
diff
changeset
|
326 YAHOO_PRINT(session, YAHOO_LOG_NOTICE, "closing buddy list host connnection"); |
1546 | 327 yahoo_close(session, conn); |
1565
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
328 g_free(buf); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
329 } else if (conn->type == YAHOO_CONN_TYPE_PROXY) { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
330 char *buf = g_malloc0(5000); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
331 int nlc = 0; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
332 while ((nlc != 2) && (read(socket, &buf[pos++], 1) == 1)) |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
333 if (buf[pos-1] == '\n') |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
334 nlc++; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
335 if (pos == 1) { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
336 g_free(buf); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
337 yahoo_close(session, conn); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
338 YAHOO_PRINT(session, YAHOO_LOG_ERROR, "error reading from proxy"); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
339 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
340 return; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
341 } |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
342 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
343 if (!strncasecmp(buf, HTTP_GOODSTRING1, strlen(HTTP_GOODSTRING1)) || |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
344 !strncasecmp(buf, HTTP_GOODSTRING2, strlen(HTTP_GOODSTRING2))) { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
345 conn->type = YAHOO_CONN_TYPE_MAIN; |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
346 YAHOO_PRINT(session, YAHOO_LOG_NOTICE, "proxy connected successfully"); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
347 CALLBACK(session, YAHOO_HANDLE_MAINCONNECT); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
348 } else { |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
349 yahoo_close(session, conn); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
350 YAHOO_PRINT(session, YAHOO_LOG_ERROR, "proxy could not connect"); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
351 CALLBACK(session, YAHOO_HANDLE_DISCONNECT); |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
352 } |
2c66d386be90
[gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1563
diff
changeset
|
353 g_free(buf); |
1546 | 354 } |
355 } | |
356 | |
357 void yahoo_add_handler(struct yahoo_session *session, int type, yahoo_callback function) | |
358 { | |
359 if (!session) | |
360 return; | |
361 | |
362 session->callbacks[type].function = function; | |
363 } |