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