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