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