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