Mercurial > pidgin.yaz
annotate src/protocols/yahoo/yahoo.c @ 10575:96307e1a47c9
[gaim-migrate @ 11968]
This makes Yahoo roomlist & filetransfer work with HTTP proxies (except when
authentication is needed), webauth probably works too but I couldn't work out
how to test that.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 05 Feb 2005 18:24:50 +0000 |
parents | 7d165e1eec4d |
children | 74cc119beceb |
rev | line source |
---|---|
2681 | 1 /* |
2 * gaim | |
3 * | |
8046 | 4 * Gaim is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
2681 | 7 * |
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 */ | |
9369 | 23 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
24 #include "internal.h" |
2681 | 25 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
26 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
27 #include "accountopt.h" |
6760 | 28 #include "blist.h" |
10119 | 29 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
30 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
31 #include "notify.h" |
6760 | 32 #include "privacy.h" |
2681 | 33 #include "prpl.h" |
34 #include "proxy.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
35 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
36 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
37 #include "util.h" |
9943 | 38 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
39 |
6986 | 40 #include "sha.h" |
6513 | 41 #include "yahoo.h" |
10392 | 42 #include "yahoo_packet.h" |
9278 | 43 #include "yahoo_friend.h" |
6729 | 44 #include "yahoochat.h" |
9376 | 45 #include "ycht.h" |
8349 | 46 #include "yahoo_auth.h" |
7651 | 47 #include "yahoo_filexfer.h" |
9306 | 48 #include "yahoo_picture.h" |
3147 | 49 #include "md5.h" |
2681 | 50 |
5583 | 51 extern char *yahoo_crypt(const char *, const char *); |
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
52 |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
53 /* #define YAHOO_DEBUG */ |
2681 | 54 |
9285 | 55 static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *, GaimGroup *); |
9410 | 56 static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len); |
9306 | 57 |
6784 | 58 |
9278 | 59 static void yahoo_update_status(GaimConnection *gc, const char *name, YahooFriend *f) |
6784 | 60 { |
9927 | 61 gboolean online = TRUE; |
9983 | 62 char *status = NULL; |
6840 | 63 |
6784 | 64 if (!gc || !name || !f || !gaim_find_buddy(gaim_connection_get_account(gc), name)) |
65 return; | |
66 | |
6840 | 67 if (f->status == YAHOO_STATUS_OFFLINE) |
9927 | 68 online = FALSE; |
6840 | 69 |
9983 | 70 switch (f->status) { |
71 case YAHOO_STATUS_AVAILABLE: | |
10373 | 72 status = YAHOO_STATUS_TYPE_AVAILABLE; |
9983 | 73 break; |
74 case YAHOO_STATUS_BRB: | |
10373 | 75 status = YAHOO_STATUS_TYPE_BRB; |
9983 | 76 break; |
77 case YAHOO_STATUS_BUSY: | |
10373 | 78 status = YAHOO_STATUS_TYPE_BUSY; |
9983 | 79 break; |
80 case YAHOO_STATUS_NOTATHOME: | |
10373 | 81 status = YAHOO_STATUS_TYPE_NOTATHOME; |
9983 | 82 break; |
83 case YAHOO_STATUS_NOTATDESK: | |
10373 | 84 status = YAHOO_STATUS_TYPE_NOTATDESK; |
9983 | 85 break; |
86 case YAHOO_STATUS_NOTINOFFICE: | |
10373 | 87 status = YAHOO_STATUS_TYPE_NOTINOFFICE; |
9983 | 88 break; |
89 case YAHOO_STATUS_ONPHONE: | |
10373 | 90 status = YAHOO_STATUS_TYPE_ONPHONE; |
9983 | 91 break; |
92 case YAHOO_STATUS_ONVACATION: | |
10373 | 93 status = YAHOO_STATUS_TYPE_ONVACATION; |
9983 | 94 break; |
95 case YAHOO_STATUS_OUTTOLUNCH: | |
10373 | 96 status = YAHOO_STATUS_TYPE_OUTTOLUNCH; |
9983 | 97 break; |
98 case YAHOO_STATUS_STEPPEDOUT: | |
10373 | 99 status = YAHOO_STATUS_TYPE_STEPPEDOUT; |
9983 | 100 break; |
101 case YAHOO_STATUS_INVISIBLE: /* this should never happen? */ | |
10373 | 102 status = YAHOO_STATUS_TYPE_INVISIBLE; |
9983 | 103 break; |
104 case YAHOO_STATUS_CUSTOM: | |
105 if (!f->away) | |
10373 | 106 status = YAHOO_STATUS_TYPE_AVAILABLE_WM; |
9983 | 107 else |
10373 | 108 status = YAHOO_STATUS_TYPE_AWAY; |
9983 | 109 break; |
10141 | 110 case YAHOO_STATUS_IDLE: |
9983 | 111 break; |
112 default: | |
113 gaim_debug_warning("yahoo", "Warning, unknown status %d\n", f->status); | |
114 break; | |
115 } | |
116 | |
117 if (status) { | |
118 if (f->status == YAHOO_STATUS_CUSTOM) | |
119 gaim_prpl_got_user_status(gaim_connection_get_account(gc), name, status, "message", | |
120 yahoo_friend_get_status_message(f), NULL); | |
121 else | |
122 gaim_prpl_got_user_status(gaim_connection_get_account(gc), name, status, NULL); | |
123 } | |
124 | |
10141 | 125 if (f->idle != 0) |
126 gaim_prpl_got_user_idle(gaim_connection_get_account(gc), name, TRUE, f->idle); | |
127 else | |
128 gaim_prpl_got_user_idle(gaim_connection_get_account(gc), name, FALSE, 0); | |
6784 | 129 } |
130 | |
5583 | 131 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 132 { |
9983 | 133 GaimAccount *account = gaim_connection_get_account(gc); |
2681 | 134 struct yahoo_data *yd = gc->proto_data; |
135 GSList *l = pkt->hash; | |
9278 | 136 YahooFriend *f = NULL; |
2681 | 137 char *name = NULL; |
6784 | 138 |
7892 | 139 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { |
8383 | 140 gc->wants_to_die = TRUE; |
7892 | 141 gaim_connection_error(gc, _("You have been logged off as you have logged in on a different machine or device.")); |
142 return; | |
143 } | |
6686 | 144 |
2681 | 145 while (l) { |
146 struct yahoo_pair *pair = l->data; | |
147 | |
148 switch (pair->key) { | |
149 case 0: /* we won't actually do anything with this */ | |
150 break; | |
151 case 1: /* we don't get the full buddy list here. */ | |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
152 if (!yd->logged_in) { |
7664 | 153 gaim_connection_set_display_name(gc, pair->value); |
5583 | 154 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
155 serv_finish_login(gc); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
156 yd->logged_in = TRUE; |
9306 | 157 if (yd->picture_upload_todo) { |
158 yahoo_buddy_icon_upload(gc, yd->picture_upload_todo); | |
159 yd->picture_upload_todo = NULL; | |
160 } | |
2681 | 161 |
3147 | 162 /* this requests the list. i have a feeling that this is very evil |
163 * | |
6686 | 164 * scs.yahoo.com sends you the list before this packet without it being |
3147 | 165 * requested |
166 * | |
167 * do_import(gc, NULL); | |
168 * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); | |
10392 | 169 * yahoo_packet_send_and_free(newpkt, yd); |
3147 | 170 */ |
171 | |
172 } | |
2681 | 173 break; |
174 case 8: /* how many online buddies we have */ | |
175 break; | |
176 case 7: /* the current buddy */ | |
10553 | 177 if (name && f) /* update the previous buddy before changing the variables */ |
178 yahoo_update_status(gc, name, f); | |
2681 | 179 name = pair->value; |
9886 | 180 if (name && g_utf8_validate(name, -1, NULL)) |
181 f = yahoo_friend_find_or_new(gc, name); | |
9888 | 182 else { |
183 f = NULL; | |
184 name = NULL; | |
185 } | |
2681 | 186 break; |
187 case 10: /* state */ | |
6784 | 188 if (!f) |
189 break; | |
190 | |
191 f->status = strtol(pair->value, NULL, 10); | |
192 if ((f->status >= YAHOO_STATUS_BRB) && (f->status <= YAHOO_STATUS_STEPPEDOUT)) | |
193 f->away = 1; | |
194 else | |
195 f->away = 0; | |
10141 | 196 |
197 if (f->status == YAHOO_STATUS_IDLE) { | |
198 /* Idle may have already been set in a more precise way in case 137 */ | |
199 if (f->idle == 0) | |
200 f->idle = time(NULL); | |
201 } else | |
6804 | 202 f->idle = 0; |
10141 | 203 |
9283 | 204 if (f->status != YAHOO_STATUS_CUSTOM) |
205 yahoo_friend_set_status_message(f, NULL); | |
6847 | 206 |
207 f->sms = 0; | |
2681 | 208 break; |
209 case 19: /* custom message */ | |
9283 | 210 if (f) |
211 yahoo_friend_set_status_message(f, yahoo_string_decode(gc, pair->value, FALSE)); | |
2681 | 212 break; |
6686 | 213 case 11: /* this is the buddy's session id */ |
2681 | 214 break; |
215 case 17: /* in chat? */ | |
216 break; | |
6784 | 217 case 47: /* is custom status away or not? 2=idle*/ |
218 if (!f) | |
219 break; | |
8441 | 220 |
221 /* I have no idea what it means when this is | |
222 * set when someone's available, but it doesn't | |
223 * mean idle. */ | |
224 if (f->status == YAHOO_STATUS_AVAILABLE) | |
225 break; | |
10141 | 226 |
6784 | 227 f->away = strtol(pair->value, NULL, 10); |
10141 | 228 if (f->away == 2) { |
229 /* Idle may have already been set in a more precise way in case 137 */ | |
230 if (f->idle == 0) | |
231 f->idle = time(NULL); | |
232 } | |
233 | |
6686 | 234 break; |
6784 | 235 case 138: /* either we're not idle, or we are but won't say how long */ |
236 if (!f) | |
237 break; | |
238 | |
239 if (f->idle) | |
240 f->idle = -1; | |
241 break; | |
242 case 137: /* usually idle time in seconds, sometimes login time */ | |
243 if (!f) | |
244 break; | |
245 | |
246 if (f->status != YAHOO_STATUS_AVAILABLE) | |
247 f->idle = time(NULL) - strtol(pair->value, NULL, 10); | |
6686 | 248 break; |
249 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ | |
6784 | 250 if (strtol(pair->value, NULL, 10) == 0) { |
251 if (f) | |
252 f->status = YAHOO_STATUS_OFFLINE; | |
9983 | 253 gaim_prpl_got_user_status(account, name, "offline", NULL); |
2807
f01e6a425136
[gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2805
diff
changeset
|
254 break; |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
255 } |
6784 | 256 break; |
257 case 60: /* SMS */ | |
258 if (f) { | |
259 f->sms = strtol(pair->value, NULL, 10); | |
260 yahoo_update_status(gc, name, f); | |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
261 } |
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
262 break; |
9292 | 263 case 197: /* Avatars */ |
9277 | 264 { |
265 char *decoded, *tmp; | |
266 guint len; | |
267 | |
268 if (pair->value) { | |
269 gaim_base64_decode(pair->value, &decoded, &len); | |
270 if (len) { | |
271 tmp = gaim_str_binary_to_ascii(decoded, len); | |
272 gaim_debug_info("yahoo", "Got key 197, value = %s\n", tmp); | |
273 g_free(tmp); | |
274 } | |
275 g_free(decoded); | |
276 } | |
277 break; | |
278 } | |
9292 | 279 case 192: /* Pictures, aka Buddy Icons, checksum */ |
280 { | |
281 int cksum = strtol(pair->value, NULL, 10); | |
282 GaimBuddy *b; | |
283 | |
284 if (!name) | |
285 break; | |
286 | |
9325 | 287 b = gaim_find_buddy(gc->account, name); |
288 | |
9292 | 289 if (!cksum || (cksum == -1)) { |
9325 | 290 if (f) |
291 yahoo_friend_set_buddy_icon_need_request(f, TRUE); | |
9292 | 292 gaim_buddy_icons_set_for_user(gc->account, name, NULL, 0); |
9325 | 293 if (b) |
294 gaim_blist_node_remove_setting((GaimBlistNode *)b, YAHOO_ICON_CHECKSUM_KEY); | |
9292 | 295 break; |
296 } | |
297 | |
298 if (!f) | |
299 break; | |
9325 | 300 |
9292 | 301 yahoo_friend_set_buddy_icon_need_request(f, FALSE); |
302 if (cksum != gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY)) | |
9310 | 303 yahoo_send_picture_request(gc, name); |
9292 | 304 |
305 break; | |
306 } | |
2979 | 307 case 16: /* Custom error message */ |
7827 | 308 { |
309 char *tmp = yahoo_string_decode(gc, pair->value, TRUE); | |
310 gaim_notify_error(gc, NULL, tmp, NULL); | |
311 g_free(tmp); | |
312 } | |
2951 | 313 break; |
2681 | 314 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
315 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
316 "Unknown status key %d\n", pair->key); |
2681 | 317 break; |
318 } | |
319 | |
320 l = l->next; | |
321 } | |
10553 | 322 |
323 if (name && f) /* update the last buddy */ | |
324 yahoo_update_status(gc, name, f); | |
2681 | 325 } |
326 | |
9285 | 327 static void yahoo_do_group_check(GaimAccount *account, GHashTable *ht, const char *name, const char *group) |
6820 | 328 { |
329 GaimBuddy *b; | |
330 GaimGroup *g; | |
331 GSList *list, *i; | |
332 gboolean onlist = 0; | |
333 char *oname = NULL; | |
334 | |
9015 | 335 char **oname_p = &oname; |
336 GSList **list_p = &list; | |
337 | |
338 if (!g_hash_table_lookup_extended(ht, gaim_normalize(account, name), (gpointer *) oname_p, (gpointer *) list_p)) | |
6820 | 339 list = gaim_find_buddies(account, name); |
340 else | |
341 g_hash_table_steal(ht, name); | |
342 | |
343 for (i = list; i; i = i->next) { | |
344 b = i->data; | |
345 g = gaim_find_buddys_group(b); | |
346 if (!gaim_utf8_strcasecmp(group, g->name)) { | |
347 gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
348 "Oh good, %s is in the right group (%s).\n", name, group); | |
349 list = g_slist_delete_link(list, i); | |
350 onlist = 1; | |
351 break; | |
352 } | |
353 } | |
354 | |
355 if (!onlist) { | |
356 gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
357 "Uhoh, %s isn't on the list (or not in this group), adding him to group %s.\n", name, group); | |
358 if (!(g = gaim_find_group(group))) { | |
359 g = gaim_group_new(group); | |
360 gaim_blist_add_group(g, NULL); | |
361 } | |
362 b = gaim_buddy_new(account, name, NULL); | |
363 gaim_blist_add_buddy(b, NULL, g, NULL); | |
364 } | |
365 | |
366 if (list) { | |
367 if (!oname) | |
7823 | 368 oname = g_strdup(gaim_normalize(account, name)); |
6820 | 369 g_hash_table_insert(ht, oname, list); |
370 } else if (oname) | |
371 g_free(oname); | |
372 } | |
373 | |
374 static void yahoo_do_group_cleanup(gpointer key, gpointer value, gpointer user_data) | |
375 { | |
376 char *name = key; | |
377 GSList *list = value, *i; | |
378 GaimBuddy *b; | |
379 GaimGroup *g; | |
380 | |
381 for (i = list; i; i = i->next) { | |
382 b = i->data; | |
383 g = gaim_find_buddys_group(b); | |
384 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, g->name); | |
385 gaim_blist_remove_buddy(b); | |
386 } | |
387 } | |
388 | |
7651 | 389 static char *_getcookie(char *rawcookie) |
390 { | |
391 char *cookie = NULL; | |
392 char *tmpcookie; | |
393 char *cookieend; | |
394 | |
395 if (strlen(rawcookie) < 2) | |
396 return NULL; | |
397 tmpcookie = g_strdup(rawcookie+2); | |
398 cookieend = strchr(tmpcookie, ';'); | |
399 | |
400 if (cookieend) | |
401 *cookieend = '\0'; | |
402 | |
403 cookie = g_strdup(tmpcookie); | |
404 g_free(tmpcookie); | |
405 | |
406 return cookie; | |
407 } | |
408 | |
409 static void yahoo_process_cookie(struct yahoo_data *yd, char *c) | |
410 { | |
411 if (c[0] == 'Y') { | |
412 if (yd->cookie_y) | |
413 g_free(yd->cookie_y); | |
414 yd->cookie_y = _getcookie(c); | |
415 } else if (c[0] == 'T') { | |
416 if (yd->cookie_t) | |
417 g_free(yd->cookie_t); | |
418 yd->cookie_t = _getcookie(c); | |
419 } | |
420 } | |
421 | |
5583 | 422 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 423 { |
424 GSList *l = pkt->hash; | |
425 gboolean export = FALSE; | |
6760 | 426 gboolean got_serv_list = FALSE; |
6695 | 427 GaimBuddy *b; |
428 GaimGroup *g; | |
9278 | 429 YahooFriend *f = NULL; |
6820 | 430 GaimAccount *account = gaim_connection_get_account(gc); |
6784 | 431 struct yahoo_data *yd = gc->proto_data; |
6820 | 432 GHashTable *ht; |
6784 | 433 |
434 char **lines; | |
435 char **split; | |
436 char **buddies; | |
7823 | 437 char **tmp, **bud, *norm_bud; |
7827 | 438 char *grp = NULL; |
2681 | 439 |
7651 | 440 if (pkt->id) |
441 yd->session_id = pkt->id; | |
442 | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
443 while (l) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
444 struct yahoo_pair *pair = l->data; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
445 l = l->next; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
446 |
6760 | 447 switch (pair->key) { |
448 case 87: | |
6784 | 449 if (!yd->tmp_serv_blist) |
450 yd->tmp_serv_blist = g_string_new(pair->value); | |
451 else | |
452 g_string_append(yd->tmp_serv_blist, pair->value); | |
6760 | 453 break; |
454 case 88: | |
6784 | 455 if (!yd->tmp_serv_ilist) |
456 yd->tmp_serv_ilist = g_string_new(pair->value); | |
457 else | |
458 g_string_append(yd->tmp_serv_ilist, pair->value); | |
6760 | 459 break; |
7651 | 460 case 59: /* cookies, yum */ |
461 yahoo_process_cookie(yd, pair->value); | |
462 break; | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
463 } |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
464 } |
2681 | 465 |
6784 | 466 if (pkt->status != 0) |
467 return; | |
468 | |
469 if (yd->tmp_serv_blist) { | |
6820 | 470 ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free); |
471 | |
6784 | 472 lines = g_strsplit(yd->tmp_serv_blist->str, "\n", -1); |
473 for (tmp = lines; *tmp; tmp++) { | |
474 split = g_strsplit(*tmp, ":", 2); | |
475 if (!split) | |
476 continue; | |
477 if (!split[0] || !split[1]) { | |
478 g_strfreev(split); | |
479 continue; | |
480 } | |
7827 | 481 grp = yahoo_string_decode(gc, split[0], FALSE); |
6784 | 482 buddies = g_strsplit(split[1], ",", -1); |
483 for (bud = buddies; bud && *bud; bud++) { | |
7823 | 484 norm_bud = g_strdup(gaim_normalize(account, *bud)); |
9279 | 485 f = yahoo_friend_find_or_new(gc, norm_bud); |
486 | |
7827 | 487 if (!(b = gaim_find_buddy(account, norm_bud))) { |
488 if (!(g = gaim_find_group(grp))) { | |
489 g = gaim_group_new(grp); | |
6784 | 490 gaim_blist_add_group(g, NULL); |
491 } | |
7823 | 492 b = gaim_buddy_new(account, norm_bud, NULL); |
6784 | 493 gaim_blist_add_buddy(b, NULL, g, NULL); |
494 export = TRUE; | |
6820 | 495 } |
6784 | 496 |
9285 | 497 yahoo_do_group_check(account, ht, norm_bud, grp); |
7823 | 498 g_free(norm_bud); |
6784 | 499 } |
500 g_strfreev(buddies); | |
501 g_strfreev(split); | |
7827 | 502 g_free(grp); |
6784 | 503 } |
504 g_strfreev(lines); | |
505 | |
506 g_string_free(yd->tmp_serv_blist, TRUE); | |
507 yd->tmp_serv_blist = NULL; | |
9285 | 508 g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); |
6820 | 509 g_hash_table_destroy(ht); |
6784 | 510 } |
511 | |
512 | |
513 if (yd->tmp_serv_ilist) { | |
514 buddies = g_strsplit(yd->tmp_serv_ilist->str, ",", -1); | |
515 for (bud = buddies; bud && *bud; bud++) { | |
516 /* The server is already ignoring the user */ | |
517 got_serv_list = TRUE; | |
518 gaim_privacy_deny_add(gc->account, *bud, 1); | |
519 } | |
520 g_strfreev(buddies); | |
521 | |
522 g_string_free(yd->tmp_serv_ilist, TRUE); | |
523 yd->tmp_serv_ilist = NULL; | |
524 } | |
525 | |
526 if (got_serv_list) { | |
527 gc->account->perm_deny = 4; | |
528 serv_set_permit_deny(gc); | |
529 } | |
2681 | 530 } |
531 | |
5583 | 532 static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) |
2993 | 533 { |
534 char *msg = NULL; | |
535 char *from = NULL; | |
3019 | 536 char *stat = NULL; |
537 char *game = NULL; | |
9278 | 538 YahooFriend *f = NULL; |
2993 | 539 GSList *l = pkt->hash; |
6784 | 540 |
2993 | 541 while (l) { |
542 struct yahoo_pair *pair = l->data; | |
543 if (pair->key == 4) | |
544 from = pair->value; | |
545 if (pair->key == 49) | |
546 msg = pair->value; | |
3001 | 547 if (pair->key == 13) |
3019 | 548 stat = pair->value; |
549 if (pair->key == 14) | |
550 game = pair->value; | |
2993 | 551 l = l->next; |
552 } | |
3640 | 553 |
6784 | 554 if (!from || !msg) |
3640 | 555 return; |
6686 | 556 |
4793 | 557 if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) { |
3019 | 558 if (*stat == '1') |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
559 serv_got_typing(gc, from, 0, GAIM_TYPING); |
3019 | 560 else |
561 serv_got_typing_stopped(gc, from); | |
4793 | 562 } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) { |
6695 | 563 GaimBuddy *bud = gaim_find_buddy(gc->account, from); |
6784 | 564 |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
565 if (!bud) { |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
566 gaim_debug(GAIM_DEBUG_WARNING, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
567 "%s is playing a game, and doesn't want " |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
568 "you to know.\n", from); |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
569 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
570 |
9279 | 571 f = yahoo_friend_find(gc, from); |
6784 | 572 if (!f) |
573 return; /* if they're not on the list, don't bother */ | |
574 | |
9283 | 575 yahoo_friend_set_game(f, NULL); |
6784 | 576 |
3019 | 577 if (*stat == '1') { |
9283 | 578 yahoo_friend_set_game(f, game); |
3020 | 579 if (bud) |
6784 | 580 yahoo_update_status(gc, from, f); |
3019 | 581 } |
582 } | |
2993 | 583 } |
584 | |
7827 | 585 |
586 struct _yahoo_im { | |
587 char *from; | |
588 int time; | |
589 int utf8; | |
9284 | 590 int buddy_icon; |
7827 | 591 char *msg; |
592 }; | |
593 | |
5583 | 594 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 595 { |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
596 GSList *l = pkt->hash; |
7827 | 597 GSList *list = NULL; |
598 struct _yahoo_im *im = NULL; | |
6069 | 599 |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
600 if (pkt->status <= 1 || pkt->status == 5) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
601 while (l) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
602 struct yahoo_pair *pair = l->data; |
7827 | 603 if (pair->key == 4) { |
604 im = g_new0(struct _yahoo_im, 1); | |
605 list = g_slist_append(list, im); | |
606 im->from = pair->value; | |
607 im->time = time(NULL); | |
608 } | |
609 if (pair->key == 97) | |
610 if (im) | |
611 im->utf8 = strtol(pair->value, NULL, 10); | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
612 if (pair->key == 15) |
7827 | 613 if (im) |
614 im->time = strtol(pair->value, NULL, 10); | |
9284 | 615 if (pair->key == 206) |
616 if (im) | |
617 im->buddy_icon = strtol(pair->value, NULL, 10); | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
618 if (pair->key == 14) { |
7827 | 619 if (im) |
620 im->msg = pair->value; | |
6687 | 621 } |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
622 l = l->next; |
6687 | 623 } |
2681 | 624 } else if (pkt->status == 2) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
625 gaim_notify_error(gc, NULL, |
10386 | 626 _("Your Yahoo! message did not get sent."), NULL); |
2681 | 627 } |
7827 | 628 |
629 for (l = list; l; l = l->next) { | |
9306 | 630 YahooFriend *f; |
7827 | 631 char *m, *m2; |
632 im = l->data; | |
633 | |
634 if (!im->from || !im->msg) { | |
635 g_free(im); | |
636 continue; | |
637 } | |
638 | |
639 m = yahoo_string_decode(gc, im->msg, im->utf8); | |
640 gaim_str_strip_cr(m); | |
8375 | 641 |
642 if (!strcmp(m, "<ding>")) { | |
643 GaimConversation *c = gaim_conversation_new(GAIM_CONV_IM, | |
644 gaim_connection_get_account(gc), im->from); | |
645 gaim_conv_im_write(GAIM_CONV_IM(c), "", _("Buzz!!"), GAIM_MESSAGE_NICK|GAIM_MESSAGE_RECV, | |
646 im->time); | |
647 g_free(m); | |
648 g_free(im); | |
649 continue; | |
650 } | |
651 | |
7827 | 652 m2 = yahoo_codes_to_html(m); |
653 g_free(m); | |
654 serv_got_im(gc, im->from, m2, 0, im->time); | |
655 g_free(m2); | |
9284 | 656 |
657 if ((f = yahoo_friend_find(gc, im->from)) && im->buddy_icon == 2) { | |
658 if (yahoo_friend_get_buddy_icon_need_request(f)) { | |
9310 | 659 yahoo_send_picture_request(gc, im->from); |
9284 | 660 yahoo_friend_set_buddy_icon_need_request(f, FALSE); |
661 } | |
662 } | |
663 | |
7827 | 664 g_free(im); |
665 } | |
666 g_slist_free(list); | |
2681 | 667 } |
668 | |
7865 | 669 static void yahoo_process_sysmessage(GaimConnection *gc, struct yahoo_packet *pkt) |
670 { | |
671 GSList *l = pkt->hash; | |
10070 | 672 char *prim, *me = NULL, *msg = NULL, *escmsg = NULL; |
7865 | 673 |
674 while (l) { | |
675 struct yahoo_pair *pair = l->data; | |
676 | |
677 if (pair->key == 5) | |
678 me = pair->value; | |
679 if (pair->key == 14) | |
680 msg = pair->value; | |
681 | |
682 l = l->next; | |
683 } | |
684 | |
10070 | 685 if (!msg || !g_utf8_validate(msg, -1, NULL)) |
7865 | 686 return; |
687 | |
10070 | 688 escmsg = gaim_escape_html(msg); |
689 | |
7865 | 690 prim = g_strdup_printf(_("Yahoo! system message for %s:"), |
691 me?me:gaim_connection_get_display_name(gc)); | |
10070 | 692 gaim_notify_info(NULL, NULL, prim, escmsg); |
7865 | 693 g_free(prim); |
10070 | 694 g_free(escmsg); |
7865 | 695 } |
696 | |
6686 | 697 static void yahoo_buddy_added_us(GaimConnection *gc, struct yahoo_packet *pkt) { |
2681 | 698 char *id = NULL; |
699 char *who = NULL; | |
7827 | 700 char *msg = NULL, *tmpmsg = NULL; |
2681 | 701 GSList *l = pkt->hash; |
702 | |
703 while (l) { | |
704 struct yahoo_pair *pair = l->data; | |
6686 | 705 |
706 switch (pair->key) { | |
707 case 1: | |
2681 | 708 id = pair->value; |
6686 | 709 break; |
710 case 3: | |
2681 | 711 who = pair->value; |
6686 | 712 break; |
713 case 15: /* time, for when they add us and we're offline */ | |
714 break; | |
715 case 14: | |
2681 | 716 msg = pair->value; |
6686 | 717 break; |
718 } | |
2681 | 719 l = l->next; |
720 } | |
721 | |
7827 | 722 if (id) { |
723 if (msg) | |
724 tmpmsg = yahoo_string_decode(gc, msg, FALSE); | |
725 gaim_account_notify_added(gc->account, id, who, NULL, tmpmsg); | |
726 if (tmpmsg) | |
727 g_free(tmpmsg); | |
728 } | |
6686 | 729 } |
730 | |
731 static void yahoo_buddy_denied_our_add(GaimConnection *gc, struct yahoo_packet *pkt) | |
732 { | |
733 char *who = NULL; | |
734 char *msg = NULL; | |
735 GSList *l = pkt->hash; | |
736 GString *buf = NULL; | |
6784 | 737 struct yahoo_data *yd = gc->proto_data; |
6686 | 738 |
739 while (l) { | |
740 struct yahoo_pair *pair = l->data; | |
741 | |
742 switch (pair->key) { | |
743 case 3: | |
744 who = pair->value; | |
745 break; | |
746 case 14: | |
747 msg = pair->value; | |
748 break; | |
749 } | |
750 l = l->next; | |
751 } | |
752 | |
753 if (who) { | |
7827 | 754 char *msg2; |
6686 | 755 buf = g_string_sized_new(0); |
7827 | 756 if (!msg) { |
6686 | 757 g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list."), who); |
7827 | 758 } else { |
759 msg2 = yahoo_string_decode(gc, msg, FALSE); | |
760 g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg2); | |
761 g_free(msg2); | |
762 } | |
6840 | 763 gaim_notify_info(gc, NULL, _("Add buddy rejected"), buf->str); |
6686 | 764 g_string_free(buf, TRUE); |
6784 | 765 g_hash_table_remove(yd->friends, who); |
9983 | 766 gaim_prpl_got_user_status(gaim_connection_get_account(gc), who, "offline", NULL); /* FIXME: make this set not on list status instead */ |
6686 | 767 } |
768 } | |
769 | |
770 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt) | |
771 { | |
772 | |
773 | |
774 switch (pkt->status) { | |
775 case 1: | |
776 yahoo_process_status(gc, pkt); | |
777 return; | |
778 case 3: | |
779 yahoo_buddy_added_us(gc, pkt); | |
780 break; | |
781 case 7: | |
782 yahoo_buddy_denied_our_add(gc, pkt); | |
783 break; | |
784 default: | |
785 break; | |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
786 } |
2681 | 787 } |
788 | |
7747 | 789 #define OUT_CHARSET "utf-8" |
790 | |
791 static char *yahoo_decode(const char *text) | |
792 { | |
9221 | 793 char *converted = NULL; |
8125 | 794 char *n, *new; |
795 const char *end, *p; | |
8616 | 796 int i, k; |
8125 | 797 |
7771 | 798 n = new = g_malloc(strlen (text) + 1); |
8118 | 799 end = text + strlen(text); |
800 | |
8125 | 801 for (p = text; p < end; p++, n++) { |
7747 | 802 if (*p == '\\') { |
9064 | 803 if (p[1] >= '0' && p[1] <= '7') { |
804 p += 1; | |
805 for (i = 0, k = 0; k < 3; k += 1) { | |
806 char c = p[k]; | |
9065 | 807 if (c < '0' || c > '7') break; |
9064 | 808 i *= 8; |
809 i += c - '0'; | |
810 } | |
811 *n = i; | |
812 p += k - 1; | |
813 } else { /* bug 959248 */ | |
814 /* If we see a \ not followed by an octal number, | |
815 * it means that it is actually a \\ with one \ | |
816 * already eaten by some unknown function. | |
817 * This is arguably broken. | |
818 * | |
819 * I think wing is wrong here, there is no function | |
820 * called that I see that could have done it. I guess | |
821 * it is just really sending single \'s. That's yahoo | |
822 * for you. | |
823 */ | |
824 *n = *p; | |
825 } | |
7747 | 826 } |
827 else | |
828 *n = *p; | |
829 } | |
830 | |
831 *n = '\0'; | |
8125 | 832 |
9221 | 833 if (strstr(text, "\033$B")) |
834 converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL); | |
835 if (!converted) | |
836 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL); | |
7747 | 837 g_free(new); |
838 | |
839 return converted; | |
840 } | |
841 | |
5583 | 842 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 843 { |
5583 | 844 GaimAccount *account = gaim_connection_get_account(gc); |
9221 | 845 struct yahoo_data *yd = gc->proto_data; |
2681 | 846 char *who = NULL; |
847 char *email = NULL; | |
848 char *subj = NULL; | |
9221 | 849 char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); |
2681 | 850 int count = 0; |
851 GSList *l = pkt->hash; | |
852 | |
5583 | 853 if (!gaim_account_get_check_mail(account)) |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
854 return; |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
855 |
2681 | 856 while (l) { |
857 struct yahoo_pair *pair = l->data; | |
858 if (pair->key == 9) | |
859 count = strtol(pair->value, NULL, 10); | |
860 else if (pair->key == 43) | |
861 who = pair->value; | |
862 else if (pair->key == 42) | |
863 email = pair->value; | |
864 else if (pair->key == 18) | |
865 subj = pair->value; | |
866 l = l->next; | |
867 } | |
868 | |
4001 | 869 if (who && subj && email && *email) { |
7747 | 870 char *dec_who = yahoo_decode(who); |
871 char *dec_subj = yahoo_decode(subj); | |
872 char *from = g_strdup_printf("%s (%s)", dec_who, email); | |
873 | |
874 gaim_notify_email(gc, dec_subj, from, gaim_account_get_username(account), | |
9221 | 875 yahoo_mail_url, NULL, NULL); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
876 |
7747 | 877 g_free(dec_who); |
878 g_free(dec_subj); | |
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
879 g_free(from); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
880 } else if (count > 0) { |
5583 | 881 const char *to = gaim_account_get_username(account); |
9221 | 882 const char *url = yahoo_mail_url; |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
883 |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
884 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
885 NULL, NULL); |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
886 } |
2681 | 887 } |
3147 | 888 /* This is the y64 alphabet... it's like base64, but has a . and a _ */ |
889 char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; | |
890 | |
891 /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function | |
892 * in util.c, but it has a bug I don't feel like finding right now ;) */ | |
893 void to_y64(unsigned char *out, const unsigned char *in, int inlen) | |
894 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ | |
895 { | |
896 for (; inlen >= 3; inlen -= 3) | |
897 { | |
898 *out++ = base64digits[in[0] >> 2]; | |
899 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | |
900 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; | |
901 *out++ = base64digits[in[2] & 0x3f]; | |
902 in += 3; | |
903 } | |
904 if (inlen > 0) | |
905 { | |
906 unsigned char fragment; | |
907 | |
908 *out++ = base64digits[in[0] >> 2]; | |
909 fragment = (in[0] << 4) & 0x30; | |
910 if (inlen > 1) | |
911 fragment |= in[1] >> 4; | |
912 *out++ = base64digits[fragment]; | |
913 *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c]; | |
914 *out++ = '-'; | |
915 } | |
916 *out = '\0'; | |
917 } | |
918 | |
6986 | 919 static void yahoo_process_auth_old(GaimConnection *gc, const char *seed) |
920 { | |
921 struct yahoo_packet *pack; | |
922 GaimAccount *account = gaim_connection_get_account(gc); | |
7261 | 923 const char *name = gaim_normalize(account, gaim_account_get_username(account)); |
6986 | 924 const char *pass = gaim_account_get_password(account); |
925 struct yahoo_data *yd = gc->proto_data; | |
926 | |
927 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly | |
928 * will soon do so in the rest of the world. | |
929 * | |
930 * The new clients use this authentication method. I warn you in advance, it's | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
931 * bizarre, convoluted, inordinately complicated. It's also no more secure than |
6986 | 932 * crypt() was. The only purpose this scheme could serve is to prevent third |
933 * part clients from connecting to their servers. | |
934 * | |
935 * Sorry, Yahoo. | |
936 */ | |
9277 | 937 |
6986 | 938 md5_byte_t result[16]; |
939 md5_state_t ctx; | |
9277 | 940 |
6986 | 941 char *crypt_result; |
942 char password_hash[25]; | |
943 char crypt_hash[25]; | |
944 char *hash_string_p = g_malloc(50 + strlen(name)); | |
945 char *hash_string_c = g_malloc(50 + strlen(name)); | |
9277 | 946 |
6986 | 947 char checksum; |
9277 | 948 |
6986 | 949 int sv; |
9277 | 950 |
6986 | 951 char result6[25]; |
952 char result96[25]; | |
953 | |
954 sv = seed[15]; | |
955 sv = sv % 8; | |
956 | |
957 md5_init(&ctx); | |
958 md5_append(&ctx, pass, strlen(pass)); | |
959 md5_finish(&ctx, result); | |
960 to_y64(password_hash, result, 16); | |
9277 | 961 |
6986 | 962 md5_init(&ctx); |
9277 | 963 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
6986 | 964 md5_append(&ctx, crypt_result, strlen(crypt_result)); |
965 md5_finish(&ctx, result); | |
966 to_y64(crypt_hash, result, 16); | |
967 | |
968 switch (sv) { | |
969 case 1: | |
970 case 6: | |
971 checksum = seed[seed[9] % 16]; | |
972 g_snprintf(hash_string_p, strlen(name) + 50, | |
973 "%c%s%s%s", checksum, name, seed, password_hash); | |
974 g_snprintf(hash_string_c, strlen(name) + 50, | |
975 "%c%s%s%s", checksum, name, seed, crypt_hash); | |
976 break; | |
977 case 2: | |
978 case 7: | |
979 checksum = seed[seed[15] % 16]; | |
980 g_snprintf(hash_string_p, strlen(name) + 50, | |
981 "%c%s%s%s", checksum, seed, password_hash, name); | |
982 g_snprintf(hash_string_c, strlen(name) + 50, | |
983 "%c%s%s%s", checksum, seed, crypt_hash, name); | |
984 break; | |
985 case 3: | |
986 checksum = seed[seed[1] % 16]; | |
987 g_snprintf(hash_string_p, strlen(name) + 50, | |
988 "%c%s%s%s", checksum, name, password_hash, seed); | |
989 g_snprintf(hash_string_c, strlen(name) + 50, | |
990 "%c%s%s%s", checksum, name, crypt_hash, seed); | |
991 break; | |
992 case 4: | |
993 checksum = seed[seed[3] % 16]; | |
994 g_snprintf(hash_string_p, strlen(name) + 50, | |
995 "%c%s%s%s", checksum, password_hash, seed, name); | |
996 g_snprintf(hash_string_c, strlen(name) + 50, | |
997 "%c%s%s%s", checksum, crypt_hash, seed, name); | |
998 break; | |
999 case 0: | |
1000 case 5: | |
1001 checksum = seed[seed[7] % 16]; | |
1002 g_snprintf(hash_string_p, strlen(name) + 50, | |
1003 "%c%s%s%s", checksum, password_hash, name, seed); | |
1004 g_snprintf(hash_string_c, strlen(name) + 50, | |
1005 "%c%s%s%s", checksum, crypt_hash, name, seed); | |
1006 break; | |
1007 } | |
9277 | 1008 |
1009 md5_init(&ctx); | |
6986 | 1010 md5_append(&ctx, hash_string_p, strlen(hash_string_p)); |
1011 md5_finish(&ctx, result); | |
1012 to_y64(result6, result, 16); | |
9277 | 1013 |
1014 md5_init(&ctx); | |
6986 | 1015 md5_append(&ctx, hash_string_c, strlen(hash_string_c)); |
1016 md5_finish(&ctx, result); | |
1017 to_y64(result96, result, 16); | |
1018 | |
1019 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 1020 yahoo_packet_hash(pack, "ssss", 0, name, 6, result6, 96, result96, 1, name); |
10392 | 1021 yahoo_packet_send_and_free(pack, yd); |
9277 | 1022 |
6986 | 1023 g_free(hash_string_p); |
1024 g_free(hash_string_c); | |
1025 } | |
1026 | |
6998 | 1027 /* I'm dishing out some uber-mad props to Cerulean Studios for cracking this |
1028 * and sending the fix! Thanks guys. */ | |
1029 | |
6986 | 1030 static void yahoo_process_auth_new(GaimConnection *gc, const char *seed) |
1031 { | |
1032 struct yahoo_packet *pack = NULL; | |
1033 GaimAccount *account = gaim_connection_get_account(gc); | |
7261 | 1034 const char *name = gaim_normalize(account, gaim_account_get_username(account)); |
6986 | 1035 const char *pass = gaim_account_get_password(account); |
1036 struct yahoo_data *yd = gc->proto_data; | |
9277 | 1037 |
8349 | 1038 md5_byte_t result[16]; |
1039 md5_state_t ctx; | |
9277 | 1040 |
8349 | 1041 SHA_CTX ctx1; |
1042 SHA_CTX ctx2; | |
9277 | 1043 |
8349 | 1044 char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; |
1045 char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop"; | |
1046 | |
1047 char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5"; | |
1048 char *operand_lookup = "+|&%/*^-"; | |
1049 char *delimit_lookup = ",;"; | |
1050 | |
1051 char *password_hash = (char *)g_malloc(25); | |
1052 char *crypt_hash = (char *)g_malloc(25); | |
1053 char *crypt_result = NULL; | |
1054 | |
1055 char pass_hash_xor1[64]; | |
1056 char pass_hash_xor2[64]; | |
1057 char crypt_hash_xor1[64]; | |
1058 char crypt_hash_xor2[64]; | |
1059 char resp_6[100]; | |
1060 char resp_96[100]; | |
1061 | |
1062 unsigned char digest1[20]; | |
1063 unsigned char digest2[20]; | |
1064 unsigned char comparison_src[20]; | |
1065 unsigned char magic_key_char[4]; | |
8375 | 1066 const unsigned char *magic_ptr; |
8349 | 1067 |
1068 unsigned int magic[64]; | |
1069 unsigned int magic_work = 0; | |
1070 unsigned int magic_4 = 0; | |
1071 | |
1072 int x; | |
1073 int y; | |
1074 int cnt = 0; | |
1075 int magic_cnt = 0; | |
1076 int magic_len; | |
1077 | |
1078 memset(password_hash, 0, 25); | |
1079 memset(crypt_hash, 0, 25); | |
6986 | 1080 memset(&pass_hash_xor1, 0, 64); |
1081 memset(&pass_hash_xor2, 0, 64); | |
1082 memset(&crypt_hash_xor1, 0, 64); | |
1083 memset(&crypt_hash_xor2, 0, 64); | |
1084 memset(&digest1, 0, 20); | |
1085 memset(&digest2, 0, 20); | |
1086 memset(&magic, 0, 64); | |
1087 memset(&resp_6, 0, 100); | |
1088 memset(&resp_96, 0, 100); | |
1089 memset(&magic_key_char, 0, 4); | |
8349 | 1090 memset(&comparison_src, 0, 20); |
6986 | 1091 |
1092 /* | |
8349 | 1093 * Magic: Phase 1. Generate what seems to be a 30 byte value (could change if base64 |
1094 * ends up differently? I don't remember and I'm tired, so use a 64 byte buffer. | |
6986 | 1095 */ |
9277 | 1096 |
6986 | 1097 magic_ptr = seed; |
8375 | 1098 |
6986 | 1099 while (*magic_ptr != (int)NULL) { |
8349 | 1100 char *loc; |
6986 | 1101 |
8349 | 1102 /* Ignore parentheses. |
1103 */ | |
6986 | 1104 |
1105 if (*magic_ptr == '(' || *magic_ptr == ')') { | |
1106 magic_ptr++; | |
1107 continue; | |
1108 } | |
1109 | |
8349 | 1110 /* Characters and digits verify against the challenge lookup. |
1111 */ | |
6986 | 1112 |
1113 if (isalpha(*magic_ptr) || isdigit(*magic_ptr)) { | |
1114 loc = strchr(challenge_lookup, *magic_ptr); | |
1115 if (!loc) { | |
8349 | 1116 /* SME XXX Error - disconnect here */ |
6986 | 1117 } |
1118 | |
8349 | 1119 /* Get offset into lookup table and shl 3. |
1120 */ | |
6986 | 1121 |
1122 magic_work = loc - challenge_lookup; | |
1123 magic_work <<= 3; | |
1124 | |
1125 magic_ptr++; | |
1126 continue; | |
1127 } else { | |
8349 | 1128 unsigned int local_store; |
6986 | 1129 |
1130 loc = strchr(operand_lookup, *magic_ptr); | |
1131 if (!loc) { | |
8349 | 1132 /* SME XXX Disconnect */ |
6986 | 1133 } |
1134 | |
1135 local_store = loc - operand_lookup; | |
8349 | 1136 |
1137 /* Oops; how did this happen? | |
1138 */ | |
1139 | |
6986 | 1140 if (magic_cnt >= 64) |
1141 break; | |
8349 | 1142 |
6986 | 1143 magic[magic_cnt++] = magic_work | local_store; |
1144 magic_ptr++; | |
1145 continue; | |
1146 } | |
8349 | 1147 } |
6986 | 1148 |
1149 magic_len = magic_cnt; | |
1150 magic_cnt = 0; | |
1151 | |
8349 | 1152 /* Magic: Phase 2. Take generated magic value and sprinkle fairy dust on the values. |
1153 */ | |
1154 | |
6986 | 1155 for (magic_cnt = magic_len-2; magic_cnt >= 0; magic_cnt--) { |
8349 | 1156 unsigned char byte1; |
1157 unsigned char byte2; | |
6986 | 1158 |
1159 /* Bad. Abort. | |
1160 */ | |
8349 | 1161 |
1162 if ((magic_cnt + 1 > magic_len) || (magic_cnt > magic_len)) | |
6986 | 1163 break; |
1164 | |
1165 byte1 = magic[magic_cnt]; | |
1166 byte2 = magic[magic_cnt+1]; | |
8349 | 1167 |
6986 | 1168 byte1 *= 0xcd; |
1169 byte1 ^= byte2; | |
1170 | |
1171 magic[magic_cnt+1] = byte1; | |
8349 | 1172 } |
1173 | |
1174 /* | |
1175 * Magic: Phase 3. This computes 20 bytes. The first 4 bytes are used as our magic | |
1176 * key (and may be changed later); the next 16 bytes are an MD5 sum of the magic key | |
1177 * plus 3 bytes. The 3 bytes are found by looping, and they represent the offsets | |
1178 * into particular functions we'll later call to potentially alter the magic key. | |
1179 * | |
1180 * %-) | |
1181 */ | |
1182 | |
1183 magic_cnt = 1; | |
1184 x = 0; | |
1185 | |
1186 do { | |
1187 unsigned int bl = 0; | |
1188 unsigned int cl = magic[magic_cnt++]; | |
1189 | |
1190 if (magic_cnt >= magic_len) | |
1191 break; | |
1192 | |
1193 if (cl > 0x7F) { | |
1194 if (cl < 0xe0) | |
1195 bl = cl = (cl & 0x1f) << 6; | |
1196 else { | |
1197 bl = magic[magic_cnt++]; | |
1198 cl = (cl & 0x0f) << 6; | |
1199 bl = ((bl & 0x3f) + cl) << 6; | |
1200 } | |
9277 | 1201 |
8349 | 1202 cl = magic[magic_cnt++]; |
1203 bl = (cl & 0x3f) + bl; | |
1204 } else | |
1205 bl = cl; | |
1206 | |
1207 comparison_src[x++] = (bl & 0xff00) >> 8; | |
1208 comparison_src[x++] = bl & 0xff; | |
1209 } while (x < 20); | |
1210 | |
1211 /* First four bytes are magic key. | |
1212 */ | |
1213 | |
1214 memcpy(&magic_key_char[0], comparison_src, 4); | |
8482 | 1215 magic_4 = magic_key_char[0] | (magic_key_char[1]<<8) | (magic_key_char[2]<<16) | (magic_key_char[3]<<24); |
8349 | 1216 |
1217 /* | |
1218 * Magic: Phase 4. Determine what function to use later by getting outside/inside | |
1219 * loop values until we match our previous buffer. | |
1220 */ | |
1221 | |
1222 for (x = 0; x < 65535; x++) { | |
1223 int leave = 0; | |
1224 | |
1225 for (y = 0; y < 5; y++) { | |
1226 md5_byte_t result[16]; | |
1227 md5_state_t ctx; | |
1228 | |
1229 unsigned char test[3]; | |
1230 | |
1231 memset(&result, 0, 16); | |
1232 memset(&test, 0, 3); | |
1233 | |
1234 /* Calculate buffer. | |
1235 */ | |
1236 | |
1237 test[0] = x; | |
1238 test[1] = x >> 8; | |
1239 test[2] = y; | |
1240 | |
1241 md5_init(&ctx); | |
1242 md5_append(&ctx, magic_key_char, 4); | |
1243 md5_append(&ctx, test, 3); | |
1244 md5_finish(&ctx, result); | |
1245 | |
1246 if (!memcmp(result, comparison_src+4, 16)) { | |
1247 leave = 1; | |
1248 break; | |
1249 } | |
1250 } | |
1251 | |
1252 if (leave == 1) | |
1253 break; | |
6986 | 1254 } |
1255 | |
8349 | 1256 /* If y != 0, we need some help. |
1257 */ | |
6986 | 1258 |
8349 | 1259 if (y != 0) { |
1260 unsigned int updated_key; | |
6986 | 1261 |
8349 | 1262 /* Update magic stuff. Call it twice because Yahoo's encryption is super bad ass. |
1263 */ | |
7127 | 1264 |
8349 | 1265 updated_key = yahoo_auth_finalCountdown(magic_4, 0x60, y, x); |
1266 updated_key = yahoo_auth_finalCountdown(updated_key, 0x60, y, x); | |
6986 | 1267 |
8482 | 1268 magic_key_char[0] = updated_key & 0xff; |
1269 magic_key_char[1] = (updated_key >> 8) & 0xff; | |
1270 magic_key_char[2] = (updated_key >> 16) & 0xff; | |
1271 magic_key_char[3] = (updated_key >> 24) & 0xff; | |
8349 | 1272 } |
7127 | 1273 |
8349 | 1274 /* Get password and crypt hashes as per usual. |
1275 */ | |
1276 | |
6986 | 1277 md5_init(&ctx); |
8349 | 1278 md5_append(&ctx, pass, strlen(pass)); |
6986 | 1279 md5_finish(&ctx, result); |
1280 to_y64(password_hash, result, 16); | |
1281 | |
1282 md5_init(&ctx); | |
1283 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); | |
1284 md5_append(&ctx, crypt_result, strlen(crypt_result)); | |
1285 md5_finish(&ctx, result); | |
1286 to_y64(crypt_hash, result, 16); | |
8349 | 1287 |
1288 /* Our first authentication response is based off of the password hash. | |
1289 */ | |
6986 | 1290 |
1291 for (x = 0; x < (int)strlen(password_hash); x++) | |
1292 pass_hash_xor1[cnt++] = password_hash[x] ^ 0x36; | |
1293 | |
1294 if (cnt < 64) | |
1295 memset(&(pass_hash_xor1[cnt]), 0x36, 64-cnt); | |
8349 | 1296 |
6986 | 1297 cnt = 0; |
1298 | |
1299 for (x = 0; x < (int)strlen(password_hash); x++) | |
1300 pass_hash_xor2[cnt++] = password_hash[x] ^ 0x5c; | |
1301 | |
1302 if (cnt < 64) | |
1303 memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt); | |
1304 | |
1305 shaInit(&ctx1); | |
1306 shaInit(&ctx2); | |
1307 | |
8349 | 1308 /* |
1309 * The first context gets the password hash XORed with 0x36 plus a magic value | |
1310 * which we previously extrapolated from our challenge. | |
1311 */ | |
6986 | 1312 |
1313 shaUpdate(&ctx1, pass_hash_xor1, 64); | |
9382 | 1314 if (y >= 3) |
1315 ctx1.sizeLo = 0x1ff; | |
6986 | 1316 shaUpdate(&ctx1, magic_key_char, 4); |
1317 shaFinal(&ctx1, digest1); | |
1318 | |
8349 | 1319 /* |
1320 * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest | |
1321 * of the first context. | |
1322 */ | |
6986 | 1323 |
1324 shaUpdate(&ctx2, pass_hash_xor2, 64); | |
1325 shaUpdate(&ctx2, digest1, 20); | |
1326 shaFinal(&ctx2, digest2); | |
1327 | |
8349 | 1328 /* |
1329 * Now that we have digest2, use it to fetch characters from an alphabet to construct | |
1330 * our first authentication response. | |
1331 */ | |
1332 | |
6986 | 1333 for (x = 0; x < 20; x += 2) { |
8349 | 1334 unsigned int val = 0; |
1335 unsigned int lookup = 0; | |
6986 | 1336 |
8349 | 1337 char byte[6]; |
1338 | |
6986 | 1339 memset(&byte, 0, 6); |
8349 | 1340 |
1341 /* First two bytes of digest stuffed together. | |
6986 | 1342 */ |
9277 | 1343 |
6986 | 1344 val = digest2[x]; |
1345 val <<= 8; | |
1346 val += digest2[x+1]; | |
1347 | |
1348 lookup = (val >> 0x0b); | |
1349 lookup &= 0x1f; | |
1350 if (lookup >= strlen(alphabet1)) | |
1351 break; | |
1352 sprintf(byte, "%c", alphabet1[lookup]); | |
1353 strcat(resp_6, byte); | |
1354 strcat(resp_6, "="); | |
8349 | 1355 |
6986 | 1356 lookup = (val >> 0x06); |
1357 lookup &= 0x1f; | |
1358 if (lookup >= strlen(alphabet2)) | |
1359 break; | |
1360 sprintf(byte, "%c", alphabet2[lookup]); | |
1361 strcat(resp_6, byte); | |
1362 | |
1363 lookup = (val >> 0x01); | |
1364 lookup &= 0x1f; | |
1365 if (lookup >= strlen(alphabet2)) | |
1366 break; | |
1367 sprintf(byte, "%c", alphabet2[lookup]); | |
1368 strcat(resp_6, byte); | |
8349 | 1369 |
6986 | 1370 lookup = (val & 0x01); |
1371 if (lookup >= strlen(delimit_lookup)) | |
1372 break; | |
1373 sprintf(byte, "%c", delimit_lookup[lookup]); | |
1374 strcat(resp_6, byte); | |
1375 } | |
1376 | |
8349 | 1377 /* Our second authentication response is based off of the crypto hash. |
1378 */ | |
6986 | 1379 |
1380 cnt = 0; | |
1381 memset(&digest1, 0, 20); | |
1382 memset(&digest2, 0, 20); | |
1383 | |
1384 for (x = 0; x < (int)strlen(crypt_hash); x++) | |
1385 crypt_hash_xor1[cnt++] = crypt_hash[x] ^ 0x36; | |
1386 | |
1387 if (cnt < 64) | |
1388 memset(&(crypt_hash_xor1[cnt]), 0x36, 64-cnt); | |
8349 | 1389 |
6986 | 1390 cnt = 0; |
1391 | |
1392 for (x = 0; x < (int)strlen(crypt_hash); x++) | |
1393 crypt_hash_xor2[cnt++] = crypt_hash[x] ^ 0x5c; | |
1394 | |
1395 if (cnt < 64) | |
1396 memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt); | |
1397 | |
1398 shaInit(&ctx1); | |
1399 shaInit(&ctx2); | |
1400 | |
8349 | 1401 /* |
1402 * The first context gets the password hash XORed with 0x36 plus a magic value | |
1403 * which we previously extrapolated from our challenge. | |
1404 */ | |
6986 | 1405 |
1406 shaUpdate(&ctx1, crypt_hash_xor1, 64); | |
9382 | 1407 if (y >= 3) |
1408 ctx1.sizeLo = 0x1ff; | |
6986 | 1409 shaUpdate(&ctx1, magic_key_char, 4); |
1410 shaFinal(&ctx1, digest1); | |
1411 | |
8349 | 1412 /* |
1413 * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest | |
1414 * of the first context. | |
1415 */ | |
6986 | 1416 |
1417 shaUpdate(&ctx2, crypt_hash_xor2, 64); | |
1418 shaUpdate(&ctx2, digest1, 20); | |
1419 shaFinal(&ctx2, digest2); | |
1420 | |
8349 | 1421 /* |
1422 * Now that we have digest2, use it to fetch characters from an alphabet to construct | |
1423 * our first authentication response. | |
1424 */ | |
6986 | 1425 |
1426 for (x = 0; x < 20; x += 2) { | |
8349 | 1427 unsigned int val = 0; |
1428 unsigned int lookup = 0; | |
6986 | 1429 |
8349 | 1430 char byte[6]; |
6986 | 1431 |
1432 memset(&byte, 0, 6); | |
1433 | |
8349 | 1434 /* First two bytes of digest stuffed together. |
1435 */ | |
6986 | 1436 |
1437 val = digest2[x]; | |
1438 val <<= 8; | |
1439 val += digest2[x+1]; | |
8349 | 1440 |
6986 | 1441 lookup = (val >> 0x0b); |
1442 lookup &= 0x1f; | |
1443 if (lookup >= strlen(alphabet1)) | |
1444 break; | |
1445 sprintf(byte, "%c", alphabet1[lookup]); | |
1446 strcat(resp_96, byte); | |
1447 strcat(resp_96, "="); | |
1448 | |
1449 lookup = (val >> 0x06); | |
1450 lookup &= 0x1f; | |
1451 if (lookup >= strlen(alphabet2)) | |
1452 break; | |
1453 sprintf(byte, "%c", alphabet2[lookup]); | |
1454 strcat(resp_96, byte); | |
1455 | |
1456 lookup = (val >> 0x01); | |
1457 lookup &= 0x1f; | |
1458 if (lookup >= strlen(alphabet2)) | |
1459 break; | |
1460 sprintf(byte, "%c", alphabet2[lookup]); | |
1461 strcat(resp_96, byte); | |
1462 | |
1463 lookup = (val & 0x01); | |
1464 if (lookup >= strlen(delimit_lookup)) | |
1465 break; | |
1466 sprintf(byte, "%c", delimit_lookup[lookup]); | |
1467 strcat(resp_96, byte); | |
1468 } | |
10400 | 1469 printf("yahoo status : %d\n", yd->current_status); |
1470 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->current_status, 0); | |
10394 | 1471 yahoo_packet_hash(pack, "sssss", 0, name, 6, resp_6, 96, resp_96, 1, |
1472 name, 135, "6,0,0,1710"); | |
1473 if (yd->picture_checksum) | |
1474 yahoo_packet_hash_int(pack, 192, yd->picture_checksum); | |
1475 | |
10392 | 1476 yahoo_packet_send_and_free(pack, yd); |
6986 | 1477 |
7424 | 1478 g_free(password_hash); |
1479 g_free(crypt_hash); | |
6986 | 1480 } |
1481 | |
5583 | 1482 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt) |
3147 | 1483 { |
1484 char *seed = NULL; | |
1485 char *sn = NULL; | |
1486 GSList *l = pkt->hash; | |
7010 | 1487 int m = 0; |
9277 | 1488 gchar *buf; |
1489 | |
1490 | |
3147 | 1491 while (l) { |
1492 struct yahoo_pair *pair = l->data; | |
1493 if (pair->key == 94) | |
1494 seed = pair->value; | |
1495 if (pair->key == 1) | |
1496 sn = pair->value; | |
6986 | 1497 if (pair->key == 13) |
1498 m = atoi(pair->value); | |
3147 | 1499 l = l->next; |
1500 } | |
9277 | 1501 |
3147 | 1502 if (seed) { |
6986 | 1503 switch (m) { |
1504 case 0: | |
1505 yahoo_process_auth_old(gc, seed); | |
1506 break; | |
3147 | 1507 case 1: |
6986 | 1508 yahoo_process_auth_new(gc, seed); |
3147 | 1509 break; |
6986 | 1510 default: |
7043 | 1511 buf = g_strdup_printf(_("The Yahoo server has requested the use of an unrecognized " |
7129 | 1512 "authentication method. This version of Gaim will likely not be able " |
7043 | 1513 "to successfully sign on to Yahoo. Check %s for updates."), GAIM_WEBSITE); |
6986 | 1514 gaim_notify_error(gc, "", _("Failed Yahoo! Authentication"), |
7043 | 1515 buf); |
1516 g_free(buf); | |
6986 | 1517 yahoo_process_auth_new(gc, seed); /* Can't hurt to try it anyway. */ |
3147 | 1518 } |
1519 } | |
1520 } | |
2681 | 1521 |
9285 | 1522 static void ignore_buddy(GaimBuddy *buddy) { |
1523 GaimGroup *group; | |
1524 GaimConversation *conv; | |
6760 | 1525 GaimAccount *account; |
1526 gchar *name; | |
1527 | |
9285 | 1528 if (!buddy) |
6792 | 1529 return; |
6760 | 1530 |
9285 | 1531 group = gaim_find_buddys_group(buddy); |
1532 name = g_strdup(buddy->name); | |
1533 account = buddy->account; | |
6760 | 1534 |
6792 | 1535 gaim_debug(GAIM_DEBUG_INFO, "blist", |
9285 | 1536 "Removing '%s' from buddy list.\n", buddy->name); |
1537 serv_remove_buddy(account->gc, buddy, group); | |
1538 gaim_blist_remove_buddy(buddy); | |
6760 | 1539 |
6792 | 1540 serv_add_deny(account->gc, name); |
9285 | 1541 |
10246 | 1542 /* The follow should really be done by the core... */ |
1543 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
9285 | 1544 |
1545 if (conv != NULL) | |
1546 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
6760 | 1547 |
1548 g_free(name); | |
1549 } | |
1550 | |
1551 static void keep_buddy(GaimBuddy *b) { | |
1552 gaim_privacy_deny_remove(b->account, b->name, 1); | |
1553 } | |
1554 | |
1555 static void yahoo_process_ignore(GaimConnection *gc, struct yahoo_packet *pkt) { | |
1556 GaimBuddy *b; | |
1557 GSList *l; | |
1558 gchar *who = NULL; | |
1559 gchar *sn = NULL; | |
1560 gchar buf[BUF_LONG]; | |
1561 gint ignore = 0; | |
1562 gint status = 0; | |
1563 | |
1564 for (l = pkt->hash; l; l = l->next) { | |
1565 struct yahoo_pair *pair = l->data; | |
1566 switch (pair->key) { | |
1567 case 0: | |
1568 who = pair->value; | |
1569 break; | |
1570 case 1: | |
1571 sn = pair->value; | |
1572 break; | |
1573 case 13: | |
1574 ignore = strtol(pair->value, NULL, 10); | |
1575 break; | |
1576 case 66: | |
1577 status = strtol(pair->value, NULL, 10); | |
1578 break; | |
1579 default: | |
1580 break; | |
1581 } | |
1582 } | |
1583 | |
1584 switch (status) { | |
1585 case 12: | |
1586 b = gaim_find_buddy(gc->account, who); | |
1587 g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " | |
1588 "user is on your buddy list. Clicking \"Yes\" " | |
1589 "will remove and ignore the buddy."), who); | |
1590 gaim_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, b, | |
1591 G_CALLBACK(ignore_buddy), | |
1592 G_CALLBACK(keep_buddy)); | |
1593 break; | |
1594 case 2: | |
1595 case 3: | |
1596 case 0: | |
1597 default: | |
1598 break; | |
1599 } | |
1600 } | |
1601 | |
6761 | 1602 static void yahoo_process_authresp(GaimConnection *gc, struct yahoo_packet *pkt) |
1603 { | |
9410 | 1604 struct yahoo_data *yd = gc->proto_data; |
6761 | 1605 GSList *l = pkt->hash; |
1606 int err = 0; | |
1607 char *msg; | |
7865 | 1608 char *url = NULL; |
1609 char *fullmsg; | |
6761 | 1610 |
1611 while (l) { | |
1612 struct yahoo_pair *pair = l->data; | |
1613 | |
1614 if (pair->key == 66) | |
1615 err = strtol(pair->value, NULL, 10); | |
7865 | 1616 if (pair->key == 20) |
1617 url = pair->value; | |
6761 | 1618 |
1619 l = l->next; | |
1620 } | |
1621 | |
1622 switch (err) { | |
1623 case 3: | |
7865 | 1624 msg = g_strdup(_("Invalid username.")); |
6761 | 1625 break; |
1626 case 13: | |
9410 | 1627 if (!yd->wm) { |
1628 yd->wm = TRUE; | |
1629 if (yd->fd >= 0) | |
1630 close(yd->fd); | |
1631 if (gc->inpa) | |
1632 gaim_input_remove(gc->inpa); | |
1633 gaim_url_fetch(WEBMESSENGER_URL, TRUE, "Gaim/" VERSION, FALSE, | |
1634 yahoo_login_page_cb, gc); | |
9835 | 1635 gaim_notify_warning(gc, NULL, _("Normal authentication failed!"), |
1636 _("The normal authentication method has failed. " | |
9410 | 1637 "This means either your password is incorrect, " |
9835 | 1638 "or Yahoo!'s authentication scheme has changed. " |
9410 | 1639 "Gaim will now attempt to log in using Web " |
9835 | 1640 "Messenger authentication, which will result " |
9410 | 1641 "in reduced functionality and features.")); |
1642 return; | |
1643 } | |
7865 | 1644 msg = g_strdup(_("Incorrect password.")); |
1645 break; | |
1646 case 14: | |
9280 | 1647 msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website.")); |
6761 | 1648 break; |
1649 default: | |
9280 | 1650 msg = g_strdup_printf(_("Unknown error number %d. Logging into the Yahoo! website may fix this."), err); |
6761 | 1651 } |
7865 | 1652 |
1653 if (url) | |
1654 fullmsg = g_strdup_printf("%s\n%s", msg, url); | |
1655 else | |
1656 fullmsg = g_strdup(msg); | |
1657 | |
9280 | 1658 gc->wants_to_die = TRUE; |
7865 | 1659 gaim_connection_error(gc, fullmsg); |
1660 g_free(msg); | |
1661 g_free(fullmsg); | |
6761 | 1662 } |
1663 | |
6840 | 1664 static void yahoo_process_addbuddy(GaimConnection *gc, struct yahoo_packet *pkt) |
1665 { | |
1666 int err = 0; | |
1667 char *who = NULL; | |
1668 char *group = NULL; | |
7827 | 1669 char *decoded_group; |
6840 | 1670 char *buf; |
9278 | 1671 YahooFriend *f; |
6840 | 1672 GSList *l = pkt->hash; |
1673 | |
1674 while (l) { | |
1675 struct yahoo_pair *pair = l->data; | |
1676 | |
1677 switch (pair->key) { | |
1678 case 66: | |
1679 err = strtol(pair->value, NULL, 10); | |
1680 break; | |
1681 case 7: | |
1682 who = pair->value; | |
1683 break; | |
1684 case 65: | |
1685 group = pair->value; | |
1686 break; | |
1687 } | |
1688 | |
1689 l = l->next; | |
1690 } | |
1691 | |
1692 if (!who) | |
1693 return; | |
1694 if (!group) | |
1695 group = ""; | |
1696 | |
1697 if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */ | |
9279 | 1698 f = yahoo_friend_find_or_new(gc, who); |
1699 yahoo_update_status(gc, who, f); | |
6840 | 1700 return; |
1701 } | |
1702 | |
7827 | 1703 decoded_group = yahoo_string_decode(gc, group, FALSE); |
6840 | 1704 buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."), |
7827 | 1705 who, decoded_group, gaim_connection_get_display_name(gc)); |
9637 | 1706 if (!gaim_conv_present_error(who, gaim_connection_get_account(gc), buf)) |
1707 gaim_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); | |
6840 | 1708 g_free(buf); |
7827 | 1709 g_free(decoded_group); |
6840 | 1710 } |
1711 | |
9062 | 1712 static void yahoo_process_p2p(GaimConnection *gc, struct yahoo_packet *pkt) |
1713 { | |
1714 GSList *l = pkt->hash; | |
1715 char *who = NULL; | |
1716 char *base64 = NULL; | |
9277 | 1717 char *decoded; |
9062 | 1718 int len; |
1719 | |
1720 while (l) { | |
1721 struct yahoo_pair *pair = l->data; | |
1722 | |
1723 switch (pair->key) { | |
1724 case 5: | |
1725 /* our identity */ | |
1726 break; | |
1727 case 4: | |
1728 who = pair->value; | |
1729 break; | |
1730 case 1: | |
1731 /* who again, the master identity this time? */ | |
1732 break; | |
1733 case 12: | |
1734 base64 = pair->value; | |
1735 /* so, this is an ip address. in base64. decoded it's in ascii. | |
1736 after strtol, it's in reversed byte order. Who thought this up?*/ | |
1737 break; | |
1738 /* | |
1739 TODO: figure these out | |
1740 yahoo: Key: 61 Value: 0 | |
1741 yahoo: Key: 2 Value: | |
1742 yahoo: Key: 13 Value: 0 | |
1743 yahoo: Key: 49 Value: PEERTOPEER | |
1744 yahoo: Key: 140 Value: 1 | |
1745 yahoo: Key: 11 Value: -1786225828 | |
1746 */ | |
1747 | |
1748 } | |
1749 | |
1750 l = l->next; | |
1751 } | |
1752 | |
9277 | 1753 if (base64) { |
9281 | 1754 guint32 ip; |
1755 char *tmp2; | |
1756 YahooFriend *f; | |
1757 | |
9062 | 1758 gaim_base64_decode(base64, &decoded, &len); |
9277 | 1759 if (len) { |
1760 char *tmp = gaim_str_binary_to_ascii(decoded, len); | |
1761 gaim_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, tmp); | |
1762 g_free(tmp); | |
1763 } | |
9281 | 1764 |
1765 tmp2 = g_strndup(decoded, len); /* so its \0 terminated...*/ | |
1766 ip = strtol(tmp2, NULL, 10); | |
1767 g_free(tmp2); | |
9062 | 1768 g_free(decoded); |
9281 | 1769 tmp2 = g_strdup_printf("%u.%u.%u.%u", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, |
1770 (ip >> 24) & 0xff); | |
1771 f = yahoo_friend_find(gc, who); | |
1772 if (f) | |
1773 yahoo_friend_set_ip(f, tmp2); | |
1774 g_free(tmp2); | |
9062 | 1775 } |
1776 } | |
1777 | |
9604 | 1778 static void yahoo_process_audible(GaimConnection *gc, struct yahoo_packet *pkt) |
1779 { | |
1780 char *who = NULL, *msg = NULL; | |
1781 GSList *l = pkt->hash; | |
1782 | |
1783 while (l) { | |
1784 struct yahoo_pair *pair = l->data; | |
1785 | |
1786 switch (pair->key) { | |
1787 case 4: | |
1788 who = pair->value; | |
1789 break; | |
1790 case 5: | |
1791 /* us */ | |
1792 break; | |
1793 case 230: | |
1794 /* the audible, in foo.bar.baz format */ | |
1795 break; | |
1796 case 231: | |
1797 /* the text of the audible */ | |
1798 msg = pair->value; | |
1799 break; | |
1800 case 232: | |
1801 /* weird number (md5 hash?), like 8ebab9094156135f5dcbaccbeee662a5c5fd1420 */ | |
1802 break; | |
1803 } | |
1804 | |
1805 l = l->next; | |
1806 } | |
1807 | |
1808 if (!who || !msg) | |
1809 return; | |
1810 if (!g_utf8_validate(msg, -1, NULL)) { | |
1811 gaim_debug_misc("yahoo", "Warning, nonutf8 audible, ignoring!\n"); | |
1812 return; | |
1813 } | |
1814 | |
1815 serv_got_im(gc, who, msg, 0, time(NULL)); | |
1816 } | |
1817 | |
5583 | 1818 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 1819 { |
6760 | 1820 switch (pkt->service) { |
2681 | 1821 case YAHOO_SERVICE_LOGON: |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
1822 case YAHOO_SERVICE_LOGOFF: |
2681 | 1823 case YAHOO_SERVICE_ISAWAY: |
2737
f61c1f3a6afa
[gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2724
diff
changeset
|
1824 case YAHOO_SERVICE_ISBACK: |
3019 | 1825 case YAHOO_SERVICE_GAMELOGON: |
1826 case YAHOO_SERVICE_GAMELOGOFF: | |
6686 | 1827 case YAHOO_SERVICE_CHATLOGON: |
1828 case YAHOO_SERVICE_CHATLOGOFF: | |
10373 | 1829 case YAHOO_SERVICE_Y6_STATUS_UPDATE: |
2681 | 1830 yahoo_process_status(gc, pkt); |
1831 break; | |
3019 | 1832 case YAHOO_SERVICE_NOTIFY: |
1833 yahoo_process_notify(gc, pkt); | |
2993 | 1834 break; |
2681 | 1835 case YAHOO_SERVICE_MESSAGE: |
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
1836 case YAHOO_SERVICE_GAMEMSG: |
5939 | 1837 case YAHOO_SERVICE_CHATMSG: |
2681 | 1838 yahoo_process_message(gc, pkt); |
1839 break; | |
7865 | 1840 case YAHOO_SERVICE_SYSMESSAGE: |
1841 yahoo_process_sysmessage(gc, pkt); | |
1842 break; | |
2681 | 1843 case YAHOO_SERVICE_NEWMAIL: |
1844 yahoo_process_mail(gc, pkt); | |
1845 break; | |
1846 case YAHOO_SERVICE_NEWCONTACT: | |
1847 yahoo_process_contact(gc, pkt); | |
1848 break; | |
6784 | 1849 case YAHOO_SERVICE_AUTHRESP: |
1850 yahoo_process_authresp(gc, pkt); | |
1851 break; | |
2681 | 1852 case YAHOO_SERVICE_LIST: |
1853 yahoo_process_list(gc, pkt); | |
1854 break; | |
3147 | 1855 case YAHOO_SERVICE_AUTH: |
1856 yahoo_process_auth(gc, pkt); | |
1857 break; | |
6840 | 1858 case YAHOO_SERVICE_ADDBUDDY: |
1859 yahoo_process_addbuddy(gc, pkt); | |
1860 break; | |
6760 | 1861 case YAHOO_SERVICE_IGNORECONTACT: |
1862 yahoo_process_ignore(gc, pkt); | |
1863 break; | |
6729 | 1864 case YAHOO_SERVICE_CONFINVITE: |
1865 case YAHOO_SERVICE_CONFADDINVITE: | |
1866 yahoo_process_conference_invite(gc, pkt); | |
1867 break; | |
1868 case YAHOO_SERVICE_CONFDECLINE: | |
1869 yahoo_process_conference_decline(gc, pkt); | |
1870 break; | |
1871 case YAHOO_SERVICE_CONFLOGON: | |
1872 yahoo_process_conference_logon(gc, pkt); | |
1873 break; | |
1874 case YAHOO_SERVICE_CONFLOGOFF: | |
1875 yahoo_process_conference_logoff(gc, pkt); | |
1876 break; | |
1877 case YAHOO_SERVICE_CONFMSG: | |
1878 yahoo_process_conference_message(gc, pkt); | |
1879 break; | |
1880 case YAHOO_SERVICE_CHATONLINE: | |
1881 yahoo_process_chat_online(gc, pkt); | |
1882 break; | |
1883 case YAHOO_SERVICE_CHATLOGOUT: | |
1884 yahoo_process_chat_logout(gc, pkt); | |
1885 break; | |
1886 case YAHOO_SERVICE_CHATGOTO: | |
1887 yahoo_process_chat_goto(gc, pkt); | |
1888 break; | |
1889 case YAHOO_SERVICE_CHATJOIN: | |
1890 yahoo_process_chat_join(gc, pkt); | |
1891 break; | |
1892 case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */ | |
1893 case YAHOO_SERVICE_CHATEXIT: | |
1894 yahoo_process_chat_exit(gc, pkt); | |
1895 break; | |
1896 case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */ | |
1897 case YAHOO_SERVICE_CHATADDINVITE: | |
1898 yahoo_process_chat_addinvite(gc, pkt); | |
1899 break; | |
1900 case YAHOO_SERVICE_COMMENT: | |
1901 yahoo_process_chat_message(gc, pkt); | |
1902 break; | |
7651 | 1903 case YAHOO_SERVICE_P2PFILEXFER: |
1904 case YAHOO_SERVICE_FILETRANSFER: | |
1905 yahoo_process_filetransfer(gc, pkt); | |
1906 break; | |
9062 | 1907 case YAHOO_SERVICE_PEEPTOPEER: |
1908 yahoo_process_p2p(gc, pkt); | |
1909 break; | |
9284 | 1910 case YAHOO_SERVICE_PICTURE: |
1911 yahoo_process_picture(gc, pkt); | |
1912 break; | |
9292 | 1913 case YAHOO_SERVICE_PICTURE_UPDATE: |
1914 yahoo_process_picture_update(gc, pkt); | |
1915 break; | |
1916 case YAHOO_SERVICE_PICTURE_CHECKSUM: | |
1917 yahoo_process_picture_checksum(gc, pkt); | |
1918 break; | |
9306 | 1919 case YAHOO_SERVICE_PICTURE_UPLOAD: |
1920 yahoo_process_picture_upload(gc, pkt); | |
1921 break; | |
9604 | 1922 case YAHOO_SERVICE_AUDIBLE: |
1923 yahoo_process_audible(gc, pkt); | |
2681 | 1924 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1925 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1926 "Unhandled service 0x%02x\n", pkt->service); |
2681 | 1927 break; |
1928 } | |
1929 } | |
1930 | |
1931 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
1932 { | |
5583 | 1933 GaimConnection *gc = data; |
2681 | 1934 struct yahoo_data *yd = gc->proto_data; |
1935 char buf[1024]; | |
1936 int len; | |
1937 | |
1938 len = read(yd->fd, buf, sizeof(buf)); | |
1939 | |
1940 if (len <= 0) { | |
6321 | 1941 gaim_connection_error(gc, _("Unable to read")); |
2681 | 1942 return; |
1943 } | |
1944 | |
1945 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
1946 memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
1947 yd->rxlen += len; | |
1948 | |
1949 while (1) { | |
1950 struct yahoo_packet *pkt; | |
1951 int pos = 0; | |
1952 int pktlen; | |
1953 | |
1954 if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
1955 return; | |
1956 | |
1957 pos += 4; /* YMSG */ | |
1958 pos += 2; | |
1959 pos += 2; | |
1960 | |
1961 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1962 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1963 "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
2681 | 1964 |
1965 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
1966 return; | |
1967 | |
1968 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
1969 | |
1970 pkt = yahoo_packet_new(0, 0, 0); | |
1971 | |
1972 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
3021 | 1973 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1974 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1975 "Yahoo Service: 0x%02x Status: %d\n", |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1976 pkt->service, pkt->status); |
2681 | 1977 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
1978 | |
1979 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
1980 | |
1981 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
1982 if (yd->rxlen) { | |
1983 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
1984 g_free(yd->rxqueue); | |
1985 yd->rxqueue = tmp; | |
1986 } else { | |
1987 g_free(yd->rxqueue); | |
1988 yd->rxqueue = NULL; | |
1989 } | |
1990 | |
1991 yahoo_packet_process(gc, pkt); | |
1992 | |
1993 yahoo_packet_free(pkt); | |
1994 } | |
1995 } | |
1996 | |
1997 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
1998 { | |
5583 | 1999 GaimConnection *gc = data; |
2681 | 2000 struct yahoo_data *yd; |
2001 struct yahoo_packet *pkt; | |
10400 | 2002 |
5590
011a0a975060
[gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents:
5583
diff
changeset
|
2003 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2681 | 2004 close(source); |
2005 return; | |
2006 } | |
2007 | |
2008 if (source < 0) { | |
8057 | 2009 gaim_connection_error(gc, _("Unable to connect.")); |
2681 | 2010 return; |
2011 } | |
2012 | |
2013 yd = gc->proto_data; | |
2014 yd->fd = source; | |
10400 | 2015 |
3147 | 2016 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); |
2681 | 2017 |
10394 | 2018 yahoo_packet_hash_str(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); |
10392 | 2019 yahoo_packet_send_and_free(pkt, yd); |
2681 | 2020 |
2021 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
2022 } | |
9370 | 2023 |
7134 | 2024 static void yahoo_got_web_connected(gpointer data, gint source, GaimInputCondition cond) |
2025 { | |
2026 GaimConnection *gc = data; | |
2027 struct yahoo_data *yd; | |
2028 struct yahoo_packet *pkt; | |
2029 | |
2030 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
2031 close(source); | |
2032 return; | |
2033 } | |
2034 | |
2035 if (source < 0) { | |
8057 | 2036 gaim_connection_error(gc, _("Unable to connect.")); |
7134 | 2037 return; |
2038 } | |
2039 | |
2040 yd = gc->proto_data; | |
2041 yd->fd = source; | |
2042 | |
2043 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); | |
2044 | |
10394 | 2045 yahoo_packet_hash(pkt, "sss", 0, |
2046 gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))), | |
2047 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))), | |
2048 6, yd->auth); | |
10392 | 2049 yahoo_packet_send_and_free(pkt, yd); |
2050 | |
7134 | 2051 g_free(yd->auth); |
2052 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
2053 } | |
2054 | |
2055 static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond) | |
2056 { | |
2057 GaimConnection *gc = data; | |
2058 GaimAccount *account = gaim_connection_get_account(gc); | |
2059 struct yahoo_data *yd = gc->proto_data; | |
8243 | 2060 char buf[2048], *i = buf; |
8161 | 2061 int len; |
2062 GString *s; | |
7134 | 2063 |
8118 | 2064 len = read(source, buf, sizeof(buf)-1); |
8216
dcace041cfb8
[gaim-migrate @ 8939]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
2065 if (len <= 0 || (strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) && |
dcace041cfb8
[gaim-migrate @ 8939]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
2066 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { |
7134 | 2067 gaim_connection_error(gc, _("Unable to read")); |
2068 return; | |
2069 } | |
8161 | 2070 |
2071 s = g_string_sized_new(len); | |
8118 | 2072 buf[sizeof(buf)-1] = '\0'; |
8161 | 2073 |
2074 while ((i = strstr(i, "Set-Cookie: "))) { | |
2075 i += strlen("Set-Cookie: "); | |
8243 | 2076 for (;*i != ';' && *i != '\0'; i++) |
8161 | 2077 g_string_append_c(s, *i); |
2078 | |
2079 g_string_append(s, "; "); | |
7134 | 2080 } |
8161 | 2081 |
2082 yd->auth = g_string_free(s, FALSE); | |
7134 | 2083 gaim_input_remove(gc->inpa); |
2084 close(source); | |
2085 /* Now we have our cookies to login with. I'll go get the milk. */ | |
8045 | 2086 if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", |
7134 | 2087 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), |
2088 yahoo_got_web_connected, gc) != 0) { | |
2089 gaim_connection_error(gc, _("Connection problem")); | |
2090 return; | |
2091 } | |
2092 } | |
2093 | |
2094 static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) | |
2095 { | |
2096 GaimConnection *gc = data; | |
2097 struct yahoo_data *yd = gc->proto_data; | |
2098 if (source < 0) { | |
8057 | 2099 gaim_connection_error(gc, _("Unable to connect.")); |
7134 | 2100 return; |
2101 } | |
2102 write(source, yd->auth, strlen(yd->auth)); | |
2103 g_free(yd->auth); | |
2104 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); | |
2105 } | |
2106 | |
2107 static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url) | |
2108 { | |
2109 if (!strcmp(key, "passwd")) | |
2110 return; | |
2111 url = g_string_append_c(url, '&'); | |
2112 url = g_string_append(url, key); | |
2113 url = g_string_append_c(url, '='); | |
2114 if (!strcmp(key, ".save") || !strcmp(key, ".js")) | |
2115 url = g_string_append_c(url, '1'); | |
2116 else if (!strcmp(key, ".challenge")) | |
2117 url = g_string_append(url, val); | |
2118 else | |
2119 url = g_string_append(url, gaim_url_encode(val)); | |
2120 } | |
2121 | |
2122 static GHashTable *yahoo_login_page_hash(const char *buf, size_t len) | |
2123 { | |
2124 GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2125 const char *c = buf; |
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2126 char *d; |
7134 | 2127 char name[64], value[64]; |
8118 | 2128 int count = sizeof(name)-1; |
7134 | 2129 while ((c < (buf + len)) && (c = strstr(c, "<input "))) { |
2130 c = strstr(c, "name=\"") + strlen("name=\""); | |
8118 | 2131 for (d = name; *c!='"' && count; c++, d++, count--) |
7134 | 2132 *d = *c; |
2133 *d = '\0'; | |
8118 | 2134 count = sizeof(value)-1; |
7134 | 2135 d = strstr(c, "value=\"") + strlen("value=\""); |
2136 if (strchr(c, '>') < d) | |
2137 break; | |
8118 | 2138 for (c = d, d = value; *c!='"' && count; c++, d++, count--) |
7134 | 2139 *d = *c; |
2140 *d = '\0'; | |
2141 g_hash_table_insert(hash, g_strdup(name), g_strdup(value)); | |
2142 } | |
2143 return hash; | |
2144 } | |
2145 | |
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2146 static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len) |
7134 | 2147 { |
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2148 GaimConnection *gc = (GaimConnection *)user_data; |
7134 | 2149 GaimAccount *account = gaim_connection_get_account(gc); |
2150 struct yahoo_data *yd = gc->proto_data; | |
2151 const char *sn = gaim_account_get_username(account); | |
2152 const char *pass = gaim_account_get_password(account); | |
2153 GHashTable *hash = yahoo_login_page_hash(buf, len); | |
10575 | 2154 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); |
7134 | 2155 char md5[33], *hashp = md5, *chal; |
2156 int i; | |
2157 md5_byte_t result[16]; | |
2158 md5_state_t ctx; | |
7191
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2159 |
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2160 url = g_string_append(url, sn); |
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2161 url = g_string_append(url, "&passwd="); |
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2162 |
7134 | 2163 md5_init(&ctx); |
2164 md5_append(&ctx, pass, strlen(pass)); | |
2165 md5_finish(&ctx, result); | |
2166 for (i = 0; i < 16; ++i) { | |
2167 g_snprintf(hashp, 3, "%02x", result[i]); | |
2168 hashp += 2; | |
2169 } | |
2170 chal = g_strconcat(md5, g_hash_table_lookup(hash, ".challenge"), NULL); | |
2171 md5_init(&ctx); | |
2172 md5_append(&ctx, chal, strlen(chal)); | |
2173 md5_finish(&ctx, result); | |
2174 hashp = md5; | |
2175 for (i = 0; i < 16; ++i) { | |
2176 g_snprintf(hashp, 3, "%02x", result[i]); | |
2177 hashp += 2; | |
2178 } | |
2179 /* | |
2180 md5_init(&ctx); | |
2181 md5_append(&ctx, md5, strlen(md5)); | |
2182 md5_finish(&ctx, result); | |
2183 hashp = md5; | |
2184 for (i = 0; i < 16; ++i) { | |
2185 g_snprintf(hashp, 3, "%02x", result[i]); | |
2186 hashp += 2; | |
2187 } | |
2188 */ | |
2189 g_free(chal); | |
2190 | |
2191 url = g_string_append(url, md5); | |
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2192 g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url); |
7134 | 2193 |
2194 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" | |
2195 "Host: login.yahoo.com\r\n\r\n"); | |
2196 g_hash_table_destroy(hash); | |
2197 yd->auth = g_string_free(url, FALSE); | |
2198 if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) { | |
2199 gaim_connection_error(gc, _("Connection problem")); | |
2200 return; | |
2201 } | |
2202 } | |
2203 | |
7883 | 2204 static void yahoo_server_check(GaimAccount *account) |
2205 { | |
2206 const char *server; | |
2207 | |
2208 server = gaim_account_get_string(account, "server", YAHOO_PAGER_HOST); | |
2209 | |
2210 if (strcmp(server, "scs.yahoo.com") == 0) | |
2211 gaim_account_set_string(account, "server", YAHOO_PAGER_HOST); | |
2212 } | |
9306 | 2213 |
2214 static void yahoo_picture_check(GaimAccount *account) | |
2215 { | |
2216 GaimConnection *gc = gaim_account_get_connection(account); | |
2217 const char *buddyicon; | |
2218 | |
2219 buddyicon = gaim_account_get_buddy_icon(account); | |
2220 yahoo_set_buddy_icon(gc, buddyicon); | |
2221 } | |
2222 | |
7883 | 2223 |
10400 | 2224 static void yahoo_login(GaimAccount *account, GaimStatus *status) { |
5583 | 2225 GaimConnection *gc = gaim_account_get_connection(account); |
2681 | 2226 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
10401 | 2227 const char *id = gaim_status_get_id(status); |
9041 | 2228 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC; |
6629 | 2229 |
5583 | 2230 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
2681 | 2231 |
8235 | 2232 gaim_connection_set_display_name(gc, gaim_account_get_username(account)); |
2233 | |
2681 | 2234 yd->fd = -1; |
6784 | 2235 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
6729 | 2236 yd->confs = NULL; |
2237 yd->conf_id = 2; | |
10400 | 2238 |
2239 if (!strcmp(id, YAHOO_STATUS_TYPE_AVAILABLE) || !strcmp(id, YAHOO_STATUS_TYPE_ONLINE)) { | |
2240 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
2241 } else if (!strcmp(id, YAHOO_STATUS_TYPE_BRB)) { | |
2242 yd->current_status = YAHOO_STATUS_BRB; | |
2243 } else if (!strcmp(id, YAHOO_STATUS_TYPE_BUSY)) { | |
2244 yd->current_status = YAHOO_STATUS_BUSY; | |
2245 } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTATHOME)) { | |
2246 yd->current_status = YAHOO_STATUS_NOTATHOME; | |
2247 } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTATDESK)) { | |
2248 yd->current_status = YAHOO_STATUS_NOTATDESK; | |
2249 } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTINOFFICE)) { | |
2250 yd->current_status = YAHOO_STATUS_NOTINOFFICE; | |
2251 } else if (!strcmp(id, YAHOO_STATUS_TYPE_ONPHONE)) { | |
2252 yd->current_status = YAHOO_STATUS_ONPHONE; | |
2253 } else if (!strcmp(id, YAHOO_STATUS_TYPE_ONVACATION)) { | |
2254 yd->current_status = YAHOO_STATUS_ONVACATION; | |
2255 } else if (!strcmp(id, YAHOO_STATUS_TYPE_OUTTOLUNCH)) { | |
2256 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; | |
2257 } else if (!strcmp(id, YAHOO_STATUS_TYPE_STEPPEDOUT)) { | |
2258 yd->current_status = YAHOO_STATUS_STEPPEDOUT; | |
2259 } else if (!strcmp(id, YAHOO_STATUS_TYPE_INVISIBLE)) { | |
2260 yd->current_status = YAHOO_STATUS_INVISIBLE; | |
2261 } else if (!strcmp(id, YAHOO_STATUS_TYPE_AWAY)) { | |
2262 yd->current_status = YAHOO_STATUS_CUSTOM; | |
2263 } else if (!strcmp(id, YAHOO_STATUS_TYPE_AVAILABLE_WM)) { | |
2264 yd->current_status = YAHOO_STATUS_CUSTOM; | |
2265 } else if (gc->is_idle) { /* i think this is broken */ | |
2266 yd->current_status = YAHOO_STATUS_IDLE; | |
2267 } else { | |
2268 gaim_debug_error("yahoo", "Unexpected GaimStatus passed to yahoo_set_status!\n"); | |
2269 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
2270 } | |
7883 | 2271 yahoo_server_check(account); |
9306 | 2272 yahoo_picture_check(account); |
7883 | 2273 |
9164 | 2274 if (gaim_account_get_bool(account, "yahoojp", FALSE)) { |
2275 yd->jp = TRUE; | |
2276 if (gaim_proxy_connect(account, | |
2277 gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), | |
2278 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
2279 yahoo_got_connected, gc) != 0) | |
2280 { | |
2281 gaim_connection_error(gc, _("Connection problem")); | |
2282 return; | |
2283 } | |
2284 } else { | |
2285 yd->jp = FALSE; | |
2286 if (gaim_proxy_connect(account, | |
2287 gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), | |
2288 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
2289 yahoo_got_connected, gc) != 0) | |
2290 { | |
2291 gaim_connection_error(gc, _("Connection problem")); | |
2292 return; | |
2293 } | |
2681 | 2294 } |
9370 | 2295 |
2681 | 2296 |
2297 } | |
2298 | |
5583 | 2299 static void yahoo_close(GaimConnection *gc) { |
2681 | 2300 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
9782 | 2301 GSList *l; |
2302 | |
2303 for (l = yd->confs; l; l = l->next) { | |
2304 GaimConversation *conv = l->data; | |
2305 | |
2306 yahoo_conf_leave(yd, gaim_conversation_get_name(conv), | |
2307 gaim_connection_get_display_name(gc), | |
2308 gaim_conv_chat_get_users(GAIM_CONV_CHAT(conv))); | |
2309 } | |
2310 g_slist_free(yd->confs); | |
6729 | 2311 |
6784 | 2312 g_hash_table_destroy(yd->friends); |
2313 if (yd->chat_name) | |
2314 g_free(yd->chat_name); | |
6729 | 2315 |
7651 | 2316 if (yd->cookie_y) |
2317 g_free(yd->cookie_y); | |
2318 if (yd->cookie_t) | |
2319 g_free(yd->cookie_t); | |
2320 | |
2681 | 2321 if (yd->fd >= 0) |
2322 close(yd->fd); | |
3720
34c95669952f
[gaim-migrate @ 3853]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3642
diff
changeset
|
2323 |
2681 | 2324 if (yd->rxqueue) |
2325 g_free(yd->rxqueue); | |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2686
diff
changeset
|
2326 yd->rxlen = 0; |
9306 | 2327 if (yd->picture_url) |
2328 g_free(yd->picture_url); | |
2329 if (yd->picture_upload_todo) | |
2330 yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo); | |
9376 | 2331 if (yd->ycht) |
2332 ycht_connection_close(yd->ycht); | |
2681 | 2333 if (gc->inpa) |
2334 gaim_input_remove(gc->inpa); | |
2335 g_free(yd); | |
2336 } | |
2337 | |
6695 | 2338 static const char *yahoo_list_icon(GaimAccount *a, GaimBuddy *b) |
2681 | 2339 { |
4687 | 2340 return "yahoo"; |
2681 | 2341 } |
4916 | 2342 |
9972 | 2343 static void yahoo_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4916 | 2344 { |
2345 int i = 0; | |
2346 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
6784 | 2347 GaimAccount *account; |
2348 GaimConnection *gc; | |
2349 struct yahoo_data *yd; | |
9278 | 2350 YahooFriend *f; |
10126 | 2351 GaimPresence *presence; |
2352 GaimStatus *status; | |
2353 const char *status_id; | |
6784 | 2354 |
2355 if (!b || !(account = b->account) || !(gc = gaim_account_get_connection(account)) || | |
2356 !(yd = gc->proto_data)) | |
2357 return; | |
2358 | |
9279 | 2359 f = yahoo_friend_find(gc, b->name); |
6784 | 2360 if (!f) { |
2361 *se = "notauthorized"; | |
2362 return; | |
2363 } | |
2364 | |
10126 | 2365 presence = gaim_buddy_get_presence(b); |
2366 status = gaim_presence_get_active_status(presence); | |
2367 status_id = gaim_status_get_id(status); | |
2368 | |
2369 if (gaim_presence_is_online(presence) == FALSE) { | |
4916 | 2370 *se = "offline"; |
2371 return; | |
2372 } else { | |
6784 | 2373 if (f->away) |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2374 emblems[i++] = "away"; |
6784 | 2375 if (f->sms) |
2376 emblems[i++] = "wireless"; | |
9283 | 2377 if (yahoo_friend_get_game(f)) |
4916 | 2378 emblems[i++] = "game"; |
2379 } | |
2380 *se = emblems[0]; | |
2381 *sw = emblems[1]; | |
2382 *nw = emblems[2]; | |
2383 *ne = emblems[3]; | |
2384 } | |
2681 | 2385 |
2386 static char *yahoo_get_status_string(enum yahoo_status a) | |
2387 { | |
2388 switch (a) { | |
2389 case YAHOO_STATUS_BRB: | |
4596 | 2390 return _("Be Right Back"); |
2681 | 2391 case YAHOO_STATUS_BUSY: |
4596 | 2392 return _("Busy"); |
2681 | 2393 case YAHOO_STATUS_NOTATHOME: |
4596 | 2394 return _("Not At Home"); |
2681 | 2395 case YAHOO_STATUS_NOTATDESK: |
4596 | 2396 return _("Not At Desk"); |
2681 | 2397 case YAHOO_STATUS_NOTINOFFICE: |
4596 | 2398 return _("Not In Office"); |
2681 | 2399 case YAHOO_STATUS_ONPHONE: |
4606 | 2400 return _("On The Phone"); |
2681 | 2401 case YAHOO_STATUS_ONVACATION: |
4596 | 2402 return _("On Vacation"); |
2681 | 2403 case YAHOO_STATUS_OUTTOLUNCH: |
4596 | 2404 return _("Out To Lunch"); |
2681 | 2405 case YAHOO_STATUS_STEPPEDOUT: |
4596 | 2406 return _("Stepped Out"); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
2407 case YAHOO_STATUS_INVISIBLE: |
4596 | 2408 return _("Invisible"); |
4730 | 2409 case YAHOO_STATUS_IDLE: |
2410 return _("Idle"); | |
6784 | 2411 case YAHOO_STATUS_OFFLINE: |
2412 return _("Offline"); | |
2879
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
2413 default: |
4596 | 2414 return _("Online"); |
2681 | 2415 } |
2416 } | |
2417 | |
9030 | 2418 static void yahoo_initiate_conference(GaimBlistNode *node, gpointer data) { |
2419 | |
2420 GaimBuddy *buddy; | |
2421 GaimConnection *gc; | |
2422 | |
6729 | 2423 GHashTable *components; |
2424 struct yahoo_data *yd; | |
2425 int id; | |
2426 | |
9030 | 2427 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
2428 | |
2429 buddy = (GaimBuddy *) node; | |
2430 gc = gaim_account_get_connection(buddy->account); | |
6729 | 2431 yd = gc->proto_data; |
2432 id = yd->conf_id; | |
2433 | |
2434 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
2435 g_hash_table_replace(components, g_strdup("room"), | |
2436 g_strdup_printf("%s-%d", gaim_connection_get_display_name(gc), id)); | |
2437 g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference...")); | |
2438 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | |
2439 yahoo_c_join(gc, components); | |
2440 g_hash_table_destroy(components); | |
2441 | |
9030 | 2442 yahoo_c_invite(gc, id, "Join my conference...", buddy->name); |
6729 | 2443 } |
2444 | |
9030 | 2445 static void yahoo_game(GaimBlistNode *node, gpointer data) { |
2446 | |
2447 GaimBuddy *buddy; | |
2448 GaimConnection *gc; | |
2449 | |
2450 struct yahoo_data *yd; | |
9283 | 2451 const char *game; |
2452 char *game2; | |
3019 | 2453 char *t; |
2454 char url[256]; | |
9278 | 2455 YahooFriend *f; |
3019 | 2456 |
9030 | 2457 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
2458 | |
2459 buddy = (GaimBuddy *) node; | |
2460 gc = gaim_account_get_connection(buddy->account); | |
2461 yd = (struct yahoo_data *) gc->proto_data; | |
2462 | |
9279 | 2463 f = yahoo_friend_find(gc, buddy->name); |
6784 | 2464 if (!f) |
2465 return; | |
2466 | |
9283 | 2467 game = yahoo_friend_get_game(f); |
3019 | 2468 if (!game) |
2469 return; | |
6784 | 2470 |
9283 | 2471 t = game2 = g_strdup(strstr(game, "ante?room=")); |
2472 while (*t && *t != '\t') | |
3019 | 2473 t++; |
2474 *t = 0; | |
9283 | 2475 g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game2); |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
2476 gaim_notify_uri(gc, url); |
9283 | 2477 g_free(game2); |
3019 | 2478 } |
4722 | 2479 |
6695 | 2480 static char *yahoo_status_text(GaimBuddy *b) |
4722 | 2481 { |
9278 | 2482 YahooFriend *f = NULL; |
9283 | 2483 const char *msg; |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2484 |
9279 | 2485 f = yahoo_friend_find(b->account->gc, b->name); |
6784 | 2486 if (!f) |
2487 return g_strdup(_("Not on server list")); | |
2488 | |
2489 switch (f->status) { | |
2490 case YAHOO_STATUS_AVAILABLE: | |
2491 return NULL; | |
2492 case YAHOO_STATUS_IDLE: | |
2493 if (f->idle == -1) | |
2494 return g_strdup(yahoo_get_status_string(f->status)); | |
2495 return NULL; | |
2496 case YAHOO_STATUS_CUSTOM: | |
9283 | 2497 if (!(msg = yahoo_friend_get_status_message(f))) |
6784 | 2498 return NULL; |
9283 | 2499 return g_markup_escape_text(msg, strlen(msg)); |
9224 | 2500 |
6784 | 2501 default: |
2502 return g_strdup(yahoo_get_status_string(f->status)); | |
2503 } | |
4722 | 2504 } |
2505 | |
9220 | 2506 char *yahoo_tooltip_text(GaimBuddy *b) |
4724 | 2507 { |
9278 | 2508 YahooFriend *f; |
6784 | 2509 char *escaped, *status, *ret; |
2510 | |
9279 | 2511 f = yahoo_friend_find(b->account->gc, b->name); |
6784 | 2512 if (!f) |
8591 | 2513 status = g_strdup_printf("\n%s", _("Not on server list")); |
6784 | 2514 else |
2515 switch (f->status) { | |
2516 case YAHOO_STATUS_IDLE: | |
2517 if (f->idle == -1) { | |
2518 status = g_strdup(yahoo_get_status_string(f->status)); | |
2519 break; | |
2520 } | |
2521 return NULL; | |
2522 case YAHOO_STATUS_CUSTOM: | |
9283 | 2523 if (!yahoo_friend_get_status_message(f)) |
6784 | 2524 return NULL; |
9283 | 2525 status = g_strdup(yahoo_friend_get_status_message(f)); |
6784 | 2526 break; |
2527 default: | |
2528 status = g_strdup(yahoo_get_status_string(f->status)); | |
2529 break; | |
4745 | 2530 } |
6784 | 2531 |
2532 escaped = g_markup_escape_text(status, strlen(status)); | |
8591 | 2533 ret = g_strdup_printf(_("\n<b>%s:</b> %s"), _("Status"), escaped); |
6784 | 2534 g_free(status); |
2535 g_free(escaped); | |
2536 | |
2537 return ret; | |
4729 | 2538 } |
2539 | |
9030 | 2540 static void yahoo_addbuddyfrommenu_cb(GaimBlistNode *node, gpointer data) |
2541 { | |
2542 GaimBuddy *buddy; | |
2543 GaimConnection *gc; | |
2544 | |
2545 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
2546 | |
2547 buddy = (GaimBuddy *) node; | |
2548 gc = gaim_account_get_connection(buddy->account); | |
2549 | |
9285 | 2550 yahoo_add_buddy(gc, buddy, NULL); |
9030 | 2551 } |
2552 | |
2553 | |
2554 static void yahoo_chat_goto_menu(GaimBlistNode *node, gpointer data) | |
6796 | 2555 { |
9030 | 2556 GaimBuddy *buddy; |
2557 GaimConnection *gc; | |
2558 | |
2559 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
2560 | |
2561 buddy = (GaimBuddy *) node; | |
2562 gc = gaim_account_get_connection(buddy->account); | |
2563 | |
2564 yahoo_chat_goto(gc, buddy->name); | |
6796 | 2565 } |
2566 | |
9030 | 2567 |
2568 static GList *yahoo_buddy_menu(GaimBuddy *buddy) | |
2681 | 2569 { |
2570 GList *m = NULL; | |
9030 | 2571 GaimBlistNodeAction *act; |
2572 | |
2573 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
9370 | 2574 struct yahoo_data *yd = gc->proto_data; |
3019 | 2575 static char buf2[1024]; |
9278 | 2576 YahooFriend *f; |
6784 | 2577 |
9279 | 2578 f = yahoo_friend_find(gc, buddy->name); |
6784 | 2579 |
9370 | 2580 if (!f && !yd->wm) { |
9030 | 2581 act = gaim_blist_node_action_new(_("Add Buddy"), |
2582 yahoo_addbuddyfrommenu_cb, NULL); | |
2583 m = g_list_append(m, act); | |
6784 | 2584 |
2585 return m; | |
9030 | 2586 |
2587 } else if (f->status == YAHOO_STATUS_OFFLINE) { | |
6784 | 2588 return NULL; |
9030 | 2589 } |
2590 | |
9370 | 2591 if (!yd->wm) { |
2592 act = gaim_blist_node_action_new(_("Join in Chat"), | |
2593 yahoo_chat_goto_menu, NULL); | |
2594 m = g_list_append(m, act); | |
2595 } | |
9030 | 2596 |
2597 act = gaim_blist_node_action_new(_("Initiate Conference"), | |
2598 yahoo_initiate_conference, NULL); | |
2599 m = g_list_append(m, act); | |
6729 | 2600 |
9283 | 2601 if (yahoo_friend_get_game(f)) { |
2602 const char *game = yahoo_friend_get_game(f); | |
3019 | 2603 char *room; |
6784 | 2604 char *t; |
2605 | |
2606 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ | |
2607 return m; | |
2608 while (*room && *room != '\t') /* skip to the tab */ | |
2609 room++; | |
2610 t = room++; /* room as now at the name */ | |
2611 while (*t != '\n') | |
2612 t++; /* replace the \n with a space */ | |
2613 *t = ' '; | |
2614 g_snprintf(buf2, sizeof buf2, "%s", room); | |
9030 | 2615 |
2616 act = gaim_blist_node_action_new(buf2, yahoo_game, NULL); | |
2617 m = g_list_append(m, act); | |
3019 | 2618 } |
6729 | 2619 |
2681 | 2620 return m; |
2621 } | |
2622 | |
9030 | 2623 |
2624 static GList *yahoo_blist_node_menu(GaimBlistNode *node) | |
2625 { | |
2626 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
2627 return yahoo_buddy_menu((GaimBuddy *) node); | |
2628 } else { | |
2629 return NULL; | |
2630 } | |
2631 } | |
2632 | |
2633 | |
5583 | 2634 static void yahoo_act_id(GaimConnection *gc, const char *entry) |
2681 | 2635 { |
2636 struct yahoo_data *yd = gc->proto_data; | |
2637 | |
2638 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 2639 yahoo_packet_hash_str(pkt, 3, entry); |
10392 | 2640 yahoo_packet_send_and_free(pkt, yd); |
2681 | 2641 |
5583 | 2642 gaim_connection_set_display_name(gc, entry); |
2681 | 2643 } |
2644 | |
9015 | 2645 static void yahoo_show_act_id(GaimPluginAction *action) |
2681 | 2646 { |
9015 | 2647 GaimConnection *gc = (GaimConnection *) action->context; |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2648 gaim_request_input(gc, NULL, _("Active which ID?"), NULL, |
8697 | 2649 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2650 _("OK"), G_CALLBACK(yahoo_act_id), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2651 _("Cancel"), NULL, gc); |
2681 | 2652 } |
2653 | |
9015 | 2654 static void yahoo_show_chat_goto(GaimPluginAction *action) |
7878 | 2655 { |
9015 | 2656 GaimConnection *gc = (GaimConnection *) action->context; |
7878 | 2657 gaim_request_input(gc, NULL, _("Join who in chat?"), NULL, |
8697 | 2658 "", FALSE, FALSE, NULL, |
7878 | 2659 _("OK"), G_CALLBACK(yahoo_chat_goto), |
2660 _("Cancel"), NULL, gc); | |
2661 } | |
2662 | |
9015 | 2663 static GList *yahoo_actions(GaimPlugin *plugin, gpointer context) { |
2681 | 2664 GList *m = NULL; |
9015 | 2665 GaimPluginAction *act; |
2666 | |
2667 act = gaim_plugin_action_new(_("Activate ID..."), | |
2668 yahoo_show_act_id); | |
2669 m = g_list_append(m, act); | |
2670 | |
2671 act = gaim_plugin_action_new(_("Join user in chat..."), | |
2672 yahoo_show_chat_goto); | |
2673 m = g_list_append(m, act); | |
7878 | 2674 |
2681 | 2675 return m; |
2676 } | |
2677 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7112
diff
changeset
|
2678 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, GaimConvImFlags flags) |
2681 | 2679 { |
2680 struct yahoo_data *yd = gc->proto_data; | |
2681 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
6629 | 2682 char *msg = yahoo_html_to_codes(what); |
7827 | 2683 char *msg2; |
2684 gboolean utf8 = TRUE; | |
9828 | 2685 int ret = 1; |
7827 | 2686 |
2687 msg2 = yahoo_string_encode(gc, msg, &utf8); | |
2681 | 2688 |
10394 | 2689 yahoo_packet_hash(pkt, "ss", 1, gaim_connection_get_display_name(gc), 5, who); |
7827 | 2690 if (utf8) |
10394 | 2691 yahoo_packet_hash_str(pkt, 97, "1"); |
2692 yahoo_packet_hash_str(pkt, 14, msg2); | |
2693 | |
2694 yahoo_packet_hash_str(pkt, 63, ";0"); /* IMvironment */ | |
2695 yahoo_packet_hash_str(pkt, 64, "0"); /* no idea */ | |
2696 yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */ | |
9306 | 2697 if (!yd->picture_url) |
10394 | 2698 yahoo_packet_hash_str(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */ |
9306 | 2699 else |
10394 | 2700 yahoo_packet_hash_str(pkt, 206, "2"); |
2681 | 2701 |
9828 | 2702 /* We may need to not send any packets over 2000 bytes, but I'm not sure yet. */ |
2703 if ((YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt)) <= 2000) | |
10392 | 2704 yahoo_packet_send(pkt, yd); |
9828 | 2705 else |
2706 ret = -E2BIG; | |
2681 | 2707 |
2708 yahoo_packet_free(pkt); | |
6629 | 2709 |
2710 g_free(msg); | |
7827 | 2711 g_free(msg2); |
6629 | 2712 |
9828 | 2713 return ret; |
2681 | 2714 } |
2715 | |
6059 | 2716 int yahoo_send_typing(GaimConnection *gc, const char *who, int typ) |
2993 | 2717 { |
2718 struct yahoo_data *yd = gc->proto_data; | |
3019 | 2719 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
10394 | 2720 yahoo_packet_hash(pkt, "ssssss", 49, "TYPING", 1, gaim_connection_get_display_name(gc), |
2721 14, " ", 13, typ == GAIM_TYPING ? "1" : "0", | |
2722 5, who, 1002, "1"); | |
2993 | 2723 |
10392 | 2724 yahoo_packet_send_and_free(pkt, yd); |
2993 | 2725 |
3001 | 2726 return 0; |
2993 | 2727 } |
2728 | |
9984 | 2729 static void yahoo_set_status(GaimAccount *account, GaimStatus *status) |
2681 | 2730 { |
9984 | 2731 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 2732 struct yahoo_data *yd; |
2681 | 2733 struct yahoo_packet *pkt; |
10400 | 2734 int old_status; |
9984 | 2735 const char *id; |
7827 | 2736 char *conv_msg = NULL; |
8503 | 2737 char *conv_msg2 = NULL; |
9984 | 2738 |
2739 id = gaim_status_get_id(status); | |
10400 | 2740 if (!gaim_status_is_active(status)) |
2741 return; | |
2742 if (strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && !gc) { | |
2743 gaim_account_connect(account, status); | |
2744 return; | |
2745 } else if (!strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && gc) { | |
2746 gaim_account_disconnect(account); | |
2747 return; | |
2748 } | |
2749 | |
2750 yd = (struct yahoo_data *)gc->proto_data; | |
2751 old_status = yd->current_status; | |
9984 | 2752 |
10373 | 2753 if (!strcmp(id, YAHOO_STATUS_TYPE_AVAILABLE)) { |
9984 | 2754 yd->current_status = YAHOO_STATUS_AVAILABLE; |
10373 | 2755 } else if (!strcmp(id, YAHOO_STATUS_TYPE_BRB)) { |
9984 | 2756 yd->current_status = YAHOO_STATUS_BRB; |
10373 | 2757 } else if (!strcmp(id, YAHOO_STATUS_TYPE_BUSY)) { |
9984 | 2758 yd->current_status = YAHOO_STATUS_BUSY; |
10373 | 2759 } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTATHOME)) { |
9984 | 2760 yd->current_status = YAHOO_STATUS_NOTATHOME; |
10373 | 2761 } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTATDESK)) { |
9984 | 2762 yd->current_status = YAHOO_STATUS_NOTATDESK; |
10373 | 2763 } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTINOFFICE)) { |
9984 | 2764 yd->current_status = YAHOO_STATUS_NOTINOFFICE; |
10373 | 2765 } else if (!strcmp(id, YAHOO_STATUS_TYPE_ONPHONE)) { |
9984 | 2766 yd->current_status = YAHOO_STATUS_ONPHONE; |
10373 | 2767 } else if (!strcmp(id, YAHOO_STATUS_TYPE_ONVACATION)) { |
9984 | 2768 yd->current_status = YAHOO_STATUS_ONVACATION; |
10373 | 2769 } else if (!strcmp(id, YAHOO_STATUS_TYPE_OUTTOLUNCH)) { |
9984 | 2770 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; |
10373 | 2771 } else if (!strcmp(id, YAHOO_STATUS_TYPE_STEPPEDOUT)) { |
9984 | 2772 yd->current_status = YAHOO_STATUS_STEPPEDOUT; |
10373 | 2773 } else if (!strcmp(id, YAHOO_STATUS_TYPE_INVISIBLE)) { |
9984 | 2774 yd->current_status = YAHOO_STATUS_INVISIBLE; |
10373 | 2775 } else if (!strcmp(id, YAHOO_STATUS_TYPE_AWAY)) { |
2681 | 2776 yd->current_status = YAHOO_STATUS_CUSTOM; |
10373 | 2777 } else if (!strcmp(id, YAHOO_STATUS_TYPE_AVAILABLE_WM)) { |
9984 | 2778 yd->current_status = YAHOO_STATUS_CUSTOM; |
2779 } else if (gc->is_idle) { /* i think this is broken */ | |
2681 | 2780 yd->current_status = YAHOO_STATUS_IDLE; |
2781 } else { | |
10400 | 2782 gaim_debug_error("yahoo", "Unexpected GaimStatus passed to yahoo_login!\n"); |
2681 | 2783 yd->current_status = YAHOO_STATUS_AVAILABLE; |
2784 } | |
2785 | |
10373 | 2786 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
2787 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 2788 yahoo_packet_hash_str(pkt, 13, "2"); |
10392 | 2789 yahoo_packet_send_and_free(pkt, yd); |
10373 | 2790 |
2791 return; | |
2792 } | |
2793 | |
2794 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 2795 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
6847 | 2796 |
9984 | 2797 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
2798 const char *msg = gaim_status_get_attr_string(status, "message"); | |
10195 | 2799 |
2800 if (msg == NULL) { | |
2801 gaim_debug_info("yahoo", "Attempted to set a NULL status message.\n"); | |
2802 msg = ""; | |
2803 } | |
2804 | |
9984 | 2805 conv_msg = yahoo_string_encode(gc, msg, NULL); |
2806 conv_msg2 = gaim_markup_strip_html(conv_msg); | |
10394 | 2807 yahoo_packet_hash_str(pkt, 19, conv_msg2); |
9984 | 2808 |
10373 | 2809 } else { |
10394 | 2810 yahoo_packet_hash_str(pkt, 19, ""); |
10373 | 2811 } |
2812 | |
2813 if (gc->is_idle) | |
10394 | 2814 yahoo_packet_hash_str(pkt, 47, "2"); |
10373 | 2815 else if (!gaim_status_type_is_available(gaim_status_get_type(status))) |
10394 | 2816 yahoo_packet_hash_str(pkt, 47, "1"); |
2681 | 2817 |
10392 | 2818 yahoo_packet_send_and_free(pkt, yd); |
9984 | 2819 |
2820 g_free(conv_msg); | |
2821 g_free(conv_msg2); | |
10373 | 2822 |
2823 if (old_status == YAHOO_STATUS_INVISIBLE) { | |
2824 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 2825 yahoo_packet_hash_str(pkt, 13, "1"); |
10392 | 2826 yahoo_packet_send_and_free(pkt, yd); |
10373 | 2827 } |
2681 | 2828 } |
2829 | |
5583 | 2830 static void yahoo_set_idle(GaimConnection *gc, int idle) |
2681 | 2831 { |
2832 struct yahoo_data *yd = gc->proto_data; | |
2833 struct yahoo_packet *pkt = NULL; | |
8503 | 2834 char *msg = NULL, *msg2 = NULL; |
10373 | 2835 |
2836 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) | |
2681 | 2837 yd->current_status = YAHOO_STATUS_IDLE; |
10373 | 2838 else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) |
2681 | 2839 yd->current_status = YAHOO_STATUS_AVAILABLE; |
10373 | 2840 |
2841 | |
2842 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | |
2843 | |
10394 | 2844 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
10373 | 2845 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
10504 | 2846 const char *tmp; |
10373 | 2847 GaimStatus *status = gaim_presence_get_active_status(gaim_account_get_presence(gaim_connection_get_account(gc))); |
10504 | 2848 tmp = gaim_status_get_attr_string(status, "message"); |
2849 if (tmp != NULL) { | |
2850 msg = yahoo_string_encode(gc, tmp, NULL); | |
2851 msg2 = gaim_unescape_html(msg); | |
2852 yahoo_packet_hash_str(pkt, 19, msg2); | |
2853 } else { | |
2854 yahoo_packet_hash_str(pkt, 19, ""); | |
2855 } | |
6847 | 2856 } else { |
10394 | 2857 yahoo_packet_hash_str(pkt, 19, ""); |
2681 | 2858 } |
2859 | |
10373 | 2860 if (idle) |
10394 | 2861 yahoo_packet_hash_str(pkt, 47, "2"); |
10373 | 2862 else if (!gaim_presence_is_available(gaim_account_get_presence(gaim_connection_get_account(gc)))) |
10394 | 2863 yahoo_packet_hash_str(pkt, 47, "1"); |
10373 | 2864 |
2865 | |
10392 | 2866 yahoo_packet_send_and_free(pkt, yd); |
10373 | 2867 |
2868 g_free(msg); | |
2869 g_free(msg2); | |
2681 | 2870 } |
2871 | |
9979 | 2872 static GList *yahoo_status_types(GaimAccount *account) |
2681 | 2873 { |
9979 | 2874 GaimConnection *gc = gaim_account_get_connection(account); |
2875 struct yahoo_data *yd = NULL; | |
2876 GaimStatusType *type; | |
2877 GList *types = NULL; | |
2878 | |
2879 if (gc) | |
2880 yd = gc->proto_data; | |
2881 | |
10400 | 2882 type = gaim_status_type_new(GAIM_STATUS_OFFLINE, YAHOO_STATUS_TYPE_OFFLINE, _("Offline"), TRUE); |
9979 | 2883 types = g_list_append(types, type); |
2884 | |
10400 | 2885 type = gaim_status_type_new(GAIM_STATUS_ONLINE, YAHOO_STATUS_TYPE_ONLINE, _("Online"), TRUE); |
9979 | 2886 types = g_list_append(types, type); |
2887 | |
10373 | 2888 type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, YAHOO_STATUS_TYPE_AVAILABLE, _("Available"), TRUE); |
9979 | 2889 types = g_list_append(types, type); |
2890 | |
2891 if (!yd || !yd->wm) { | |
10373 | 2892 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, YAHOO_STATUS_TYPE_AVAILABLE_WM, |
9979 | 2893 "Available With Message", TRUE, TRUE, FALSE, |
2894 "message", _("Message"), | |
10009 | 2895 gaim_value_new(GAIM_TYPE_STRING), NULL); |
9979 | 2896 types = g_list_append(types, type); |
2897 | |
2898 | |
10373 | 2899 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_BRB, _("Be Right Back"), TRUE); |
9979 | 2900 types = g_list_append(types, type); |
2901 | |
10373 | 2902 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_BUSY, _("Busy"), TRUE); |
9979 | 2903 types = g_list_append(types, type); |
2904 | |
10373 | 2905 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTATHOME, _("Not At Home"), TRUE); |
9979 | 2906 types = g_list_append(types, type); |
2907 | |
10373 | 2908 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTATDESK, _("Not At Desk"), TRUE); |
9979 | 2909 types = g_list_append(types, type); |
2910 | |
10373 | 2911 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTINOFFICE, _("Not In Office"), TRUE); |
9979 | 2912 types = g_list_append(types, type); |
2913 | |
10373 | 2914 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_ONPHONE, _("On The Phone"), TRUE); |
9979 | 2915 types = g_list_append(types, type); |
2916 | |
10373 | 2917 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_ONVACATION, _("On Vacation"), TRUE); |
9979 | 2918 types = g_list_append(types, type); |
2919 | |
10373 | 2920 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_OUTTOLUNCH, _("Out To Lunch"), TRUE); |
9979 | 2921 types = g_list_append(types, type); |
2922 | |
10373 | 2923 type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_STEPPEDOUT, _("Stepped Out"), TRUE); |
9979 | 2924 types = g_list_append(types, type); |
2925 | |
10373 | 2926 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_AWAY, |
10195 | 2927 _("Away"), TRUE, TRUE, FALSE, |
9979 | 2928 "message", _("Message"), |
10009 | 2929 gaim_value_new(GAIM_TYPE_STRING), NULL); |
9979 | 2930 types = g_list_append(types, type); |
9370 | 2931 } |
10373 | 2932 type = gaim_status_type_new(GAIM_STATUS_HIDDEN, YAHOO_STATUS_TYPE_INVISIBLE, _("Invisible"), TRUE); |
9979 | 2933 types = g_list_append(types, type); |
2934 | |
2935 | |
2936 return types; | |
2681 | 2937 } |
2938 | |
5583 | 2939 static void yahoo_keepalive(GaimConnection *gc) |
2681 | 2940 { |
2941 struct yahoo_data *yd = gc->proto_data; | |
2942 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
10392 | 2943 yahoo_packet_send_and_free(pkt, yd); |
6729 | 2944 |
2945 if (!yd->chat_online) | |
2946 return; | |
2947 | |
9376 | 2948 if (yd->wm) { |
2949 ycht_chat_send_keepalive(yd->ycht); | |
2950 return; | |
2951 } | |
2952 | |
6729 | 2953 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); |
10394 | 2954 yahoo_packet_hash_str(pkt, 109, gaim_connection_get_display_name(gc)); |
2955 yahoo_packet_send_and_free(pkt, yd); | |
2681 | 2956 } |
2957 | |
9285 | 2958 /* XXX - What's the deal with GaimGroup *foo? */ |
2959 static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *foo) | |
2681 | 2960 { |
2961 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
2962 struct yahoo_packet *pkt; | |
6695 | 2963 GaimGroup *g; |
2681 | 2964 char *group = NULL; |
7829 | 2965 char *group2 = NULL; |
2681 | 2966 |
2967 if (!yd->logged_in) | |
2968 return; | |
2969 | |
6840 | 2970 if (foo) |
2971 group = foo->name; | |
2972 if (!group) { | |
9285 | 2973 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, buddy->name)); |
6840 | 2974 if (g) |
2975 group = g->name; | |
2976 else | |
2977 group = "Buddies"; | |
2978 } | |
2681 | 2979 |
7829 | 2980 group2 = yahoo_string_encode(gc, group, NULL); |
2681 | 2981 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
10394 | 2982 yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc), |
2983 7, buddy->name, 65, group2, 14, ""); | |
10392 | 2984 yahoo_packet_send_and_free(pkt, yd); |
7829 | 2985 g_free(group2); |
2681 | 2986 } |
2987 | |
9285 | 2988 static void yahoo_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
2681 | 2989 { |
2990 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
9278 | 2991 YahooFriend *f; |
6795
40ba19133882
[gaim-migrate @ 7334]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6793
diff
changeset
|
2992 struct yahoo_packet *pkt; |
6840 | 2993 GSList *buddies, *l; |
2994 GaimGroup *g; | |
2995 gboolean remove = TRUE; | |
7827 | 2996 char *cg; |
6784 | 2997 |
9285 | 2998 if (!(f = yahoo_friend_find(gc, buddy->name))) |
6784 | 2999 return; |
3000 | |
9285 | 3001 buddies = gaim_find_buddies(gaim_connection_get_account(gc), buddy->name); |
6840 | 3002 for (l = buddies; l; l = l->next) { |
3003 g = gaim_find_buddys_group(l->data); | |
9285 | 3004 if (gaim_utf8_strcasecmp(group->name, g->name)) { |
6840 | 3005 remove = FALSE; |
3006 break; | |
3007 } | |
3008 } | |
3009 | |
3010 g_slist_free(buddies); | |
3011 | |
3012 if (remove) | |
9285 | 3013 g_hash_table_remove(yd->friends, buddy->name); |
3014 | |
3015 cg = yahoo_string_encode(gc, group->name, NULL); | |
6795
40ba19133882
[gaim-migrate @ 7334]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6793
diff
changeset
|
3016 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
10394 | 3017 yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), |
3018 7, buddy->name, 65, cg); | |
10392 | 3019 yahoo_packet_send_and_free(pkt, yd); |
7827 | 3020 g_free(cg); |
2681 | 3021 } |
3022 | |
6760 | 3023 static void yahoo_add_deny(GaimConnection *gc, const char *who) { |
3024 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
3025 struct yahoo_packet *pkt; | |
3026 | |
3027 if (!yd->logged_in) | |
3028 return; | |
8057 | 3029 /* It seems to work better without this */ |
3030 | |
8113 | 3031 /* if (gc->account->perm_deny != 4) |
3032 return; */ | |
3033 | |
3034 if (!who || who[0] == '\0') | |
3035 return; | |
3036 | |
6760 | 3037 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); |
10394 | 3038 yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), |
3039 7, who, 13, "1"); | |
10392 | 3040 yahoo_packet_send_and_free(pkt, yd); |
6760 | 3041 } |
3042 | |
3043 static void yahoo_rem_deny(GaimConnection *gc, const char *who) { | |
3044 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
3045 struct yahoo_packet *pkt; | |
3046 | |
3047 if (!yd->logged_in) | |
3048 return; | |
3049 | |
3050 if (!who || who[0] == '\0') | |
3051 return; | |
3052 | |
3053 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 3054 yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), 7, who, 13, "2"); |
10392 | 3055 yahoo_packet_send_and_free(pkt, yd); |
6760 | 3056 } |
3057 | |
3058 static void yahoo_set_permit_deny(GaimConnection *gc) { | |
3059 GaimAccount *acct; | |
3060 GSList *deny; | |
3061 | |
3062 acct = gc->account; | |
3063 | |
3064 switch (acct->perm_deny) { | |
10105 | 3065 /* privacy 1 */ |
3066 case GAIM_PRIVACY_ALLOW_ALL: | |
10143 | 3067 for (deny = acct->deny;deny;deny = deny->next) |
3068 yahoo_rem_deny(gc, deny->data); | |
3069 break; | |
10105 | 3070 /* privacy 3 */ |
3071 case GAIM_PRIVACY_ALLOW_USERS: | |
6760 | 3072 for (deny = acct->deny;deny;deny = deny->next) |
3073 yahoo_rem_deny(gc, deny->data); | |
3074 break; | |
10105 | 3075 /* privacy 5 */ |
3076 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
3077 /* privacy 4 */ | |
3078 case GAIM_PRIVACY_DENY_USERS: | |
6760 | 3079 for (deny = acct->deny;deny;deny = deny->next) |
3080 yahoo_add_deny(gc, deny->data); | |
3081 break; | |
10105 | 3082 /* privacy 2 */ |
3083 case GAIM_PRIVACY_DENY_ALL: | |
6760 | 3084 default: |
3085 break; | |
3086 } | |
3087 } | |
3088 | |
6513 | 3089 static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
3090 { | |
3091 yahoo_dest_colorht(); | |
3092 return TRUE; | |
3093 } | |
3094 | |
6793 | 3095 static void yahoo_change_buddys_group(GaimConnection *gc, const char *who, |
3096 const char *old_group, const char *new_group) | |
3097 { | |
3098 struct yahoo_data *yd = gc->proto_data; | |
3099 struct yahoo_packet *pkt; | |
7827 | 3100 char *gpn, *gpo; |
6793 | 3101 |
3102 /* Step 0: If they aren't on the server list anyway, | |
3103 * don't bother letting the server know. | |
3104 */ | |
9279 | 3105 if (!yahoo_friend_find(gc, who)) |
6793 | 3106 return; |
3107 | |
7827 | 3108 /* If old and new are the same, we would probably |
3109 * end up deleting the buddy, which would be bad. | |
3110 * This might happen because of the charset conversation. | |
3111 */ | |
3112 gpn = yahoo_string_encode(gc, new_group, NULL); | |
3113 gpo = yahoo_string_encode(gc, old_group, NULL); | |
3114 if (!strcmp(gpn, gpo)) { | |
3115 g_free(gpn); | |
3116 g_free(gpo); | |
3117 return; | |
3118 } | |
3119 | |
6793 | 3120 /* Step 1: Add buddy to new group. */ |
3121 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 3122 yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc), |
3123 7, who, 65, gpn, 14, ""); | |
10392 | 3124 yahoo_packet_send_and_free(pkt, yd); |
6793 | 3125 |
3126 /* Step 2: Remove buddy from old group */ | |
3127 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 3128 yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), 7, who, 65, gpo); |
10392 | 3129 yahoo_packet_send_and_free(pkt, yd); |
7827 | 3130 g_free(gpn); |
3131 g_free(gpo); | |
6793 | 3132 } |
3133 | |
9285 | 3134 static void yahoo_rename_group(GaimConnection *gc, const char *old_name, |
3135 GaimGroup *group, GList *moved_buddies) | |
6793 | 3136 { |
3137 struct yahoo_data *yd = gc->proto_data; | |
3138 struct yahoo_packet *pkt; | |
7827 | 3139 char *gpn, *gpo; |
3140 | |
9285 | 3141 gpn = yahoo_string_encode(gc, group->name, NULL); |
3142 gpo = yahoo_string_encode(gc, old_name, NULL); | |
7827 | 3143 if (!strcmp(gpn, gpo)) { |
3144 g_free(gpn); | |
3145 g_free(gpo); | |
3146 return; | |
3147 } | |
6793 | 3148 |
3149 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); | |
10394 | 3150 yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), |
3151 65, gpo, 67, gpn); | |
10392 | 3152 yahoo_packet_send_and_free(pkt, yd); |
7827 | 3153 g_free(gpn); |
3154 g_free(gpo); | |
6793 | 3155 } |
3156 | |
10119 | 3157 static GaimCmdRet |
3158 yahoogaim_cmd_buzz(GaimConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) { | |
3159 | |
3160 GaimAccount *account = gaim_conversation_get_account(c); | |
3161 const char *username = gaim_account_get_username(account); | |
3162 | |
3163 if (*args && args[0]) | |
3164 return GAIM_CMD_RET_FAILED; | |
3165 | |
3166 gaim_debug(GAIM_DEBUG_INFO, "yahoo", | |
3167 "Sending <ding> on account %s to buddy %s.\n", username, c->name); | |
3168 gaim_conv_im_send(GAIM_CONV_IM(c), "<ding>"); | |
3169 gaim_conv_im_write(GAIM_CONV_IM(c), "", _("Buzz!!"), GAIM_MESSAGE_NICK|GAIM_MESSAGE_RECV, time(NULL)); | |
3170 return GAIM_CMD_RET_OK; | |
3171 } | |
3172 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3173 static GaimPlugin *my_protocol = NULL; |
2681 | 3174 |
10119 | 3175 /********************************* Commands **********************************/ |
3176 | |
3177 static GaimCmdRet | |
3178 yahoogaim_cmd_chat_join(GaimConversation *conv, const char *cmd, | |
3179 char **args, char **error, void *data) | |
3180 { | |
3181 GHashTable *comp; | |
3182 GaimConnection *gc; | |
3183 struct yahoo_data *yd; | |
3184 int id; | |
3185 | |
3186 if (!args || !args[0]) | |
3187 return GAIM_CMD_RET_FAILED; | |
3188 | |
3189 gc = gaim_conversation_get_gc(conv); | |
3190 yd = gc->proto_data; | |
3191 id = yd->conf_id; | |
3192 gaim_debug(GAIM_DEBUG_INFO, "yahoo", | |
3193 "Trying to join %s \n", args[0]); | |
3194 | |
3195 comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
3196 g_hash_table_replace(comp, g_strdup("room"), | |
3197 g_strdup_printf("%s", g_ascii_strdown(args[0], strlen(args[0])))); | |
3198 g_hash_table_replace(comp, g_strdup("type"), g_strdup("Chat")); | |
3199 | |
3200 yahoo_c_join(gc, comp); | |
3201 | |
3202 g_hash_table_destroy(comp); | |
3203 return GAIM_CMD_RET_OK; | |
3204 } | |
3205 /************************** Plugin Initialization ****************************/ | |
3206 static void | |
3207 yahoogaim_register_commands(void) | |
3208 { | |
3209 gaim_cmd_register("join", "s", GAIM_CMD_P_PRPL, | |
3210 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
3211 GAIM_CMD_FLAG_PRPL_ONLY, | |
3212 "prpl-yahoo", yahoogaim_cmd_chat_join, | |
3213 _("join <room>: Join a chat room on the Yahoo network"), NULL); | |
10121 | 3214 gaim_cmd_register("buzz", "", GAIM_CMD_P_PRPL, |
10119 | 3215 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_PRPL_ONLY, |
3216 "prpl-yahoo", yahoogaim_cmd_buzz, | |
3217 _("buzz: Buzz a contact to get their attention"), NULL); | |
3218 } | |
3219 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3220 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3221 { |
9308 | 3222 OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, |
6729 | 3223 NULL, /* user_splits */ |
3224 NULL, /* protocol_options */ | |
9318 | 3225 {"png", 96, 96, 96, 96, GAIM_ICON_SCALE_SEND}, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3226 yahoo_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3227 yahoo_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3228 yahoo_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3229 yahoo_tooltip_text, |
9979 | 3230 yahoo_status_types, |
9030 | 3231 yahoo_blist_node_menu, |
6729 | 3232 yahoo_c_info, |
9768 | 3233 yahoo_c_info_defaults, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3234 yahoo_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3235 yahoo_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3236 yahoo_send_im, |
6729 | 3237 NULL, /* set info */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3238 yahoo_send_typing, |
6514 | 3239 yahoo_get_info, |
9984 | 3240 yahoo_set_status, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3241 yahoo_set_idle, |
6729 | 3242 NULL, /* change_passwd*/ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3243 yahoo_add_buddy, |
6729 | 3244 NULL, /* add_buddies */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3245 yahoo_remove_buddy, |
6729 | 3246 NULL, /*remove_buddies */ |
3247 NULL, /* add_permit */ | |
6760 | 3248 yahoo_add_deny, |
6729 | 3249 NULL, /* rem_permit */ |
6760 | 3250 yahoo_rem_deny, |
3251 yahoo_set_permit_deny, | |
6729 | 3252 NULL, /* warn */ |
3253 yahoo_c_join, | |
8562 | 3254 NULL, /* reject chat invite */ |
9917 | 3255 yahoo_get_chat_name, |
6729 | 3256 yahoo_c_invite, |
3257 yahoo_c_leave, | |
3258 NULL, /* chat whisper */ | |
3259 yahoo_c_send, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3260 yahoo_keepalive, |
6729 | 3261 NULL, /* register_user */ |
3262 NULL, /* get_cb_info */ | |
3263 NULL, /* get_cb_away */ | |
3264 NULL, /* alias_buddy */ | |
6793 | 3265 yahoo_change_buddys_group, |
3266 yahoo_rename_group, | |
6729 | 3267 NULL, /* buddy_free */ |
3268 NULL, /* convo_closed */ | |
3269 NULL, /* normalize */ | |
9306 | 3270 yahoo_set_buddy_icon, |
7651 | 3271 NULL, /* void (*remove_group)(GaimConnection *gc, const char *group);*/ |
3272 NULL, /* char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); */ | |
9475 | 3273 NULL, /* set_chat_topic */ |
3274 NULL, /* find_blist_chat */ | |
8113 | 3275 yahoo_roomlist_get_list, |
3276 yahoo_roomlist_cancel, | |
9466 | 3277 yahoo_roomlist_expand_category, |
9475 | 3278 NULL, /* can_receive_file */ |
9466 | 3279 yahoo_send_file |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3280 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3281 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3282 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3283 { |
9943 | 3284 GAIM_PLUGIN_MAGIC, |
3285 GAIM_MAJOR_VERSION, | |
3286 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3287 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3288 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3289 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3290 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3291 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3292 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3293 "prpl-yahoo", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3294 "Yahoo", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3295 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3296 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3297 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3298 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3299 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3300 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
3301 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3302 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3303 NULL, /**< load */ |
6513 | 3304 yahoo_unload_plugin, /**< unload */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3305 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3306 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3307 NULL, /**< ui_info */ |
8993 | 3308 &prpl_info, /**< extra_info */ |
3309 NULL, | |
9015 | 3310 yahoo_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3311 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3312 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3313 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
3314 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3315 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
3316 GaimAccountOption *option; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3317 |
9164 | 3318 option = gaim_account_option_bool_new(_("Yahoo Japan"), "yahoojp", FALSE); |
3319 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3320 | |
7827 | 3321 option = gaim_account_option_string_new(_("Pager host"), "server", YAHOO_PAGER_HOST); |
3322 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3323 | |
9164 | 3324 option = gaim_account_option_string_new(_("Japan Pager host"), "serverjp", YAHOOJP_PAGER_HOST); |
3325 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3326 | |
7827 | 3327 option = gaim_account_option_int_new(_("Pager port"), "port", YAHOO_PAGER_PORT); |
3328 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7651 | 3329 |
3330 option = gaim_account_option_string_new(_("File transfer host"), "xfer_host", YAHOO_XFER_HOST); | |
3331 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3332 | |
9164 | 3333 option = gaim_account_option_string_new(_("Japan File transfer host"), "xferjp_host", YAHOOJP_XFER_HOST); |
3334 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3335 | |
7651 | 3336 option = gaim_account_option_int_new(_("File transfer port"), "xfer_port", YAHOO_XFER_PORT); |
3337 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3338 | |
8113 | 3339 option = gaim_account_option_string_new(_("Chat Room List Url"), "room_list", YAHOO_ROOMLIST_URL); |
3340 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
9376 | 3341 #if 0 |
3342 option = gaim_account_option_string_new(_("YCHT Host"), "ycht-server", YAHOO_YCHT_HOST); | |
3343 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3344 | |
3345 option = gaim_account_option_int_new(_("YCHT Port"), "ycht-port", YAHOO_YCHT_PORT); | |
3346 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3347 #endif | |
3348 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3349 my_protocol = plugin; |
10119 | 3350 yahoogaim_register_commands(); |
6513 | 3351 yahoo_init_colorht(); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3352 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3353 |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
3354 GAIM_INIT_PLUGIN(yahoo, init_plugin, info); |