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