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