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