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