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