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