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