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