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