Sun, 22 Jul 2007 07:30:50 +0000
Allow you to authorize msn buddies to add your yahoo account.
Allow you to add msn buddies to your list if you're previously
have conversed with them.
| 2681 | 1 | /* |
| 15884 | 2 | * purple |
| 2681 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 2681 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | * | |
| 22 | */ | |
| 9369 | 23 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
24 | #include "internal.h" |
| 2681 | 25 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
26 | #include "account.h" |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
27 | #include "accountopt.h" |
| 6760 | 28 | #include "blist.h" |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
29 | #include "cipher.h" |
| 10119 | 30 | #include "cmds.h" |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
31 | #include "core.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
32 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
33 | #include "notify.h" |
| 6760 | 34 | #include "privacy.h" |
| 2681 | 35 | #include "prpl.h" |
| 36 | #include "proxy.h" | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
37 | #include "request.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
38 | #include "server.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
39 | #include "util.h" |
| 9943 | 40 | #include "version.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
41 | |
| 6513 | 42 | #include "yahoo.h" |
| 6729 | 43 | #include "yahoochat.h" |
|
19058
9facc10e1c01
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@pidgin.im>
parents:
19053
diff
changeset
|
44 | #include "yahoo_aliases.h" |
| 8349 | 45 | #include "yahoo_auth.h" |
|
12417
ad19b5a4b41d
[gaim-migrate @ 14724]
Richard Laager <rlaager@pidgin.im>
parents:
12378
diff
changeset
|
46 | #include "yahoo_crypt.h" |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
47 | #include "yahoo_doodle.h" |
|
12417
ad19b5a4b41d
[gaim-migrate @ 14724]
Richard Laager <rlaager@pidgin.im>
parents:
12378
diff
changeset
|
48 | #include "yahoo_filexfer.h" |
|
ad19b5a4b41d
[gaim-migrate @ 14724]
Richard Laager <rlaager@pidgin.im>
parents:
12378
diff
changeset
|
49 | #include "yahoo_friend.h" |
|
ad19b5a4b41d
[gaim-migrate @ 14724]
Richard Laager <rlaager@pidgin.im>
parents:
12378
diff
changeset
|
50 | #include "yahoo_packet.h" |
|
ad19b5a4b41d
[gaim-migrate @ 14724]
Richard Laager <rlaager@pidgin.im>
parents:
12378
diff
changeset
|
51 | #include "yahoo_picture.h" |
|
ad19b5a4b41d
[gaim-migrate @ 14724]
Richard Laager <rlaager@pidgin.im>
parents:
12378
diff
changeset
|
52 | #include "ycht.h" |
|
2795
b2e15894ab75
[gaim-migrate @ 2808]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2786
diff
changeset
|
53 | |
|
5493
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
54 | /* #define YAHOO_DEBUG */ |
| 2681 | 55 | |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
56 | /* #define TRY_WEBMESSENGER_LOGIN 0 */ |
|
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
57 | |
| 15884 | 58 | static void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *, PurpleGroup *); |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
59 | #ifdef TRY_WEBMESSENGER_LOGIN |
| 15884 | 60 | static void yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, size_t len, const gchar *error_message); |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
61 | #endif |
| 15884 | 62 | static void yahoo_set_status(PurpleAccount *account, PurpleStatus *status); |
| 9306 | 63 | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
64 | static void |
| 15884 | 65 | yahoo_add_permit(PurpleConnection *gc, const char *who) |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
66 | { |
| 15884 | 67 | purple_debug_info("yahoo", |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
68 | "Permitting ID %s local contact rights for account %s\n", who, gc->account); |
| 15884 | 69 | purple_privacy_permit_add(gc->account,who,TRUE); |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
70 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
71 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
72 | static void |
| 15884 | 73 | yahoo_rem_permit(PurpleConnection *gc, const char *who) |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
74 | { |
| 15884 | 75 | purple_debug_info("yahoo", |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
76 | "Denying ID %s local contact rights for account %s\n", who, gc->account); |
| 15884 | 77 | purple_privacy_permit_remove(gc->account,who,TRUE); |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
78 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
79 | |
| 16527 | 80 | gboolean |
| 81 | yahoo_privacy_check(PurpleConnection *gc, const char *who) | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
82 | { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
83 | /* returns TRUE if allowed through, FALSE otherwise */ |
|
11111
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
84 | gboolean permitted; |
|
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
85 | |
| 15884 | 86 | permitted = purple_privacy_check(gc->account, who); |
|
11111
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
87 | |
|
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
88 | /* print some debug info */ |
|
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
89 | if (!permitted) { |
|
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
90 | char *deb = NULL; |
|
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
91 | switch (gc->account->perm_deny) |
|
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
92 | { |
| 15884 | 93 | case PURPLE_PRIVACY_DENY_ALL: |
| 94 | deb = "PURPLE_PRIVACY_DENY_ALL"; | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
95 | break; |
| 15884 | 96 | case PURPLE_PRIVACY_DENY_USERS: |
| 97 | deb = "PURPLE_PRIVACY_DENY_USERS"; | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
98 | break; |
| 15884 | 99 | case PURPLE_PRIVACY_ALLOW_BUDDYLIST: |
| 100 | deb = "PURPLE_PRIVACY_ALLOW_BUDDYLIST"; | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
101 | break; |
|
11111
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
102 | } |
|
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
103 | if(deb) |
| 15884 | 104 | purple_debug_info("yahoo", |
|
11111
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
105 | "%s blocked data received from %s (%s)\n", |
|
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
106 | gc->account->username,who, deb); |
| 15884 | 107 | } else if (gc->account->perm_deny == PURPLE_PRIVACY_ALLOW_USERS) { |
| 108 | purple_debug_info("yahoo", | |
| 109 | "%s allowed data received from %s (PURPLE_PRIVACY_ALLOW_USERS)\n", | |
|
11111
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11109
diff
changeset
|
110 | gc->account->username,who); |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
111 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
112 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
113 | return permitted; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
114 | } |
| 6784 | 115 | |
| 15884 | 116 | static void yahoo_update_status(PurpleConnection *gc, const char *name, YahooFriend *f) |
| 6784 | 117 | { |
| 9983 | 118 | char *status = NULL; |
| 6840 | 119 | |
| 15884 | 120 | if (!gc || !name || !f || !purple_find_buddy(purple_connection_get_account(gc), name)) |
| 6784 | 121 | return; |
| 122 | ||
| 6840 | 123 | if (f->status == YAHOO_STATUS_OFFLINE) |
|
11250
f541803353ed
[gaim-migrate @ 13419]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11188
diff
changeset
|
124 | { |
|
f541803353ed
[gaim-migrate @ 13419]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11188
diff
changeset
|
125 | return; |
|
f541803353ed
[gaim-migrate @ 13419]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11188
diff
changeset
|
126 | } |
| 6840 | 127 | |
| 9983 | 128 | switch (f->status) { |
| 129 | case YAHOO_STATUS_AVAILABLE: | |
| 10373 | 130 | status = YAHOO_STATUS_TYPE_AVAILABLE; |
| 9983 | 131 | break; |
| 132 | case YAHOO_STATUS_BRB: | |
| 10373 | 133 | status = YAHOO_STATUS_TYPE_BRB; |
| 9983 | 134 | break; |
| 135 | case YAHOO_STATUS_BUSY: | |
| 10373 | 136 | status = YAHOO_STATUS_TYPE_BUSY; |
| 9983 | 137 | break; |
| 138 | case YAHOO_STATUS_NOTATHOME: | |
| 10373 | 139 | status = YAHOO_STATUS_TYPE_NOTATHOME; |
| 9983 | 140 | break; |
| 141 | case YAHOO_STATUS_NOTATDESK: | |
| 10373 | 142 | status = YAHOO_STATUS_TYPE_NOTATDESK; |
| 9983 | 143 | break; |
| 144 | case YAHOO_STATUS_NOTINOFFICE: | |
| 10373 | 145 | status = YAHOO_STATUS_TYPE_NOTINOFFICE; |
| 9983 | 146 | break; |
| 147 | case YAHOO_STATUS_ONPHONE: | |
| 10373 | 148 | status = YAHOO_STATUS_TYPE_ONPHONE; |
| 9983 | 149 | break; |
| 150 | case YAHOO_STATUS_ONVACATION: | |
| 10373 | 151 | status = YAHOO_STATUS_TYPE_ONVACATION; |
| 9983 | 152 | break; |
| 153 | case YAHOO_STATUS_OUTTOLUNCH: | |
| 10373 | 154 | status = YAHOO_STATUS_TYPE_OUTTOLUNCH; |
| 9983 | 155 | break; |
| 156 | case YAHOO_STATUS_STEPPEDOUT: | |
| 10373 | 157 | status = YAHOO_STATUS_TYPE_STEPPEDOUT; |
| 9983 | 158 | break; |
| 159 | case YAHOO_STATUS_INVISIBLE: /* this should never happen? */ | |
| 10373 | 160 | status = YAHOO_STATUS_TYPE_INVISIBLE; |
| 9983 | 161 | break; |
| 162 | case YAHOO_STATUS_CUSTOM: | |
|
13688
240e5b90adb4
[gaim-migrate @ 16089]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13559
diff
changeset
|
163 | case YAHOO_STATUS_IDLE: |
| 9983 | 164 | if (!f->away) |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
165 | status = YAHOO_STATUS_TYPE_AVAILABLE; |
| 9983 | 166 | else |
| 10373 | 167 | status = YAHOO_STATUS_TYPE_AWAY; |
| 9983 | 168 | break; |
| 169 | default: | |
| 15884 | 170 | purple_debug_warning("yahoo", "Warning, unknown status %d\n", f->status); |
| 9983 | 171 | break; |
| 172 | } | |
| 173 | ||
| 174 | if (status) { | |
| 175 | if (f->status == YAHOO_STATUS_CUSTOM) | |
| 15884 | 176 | purple_prpl_got_user_status(purple_connection_get_account(gc), name, status, "message", |
| 9983 | 177 | yahoo_friend_get_status_message(f), NULL); |
| 178 | else | |
| 15884 | 179 | purple_prpl_got_user_status(purple_connection_get_account(gc), name, status, NULL); |
| 9983 | 180 | } |
| 181 | ||
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
182 | if (f->idle != 0) |
| 15884 | 183 | purple_prpl_got_user_idle(purple_connection_get_account(gc), name, TRUE, f->idle); |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
184 | else |
| 15884 | 185 | purple_prpl_got_user_idle(purple_connection_get_account(gc), name, FALSE, 0); |
| 15589 | 186 | |
| 187 | if (f->sms) | |
| 15884 | 188 | purple_prpl_got_user_status(purple_connection_get_account(gc), name, YAHOO_STATUS_TYPE_MOBILE, NULL); |
| 15589 | 189 | else |
| 15884 | 190 | purple_prpl_got_user_status_deactive(purple_connection_get_account(gc), name, YAHOO_STATUS_TYPE_MOBILE); |
| 6784 | 191 | } |
| 192 | ||
| 15884 | 193 | static void yahoo_process_status(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 194 | { |
| 15884 | 195 | PurpleAccount *account = purple_connection_get_account(gc); |
| 2681 | 196 | struct yahoo_data *yd = gc->proto_data; |
| 197 | GSList *l = pkt->hash; | |
| 9278 | 198 | YahooFriend *f = NULL; |
| 2681 | 199 | char *name = NULL; |
|
19053
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
200 | gboolean unicode = FALSE; |
|
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
201 | char *message = NULL; |
| 6784 | 202 | |
| 7892 | 203 | if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { |
| 8383 | 204 | gc->wants_to_die = TRUE; |
| 15884 | 205 | purple_connection_error(gc, _("You have signed on from another location.")); |
| 7892 | 206 | return; |
| 207 | } | |
| 6686 | 208 | |
| 2681 | 209 | while (l) { |
| 210 | struct yahoo_pair *pair = l->data; | |
| 211 | ||
| 212 | switch (pair->key) { | |
| 213 | case 0: /* we won't actually do anything with this */ | |
| 214 | break; | |
| 215 | 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
|
216 | if (!yd->logged_in) { |
| 15884 | 217 | purple_connection_set_display_name(gc, pair->value); |
| 218 | purple_connection_set_state(gc, PURPLE_CONNECTED); | |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
219 | yd->logged_in = TRUE; |
| 9306 | 220 | if (yd->picture_upload_todo) { |
| 221 | yahoo_buddy_icon_upload(gc, yd->picture_upload_todo); | |
| 222 | yd->picture_upload_todo = NULL; | |
| 223 | } | |
| 15884 | 224 | yahoo_set_status(account, purple_account_get_active_status(account)); |
| 2681 | 225 | |
| 3147 | 226 | /* this requests the list. i have a feeling that this is very evil |
| 227 | * | |
| 6686 | 228 | * scs.yahoo.com sends you the list before this packet without it being |
| 3147 | 229 | * requested |
| 230 | * | |
| 231 | * do_import(gc, NULL); | |
| 232 | * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); | |
| 10392 | 233 | * yahoo_packet_send_and_free(newpkt, yd); |
| 3147 | 234 | */ |
| 235 | ||
| 236 | } | |
| 2681 | 237 | break; |
| 238 | case 8: /* how many online buddies we have */ | |
| 239 | break; | |
| 240 | case 7: /* the current buddy */ | |
| 10553 | 241 | if (name && f) /* update the previous buddy before changing the variables */ |
| 242 | yahoo_update_status(gc, name, f); | |
| 2681 | 243 | name = pair->value; |
| 9886 | 244 | if (name && g_utf8_validate(name, -1, NULL)) |
| 245 | f = yahoo_friend_find_or_new(gc, name); | |
| 9888 | 246 | else { |
| 247 | f = NULL; | |
| 248 | name = NULL; | |
| 249 | } | |
| 2681 | 250 | break; |
| 251 | case 10: /* state */ | |
| 6784 | 252 | if (!f) |
| 253 | break; | |
| 254 | ||
| 255 | f->status = strtol(pair->value, NULL, 10); | |
| 256 | if ((f->status >= YAHOO_STATUS_BRB) && (f->status <= YAHOO_STATUS_STEPPEDOUT)) | |
| 257 | f->away = 1; | |
| 258 | else | |
| 259 | f->away = 0; | |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
260 | |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
261 | if (f->status == YAHOO_STATUS_IDLE) { |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
262 | /* 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
|
263 | if (f->idle == 0) |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
264 | f->idle = time(NULL); |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
265 | } else |
| 6804 | 266 | f->idle = 0; |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
267 | |
| 9283 | 268 | if (f->status != YAHOO_STATUS_CUSTOM) |
| 269 | yahoo_friend_set_status_message(f, NULL); | |
| 6847 | 270 | |
| 271 | f->sms = 0; | |
| 2681 | 272 | break; |
| 273 | case 19: /* custom message */ | |
| 9283 | 274 | if (f) |
|
19053
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
275 | message = pair->value; |
| 2681 | 276 | break; |
| 6686 | 277 | case 11: /* this is the buddy's session id */ |
| 2681 | 278 | break; |
| 279 | case 17: /* in chat? */ | |
| 280 | break; | |
| 6784 | 281 | case 47: /* is custom status away or not? 2=idle*/ |
| 282 | if (!f) | |
| 283 | break; | |
| 8441 | 284 | |
| 285 | /* I have no idea what it means when this is | |
| 286 | * set when someone's available, but it doesn't | |
| 287 | * mean idle. */ | |
| 288 | if (f->status == YAHOO_STATUS_AVAILABLE) | |
| 289 | break; | |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
290 | |
| 6784 | 291 | f->away = strtol(pair->value, NULL, 10); |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
292 | if (f->away == 2) { |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
293 | /* 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
|
294 | if (f->idle == 0) |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
295 | f->idle = time(NULL); |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
296 | } |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
297 | |
| 6686 | 298 | break; |
| 6784 | 299 | case 138: /* either we're not idle, or we are but won't say how long */ |
| 300 | if (!f) | |
| 301 | break; | |
| 302 | ||
| 303 | if (f->idle) | |
| 304 | f->idle = -1; | |
| 305 | break; | |
| 306 | case 137: /* usually idle time in seconds, sometimes login time */ | |
| 307 | if (!f) | |
| 308 | break; | |
| 309 | ||
| 310 | if (f->status != YAHOO_STATUS_AVAILABLE) | |
| 311 | f->idle = time(NULL) - strtol(pair->value, NULL, 10); | |
| 6686 | 312 | break; |
| 313 | case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ | |
| 6784 | 314 | if (strtol(pair->value, NULL, 10) == 0) { |
| 315 | if (f) | |
| 316 | f->status = YAHOO_STATUS_OFFLINE; | |
| 15589 | 317 | if (name) { |
| 15884 | 318 | purple_prpl_got_user_status(account, name, "offline", NULL); |
| 319 | purple_prpl_got_user_status_deactive(account, name, YAHOO_STATUS_TYPE_MOBILE); | |
| 15589 | 320 | } |
|
2807
fe1ea0453890
[gaim-migrate @ 2820]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2805
diff
changeset
|
321 | break; |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
322 | } |
| 6784 | 323 | break; |
| 324 | case 60: /* SMS */ | |
| 325 | if (f) { | |
| 326 | f->sms = strtol(pair->value, NULL, 10); | |
| 327 | yahoo_update_status(gc, name, f); | |
|
2771
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
328 | } |
|
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
329 | break; |
| 9292 | 330 | case 197: /* Avatars */ |
| 9277 | 331 | { |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
332 | guchar *decoded; |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11111
diff
changeset
|
333 | char *tmp; |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11111
diff
changeset
|
334 | gsize len; |
| 9277 | 335 | |
| 336 | if (pair->value) { | |
| 15884 | 337 | decoded = purple_base64_decode(pair->value, &len); |
| 9277 | 338 | if (len) { |
| 15884 | 339 | tmp = purple_str_binary_to_ascii(decoded, len); |
| 340 | purple_debug_info("yahoo", "Got key 197, value = %s\n", tmp); | |
| 9277 | 341 | g_free(tmp); |
| 342 | } | |
| 343 | g_free(decoded); | |
| 344 | } | |
| 345 | break; | |
| 346 | } | |
| 9292 | 347 | case 192: /* Pictures, aka Buddy Icons, checksum */ |
| 348 | { | |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16007
diff
changeset
|
349 | /* FIXME: Please, if you know this protocol, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16007
diff
changeset
|
350 | * FIXME: fix up the strtol() stuff if possible. */ |
| 9292 | 351 | int cksum = strtol(pair->value, NULL, 10); |
|
16606
b31fca4f6f60
Thanks to Bleeter, yahoo will not crash for non-existent buddyicons anymore.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16545
diff
changeset
|
352 | const char *locksum = NULL; |
| 15884 | 353 | PurpleBuddy *b; |
| 9292 | 354 | |
| 355 | if (!name) | |
| 356 | break; | |
| 357 | ||
| 15884 | 358 | b = purple_find_buddy(gc->account, name); |
| 9325 | 359 | |
| 9292 | 360 | if (!cksum || (cksum == -1)) { |
| 9325 | 361 | if (f) |
| 362 | yahoo_friend_set_buddy_icon_need_request(f, TRUE); | |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16007
diff
changeset
|
363 | purple_buddy_icons_set_for_user(gc->account, name, NULL, 0, NULL); |
| 9292 | 364 | break; |
| 365 | } | |
| 366 | ||
| 367 | if (!f) | |
| 368 | break; | |
| 9325 | 369 | |
| 9292 | 370 | yahoo_friend_set_buddy_icon_need_request(f, FALSE); |
|
17151
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
17044
diff
changeset
|
371 | if (b) { |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
17044
diff
changeset
|
372 | locksum = purple_buddy_icons_get_checksum_for_user(b); |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
17044
diff
changeset
|
373 | if (!locksum || (cksum != strtol(locksum, NULL, 10))) |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
17044
diff
changeset
|
374 | yahoo_send_picture_request(gc, name); |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
17044
diff
changeset
|
375 | } |
| 9292 | 376 | |
| 377 | break; | |
| 378 | } | |
| 2979 | 379 | case 16: /* Custom error message */ |
| 7827 | 380 | { |
| 381 | char *tmp = yahoo_string_decode(gc, pair->value, TRUE); | |
| 15884 | 382 | purple_notify_error(gc, NULL, tmp, NULL); |
| 7827 | 383 | g_free(tmp); |
| 384 | } | |
| 2951 | 385 | break; |
|
19053
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
386 | case 97: /* Unicode status message */ |
|
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
387 | unicode = !strcmp(pair->value, "1"); |
|
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
388 | break; |
|
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
389 | |
| 2681 | 390 | default: |
| 15884 | 391 | purple_debug(PURPLE_DEBUG_ERROR, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
392 | "Unknown status key %d\n", pair->key); |
| 2681 | 393 | break; |
| 394 | } | |
| 395 | ||
| 396 | l = l->next; | |
| 397 | } | |
| 10553 | 398 | |
|
19053
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
399 | if (message && f) |
|
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
400 | yahoo_friend_set_status_message(f, yahoo_string_decode(gc, message, unicode)); |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
401 | |
| 10553 | 402 | if (name && f) /* update the last buddy */ |
| 403 | yahoo_update_status(gc, name, f); | |
| 2681 | 404 | } |
| 405 | ||
| 15884 | 406 | static void yahoo_do_group_check(PurpleAccount *account, GHashTable *ht, const char *name, const char *group) |
| 6820 | 407 | { |
| 15884 | 408 | PurpleBuddy *b; |
| 409 | PurpleGroup *g; | |
| 6820 | 410 | GSList *list, *i; |
| 411 | gboolean onlist = 0; | |
| 412 | char *oname = NULL; | |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
413 | char **oname_p = &oname; |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
414 | GSList **list_p = &list; |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
415 | |
| 15884 | 416 | if (!g_hash_table_lookup_extended(ht, purple_normalize(account, name), (gpointer *) oname_p, (gpointer *) list_p)) |
| 417 | list = purple_find_buddies(account, name); | |
| 6820 | 418 | else |
| 419 | g_hash_table_steal(ht, name); | |
| 420 | ||
| 421 | for (i = list; i; i = i->next) { | |
| 422 | b = i->data; | |
| 15884 | 423 | g = purple_buddy_get_group(b); |
| 424 | if (!purple_utf8_strcasecmp(group, g->name)) { | |
| 425 | purple_debug(PURPLE_DEBUG_MISC, "yahoo", | |
| 6820 | 426 | "Oh good, %s is in the right group (%s).\n", name, group); |
| 427 | list = g_slist_delete_link(list, i); | |
| 428 | onlist = 1; | |
| 429 | break; | |
| 430 | } | |
| 431 | } | |
| 432 | ||
| 433 | if (!onlist) { | |
| 15884 | 434 | purple_debug(PURPLE_DEBUG_MISC, "yahoo", |
| 6820 | 435 | "Uhoh, %s isn't on the list (or not in this group), adding him to group %s.\n", name, group); |
| 15884 | 436 | if (!(g = purple_find_group(group))) { |
| 437 | g = purple_group_new(group); | |
| 438 | purple_blist_add_group(g, NULL); | |
| 6820 | 439 | } |
| 15884 | 440 | b = purple_buddy_new(account, name, NULL); |
| 441 | purple_blist_add_buddy(b, NULL, g, NULL); | |
| 6820 | 442 | } |
| 443 | ||
| 444 | if (list) { | |
| 445 | if (!oname) | |
| 15884 | 446 | oname = g_strdup(purple_normalize(account, name)); |
| 6820 | 447 | g_hash_table_insert(ht, oname, list); |
| 448 | } else if (oname) | |
| 449 | g_free(oname); | |
| 450 | } | |
| 451 | ||
| 452 | static void yahoo_do_group_cleanup(gpointer key, gpointer value, gpointer user_data) | |
| 453 | { | |
| 454 | char *name = key; | |
| 455 | GSList *list = value, *i; | |
| 15884 | 456 | PurpleBuddy *b; |
| 457 | PurpleGroup *g; | |
| 6820 | 458 | |
| 459 | for (i = list; i; i = i->next) { | |
| 460 | b = i->data; | |
| 15884 | 461 | g = purple_buddy_get_group(b); |
| 462 | purple_debug(PURPLE_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, g->name); | |
| 463 | purple_blist_remove_buddy(b); | |
| 6820 | 464 | } |
| 465 | } | |
| 466 | ||
| 7651 | 467 | static char *_getcookie(char *rawcookie) |
| 468 | { | |
| 469 | char *cookie = NULL; | |
| 470 | char *tmpcookie; | |
| 471 | char *cookieend; | |
| 472 | ||
| 473 | if (strlen(rawcookie) < 2) | |
| 474 | return NULL; | |
| 475 | tmpcookie = g_strdup(rawcookie+2); | |
| 476 | cookieend = strchr(tmpcookie, ';'); | |
| 477 | ||
| 478 | if (cookieend) | |
| 479 | *cookieend = '\0'; | |
| 480 | ||
| 481 | cookie = g_strdup(tmpcookie); | |
| 482 | g_free(tmpcookie); | |
| 483 | ||
| 484 | return cookie; | |
| 485 | } | |
| 486 | ||
| 487 | static void yahoo_process_cookie(struct yahoo_data *yd, char *c) | |
| 488 | { | |
| 489 | if (c[0] == 'Y') { | |
| 490 | if (yd->cookie_y) | |
| 491 | g_free(yd->cookie_y); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
492 | yd->cookie_y = _getcookie(c); |
| 7651 | 493 | } else if (c[0] == 'T') { |
| 494 | if (yd->cookie_t) | |
| 495 | g_free(yd->cookie_t); | |
| 496 | yd->cookie_t = _getcookie(c); | |
|
19038
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
497 | } else |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
498 | purple_debug_info("yahoo", "Ignoring unrecognized cookie '%c'\n", c[0]); |
| 7651 | 499 | } |
| 500 | ||
| 15884 | 501 | static void yahoo_process_list_15(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 14320 | 502 | { |
| 503 | GSList *l = pkt->hash; | |
| 504 | ||
| 15884 | 505 | PurpleAccount *account = purple_connection_get_account(gc); |
| 14320 | 506 | GHashTable *ht; |
| 507 | char *grp = NULL; | |
| 508 | char *norm_bud = NULL; | |
| 14362 | 509 | YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */ |
| 510 | /* But what if you had no friends? */ | |
| 15884 | 511 | PurpleBuddy *b; |
| 512 | PurpleGroup *g; | |
| 14362 | 513 | |
| 14320 | 514 | |
| 515 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free); | |
| 516 | ||
| 517 | while (l) { | |
| 518 | struct yahoo_pair *pair = l->data; | |
| 519 | l = l->next; | |
| 520 | ||
| 521 | switch (pair->key) { | |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
522 | case 302: |
|
14699
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
523 | /* This is always 318 before a group, 319 before the first s/n in a group, 320 before any ignored s/n. |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
524 | * It is not sent for s/n's in a group after the first. |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
525 | * All ignored s/n's are listed last, so when we see a 320 we clear the group and begin marking the |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
526 | * s/n's as ignored. It is always followed by an identical 300 key. |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
527 | */ |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
528 | if (pair->value && !strcmp(pair->value, "320")) { |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
529 | /* No longer in any group; this indicates the start of the ignore list. */ |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
530 | g_free(grp); |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
531 | grp = NULL; |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
532 | } |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
533 | |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
534 | break; |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
535 | case 301: /* This is 319 before all s/n's in a group after the first. It is followed by an identical 300. */ |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
536 | break; |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
537 | case 300: /* This is 318 before a group, 319 before any s/n in a group, and 320 before any ignored s/n. */ |
| 14320 | 538 | break; |
| 539 | case 65: /* This is the group */ | |
| 540 | g_free(grp); | |
| 541 | grp = yahoo_string_decode(gc, pair->value, FALSE); | |
| 542 | break; | |
| 543 | case 7: /* buddy's s/n */ | |
| 544 | g_free(norm_bud); | |
| 15884 | 545 | norm_bud = g_strdup(purple_normalize(account, pair->value)); |
|
14699
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
546 | |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
547 | if (grp) { |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
548 | /* This buddy is in a group */ |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
549 | f = yahoo_friend_find_or_new(gc, norm_bud); |
| 15884 | 550 | if (!(b = purple_find_buddy(account, norm_bud))) { |
| 551 | if (!(g = purple_find_group(grp))) { | |
| 552 | g = purple_group_new(grp); | |
| 553 | purple_blist_add_group(g, NULL); | |
|
14699
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
554 | } |
| 15884 | 555 | b = purple_buddy_new(account, norm_bud, NULL); |
| 556 | purple_blist_add_buddy(b, NULL, g, NULL); | |
| 14320 | 557 | } |
|
14699
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
558 | yahoo_do_group_check(account, ht, norm_bud, grp); |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
559 | |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
560 | } else { |
|
f4953b1a192e
[gaim-migrate @ 17383]
Evan Schoenberg <evands@pidgin.im>
parents:
14693
diff
changeset
|
561 | /* This buddy is on the ignore list (and therefore in no group) */ |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
562 | purple_privacy_deny_add(account, norm_bud, 1); |
| 14320 | 563 | } |
| 564 | break; | |
| 14346 | 565 | case 241: /* another protocol user */ |
| 14362 | 566 | if (f) { |
| 14346 | 567 | f->protocol = strtol(pair->value, NULL, 10); |
| 15884 | 568 | purple_debug_info("yahoo", "Setting protocol to %d\n", f->protocol); |
| 14362 | 569 | } |
| 14320 | 570 | break; |
| 571 | /* case 242: */ /* this seems related to 241 */ | |
| 572 | /* break; */ | |
| 573 | } | |
| 574 | } | |
| 575 | ||
| 576 | g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); | |
| 577 | g_hash_table_destroy(ht); | |
| 578 | g_free(grp); | |
| 579 | g_free(norm_bud); | |
| 580 | } | |
| 581 | ||
| 15884 | 582 | static void yahoo_process_list(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 583 | { |
| 584 | GSList *l = pkt->hash; | |
| 585 | gboolean export = FALSE; | |
| 6760 | 586 | gboolean got_serv_list = FALSE; |
| 15884 | 587 | PurpleBuddy *b; |
| 588 | PurpleGroup *g; | |
| 9278 | 589 | YahooFriend *f = NULL; |
| 15884 | 590 | PurpleAccount *account = purple_connection_get_account(gc); |
| 6784 | 591 | struct yahoo_data *yd = gc->proto_data; |
| 6820 | 592 | GHashTable *ht; |
| 6784 | 593 | |
| 594 | char **lines; | |
| 595 | char **split; | |
| 596 | char **buddies; | |
| 7823 | 597 | char **tmp, **bud, *norm_bud; |
| 7827 | 598 | char *grp = NULL; |
| 2681 | 599 | |
| 7651 | 600 | if (pkt->id) |
| 601 | yd->session_id = pkt->id; | |
| 602 | ||
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
603 | while (l) { |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
604 | struct yahoo_pair *pair = l->data; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
605 | l = l->next; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
606 | |
| 6760 | 607 | switch (pair->key) { |
| 608 | case 87: | |
| 6784 | 609 | if (!yd->tmp_serv_blist) |
| 610 | yd->tmp_serv_blist = g_string_new(pair->value); | |
| 611 | else | |
| 612 | g_string_append(yd->tmp_serv_blist, pair->value); | |
| 6760 | 613 | break; |
| 614 | case 88: | |
| 6784 | 615 | if (!yd->tmp_serv_ilist) |
| 616 | yd->tmp_serv_ilist = g_string_new(pair->value); | |
| 617 | else | |
| 618 | g_string_append(yd->tmp_serv_ilist, pair->value); | |
| 6760 | 619 | break; |
| 7651 | 620 | case 59: /* cookies, yum */ |
| 621 | yahoo_process_cookie(yd, pair->value); | |
| 622 | break; | |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
623 | case YAHOO_SERVICE_PRESENCE_PERM: |
|
12203
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
624 | if (!yd->tmp_serv_plist) |
|
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
625 | yd->tmp_serv_plist = g_string_new(pair->value); |
|
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
626 | else |
|
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
627 | g_string_append(yd->tmp_serv_plist, pair->value); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
628 | break; |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
629 | } |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
630 | } |
| 2681 | 631 | |
| 6784 | 632 | if (pkt->status != 0) |
| 633 | return; | |
| 634 | ||
| 635 | if (yd->tmp_serv_blist) { | |
| 6820 | 636 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free); |
| 637 | ||
| 6784 | 638 | lines = g_strsplit(yd->tmp_serv_blist->str, "\n", -1); |
| 639 | for (tmp = lines; *tmp; tmp++) { | |
| 640 | split = g_strsplit(*tmp, ":", 2); | |
| 641 | if (!split) | |
| 642 | continue; | |
| 643 | if (!split[0] || !split[1]) { | |
| 644 | g_strfreev(split); | |
| 645 | continue; | |
| 646 | } | |
| 7827 | 647 | grp = yahoo_string_decode(gc, split[0], FALSE); |
| 6784 | 648 | buddies = g_strsplit(split[1], ",", -1); |
| 649 | for (bud = buddies; bud && *bud; bud++) { | |
| 15884 | 650 | norm_bud = g_strdup(purple_normalize(account, *bud)); |
| 9279 | 651 | f = yahoo_friend_find_or_new(gc, norm_bud); |
| 652 | ||
| 15884 | 653 | if (!(b = purple_find_buddy(account, norm_bud))) { |
| 654 | if (!(g = purple_find_group(grp))) { | |
| 655 | g = purple_group_new(grp); | |
| 656 | purple_blist_add_group(g, NULL); | |
| 6784 | 657 | } |
| 15884 | 658 | b = purple_buddy_new(account, norm_bud, NULL); |
| 659 | purple_blist_add_buddy(b, NULL, g, NULL); | |
| 6784 | 660 | export = TRUE; |
| 6820 | 661 | } |
| 6784 | 662 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
663 | yahoo_do_group_check(account, ht, norm_bud, grp); |
| 7823 | 664 | g_free(norm_bud); |
| 6784 | 665 | } |
| 666 | g_strfreev(buddies); | |
| 667 | g_strfreev(split); | |
| 7827 | 668 | g_free(grp); |
| 6784 | 669 | } |
| 670 | g_strfreev(lines); | |
| 671 | ||
| 672 | g_string_free(yd->tmp_serv_blist, TRUE); | |
| 673 | yd->tmp_serv_blist = NULL; | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
674 | g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); |
| 6820 | 675 | g_hash_table_destroy(ht); |
| 6784 | 676 | } |
| 677 | ||
| 678 | if (yd->tmp_serv_ilist) { | |
| 679 | buddies = g_strsplit(yd->tmp_serv_ilist->str, ",", -1); | |
| 680 | for (bud = buddies; bud && *bud; bud++) { | |
| 681 | /* The server is already ignoring the user */ | |
| 682 | got_serv_list = TRUE; | |
| 15884 | 683 | purple_privacy_deny_add(gc->account, *bud, 1); |
| 6784 | 684 | } |
| 685 | g_strfreev(buddies); | |
| 686 | ||
| 687 | g_string_free(yd->tmp_serv_ilist, TRUE); | |
| 688 | yd->tmp_serv_ilist = NULL; | |
| 689 | } | |
| 690 | ||
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
691 | if (got_serv_list && |
| 15884 | 692 | ((gc->account->perm_deny != PURPLE_PRIVACY_ALLOW_BUDDYLIST) && |
| 693 | (gc->account->perm_deny != PURPLE_PRIVACY_DENY_ALL) && | |
| 694 | (gc->account->perm_deny != PURPLE_PRIVACY_ALLOW_USERS))) | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
695 | { |
| 15884 | 696 | gc->account->perm_deny = PURPLE_PRIVACY_DENY_USERS; |
| 697 | purple_debug_info("yahoo", "%s privacy defaulting to PURPLE_PRIVACY_DENY_USERS.\n", | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
698 | gc->account->username); |
| 6784 | 699 | } |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
700 | |
|
12203
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
701 | if (yd->tmp_serv_plist) { |
|
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
702 | buddies = g_strsplit(yd->tmp_serv_plist->str, ",", -1); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
703 | for (bud = buddies; bud && *bud; bud++) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
704 | f = yahoo_friend_find(gc, *bud); |
|
12138
fcf3d84824d7
[gaim-migrate @ 14439]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12088
diff
changeset
|
705 | if (f) { |
| 15884 | 706 | purple_debug_info("yahoo", "%s setting presence for %s to PERM_OFFLINE\n", |
|
12138
fcf3d84824d7
[gaim-migrate @ 14439]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12088
diff
changeset
|
707 | gc->account->username, *bud); |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
708 | f->presence = YAHOO_PRESENCE_PERM_OFFLINE; |
|
12138
fcf3d84824d7
[gaim-migrate @ 14439]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12088
diff
changeset
|
709 | } |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
710 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
711 | g_strfreev(buddies); |
|
12203
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
712 | g_string_free(yd->tmp_serv_plist, TRUE); |
|
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
713 | yd->tmp_serv_plist = NULL; |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
714 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
715 | } |
|
19058
9facc10e1c01
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@pidgin.im>
parents:
19053
diff
changeset
|
716 | /* Now that we've got the list, request aliases */ |
|
9facc10e1c01
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@pidgin.im>
parents:
19053
diff
changeset
|
717 | yahoo_fetch_aliases(gc); |
| 2681 | 718 | } |
| 719 | ||
| 15884 | 720 | static void yahoo_process_notify(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 2993 | 721 | { |
| 722 | char *msg = NULL; | |
| 723 | char *from = NULL; | |
| 3019 | 724 | char *stat = NULL; |
| 725 | char *game = NULL; | |
| 9278 | 726 | YahooFriend *f = NULL; |
| 2993 | 727 | GSList *l = pkt->hash; |
| 6784 | 728 | |
| 2993 | 729 | while (l) { |
| 730 | struct yahoo_pair *pair = l->data; | |
| 731 | if (pair->key == 4) | |
| 732 | from = pair->value; | |
| 733 | if (pair->key == 49) | |
| 734 | msg = pair->value; | |
| 3001 | 735 | if (pair->key == 13) |
| 3019 | 736 | stat = pair->value; |
| 737 | if (pair->key == 14) | |
| 738 | game = pair->value; | |
| 2993 | 739 | l = l->next; |
| 740 | } | |
| 3640 | 741 | |
| 6784 | 742 | if (!from || !msg) |
| 3640 | 743 | return; |
| 6686 | 744 | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
745 | if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING")) |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
746 | && (yahoo_privacy_check(gc, from))) { |
| 3019 | 747 | if (*stat == '1') |
| 15884 | 748 | serv_got_typing(gc, from, 0, PURPLE_TYPING); |
| 3019 | 749 | else |
| 750 | serv_got_typing_stopped(gc, from); | |
| 4793 | 751 | } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) { |
| 15884 | 752 | PurpleBuddy *bud = purple_find_buddy(gc->account, from); |
| 6784 | 753 | |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
754 | if (!bud) { |
| 15884 | 755 | purple_debug(PURPLE_DEBUG_WARNING, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
756 | "%s is playing a game, and doesn't want " |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
757 | "you to know.\n", from); |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
758 | } |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
759 | |
| 9279 | 760 | f = yahoo_friend_find(gc, from); |
| 6784 | 761 | if (!f) |
| 762 | return; /* if they're not on the list, don't bother */ | |
| 763 | ||
| 9283 | 764 | yahoo_friend_set_game(f, NULL); |
| 6784 | 765 | |
| 3019 | 766 | if (*stat == '1') { |
| 9283 | 767 | yahoo_friend_set_game(f, game); |
| 3020 | 768 | if (bud) |
| 6784 | 769 | yahoo_update_status(gc, from, f); |
| 3019 | 770 | } |
| 771 | } | |
| 2993 | 772 | } |
| 773 | ||
| 7827 | 774 | |
| 775 | struct _yahoo_im { | |
| 776 | char *from; | |
| 777 | int time; | |
| 778 | int utf8; | |
| 9284 | 779 | int buddy_icon; |
| 7827 | 780 | char *msg; |
| 781 | }; | |
| 782 | ||
| 15884 | 783 | static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 784 | { |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
785 | struct yahoo_data *yd = gc->proto_data; |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
786 | GSList *l = pkt->hash; |
| 7827 | 787 | GSList *list = NULL; |
| 788 | struct _yahoo_im *im = NULL; | |
| 11608 | 789 | |
|
13462
feff8b605383
[gaim-migrate @ 15836]
Daniel Atallah <datallah@pidgin.im>
parents:
13344
diff
changeset
|
790 | const char *imv = NULL; |
| 6069 | 791 | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
792 | if (pkt->status <= 1 || pkt->status == 5) { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11897
diff
changeset
|
793 | while (l != NULL) { |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
794 | struct yahoo_pair *pair = l->data; |
| 7827 | 795 | if (pair->key == 4) { |
| 796 | im = g_new0(struct _yahoo_im, 1); | |
| 797 | list = g_slist_append(list, im); | |
| 798 | im->from = pair->value; | |
| 799 | im->time = time(NULL); | |
| 800 | } | |
| 801 | if (pair->key == 97) | |
| 802 | if (im) | |
| 803 | im->utf8 = strtol(pair->value, NULL, 10); | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
804 | if (pair->key == 15) |
| 7827 | 805 | if (im) |
| 806 | im->time = strtol(pair->value, NULL, 10); | |
| 9284 | 807 | if (pair->key == 206) |
| 808 | if (im) | |
| 809 | im->buddy_icon = strtol(pair->value, NULL, 10); | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
810 | if (pair->key == 14) { |
| 7827 | 811 | if (im) |
| 812 | im->msg = pair->value; | |
| 6687 | 813 | } |
|
11801
c19b37ac661b
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
814 | /* IMV key */ |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
815 | if (pair->key == 63) |
|
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
816 | { |
|
13462
feff8b605383
[gaim-migrate @ 15836]
Daniel Atallah <datallah@pidgin.im>
parents:
13344
diff
changeset
|
817 | imv = pair->value; |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
818 | } |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
819 | l = l->next; |
| 6687 | 820 | } |
| 2681 | 821 | } else if (pkt->status == 2) { |
| 15884 | 822 | purple_notify_error(gc, NULL, |
|
10386
6fcc45a26a16
[gaim-migrate @ 11612]
Daniel Atallah <datallah@pidgin.im>
parents:
10379
diff
changeset
|
823 | _("Your Yahoo! message did not get sent."), NULL); |
| 2681 | 824 | } |
| 11608 | 825 | |
|
13462
feff8b605383
[gaim-migrate @ 15836]
Daniel Atallah <datallah@pidgin.im>
parents:
13344
diff
changeset
|
826 | /** TODO: It seems that this check should be per IM, not global */ |
|
11801
c19b37ac661b
[gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents:
11800
diff
changeset
|
827 | /* Check for the Doodle IMV */ |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
828 | if (im != NULL && imv!= NULL && im->from != NULL) |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
829 | { |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
830 | g_hash_table_replace(yd->imvironments, g_strdup(im->from), g_strdup(imv)); |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
831 | |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
832 | if (strstr(imv, "doodle;") != NULL) |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
833 | { |
| 15884 | 834 | PurpleWhiteboard *wb; |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
835 | |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
836 | if (!yahoo_privacy_check(gc, im->from)) { |
| 15884 | 837 | purple_debug_info("yahoo", "Doodle request from %s dropped.\n", im->from); |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
838 | return; |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
839 | } |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
840 | |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
841 | /* I'm not sure the following ever happens -DAA */ |
|
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
842 | |
| 15884 | 843 | wb = purple_whiteboard_get_session(gc->account, im->from); |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
844 | |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
845 | /* If a Doodle session doesn't exist between this user */ |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
846 | if(wb == NULL) |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
847 | { |
| 15884 | 848 | wb = purple_whiteboard_create(gc->account, im->from, DOODLE_STATE_REQUESTED); |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
849 | |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
850 | yahoo_doodle_command_send_request(gc, im->from); |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
851 | yahoo_doodle_command_send_ready(gc, im->from); |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
852 | } |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
853 | } |
|
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
854 | } |
| 7827 | 855 | |
| 856 | for (l = list; l; l = l->next) { | |
| 9306 | 857 | YahooFriend *f; |
| 7827 | 858 | char *m, *m2; |
| 859 | im = l->data; | |
| 860 | ||
| 861 | if (!im->from || !im->msg) { | |
| 862 | g_free(im); | |
| 863 | continue; | |
| 864 | } | |
| 865 | ||
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
866 | if (!yahoo_privacy_check(gc, im->from)) { |
| 15884 | 867 | purple_debug_info("yahoo", "Message from %s dropped.\n", im->from); |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
868 | return; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
869 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
870 | |
| 7827 | 871 | m = yahoo_string_decode(gc, im->msg, im->utf8); |
|
12994
8340178b7b16
[gaim-migrate @ 15347]
Daniel Atallah <datallah@pidgin.im>
parents:
12970
diff
changeset
|
872 | /* This may actually not be necessary, but it appears |
|
8340178b7b16
[gaim-migrate @ 15347]
Daniel Atallah <datallah@pidgin.im>
parents:
12970
diff
changeset
|
873 | * that at least at one point some clients were sending |
|
8340178b7b16
[gaim-migrate @ 15347]
Daniel Atallah <datallah@pidgin.im>
parents:
12970
diff
changeset
|
874 | * "\r\n" as line delimiters, so we want to avoid double |
|
8340178b7b16
[gaim-migrate @ 15347]
Daniel Atallah <datallah@pidgin.im>
parents:
12970
diff
changeset
|
875 | * lines. */ |
| 15884 | 876 | m2 = purple_strreplace(m, "\r\n", "\n"); |
|
12994
8340178b7b16
[gaim-migrate @ 15347]
Daniel Atallah <datallah@pidgin.im>
parents:
12970
diff
changeset
|
877 | g_free(m); |
|
8340178b7b16
[gaim-migrate @ 15347]
Daniel Atallah <datallah@pidgin.im>
parents:
12970
diff
changeset
|
878 | m = m2; |
| 15884 | 879 | purple_util_chrreplace(m, '\r', '\n'); |
| 8375 | 880 | |
| 881 | if (!strcmp(m, "<ding>")) { | |
|
16007
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
882 | PurpleBuddy *buddy; |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
883 | PurpleAccount *account; |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
884 | PurpleConversation *c; |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
885 | char *username, *str; |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
886 | |
|
16007
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
887 | account = purple_connection_get_account(gc); |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
888 | c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, im->from); |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
889 | |
|
16007
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
890 | if ((buddy = purple_find_buddy(account, im->from)) != NULL) |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
891 | username = g_markup_escape_text(purple_buddy_get_alias(buddy), -1); |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
892 | else |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
893 | username = g_markup_escape_text(im->from, -1); |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
894 | |
|
16007
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
895 | str = g_strdup_printf(_("%s just sent you a Buzz!"), username); |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
896 | |
|
16007
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
897 | purple_conversation_write(c, NULL, str, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, im->time); |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
898 | |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
899 | g_free(username); |
|
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
900 | g_free(str); |
| 8375 | 901 | g_free(m); |
| 902 | g_free(im); | |
| 903 | continue; | |
| 904 | } | |
| 905 | ||
| 7827 | 906 | m2 = yahoo_codes_to_html(m); |
| 907 | g_free(m); | |
| 908 | serv_got_im(gc, im->from, m2, 0, im->time); | |
| 909 | g_free(m2); | |
| 9284 | 910 | |
| 911 | if ((f = yahoo_friend_find(gc, im->from)) && im->buddy_icon == 2) { | |
| 912 | if (yahoo_friend_get_buddy_icon_need_request(f)) { | |
| 9310 | 913 | yahoo_send_picture_request(gc, im->from); |
| 9284 | 914 | yahoo_friend_set_buddy_icon_need_request(f, FALSE); |
| 915 | } | |
| 916 | } | |
| 917 | ||
| 7827 | 918 | g_free(im); |
| 919 | } | |
| 920 | g_slist_free(list); | |
| 2681 | 921 | } |
| 922 | ||
| 15884 | 923 | static void yahoo_process_sysmessage(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 7865 | 924 | { |
| 925 | GSList *l = pkt->hash; | |
|
17044
47fd0afbe505
Finish removal of yahoo system message escaping. I must have been
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17041
diff
changeset
|
926 | char *prim, *me = NULL, *msg = NULL; |
| 7865 | 927 | |
| 928 | while (l) { | |
| 929 | struct yahoo_pair *pair = l->data; | |
| 930 | ||
| 931 | if (pair->key == 5) | |
| 932 | me = pair->value; | |
| 933 | if (pair->key == 14) | |
| 934 | msg = pair->value; | |
| 935 | ||
| 936 | l = l->next; | |
| 937 | } | |
| 938 | ||
| 10070 | 939 | if (!msg || !g_utf8_validate(msg, -1, NULL)) |
| 7865 | 940 | return; |
| 941 | ||
| 942 | prim = g_strdup_printf(_("Yahoo! system message for %s:"), | |
| 15884 | 943 | me?me:purple_connection_get_display_name(gc)); |
|
17044
47fd0afbe505
Finish removal of yahoo system message escaping. I must have been
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17041
diff
changeset
|
944 | purple_notify_info(NULL, NULL, prim, msg); |
| 7865 | 945 | g_free(prim); |
| 946 | } | |
| 947 | ||
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
948 | struct yahoo_add_request { |
| 15884 | 949 | PurpleConnection *gc; |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
950 | char *id; |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
951 | char *who; |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
952 | char *msg; |
|
19411
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
953 | int protocol; |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
954 | }; |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
955 | |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
956 | static void |
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
19329
diff
changeset
|
957 | yahoo_buddy_add_authorize_cb(gpointer data) { |
|
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
19329
diff
changeset
|
958 | struct yahoo_add_request *add_req = data; |
|
19411
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
959 | |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
960 | struct yahoo_packet *pkt; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
961 | struct yahoo_data *yd = add_req->gc->proto_data; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
962 | |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
963 | pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, 0); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
964 | yahoo_packet_hash(pkt, "ssiii", 1, add_req->id, 5, add_req->who, 241, add_req->protocol, |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
965 | 13, 1, 334, 0); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
966 | yahoo_packet_send_and_free(pkt, yd); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
967 | |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
968 | g_free(add_req->id); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
969 | g_free(add_req->who); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
970 | g_free(add_req->msg); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
971 | g_free(add_req); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
972 | } |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
973 | |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
974 | static void |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
975 | yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg) { |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
976 | struct yahoo_packet *pkt; |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
977 | char *encoded_msg = NULL; |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
978 | struct yahoo_data *yd = add_req->gc->proto_data; |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
979 | |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
980 | if (msg) |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
981 | encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
982 | |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
983 | pkt = yahoo_packet_new(YAHOO_SERVICE_REJECTCONTACT, |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
984 | YAHOO_STATUS_AVAILABLE, 0); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
985 | |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
986 | yahoo_packet_hash(pkt, "sss", |
| 15884 | 987 | 1, purple_normalize(add_req->gc->account, |
| 988 | purple_account_get_username( | |
| 989 | purple_connection_get_account( | |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
990 | add_req->gc))), |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
991 | 7, add_req->who, |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
992 | 14, encoded_msg ? encoded_msg : ""); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
993 | |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
994 | yahoo_packet_send_and_free(pkt, yd); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
995 | |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
996 | g_free(encoded_msg); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
997 | |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
998 | g_free(add_req->id); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
999 | g_free(add_req->who); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1000 | g_free(add_req->msg); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1001 | g_free(add_req); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1002 | } |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1003 | |
| 15119 | 1004 | static void |
| 1005 | yahoo_buddy_add_deny_noreason_cb(struct yahoo_add_request *add_req, const char*msg) | |
| 1006 | { | |
| 1007 | yahoo_buddy_add_deny_cb(add_req, NULL); | |
| 1008 | } | |
| 1009 | ||
| 1010 | static void | |
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
19329
diff
changeset
|
1011 | yahoo_buddy_add_deny_reason_cb(gpointer data) { |
|
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
19329
diff
changeset
|
1012 | struct yahoo_add_request *add_req = data; |
| 15884 | 1013 | purple_request_input(add_req->gc, NULL, _("Authorization denied message:"), |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
1014 | NULL, _("No reason given."), TRUE, FALSE, NULL, |
| 15119 | 1015 | _("OK"), G_CALLBACK(yahoo_buddy_add_deny_cb), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
1016 | _("Cancel"), G_CALLBACK(yahoo_buddy_add_deny_noreason_cb), |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
1017 | purple_connection_get_account(add_req->gc), add_req->who, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
1018 | add_req); |
| 15119 | 1019 | } |
| 1020 | ||
|
19411
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1021 | static void yahoo_buddy_auth_req_15(PurpleConnection *gc, struct yahoo_packet *pkt) { |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1022 | struct yahoo_add_request *add_req; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1023 | char *msg = NULL; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1024 | GSList *l = pkt->hash; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1025 | |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1026 | add_req = g_new0(struct yahoo_add_request, 1); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1027 | add_req->gc = gc; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1028 | |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1029 | while (l) { |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1030 | struct yahoo_pair *pair = l->data; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1031 | |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1032 | switch (pair->key) { |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1033 | case 5: |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1034 | add_req->id = g_strdup(pair->value); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1035 | break; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1036 | case 4: |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1037 | add_req->who = g_strdup(pair->value); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1038 | break; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1039 | case 241: |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1040 | add_req->protocol = strtol(pair->value, NULL, 10); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1041 | break; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1042 | case 14: |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1043 | msg = pair->value; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1044 | break; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1045 | } |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1046 | l = l->next; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1047 | } |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1048 | |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1049 | if (add_req->id) { |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1050 | if (msg) |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1051 | add_req->msg = yahoo_string_decode(gc, msg, FALSE); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1052 | |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1053 | /* DONE! this is almost exactly the same as what MSN does, |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1054 | * this should probably be moved to the core. |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1055 | */ |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1056 | purple_account_request_authorization(purple_connection_get_account(gc), add_req->who, add_req->id, |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1057 | NULL, add_req->msg, purple_find_buddy(purple_connection_get_account(gc),add_req->who) != NULL, |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1058 | yahoo_buddy_add_authorize_cb, |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1059 | yahoo_buddy_add_deny_reason_cb, |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1060 | add_req); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1061 | } else { |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1062 | g_free(add_req->id); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1063 | g_free(add_req->who); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1064 | /*g_free(add_req->msg);*/ |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1065 | g_free(add_req); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1066 | } |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1067 | } |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
1068 | |
| 15884 | 1069 | static void yahoo_buddy_added_us(PurpleConnection *gc, struct yahoo_packet *pkt) { |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1070 | struct yahoo_add_request *add_req; |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1071 | char *msg = NULL; |
| 2681 | 1072 | GSList *l = pkt->hash; |
| 1073 | ||
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1074 | add_req = g_new0(struct yahoo_add_request, 1); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1075 | add_req->gc = gc; |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1076 | |
| 2681 | 1077 | while (l) { |
| 1078 | struct yahoo_pair *pair = l->data; | |
| 6686 | 1079 | |
| 1080 | switch (pair->key) { | |
| 1081 | case 1: | |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1082 | add_req->id = g_strdup(pair->value); |
| 6686 | 1083 | break; |
| 1084 | case 3: | |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1085 | add_req->who = g_strdup(pair->value); |
| 6686 | 1086 | break; |
| 1087 | case 15: /* time, for when they add us and we're offline */ | |
| 1088 | break; | |
| 1089 | case 14: | |
| 2681 | 1090 | msg = pair->value; |
| 6686 | 1091 | break; |
| 1092 | } | |
| 2681 | 1093 | l = l->next; |
| 1094 | } | |
| 1095 | ||
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1096 | if (add_req->id) { |
| 7827 | 1097 | if (msg) |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1098 | add_req->msg = yahoo_string_decode(gc, msg, FALSE); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1099 | |
| 15119 | 1100 | /* DONE! this is almost exactly the same as what MSN does, |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1101 | * this should probably be moved to the core. |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1102 | */ |
| 15884 | 1103 | purple_account_request_authorization(purple_connection_get_account(gc), add_req->who, add_req->id, |
| 1104 | NULL, add_req->msg, purple_find_buddy(purple_connection_get_account(gc),add_req->who) != NULL, | |
|
19335
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
19329
diff
changeset
|
1105 | yahoo_buddy_add_authorize_cb, |
|
4613b53d5741
Warning fixes in the aftermath of resiak's authorize_cb and deny_cb type fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
19329
diff
changeset
|
1106 | yahoo_buddy_add_deny_reason_cb, |
| 15119 | 1107 | add_req); |
|
11109
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1108 | } else { |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1109 | g_free(add_req->id); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1110 | g_free(add_req->who); |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1111 | /*g_free(add_req->msg);*/ |
|
d90b1fa34259
[gaim-migrate @ 13161]
Daniel Atallah <datallah@pidgin.im>
parents:
11078
diff
changeset
|
1112 | g_free(add_req); |
| 7827 | 1113 | } |
| 6686 | 1114 | } |
| 1115 | ||
| 15884 | 1116 | static void yahoo_buddy_denied_our_add(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 6686 | 1117 | { |
| 1118 | char *who = NULL; | |
| 1119 | char *msg = NULL; | |
| 1120 | GSList *l = pkt->hash; | |
| 1121 | GString *buf = NULL; | |
| 6784 | 1122 | struct yahoo_data *yd = gc->proto_data; |
| 6686 | 1123 | |
| 1124 | while (l) { | |
| 1125 | struct yahoo_pair *pair = l->data; | |
| 1126 | ||
| 1127 | switch (pair->key) { | |
| 1128 | case 3: | |
| 1129 | who = pair->value; | |
| 1130 | break; | |
| 1131 | case 14: | |
| 1132 | msg = pair->value; | |
| 1133 | break; | |
| 1134 | } | |
| 1135 | l = l->next; | |
| 1136 | } | |
| 1137 | ||
| 1138 | if (who) { | |
| 7827 | 1139 | char *msg2; |
| 6686 | 1140 | buf = g_string_sized_new(0); |
| 7827 | 1141 | if (!msg) { |
| 6686 | 1142 | g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list."), who); |
| 7827 | 1143 | } else { |
| 1144 | msg2 = yahoo_string_decode(gc, msg, FALSE); | |
| 1145 | g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg2); | |
| 1146 | g_free(msg2); | |
| 1147 | } | |
| 15884 | 1148 | purple_notify_info(gc, NULL, _("Add buddy rejected"), buf->str); |
| 6686 | 1149 | g_string_free(buf, TRUE); |
| 6784 | 1150 | g_hash_table_remove(yd->friends, who); |
| 15884 | 1151 | purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL); /* FIXME: make this set not on list status instead */ |
|
11838
55ec7aa916ba
[gaim-migrate @ 14129]
Mark Doliner <markdoliner@pidgin.im>
parents:
11837
diff
changeset
|
1152 | /* TODO: Shouldn't we remove the buddy from our local list? */ |
| 6686 | 1153 | } |
| 1154 | } | |
| 1155 | ||
| 15884 | 1156 | static void yahoo_process_contact(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 6686 | 1157 | { |
| 1158 | switch (pkt->status) { | |
| 1159 | case 1: | |
| 1160 | yahoo_process_status(gc, pkt); | |
| 1161 | return; | |
| 1162 | case 3: | |
| 1163 | yahoo_buddy_added_us(gc, pkt); | |
| 1164 | break; | |
| 1165 | case 7: | |
| 1166 | yahoo_buddy_denied_our_add(gc, pkt); | |
| 1167 | break; | |
| 1168 | default: | |
| 1169 | break; | |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
1170 | } |
| 2681 | 1171 | } |
| 1172 | ||
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1173 | #define OUT_CHARSET "utf-8" |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1174 | |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1175 | static char *yahoo_decode(const char *text) |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1176 | { |
| 9221 | 1177 | char *converted = NULL; |
| 8125 | 1178 | char *n, *new; |
| 1179 | const char *end, *p; | |
| 8616 | 1180 | int i, k; |
| 8125 | 1181 | |
| 7771 | 1182 | n = new = g_malloc(strlen (text) + 1); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
1183 | end = text + strlen(text); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
1184 | |
| 8125 | 1185 | for (p = text; p < end; p++, n++) { |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1186 | if (*p == '\\') { |
| 9064 | 1187 | if (p[1] >= '0' && p[1] <= '7') { |
| 1188 | p += 1; | |
| 1189 | for (i = 0, k = 0; k < 3; k += 1) { | |
| 1190 | char c = p[k]; | |
| 9065 | 1191 | if (c < '0' || c > '7') break; |
| 9064 | 1192 | i *= 8; |
| 1193 | i += c - '0'; | |
| 1194 | } | |
| 1195 | *n = i; | |
| 1196 | p += k - 1; | |
| 1197 | } else { /* bug 959248 */ | |
| 1198 | /* If we see a \ not followed by an octal number, | |
| 1199 | * it means that it is actually a \\ with one \ | |
| 1200 | * already eaten by some unknown function. | |
| 1201 | * This is arguably broken. | |
| 1202 | * | |
| 1203 | * I think wing is wrong here, there is no function | |
| 1204 | * called that I see that could have done it. I guess | |
| 1205 | * it is just really sending single \'s. That's yahoo | |
| 1206 | * for you. | |
| 1207 | */ | |
| 1208 | *n = *p; | |
| 1209 | } | |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1210 | } |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1211 | else |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1212 | *n = *p; |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1213 | } |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1214 | |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1215 | *n = '\0'; |
| 8125 | 1216 | |
| 9221 | 1217 | if (strstr(text, "\033$B")) |
| 1218 | converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL); | |
| 1219 | if (!converted) | |
| 1220 | 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
|
1221 | g_free(new); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1222 | |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1223 | return converted; |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1224 | } |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1225 | |
| 15884 | 1226 | static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 1227 | { |
| 15884 | 1228 | PurpleAccount *account = purple_connection_get_account(gc); |
| 9221 | 1229 | struct yahoo_data *yd = gc->proto_data; |
|
19038
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
1230 | const char *who = NULL; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
1231 | const char *email = NULL; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
1232 | const char *subj = NULL; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
1233 | const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); |
| 2681 | 1234 | int count = 0; |
| 1235 | GSList *l = pkt->hash; | |
| 1236 | ||
| 15884 | 1237 | if (!purple_account_get_check_mail(account)) |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1238 | return; |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1239 | |
| 2681 | 1240 | while (l) { |
| 1241 | struct yahoo_pair *pair = l->data; | |
| 1242 | if (pair->key == 9) | |
| 1243 | count = strtol(pair->value, NULL, 10); | |
| 1244 | else if (pair->key == 43) | |
| 1245 | who = pair->value; | |
| 1246 | else if (pair->key == 42) | |
| 1247 | email = pair->value; | |
| 1248 | else if (pair->key == 18) | |
| 1249 | subj = pair->value; | |
| 1250 | l = l->next; | |
| 1251 | } | |
| 1252 | ||
| 4001 | 1253 | if (who && subj && email && *email) { |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1254 | char *dec_who = yahoo_decode(who); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1255 | char *dec_subj = yahoo_decode(subj); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1256 | char *from = g_strdup_printf("%s (%s)", dec_who, email); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1257 | |
| 15884 | 1258 | purple_notify_email(gc, dec_subj, from, purple_account_get_username(account), |
| 9221 | 1259 | yahoo_mail_url, NULL, NULL); |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1260 | |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1261 | g_free(dec_who); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
1262 | g_free(dec_subj); |
| 2850 | 1263 | g_free(from); |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1264 | } else if (count > 0) { |
| 15884 | 1265 | const char *to = purple_account_get_username(account); |
| 9221 | 1266 | const char *url = yahoo_mail_url; |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1267 | |
| 15884 | 1268 | purple_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1269 | NULL, NULL); |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1270 | } |
| 2681 | 1271 | } |
| 3147 | 1272 | /* This is the y64 alphabet... it's like base64, but has a . and a _ */ |
|
14904
cab89db4854c
[gaim-migrate @ 17611]
Henning Norén <henning.noren@gmail.com>
parents:
14899
diff
changeset
|
1273 | static const char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; |
| 3147 | 1274 | |
| 1275 | /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function | |
| 1276 | * in util.c, but it has a bug I don't feel like finding right now ;) */ | |
|
11897
10853b830964
[gaim-migrate @ 14188]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11838
diff
changeset
|
1277 | static void to_y64(char *out, const unsigned char *in, gsize inlen) |
| 3147 | 1278 | /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ |
| 1279 | { | |
| 1280 | for (; inlen >= 3; inlen -= 3) | |
| 1281 | { | |
| 1282 | *out++ = base64digits[in[0] >> 2]; | |
| 1283 | *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | |
| 1284 | *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; | |
| 1285 | *out++ = base64digits[in[2] & 0x3f]; | |
| 1286 | in += 3; | |
| 1287 | } | |
| 1288 | if (inlen > 0) | |
| 1289 | { | |
| 1290 | unsigned char fragment; | |
| 1291 | ||
| 1292 | *out++ = base64digits[in[0] >> 2]; | |
| 1293 | fragment = (in[0] << 4) & 0x30; | |
| 1294 | if (inlen > 1) | |
| 1295 | fragment |= in[1] >> 4; | |
| 1296 | *out++ = base64digits[fragment]; | |
| 1297 | *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c]; | |
| 1298 | *out++ = '-'; | |
| 1299 | } | |
| 1300 | *out = '\0'; | |
| 1301 | } | |
| 1302 | ||
| 15884 | 1303 | static void yahoo_process_auth_old(PurpleConnection *gc, const char *seed) |
| 6986 | 1304 | { |
| 1305 | struct yahoo_packet *pack; | |
| 15884 | 1306 | PurpleAccount *account = purple_connection_get_account(gc); |
| 1307 | const char *name = purple_normalize(account, purple_account_get_username(account)); | |
| 1308 | const char *pass = purple_connection_get_password(gc); | |
| 6986 | 1309 | struct yahoo_data *yd = gc->proto_data; |
| 1310 | ||
| 1311 | /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly | |
| 1312 | * will soon do so in the rest of the world. | |
| 1313 | * | |
| 1314 | * 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
|
1315 | * bizarre, convoluted, inordinately complicated. It's also no more secure than |
| 6986 | 1316 | * crypt() was. The only purpose this scheme could serve is to prevent third |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1317 | * party clients from connecting to their servers. |
| 6986 | 1318 | * |
| 1319 | * Sorry, Yahoo. | |
| 1320 | */ | |
| 9277 | 1321 | |
| 15884 | 1322 | PurpleCipher *cipher; |
| 1323 | PurpleCipherContext *context; | |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
1324 | guchar digest[16]; |
| 9277 | 1325 | |
| 6986 | 1326 | char *crypt_result; |
| 1327 | char password_hash[25]; | |
| 1328 | char crypt_hash[25]; | |
| 1329 | char *hash_string_p = g_malloc(50 + strlen(name)); | |
| 1330 | char *hash_string_c = g_malloc(50 + strlen(name)); | |
| 9277 | 1331 | |
| 6986 | 1332 | char checksum; |
| 9277 | 1333 | |
| 6986 | 1334 | int sv; |
| 9277 | 1335 | |
| 6986 | 1336 | char result6[25]; |
| 1337 | char result96[25]; | |
| 1338 | ||
| 1339 | sv = seed[15]; | |
| 1340 | sv = sv % 8; | |
| 1341 | ||
| 15884 | 1342 | cipher = purple_ciphers_find_cipher("md5"); |
| 1343 | context = purple_cipher_context_new(cipher, NULL); | |
| 1344 | ||
| 1345 | purple_cipher_context_append(context, (const guchar *)pass, strlen(pass)); | |
| 1346 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1347 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1348 | to_y64(password_hash, digest, 16); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1349 | |
| 9277 | 1350 | crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1351 | |
| 15884 | 1352 | purple_cipher_context_reset(context, NULL); |
| 1353 | purple_cipher_context_append(context, (const guchar *)crypt_result, strlen(crypt_result)); | |
| 1354 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1355 | to_y64(crypt_hash, digest, 16); |
| 6986 | 1356 | |
| 1357 | switch (sv) { | |
| 1358 | case 1: | |
| 1359 | case 6: | |
| 1360 | checksum = seed[seed[9] % 16]; | |
| 1361 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1362 | "%c%s%s%s", checksum, name, seed, password_hash); | |
| 1363 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1364 | "%c%s%s%s", checksum, name, seed, crypt_hash); | |
| 1365 | break; | |
| 1366 | case 2: | |
| 1367 | case 7: | |
| 1368 | checksum = seed[seed[15] % 16]; | |
| 1369 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1370 | "%c%s%s%s", checksum, seed, password_hash, name); | |
| 1371 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1372 | "%c%s%s%s", checksum, seed, crypt_hash, name); | |
| 1373 | break; | |
| 1374 | case 3: | |
| 1375 | checksum = seed[seed[1] % 16]; | |
| 1376 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1377 | "%c%s%s%s", checksum, name, password_hash, seed); | |
| 1378 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1379 | "%c%s%s%s", checksum, name, crypt_hash, seed); | |
| 1380 | break; | |
| 1381 | case 4: | |
| 1382 | checksum = seed[seed[3] % 16]; | |
| 1383 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1384 | "%c%s%s%s", checksum, password_hash, seed, name); | |
| 1385 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1386 | "%c%s%s%s", checksum, crypt_hash, seed, name); | |
| 1387 | break; | |
| 1388 | case 0: | |
| 1389 | case 5: | |
| 1390 | checksum = seed[seed[7] % 16]; | |
| 1391 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1392 | "%c%s%s%s", checksum, password_hash, name, seed); | |
| 1393 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1394 | "%c%s%s%s", checksum, crypt_hash, name, seed); | |
| 1395 | break; | |
| 1396 | } | |
| 9277 | 1397 | |
| 15884 | 1398 | purple_cipher_context_reset(context, NULL); |
| 1399 | purple_cipher_context_append(context, (const guchar *)hash_string_p, strlen(hash_string_p)); | |
| 1400 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1401 | to_y64(result6, digest, 16); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1402 | |
| 15884 | 1403 | purple_cipher_context_reset(context, NULL); |
| 1404 | purple_cipher_context_append(context, (const guchar *)hash_string_c, strlen(hash_string_c)); | |
| 1405 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); | |
| 1406 | purple_cipher_context_destroy(context); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1407 | to_y64(result96, digest, 16); |
| 6986 | 1408 | |
| 1409 | pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 1410 | yahoo_packet_hash(pack, "ssss", 0, name, 6, result6, 96, result96, 1, name); |
| 10392 | 1411 | yahoo_packet_send_and_free(pack, yd); |
| 9277 | 1412 | |
| 6986 | 1413 | g_free(hash_string_p); |
| 1414 | g_free(hash_string_c); | |
| 1415 | } | |
| 1416 | ||
| 6998 | 1417 | /* I'm dishing out some uber-mad props to Cerulean Studios for cracking this |
| 1418 | * and sending the fix! Thanks guys. */ | |
| 1419 | ||
| 15884 | 1420 | static void yahoo_process_auth_new(PurpleConnection *gc, const char *seed) |
| 6986 | 1421 | { |
| 1422 | struct yahoo_packet *pack = NULL; | |
| 15884 | 1423 | PurpleAccount *account = purple_connection_get_account(gc); |
| 1424 | const char *name = purple_normalize(account, purple_account_get_username(account)); | |
| 1425 | const char *pass = purple_connection_get_password(gc); | |
|
14108
8f4414c9827b
[gaim-migrate @ 16658]
Daniel Atallah <datallah@pidgin.im>
parents:
14030
diff
changeset
|
1426 | char *enc_pass; |
| 6986 | 1427 | struct yahoo_data *yd = gc->proto_data; |
| 9277 | 1428 | |
| 15884 | 1429 | PurpleCipher *md5_cipher; |
| 1430 | PurpleCipherContext *md5_ctx; | |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
1431 | guchar md5_digest[16]; |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1432 | |
| 15884 | 1433 | PurpleCipher *sha1_cipher; |
| 1434 | PurpleCipherContext *sha1_ctx1; | |
| 1435 | PurpleCipherContext *sha1_ctx2; | |
| 9277 | 1436 | |
| 8349 | 1437 | char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; |
| 1438 | char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop"; | |
| 1439 | ||
| 1440 | char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5"; | |
| 1441 | char *operand_lookup = "+|&%/*^-"; | |
| 1442 | char *delimit_lookup = ",;"; | |
| 1443 | ||
| 1444 | char *password_hash = (char *)g_malloc(25); | |
| 1445 | char *crypt_hash = (char *)g_malloc(25); | |
| 1446 | char *crypt_result = NULL; | |
| 1447 | ||
|
11144
c6fd3a852568
[gaim-migrate @ 13208]
Mark Doliner <markdoliner@pidgin.im>
parents:
11137
diff
changeset
|
1448 | unsigned char pass_hash_xor1[64]; |
|
c6fd3a852568
[gaim-migrate @ 13208]
Mark Doliner <markdoliner@pidgin.im>
parents:
11137
diff
changeset
|
1449 | unsigned char pass_hash_xor2[64]; |
|
c6fd3a852568
[gaim-migrate @ 13208]
Mark Doliner <markdoliner@pidgin.im>
parents:
11137
diff
changeset
|
1450 | unsigned char crypt_hash_xor1[64]; |
|
c6fd3a852568
[gaim-migrate @ 13208]
Mark Doliner <markdoliner@pidgin.im>
parents:
11137
diff
changeset
|
1451 | unsigned char crypt_hash_xor2[64]; |
| 8349 | 1452 | char resp_6[100]; |
| 1453 | char resp_96[100]; | |
| 1454 | ||
| 1455 | unsigned char digest1[20]; | |
| 1456 | unsigned char digest2[20]; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1457 | unsigned char comparison_src[20]; |
| 8349 | 1458 | unsigned char magic_key_char[4]; |
|
11144
c6fd3a852568
[gaim-migrate @ 13208]
Mark Doliner <markdoliner@pidgin.im>
parents:
11137
diff
changeset
|
1459 | const char *magic_ptr; |
| 8349 | 1460 | |
| 1461 | unsigned int magic[64]; | |
| 1462 | unsigned int magic_work = 0; | |
| 1463 | unsigned int magic_4 = 0; | |
| 1464 | ||
| 1465 | int x; | |
| 1466 | int y; | |
| 1467 | int cnt = 0; | |
| 1468 | int magic_cnt = 0; | |
| 1469 | int magic_len; | |
| 1470 | ||
| 1471 | memset(password_hash, 0, 25); | |
| 1472 | memset(crypt_hash, 0, 25); | |
| 6986 | 1473 | memset(&pass_hash_xor1, 0, 64); |
| 1474 | memset(&pass_hash_xor2, 0, 64); | |
| 1475 | memset(&crypt_hash_xor1, 0, 64); | |
| 1476 | memset(&crypt_hash_xor2, 0, 64); | |
| 1477 | memset(&digest1, 0, 20); | |
| 1478 | memset(&digest2, 0, 20); | |
| 1479 | memset(&magic, 0, 64); | |
| 1480 | memset(&resp_6, 0, 100); | |
| 1481 | memset(&resp_96, 0, 100); | |
| 1482 | memset(&magic_key_char, 0, 4); | |
| 8349 | 1483 | memset(&comparison_src, 0, 20); |
| 6986 | 1484 | |
| 15884 | 1485 | md5_cipher = purple_ciphers_find_cipher("md5"); |
| 1486 | md5_ctx = purple_cipher_context_new(md5_cipher, NULL); | |
| 1487 | ||
| 1488 | sha1_cipher = purple_ciphers_find_cipher("sha1"); | |
| 1489 | sha1_ctx1 = purple_cipher_context_new(sha1_cipher, NULL); | |
| 1490 | sha1_ctx2 = purple_cipher_context_new(sha1_cipher, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1491 | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1492 | /* |
| 8349 | 1493 | * Magic: Phase 1. Generate what seems to be a 30 byte value (could change if base64 |
| 1494 | * ends up differently? I don't remember and I'm tired, so use a 64 byte buffer. | |
| 6986 | 1495 | */ |
| 9277 | 1496 | |
| 6986 | 1497 | magic_ptr = seed; |
| 8375 | 1498 | |
| 6986 | 1499 | while (*magic_ptr != (int)NULL) { |
| 8349 | 1500 | char *loc; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1501 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1502 | /* Ignore parentheses. */ |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1503 | |
| 6986 | 1504 | if (*magic_ptr == '(' || *magic_ptr == ')') { |
| 1505 | magic_ptr++; | |
| 1506 | continue; | |
| 1507 | } | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1508 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1509 | /* Characters and digits verify against the challenge lookup. */ |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1510 | |
| 6986 | 1511 | if (isalpha(*magic_ptr) || isdigit(*magic_ptr)) { |
| 1512 | loc = strchr(challenge_lookup, *magic_ptr); | |
| 1513 | if (!loc) { | |
| 8349 | 1514 | /* SME XXX Error - disconnect here */ |
| 6986 | 1515 | } |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1516 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1517 | /* Get offset into lookup table and shl 3. */ |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1518 | |
| 6986 | 1519 | magic_work = loc - challenge_lookup; |
| 1520 | magic_work <<= 3; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1521 | |
| 6986 | 1522 | magic_ptr++; |
| 1523 | continue; | |
| 1524 | } else { | |
| 8349 | 1525 | unsigned int local_store; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1526 | |
| 6986 | 1527 | loc = strchr(operand_lookup, *magic_ptr); |
| 1528 | if (!loc) { | |
| 8349 | 1529 | /* SME XXX Disconnect */ |
| 6986 | 1530 | } |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1531 | |
| 6986 | 1532 | local_store = loc - operand_lookup; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1533 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1534 | /* Oops; how did this happen? */ |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1535 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1536 | if (magic_cnt >= 64) |
| 6986 | 1537 | break; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1538 | |
| 6986 | 1539 | magic[magic_cnt++] = magic_work | local_store; |
| 1540 | magic_ptr++; | |
| 1541 | continue; | |
| 1542 | } | |
| 8349 | 1543 | } |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1544 | |
| 6986 | 1545 | magic_len = magic_cnt; |
| 1546 | magic_cnt = 0; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1547 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1548 | /* Magic: Phase 2. Take generated magic value and sprinkle fairy |
|
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1549 | * dust on the values. |
| 8349 | 1550 | */ |
| 1551 | ||
| 6986 | 1552 | for (magic_cnt = magic_len-2; magic_cnt >= 0; magic_cnt--) { |
| 8349 | 1553 | unsigned char byte1; |
| 1554 | unsigned char byte2; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1555 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1556 | /* Bad. Abort. */ |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1557 | |
| 8349 | 1558 | if ((magic_cnt + 1 > magic_len) || (magic_cnt > magic_len)) |
| 6986 | 1559 | break; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1560 | |
| 6986 | 1561 | byte1 = magic[magic_cnt]; |
| 1562 | byte2 = magic[magic_cnt+1]; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1563 | |
| 6986 | 1564 | byte1 *= 0xcd; |
| 1565 | byte1 ^= byte2; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1566 | |
| 6986 | 1567 | magic[magic_cnt+1] = byte1; |
| 8349 | 1568 | } |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1569 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1570 | /* |
| 8349 | 1571 | * Magic: Phase 3. This computes 20 bytes. The first 4 bytes are used as our magic |
| 1572 | * key (and may be changed later); the next 16 bytes are an MD5 sum of the magic key | |
| 1573 | * plus 3 bytes. The 3 bytes are found by looping, and they represent the offsets | |
| 1574 | * into particular functions we'll later call to potentially alter the magic key. | |
| 1575 | * | |
| 1576 | * %-) | |
| 1577 | */ | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1578 | |
| 8349 | 1579 | magic_cnt = 1; |
| 1580 | x = 0; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1581 | |
| 8349 | 1582 | do { |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1583 | unsigned int bl = 0; |
| 8349 | 1584 | unsigned int cl = magic[magic_cnt++]; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1585 | |
| 8349 | 1586 | if (magic_cnt >= magic_len) |
| 1587 | break; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1588 | |
| 8349 | 1589 | if (cl > 0x7F) { |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1590 | if (cl < 0xe0) |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1591 | bl = cl = (cl & 0x1f) << 6; |
| 8349 | 1592 | else { |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1593 | bl = magic[magic_cnt++]; |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1594 | cl = (cl & 0x0f) << 6; |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1595 | bl = ((bl & 0x3f) + cl) << 6; |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1596 | } |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1597 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1598 | cl = magic[magic_cnt++]; |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1599 | bl = (cl & 0x3f) + bl; |
| 8349 | 1600 | } else |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1601 | bl = cl; |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1602 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1603 | comparison_src[x++] = (bl & 0xff00) >> 8; |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1604 | comparison_src[x++] = bl & 0xff; |
| 8349 | 1605 | } while (x < 20); |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1606 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1607 | /* First four bytes are magic key. */ |
| 8349 | 1608 | memcpy(&magic_key_char[0], comparison_src, 4); |
|
8482
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1609 | magic_4 = magic_key_char[0] | (magic_key_char[1]<<8) | (magic_key_char[2]<<16) | (magic_key_char[3]<<24); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1610 | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1611 | /* |
| 8349 | 1612 | * Magic: Phase 4. Determine what function to use later by getting outside/inside |
| 1613 | * loop values until we match our previous buffer. | |
| 1614 | */ | |
| 1615 | for (x = 0; x < 65535; x++) { | |
| 1616 | int leave = 0; | |
| 1617 | ||
| 1618 | for (y = 0; y < 5; y++) { | |
| 1619 | unsigned char test[3]; | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1620 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1621 | /* Calculate buffer. */ |
| 8349 | 1622 | test[0] = x; |
| 1623 | test[1] = x >> 8; | |
| 1624 | test[2] = y; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1625 | |
| 15884 | 1626 | purple_cipher_context_reset(md5_ctx, NULL); |
| 1627 | purple_cipher_context_append(md5_ctx, magic_key_char, 4); | |
| 1628 | purple_cipher_context_append(md5_ctx, test, 3); | |
| 1629 | purple_cipher_context_digest(md5_ctx, sizeof(md5_digest), | |
| 10687 | 1630 | md5_digest, NULL); |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1631 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1632 | if (!memcmp(md5_digest, comparison_src+4, 16)) { |
| 8349 | 1633 | leave = 1; |
| 1634 | break; | |
| 1635 | } | |
| 1636 | } | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1637 | |
| 8349 | 1638 | if (leave == 1) |
| 1639 | break; | |
| 6986 | 1640 | } |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1641 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1642 | /* If y != 0, we need some help. */ |
| 8349 | 1643 | if (y != 0) { |
| 1644 | unsigned int updated_key; | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1645 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1646 | /* Update magic stuff. |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1647 | * Call it twice because Yahoo's encryption is super bad ass. |
| 8349 | 1648 | */ |
| 1649 | updated_key = yahoo_auth_finalCountdown(magic_4, 0x60, y, x); | |
| 1650 | updated_key = yahoo_auth_finalCountdown(updated_key, 0x60, y, x); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1651 | |
|
8482
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1652 | magic_key_char[0] = updated_key & 0xff; |
|
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1653 | magic_key_char[1] = (updated_key >> 8) & 0xff; |
|
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1654 | magic_key_char[2] = (updated_key >> 16) & 0xff; |
|
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1655 | magic_key_char[3] = (updated_key >> 24) & 0xff; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1656 | } |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1657 | |
|
14108
8f4414c9827b
[gaim-migrate @ 16658]
Daniel Atallah <datallah@pidgin.im>
parents:
14030
diff
changeset
|
1658 | enc_pass = yahoo_string_encode(gc, pass, NULL); |
|
8f4414c9827b
[gaim-migrate @ 16658]
Daniel Atallah <datallah@pidgin.im>
parents:
14030
diff
changeset
|
1659 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1660 | /* Get password and crypt hashes as per usual. */ |
| 15884 | 1661 | purple_cipher_context_reset(md5_ctx, NULL); |
| 1662 | purple_cipher_context_append(md5_ctx, (const guchar *)enc_pass, strlen(enc_pass)); | |
| 1663 | purple_cipher_context_digest(md5_ctx, sizeof(md5_digest), | |
| 10687 | 1664 | md5_digest, NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1665 | to_y64(password_hash, md5_digest, 16); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1666 | |
|
14108
8f4414c9827b
[gaim-migrate @ 16658]
Daniel Atallah <datallah@pidgin.im>
parents:
14030
diff
changeset
|
1667 | crypt_result = yahoo_crypt(enc_pass, "$1$_2S43d5f$"); |
|
8f4414c9827b
[gaim-migrate @ 16658]
Daniel Atallah <datallah@pidgin.im>
parents:
14030
diff
changeset
|
1668 | |
|
8f4414c9827b
[gaim-migrate @ 16658]
Daniel Atallah <datallah@pidgin.im>
parents:
14030
diff
changeset
|
1669 | g_free(enc_pass); |
|
8f4414c9827b
[gaim-migrate @ 16658]
Daniel Atallah <datallah@pidgin.im>
parents:
14030
diff
changeset
|
1670 | enc_pass = NULL; |
|
8f4414c9827b
[gaim-migrate @ 16658]
Daniel Atallah <datallah@pidgin.im>
parents:
14030
diff
changeset
|
1671 | |
| 15884 | 1672 | purple_cipher_context_reset(md5_ctx, NULL); |
| 1673 | purple_cipher_context_append(md5_ctx, (const guchar *)crypt_result, strlen(crypt_result)); | |
| 1674 | purple_cipher_context_digest(md5_ctx, sizeof(md5_digest), | |
| 10687 | 1675 | md5_digest, NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1676 | to_y64(crypt_hash, md5_digest, 16); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1677 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1678 | /* Our first authentication response is based off of the password hash. */ |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1679 | for (x = 0; x < (int)strlen(password_hash); x++) |
| 6986 | 1680 | pass_hash_xor1[cnt++] = password_hash[x] ^ 0x36; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1681 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1682 | if (cnt < 64) |
| 6986 | 1683 | memset(&(pass_hash_xor1[cnt]), 0x36, 64-cnt); |
| 8349 | 1684 | |
| 6986 | 1685 | cnt = 0; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1686 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1687 | for (x = 0; x < (int)strlen(password_hash); x++) |
| 6986 | 1688 | pass_hash_xor2[cnt++] = password_hash[x] ^ 0x5c; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1689 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1690 | if (cnt < 64) |
| 6986 | 1691 | memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt); |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1692 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1693 | /* |
| 8349 | 1694 | * The first context gets the password hash XORed with 0x36 plus a magic value |
| 1695 | * which we previously extrapolated from our challenge. | |
| 1696 | */ | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1697 | |
| 15884 | 1698 | purple_cipher_context_append(sha1_ctx1, pass_hash_xor1, 64); |
| 9382 | 1699 | if (y >= 3) |
| 15884 | 1700 | purple_cipher_context_set_option(sha1_ctx1, "sizeLo", GINT_TO_POINTER(0x1ff)); |
| 1701 | purple_cipher_context_append(sha1_ctx1, magic_key_char, 4); | |
| 1702 | purple_cipher_context_digest(sha1_ctx1, sizeof(digest1), digest1, NULL); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1703 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1704 | /* |
| 8349 | 1705 | * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest |
| 1706 | * of the first context. | |
| 1707 | */ | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1708 | |
| 15884 | 1709 | purple_cipher_context_append(sha1_ctx2, pass_hash_xor2, 64); |
| 1710 | purple_cipher_context_append(sha1_ctx2, digest1, 20); | |
| 1711 | purple_cipher_context_digest(sha1_ctx2, sizeof(digest2), digest2, NULL); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1712 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1713 | /* |
| 8349 | 1714 | * Now that we have digest2, use it to fetch characters from an alphabet to construct |
| 1715 | * our first authentication response. | |
| 1716 | */ | |
| 1717 | ||
| 6986 | 1718 | for (x = 0; x < 20; x += 2) { |
| 8349 | 1719 | unsigned int val = 0; |
| 1720 | unsigned int lookup = 0; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1721 | |
| 8349 | 1722 | char byte[6]; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1723 | |
| 6986 | 1724 | memset(&byte, 0, 6); |
| 8349 | 1725 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1726 | /* First two bytes of digest stuffed together. */ |
| 9277 | 1727 | |
| 6986 | 1728 | val = digest2[x]; |
| 1729 | val <<= 8; | |
| 1730 | val += digest2[x+1]; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1731 | |
| 6986 | 1732 | lookup = (val >> 0x0b); |
| 1733 | lookup &= 0x1f; | |
| 1734 | if (lookup >= strlen(alphabet1)) | |
| 1735 | break; | |
| 1736 | sprintf(byte, "%c", alphabet1[lookup]); | |
| 1737 | strcat(resp_6, byte); | |
| 1738 | strcat(resp_6, "="); | |
| 8349 | 1739 | |
| 6986 | 1740 | lookup = (val >> 0x06); |
| 1741 | lookup &= 0x1f; | |
| 1742 | if (lookup >= strlen(alphabet2)) | |
| 1743 | break; | |
| 1744 | sprintf(byte, "%c", alphabet2[lookup]); | |
| 1745 | strcat(resp_6, byte); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1746 | |
| 6986 | 1747 | lookup = (val >> 0x01); |
| 1748 | lookup &= 0x1f; | |
| 1749 | if (lookup >= strlen(alphabet2)) | |
| 1750 | break; | |
| 1751 | sprintf(byte, "%c", alphabet2[lookup]); | |
| 1752 | strcat(resp_6, byte); | |
| 8349 | 1753 | |
| 6986 | 1754 | lookup = (val & 0x01); |
| 1755 | if (lookup >= strlen(delimit_lookup)) | |
| 1756 | break; | |
| 1757 | sprintf(byte, "%c", delimit_lookup[lookup]); | |
| 1758 | strcat(resp_6, byte); | |
| 1759 | } | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1760 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1761 | /* Our second authentication response is based off of the crypto hash. */ |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1762 | |
| 6986 | 1763 | cnt = 0; |
| 1764 | memset(&digest1, 0, 20); | |
| 1765 | memset(&digest2, 0, 20); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1766 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1767 | for (x = 0; x < (int)strlen(crypt_hash); x++) |
| 6986 | 1768 | crypt_hash_xor1[cnt++] = crypt_hash[x] ^ 0x36; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1769 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1770 | if (cnt < 64) |
| 6986 | 1771 | memset(&(crypt_hash_xor1[cnt]), 0x36, 64-cnt); |
| 8349 | 1772 | |
| 6986 | 1773 | cnt = 0; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1774 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1775 | for (x = 0; x < (int)strlen(crypt_hash); x++) |
| 6986 | 1776 | crypt_hash_xor2[cnt++] = crypt_hash[x] ^ 0x5c; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1777 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1778 | if (cnt < 64) |
| 6986 | 1779 | memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt); |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1780 | |
| 15884 | 1781 | purple_cipher_context_reset(sha1_ctx1, NULL); |
| 1782 | purple_cipher_context_reset(sha1_ctx2, NULL); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1783 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1784 | /* |
| 8349 | 1785 | * The first context gets the password hash XORed with 0x36 plus a magic value |
| 1786 | * which we previously extrapolated from our challenge. | |
| 1787 | */ | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1788 | |
| 15884 | 1789 | purple_cipher_context_append(sha1_ctx1, crypt_hash_xor1, 64); |
| 10687 | 1790 | if (y >= 3) { |
| 15884 | 1791 | purple_cipher_context_set_option(sha1_ctx1, "sizeLo", |
| 10687 | 1792 | GINT_TO_POINTER(0x1ff)); |
| 1793 | } | |
| 15884 | 1794 | purple_cipher_context_append(sha1_ctx1, magic_key_char, 4); |
| 1795 | purple_cipher_context_digest(sha1_ctx1, sizeof(digest1), digest1, NULL); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1796 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1797 | /* |
| 8349 | 1798 | * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest |
| 1799 | * of the first context. | |
| 1800 | */ | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1801 | |
| 15884 | 1802 | purple_cipher_context_append(sha1_ctx2, crypt_hash_xor2, 64); |
| 1803 | purple_cipher_context_append(sha1_ctx2, digest1, 20); | |
| 1804 | purple_cipher_context_digest(sha1_ctx2, sizeof(digest2), digest2, NULL); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1805 | |
|
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1806 | /* |
| 8349 | 1807 | * Now that we have digest2, use it to fetch characters from an alphabet to construct |
| 1808 | * our first authentication response. | |
| 1809 | */ | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1810 | |
| 6986 | 1811 | for (x = 0; x < 20; x += 2) { |
| 8349 | 1812 | unsigned int val = 0; |
| 1813 | unsigned int lookup = 0; | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1814 | |
| 8349 | 1815 | char byte[6]; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1816 | |
| 6986 | 1817 | memset(&byte, 0, 6); |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1818 | |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
1819 | /* First two bytes of digest stuffed together. */ |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1820 | |
| 6986 | 1821 | val = digest2[x]; |
| 1822 | val <<= 8; | |
| 1823 | val += digest2[x+1]; | |
| 8349 | 1824 | |
| 6986 | 1825 | lookup = (val >> 0x0b); |
| 1826 | lookup &= 0x1f; | |
| 1827 | if (lookup >= strlen(alphabet1)) | |
| 1828 | break; | |
| 1829 | sprintf(byte, "%c", alphabet1[lookup]); | |
| 1830 | strcat(resp_96, byte); | |
| 1831 | strcat(resp_96, "="); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1832 | |
| 6986 | 1833 | lookup = (val >> 0x06); |
| 1834 | lookup &= 0x1f; | |
| 1835 | if (lookup >= strlen(alphabet2)) | |
| 1836 | break; | |
| 1837 | sprintf(byte, "%c", alphabet2[lookup]); | |
| 1838 | strcat(resp_96, byte); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1839 | |
| 6986 | 1840 | lookup = (val >> 0x01); |
| 1841 | lookup &= 0x1f; | |
| 1842 | if (lookup >= strlen(alphabet2)) | |
| 1843 | break; | |
| 1844 | sprintf(byte, "%c", alphabet2[lookup]); | |
| 1845 | strcat(resp_96, byte); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1846 | |
| 6986 | 1847 | lookup = (val & 0x01); |
| 1848 | if (lookup >= strlen(delimit_lookup)) | |
| 1849 | break; | |
| 1850 | sprintf(byte, "%c", delimit_lookup[lookup]); | |
| 1851 | strcat(resp_96, byte); | |
| 1852 | } | |
| 15884 | 1853 | purple_debug_info("yahoo", "yahoo status: %d\n", yd->current_status); |
| 10400 | 1854 | pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->current_status, 0); |
| 10394 | 1855 | yahoo_packet_hash(pack, "sssss", 0, name, 6, resp_6, 96, resp_96, 1, |
| 1856 | name, 135, "6,0,0,1710"); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1857 | if (yd->picture_checksum) |
| 10394 | 1858 | yahoo_packet_hash_int(pack, 192, yd->picture_checksum); |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
1859 | |
| 10392 | 1860 | yahoo_packet_send_and_free(pack, yd); |
| 6986 | 1861 | |
| 15884 | 1862 | purple_cipher_context_destroy(md5_ctx); |
| 1863 | purple_cipher_context_destroy(sha1_ctx1); | |
| 1864 | purple_cipher_context_destroy(sha1_ctx2); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1865 | |
| 7424 | 1866 | g_free(password_hash); |
| 1867 | g_free(crypt_hash); | |
| 6986 | 1868 | } |
| 1869 | ||
| 15884 | 1870 | static void yahoo_process_auth(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 3147 | 1871 | { |
| 1872 | char *seed = NULL; | |
| 1873 | char *sn = NULL; | |
| 1874 | GSList *l = pkt->hash; | |
| 7010 | 1875 | int m = 0; |
| 9277 | 1876 | gchar *buf; |
| 1877 | ||
| 3147 | 1878 | while (l) { |
| 1879 | struct yahoo_pair *pair = l->data; | |
| 1880 | if (pair->key == 94) | |
| 1881 | seed = pair->value; | |
| 1882 | if (pair->key == 1) | |
| 1883 | sn = pair->value; | |
| 6986 | 1884 | if (pair->key == 13) |
| 1885 | m = atoi(pair->value); | |
| 3147 | 1886 | l = l->next; |
| 1887 | } | |
| 9277 | 1888 | |
| 3147 | 1889 | if (seed) { |
| 6986 | 1890 | switch (m) { |
| 1891 | case 0: | |
| 1892 | yahoo_process_auth_old(gc, seed); | |
| 1893 | break; | |
| 3147 | 1894 | case 1: |
| 14320 | 1895 | case 2: /* This case seems to work, could probably use testing */ |
| 6986 | 1896 | yahoo_process_auth_new(gc, seed); |
| 3147 | 1897 | break; |
| 6986 | 1898 | default: |
|
7043
b79933739678
[gaim-migrate @ 7606]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7015
diff
changeset
|
1899 | buf = g_strdup_printf(_("The Yahoo server has requested the use of an unrecognized " |
|
15444
b793ef258d23
I think this changes every user-visible string that contains 'Gaim.' We probably want the UI to be able
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
1900 | "authentication method. You will probably not be able " |
| 15884 | 1901 | "to successfully sign on to Yahoo. Check %s for updates."), PURPLE_WEBSITE); |
| 1902 | purple_notify_error(gc, "", _("Failed Yahoo! Authentication"), | |
|
7043
b79933739678
[gaim-migrate @ 7606]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7015
diff
changeset
|
1903 | buf); |
|
b79933739678
[gaim-migrate @ 7606]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7015
diff
changeset
|
1904 | g_free(buf); |
| 6986 | 1905 | yahoo_process_auth_new(gc, seed); /* Can't hurt to try it anyway. */ |
| 3147 | 1906 | } |
| 1907 | } | |
| 1908 | } | |
| 2681 | 1909 | |
| 15884 | 1910 | static void ignore_buddy(PurpleBuddy *buddy) { |
| 1911 | PurpleGroup *group; | |
| 1912 | PurpleAccount *account; | |
| 6760 | 1913 | gchar *name; |
| 1914 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1915 | if (!buddy) |
| 6792 | 1916 | return; |
| 6760 | 1917 | |
| 15884 | 1918 | group = purple_buddy_get_group(buddy); |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1919 | name = g_strdup(buddy->name); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1920 | account = buddy->account; |
| 6760 | 1921 | |
| 15884 | 1922 | purple_debug(PURPLE_DEBUG_INFO, "blist", |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1923 | "Removing '%s' from buddy list.\n", buddy->name); |
| 15884 | 1924 | purple_account_remove_buddy(account, buddy, group); |
| 1925 | purple_blist_remove_buddy(buddy); | |
| 6760 | 1926 | |
| 6792 | 1927 | serv_add_deny(account->gc, name); |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1928 | |
| 6760 | 1929 | g_free(name); |
| 1930 | } | |
| 1931 | ||
| 15884 | 1932 | static void keep_buddy(PurpleBuddy *b) { |
| 1933 | purple_privacy_deny_remove(b->account, b->name, 1); | |
| 6760 | 1934 | } |
| 1935 | ||
| 15884 | 1936 | static void yahoo_process_ignore(PurpleConnection *gc, struct yahoo_packet *pkt) { |
| 1937 | PurpleBuddy *b; | |
| 6760 | 1938 | GSList *l; |
| 1939 | gchar *who = NULL; | |
| 1940 | gchar *sn = NULL; | |
| 1941 | gchar buf[BUF_LONG]; | |
| 1942 | gint ignore = 0; | |
| 1943 | gint status = 0; | |
| 1944 | ||
| 1945 | for (l = pkt->hash; l; l = l->next) { | |
| 1946 | struct yahoo_pair *pair = l->data; | |
| 1947 | switch (pair->key) { | |
| 1948 | case 0: | |
| 1949 | who = pair->value; | |
| 1950 | break; | |
| 1951 | case 1: | |
| 1952 | sn = pair->value; | |
| 1953 | break; | |
| 1954 | case 13: | |
| 1955 | ignore = strtol(pair->value, NULL, 10); | |
| 1956 | break; | |
| 1957 | case 66: | |
| 1958 | status = strtol(pair->value, NULL, 10); | |
| 1959 | break; | |
| 1960 | default: | |
| 1961 | break; | |
| 1962 | } | |
| 1963 | } | |
| 1964 | ||
| 1965 | switch (status) { | |
| 1966 | case 12: | |
| 15884 | 1967 | b = purple_find_buddy(gc->account, who); |
| 6760 | 1968 | g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " |
| 1969 | "user is on your buddy list. Clicking \"Yes\" " | |
| 1970 | "will remove and ignore the buddy."), who); | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
1971 | purple_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
1972 | gc->account, who, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
1973 | b, |
| 6760 | 1974 | G_CALLBACK(ignore_buddy), |
| 1975 | G_CALLBACK(keep_buddy)); | |
| 1976 | break; | |
| 1977 | case 2: | |
| 1978 | case 3: | |
| 1979 | case 0: | |
| 1980 | default: | |
| 1981 | break; | |
| 1982 | } | |
| 1983 | } | |
| 1984 | ||
| 15884 | 1985 | static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 6761 | 1986 | { |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
1987 | #ifdef TRY_WEBMESSENGER_LOGIN |
| 9410 | 1988 | struct yahoo_data *yd = gc->proto_data; |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
1989 | #endif |
| 6761 | 1990 | GSList *l = pkt->hash; |
| 1991 | int err = 0; | |
| 1992 | char *msg; | |
| 7865 | 1993 | char *url = NULL; |
| 1994 | char *fullmsg; | |
|
18946
36989fd1718f
make us forget the password if the user didn't choose save password
Ka-Hing Cheung <khc@pidgin.im>
parents:
18940
diff
changeset
|
1995 | PurpleAccount *account = gc->account; |
| 6761 | 1996 | |
| 1997 | while (l) { | |
| 1998 | struct yahoo_pair *pair = l->data; | |
| 1999 | ||
| 2000 | if (pair->key == 66) | |
| 2001 | err = strtol(pair->value, NULL, 10); | |
| 7865 | 2002 | if (pair->key == 20) |
| 2003 | url = pair->value; | |
| 6761 | 2004 | |
| 2005 | l = l->next; | |
| 2006 | } | |
| 2007 | ||
| 2008 | switch (err) { | |
| 2009 | case 3: | |
|
15062
78e3c1c8c4f4
[gaim-migrate @ 17779]
Richard Laager <rlaager@pidgin.im>
parents:
14904
diff
changeset
|
2010 | msg = g_strdup(_("Invalid screen name.")); |
| 6761 | 2011 | break; |
| 2012 | case 13: | |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2013 | #ifdef TRY_WEBMESSENGER_LOGIN |
| 9410 | 2014 | if (!yd->wm) { |
| 15884 | 2015 | PurpleUtilFetchUrlData *url_data; |
| 9410 | 2016 | yd->wm = TRUE; |
| 2017 | if (yd->fd >= 0) | |
| 2018 | close(yd->fd); | |
| 2019 | if (gc->inpa) | |
| 15884 | 2020 | purple_input_remove(gc->inpa); |
| 2021 | url_data = purple_util_fetch_url(WEBMESSENGER_URL, TRUE, | |
| 2022 | "Purple/" VERSION, FALSE, yahoo_login_page_cb, gc); | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2023 | if (url_data != NULL) |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2024 | yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
| 9410 | 2025 | return; |
| 2026 | } | |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2027 | #endif |
|
18946
36989fd1718f
make us forget the password if the user didn't choose save password
Ka-Hing Cheung <khc@pidgin.im>
parents:
18940
diff
changeset
|
2028 | if (!purple_account_get_remember_password(account)) |
|
36989fd1718f
make us forget the password if the user didn't choose save password
Ka-Hing Cheung <khc@pidgin.im>
parents:
18940
diff
changeset
|
2029 | purple_account_set_password(account, NULL); |
|
36989fd1718f
make us forget the password if the user didn't choose save password
Ka-Hing Cheung <khc@pidgin.im>
parents:
18940
diff
changeset
|
2030 | |
| 7865 | 2031 | msg = g_strdup(_("Incorrect password.")); |
| 2032 | break; | |
| 2033 | case 14: | |
| 9280 | 2034 | msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website.")); |
| 6761 | 2035 | break; |
| 2036 | default: | |
| 9280 | 2037 | msg = g_strdup_printf(_("Unknown error number %d. Logging into the Yahoo! website may fix this."), err); |
| 6761 | 2038 | } |
| 7865 | 2039 | |
| 2040 | if (url) | |
| 2041 | fullmsg = g_strdup_printf("%s\n%s", msg, url); | |
| 2042 | else | |
| 2043 | fullmsg = g_strdup(msg); | |
| 2044 | ||
| 9280 | 2045 | gc->wants_to_die = TRUE; |
| 15884 | 2046 | purple_connection_error(gc, fullmsg); |
| 7865 | 2047 | g_free(msg); |
| 2048 | g_free(fullmsg); | |
| 6761 | 2049 | } |
| 2050 | ||
| 15884 | 2051 | static void yahoo_process_addbuddy(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 6840 | 2052 | { |
| 2053 | int err = 0; | |
| 2054 | char *who = NULL; | |
| 2055 | char *group = NULL; | |
| 7827 | 2056 | char *decoded_group; |
| 6840 | 2057 | char *buf; |
| 9278 | 2058 | YahooFriend *f; |
| 6840 | 2059 | GSList *l = pkt->hash; |
| 2060 | ||
| 2061 | while (l) { | |
| 2062 | struct yahoo_pair *pair = l->data; | |
| 2063 | ||
| 2064 | switch (pair->key) { | |
| 2065 | case 66: | |
| 2066 | err = strtol(pair->value, NULL, 10); | |
| 2067 | break; | |
| 2068 | case 7: | |
| 2069 | who = pair->value; | |
| 2070 | break; | |
| 2071 | case 65: | |
| 2072 | group = pair->value; | |
| 2073 | break; | |
| 2074 | } | |
| 2075 | ||
| 2076 | l = l->next; | |
| 2077 | } | |
| 2078 | ||
| 2079 | if (!who) | |
| 2080 | return; | |
| 2081 | if (!group) | |
| 2082 | group = ""; | |
| 2083 | ||
| 2084 | if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */ | |
| 9279 | 2085 | f = yahoo_friend_find_or_new(gc, who); |
| 2086 | yahoo_update_status(gc, who, f); | |
| 6840 | 2087 | return; |
| 2088 | } | |
| 2089 | ||
| 7827 | 2090 | decoded_group = yahoo_string_decode(gc, group, FALSE); |
| 6840 | 2091 | buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."), |
| 15884 | 2092 | who, decoded_group, purple_connection_get_display_name(gc)); |
| 2093 | if (!purple_conv_present_error(who, purple_connection_get_account(gc), buf)) | |
| 2094 | purple_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); | |
| 6840 | 2095 | g_free(buf); |
| 7827 | 2096 | g_free(decoded_group); |
| 6840 | 2097 | } |
| 2098 | ||
| 15884 | 2099 | static void yahoo_process_p2p(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9062 | 2100 | { |
| 2101 | GSList *l = pkt->hash; | |
| 2102 | char *who = NULL; | |
| 2103 | char *base64 = NULL; | |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
2104 | guchar *decoded; |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
11111
diff
changeset
|
2105 | gsize len; |
| 9062 | 2106 | |
| 2107 | while (l) { | |
| 2108 | struct yahoo_pair *pair = l->data; | |
| 2109 | ||
| 2110 | switch (pair->key) { | |
| 2111 | case 5: | |
| 2112 | /* our identity */ | |
| 2113 | break; | |
| 2114 | case 4: | |
| 2115 | who = pair->value; | |
| 2116 | break; | |
| 2117 | case 1: | |
| 2118 | /* who again, the master identity this time? */ | |
| 2119 | break; | |
| 2120 | case 12: | |
| 2121 | base64 = pair->value; | |
| 2122 | /* so, this is an ip address. in base64. decoded it's in ascii. | |
| 2123 | after strtol, it's in reversed byte order. Who thought this up?*/ | |
| 2124 | break; | |
| 2125 | /* | |
| 2126 | TODO: figure these out | |
| 2127 | yahoo: Key: 61 Value: 0 | |
| 2128 | yahoo: Key: 2 Value: | |
| 2129 | yahoo: Key: 13 Value: 0 | |
| 2130 | yahoo: Key: 49 Value: PEERTOPEER | |
| 2131 | yahoo: Key: 140 Value: 1 | |
| 2132 | yahoo: Key: 11 Value: -1786225828 | |
| 2133 | */ | |
| 2134 | ||
| 2135 | } | |
| 2136 | ||
| 2137 | l = l->next; | |
| 2138 | } | |
| 2139 | ||
| 9277 | 2140 | if (base64) { |
| 9281 | 2141 | guint32 ip; |
| 2142 | char *tmp2; | |
| 2143 | YahooFriend *f; | |
| 2144 | ||
| 15884 | 2145 | decoded = purple_base64_decode(base64, &len); |
| 9277 | 2146 | if (len) { |
| 15884 | 2147 | char *tmp = purple_str_binary_to_ascii(decoded, len); |
| 2148 | purple_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, tmp); | |
| 9277 | 2149 | g_free(tmp); |
| 2150 | } | |
| 9281 | 2151 | |
|
11144
c6fd3a852568
[gaim-migrate @ 13208]
Mark Doliner <markdoliner@pidgin.im>
parents:
11137
diff
changeset
|
2152 | tmp2 = g_strndup((const gchar *)decoded, len); /* so its \0 terminated...*/ |
| 9281 | 2153 | ip = strtol(tmp2, NULL, 10); |
| 2154 | g_free(tmp2); | |
| 9062 | 2155 | g_free(decoded); |
| 9281 | 2156 | tmp2 = g_strdup_printf("%u.%u.%u.%u", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, |
| 2157 | (ip >> 24) & 0xff); | |
| 2158 | f = yahoo_friend_find(gc, who); | |
| 2159 | if (f) | |
| 2160 | yahoo_friend_set_ip(f, tmp2); | |
| 2161 | g_free(tmp2); | |
| 9062 | 2162 | } |
| 2163 | } | |
| 2164 | ||
| 15884 | 2165 | static void yahoo_process_audible(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9604 | 2166 | { |
|
12798
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2167 | char *who = NULL, *msg = NULL, *id = NULL; |
| 9604 | 2168 | GSList *l = pkt->hash; |
| 2169 | ||
| 2170 | while (l) { | |
| 2171 | struct yahoo_pair *pair = l->data; | |
| 2172 | ||
| 2173 | switch (pair->key) { | |
| 2174 | case 4: | |
| 2175 | who = pair->value; | |
| 2176 | break; | |
| 2177 | case 5: | |
| 2178 | /* us */ | |
| 2179 | break; | |
| 2180 | case 230: | |
|
12798
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2181 | /* the audible, in foo.locale.bar.baz format |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2182 | eg: base.tw.smiley.smiley43 */ |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2183 | id = pair->value; |
| 9604 | 2184 | break; |
| 2185 | case 231: | |
| 2186 | /* the text of the audible */ | |
| 2187 | msg = pair->value; | |
| 2188 | break; | |
| 2189 | case 232: | |
| 2190 | /* weird number (md5 hash?), like 8ebab9094156135f5dcbaccbeee662a5c5fd1420 */ | |
| 2191 | break; | |
| 2192 | } | |
| 2193 | ||
| 2194 | l = l->next; | |
| 2195 | } | |
| 2196 | ||
|
12798
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2197 | if (!msg) |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2198 | msg = id; |
| 9604 | 2199 | if (!who || !msg) |
| 2200 | return; | |
| 2201 | if (!g_utf8_validate(msg, -1, NULL)) { | |
| 15884 | 2202 | purple_debug_misc("yahoo", "Warning, nonutf8 audible, ignoring!\n"); |
| 9604 | 2203 | return; |
| 2204 | } | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
2205 | if (!yahoo_privacy_check(gc, who)) { |
| 15884 | 2206 | purple_debug_misc("yahoo", "Audible message from %s for %s dropped!\n", |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
2207 | gc->account->username, who); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
2208 | return; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
2209 | } |
|
12798
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2210 | if (id) { |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2211 | /* "http://us.dl1.yimg.com/download.yahoo.com/dl/aud/"+locale+"/"+id+".swf" */ |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2212 | char **audible_locale = g_strsplit(id, ".", 0); |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2213 | char *buf = g_strdup_printf(_("[ Audible %s/%s/%s.swf ] %s"), YAHOO_AUDIBLE_URL, audible_locale[1], id, msg); |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2214 | g_strfreev(audible_locale); |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2215 | |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2216 | serv_got_im(gc, who, buf, 0, time(NULL)); |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2217 | g_free(buf); |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2218 | } else |
|
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2219 | serv_got_im(gc, who, msg, 0, time(NULL)); |
| 9604 | 2220 | } |
| 2221 | ||
| 15884 | 2222 | static void yahoo_packet_process(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 2223 | { |
| 6760 | 2224 | switch (pkt->service) { |
| 2681 | 2225 | case YAHOO_SERVICE_LOGON: |
|
2771
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
2226 | case YAHOO_SERVICE_LOGOFF: |
| 2681 | 2227 | case YAHOO_SERVICE_ISAWAY: |
|
2737
f7edb9c3f348
[gaim-migrate @ 2750]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2724
diff
changeset
|
2228 | case YAHOO_SERVICE_ISBACK: |
| 3019 | 2229 | case YAHOO_SERVICE_GAMELOGON: |
| 2230 | case YAHOO_SERVICE_GAMELOGOFF: | |
| 6686 | 2231 | case YAHOO_SERVICE_CHATLOGON: |
| 2232 | case YAHOO_SERVICE_CHATLOGOFF: | |
| 10373 | 2233 | case YAHOO_SERVICE_Y6_STATUS_UPDATE: |
| 14320 | 2234 | case YAHOO_SERVICE_STATUS_15: |
| 2681 | 2235 | yahoo_process_status(gc, pkt); |
| 2236 | break; | |
| 3019 | 2237 | case YAHOO_SERVICE_NOTIFY: |
| 2238 | yahoo_process_notify(gc, pkt); | |
| 2993 | 2239 | break; |
| 2681 | 2240 | case YAHOO_SERVICE_MESSAGE: |
| 2786 | 2241 | case YAHOO_SERVICE_GAMEMSG: |
| 5939 | 2242 | case YAHOO_SERVICE_CHATMSG: |
| 2681 | 2243 | yahoo_process_message(gc, pkt); |
| 2244 | break; | |
| 7865 | 2245 | case YAHOO_SERVICE_SYSMESSAGE: |
| 2246 | yahoo_process_sysmessage(gc, pkt); | |
| 2247 | break; | |
| 2681 | 2248 | case YAHOO_SERVICE_NEWMAIL: |
| 2249 | yahoo_process_mail(gc, pkt); | |
| 2250 | break; | |
| 2251 | case YAHOO_SERVICE_NEWCONTACT: | |
| 2252 | yahoo_process_contact(gc, pkt); | |
| 2253 | break; | |
| 6784 | 2254 | case YAHOO_SERVICE_AUTHRESP: |
| 2255 | yahoo_process_authresp(gc, pkt); | |
| 2256 | break; | |
| 2681 | 2257 | case YAHOO_SERVICE_LIST: |
| 2258 | yahoo_process_list(gc, pkt); | |
| 2259 | break; | |
| 14320 | 2260 | case YAHOO_SERVICE_LIST_15: |
| 2261 | yahoo_process_list_15(gc, pkt); | |
| 2262 | break; | |
| 3147 | 2263 | case YAHOO_SERVICE_AUTH: |
| 2264 | yahoo_process_auth(gc, pkt); | |
| 2265 | break; | |
|
19411
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
2266 | case YAHOO_SERVICE_AUTH_REQ_15: |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
2267 | yahoo_buddy_auth_req_15(gc, pkt); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
2268 | break; |
| 6840 | 2269 | case YAHOO_SERVICE_ADDBUDDY: |
| 2270 | yahoo_process_addbuddy(gc, pkt); | |
| 2271 | break; | |
| 6760 | 2272 | case YAHOO_SERVICE_IGNORECONTACT: |
| 2273 | yahoo_process_ignore(gc, pkt); | |
| 2274 | break; | |
| 6729 | 2275 | case YAHOO_SERVICE_CONFINVITE: |
| 2276 | case YAHOO_SERVICE_CONFADDINVITE: | |
| 2277 | yahoo_process_conference_invite(gc, pkt); | |
| 2278 | break; | |
| 2279 | case YAHOO_SERVICE_CONFDECLINE: | |
| 2280 | yahoo_process_conference_decline(gc, pkt); | |
| 2281 | break; | |
| 2282 | case YAHOO_SERVICE_CONFLOGON: | |
| 2283 | yahoo_process_conference_logon(gc, pkt); | |
| 2284 | break; | |
| 2285 | case YAHOO_SERVICE_CONFLOGOFF: | |
| 2286 | yahoo_process_conference_logoff(gc, pkt); | |
| 2287 | break; | |
| 2288 | case YAHOO_SERVICE_CONFMSG: | |
| 2289 | yahoo_process_conference_message(gc, pkt); | |
| 2290 | break; | |
| 2291 | case YAHOO_SERVICE_CHATONLINE: | |
| 2292 | yahoo_process_chat_online(gc, pkt); | |
| 2293 | break; | |
| 2294 | case YAHOO_SERVICE_CHATLOGOUT: | |
| 2295 | yahoo_process_chat_logout(gc, pkt); | |
| 2296 | break; | |
| 2297 | case YAHOO_SERVICE_CHATGOTO: | |
| 2298 | yahoo_process_chat_goto(gc, pkt); | |
| 2299 | break; | |
| 2300 | case YAHOO_SERVICE_CHATJOIN: | |
| 2301 | yahoo_process_chat_join(gc, pkt); | |
| 2302 | break; | |
| 2303 | case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */ | |
| 2304 | case YAHOO_SERVICE_CHATEXIT: | |
| 2305 | yahoo_process_chat_exit(gc, pkt); | |
| 2306 | break; | |
| 2307 | case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */ | |
| 2308 | case YAHOO_SERVICE_CHATADDINVITE: | |
| 2309 | yahoo_process_chat_addinvite(gc, pkt); | |
| 2310 | break; | |
| 2311 | case YAHOO_SERVICE_COMMENT: | |
| 2312 | yahoo_process_chat_message(gc, pkt); | |
| 2313 | break; | |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
2314 | case YAHOO_SERVICE_PRESENCE_PERM: |
|
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
2315 | case YAHOO_SERVICE_PRESENCE_SESSION: |
|
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
2316 | yahoo_process_presence(gc, pkt); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2317 | break; |
| 7651 | 2318 | case YAHOO_SERVICE_P2PFILEXFER: |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
2319 | /* This case had no break and continued; thus keeping it this way.*/ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11897
diff
changeset
|
2320 | yahoo_process_p2pfilexfer(gc, pkt); |
| 7651 | 2321 | case YAHOO_SERVICE_FILETRANSFER: |
| 2322 | yahoo_process_filetransfer(gc, pkt); | |
| 2323 | break; | |
|
11180
4098d74c03c2
[gaim-migrate @ 13291]
Daniel Atallah <datallah@pidgin.im>
parents:
11153
diff
changeset
|
2324 | case YAHOO_SERVICE_PEERTOPEER: |
| 9062 | 2325 | yahoo_process_p2p(gc, pkt); |
| 2326 | break; | |
| 9284 | 2327 | case YAHOO_SERVICE_PICTURE: |
| 2328 | yahoo_process_picture(gc, pkt); | |
| 2329 | break; | |
| 9292 | 2330 | case YAHOO_SERVICE_PICTURE_UPDATE: |
| 2331 | yahoo_process_picture_update(gc, pkt); | |
| 2332 | break; | |
| 2333 | case YAHOO_SERVICE_PICTURE_CHECKSUM: | |
| 2334 | yahoo_process_picture_checksum(gc, pkt); | |
| 2335 | break; | |
| 9306 | 2336 | case YAHOO_SERVICE_PICTURE_UPLOAD: |
| 2337 | yahoo_process_picture_upload(gc, pkt); | |
| 2338 | break; | |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13941
diff
changeset
|
2339 | case YAHOO_SERVICE_AVATAR_UPDATE: |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13941
diff
changeset
|
2340 | yahoo_process_avatar_update(gc, pkt); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13941
diff
changeset
|
2341 | break; |
| 9604 | 2342 | case YAHOO_SERVICE_AUDIBLE: |
| 2343 | yahoo_process_audible(gc, pkt); | |
|
12798
f8d553043aee
[gaim-migrate @ 15145]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12797
diff
changeset
|
2344 | break; |
| 2681 | 2345 | default: |
| 15884 | 2346 | purple_debug(PURPLE_DEBUG_ERROR, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2347 | "Unhandled service 0x%02x\n", pkt->service); |
| 2681 | 2348 | break; |
| 2349 | } | |
| 2350 | } | |
| 2351 | ||
| 15884 | 2352 | static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond) |
| 2681 | 2353 | { |
| 15884 | 2354 | PurpleConnection *gc = data; |
| 2681 | 2355 | struct yahoo_data *yd = gc->proto_data; |
| 2356 | char buf[1024]; | |
| 2357 | int len; | |
| 2358 | ||
| 2359 | len = read(yd->fd, buf, sizeof(buf)); | |
| 2360 | ||
|
14488
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2361 | if (len < 0) { |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2362 | gchar *tmp; |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2363 | |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2364 | if (errno == EAGAIN) |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2365 | /* No worries */ |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2366 | return; |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2367 | |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2368 | tmp = g_strdup_printf(_("Lost connection with server:\n%s"), |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2369 | strerror(errno)); |
| 15884 | 2370 | purple_connection_error(gc, tmp); |
|
14488
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2371 | g_free(tmp); |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2372 | return; |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2373 | } else if (len == 0) { |
| 15884 | 2374 | purple_connection_error(gc, _("Server closed the connection.")); |
| 2681 | 2375 | return; |
| 2376 | } | |
| 2377 | ||
| 2378 | yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
| 2379 | memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
| 2380 | yd->rxlen += len; | |
| 2381 | ||
| 2382 | while (1) { | |
| 2383 | struct yahoo_packet *pkt; | |
| 2384 | int pos = 0; | |
| 2385 | int pktlen; | |
| 2386 | ||
| 2387 | if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
| 2388 | return; | |
| 2389 | ||
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11303
diff
changeset
|
2390 | if (strncmp((char *)yd->rxqueue, "YMSG", MIN(4, yd->rxlen)) != 0) { |
| 10610 | 2391 | /* HEY! This isn't even a YMSG packet. What |
| 2392 | * are you trying to pull? */ | |
| 2393 | guchar *start; | |
| 2394 | ||
|
17540
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2395 | purple_debug_warning("yahoo", "Error in YMSG stream, got something not a YMSG packet!\n"); |
| 10611 | 2396 | |
| 10635 | 2397 | start = memchr(yd->rxqueue + 1, 'Y', yd->rxlen - 1); |
| 10610 | 2398 | if (start) { |
| 2399 | g_memmove(yd->rxqueue, start, yd->rxlen - (start - yd->rxqueue)); | |
| 2400 | yd->rxlen -= start - yd->rxqueue; | |
| 2401 | continue; | |
| 2402 | } else { | |
| 2403 | g_free(yd->rxqueue); | |
| 2404 | yd->rxqueue = NULL; | |
| 2405 | yd->rxlen = 0; | |
| 2406 | return; | |
| 2407 | } | |
| 2408 | } | |
| 2409 | ||
| 2681 | 2410 | pos += 4; /* YMSG */ |
| 2411 | pos += 2; | |
| 2412 | pos += 2; | |
| 2413 | ||
| 2414 | pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
| 15884 | 2415 | purple_debug(PURPLE_DEBUG_MISC, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2416 | "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
| 2681 | 2417 | |
| 2418 | if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
| 2419 | return; | |
| 2420 | ||
| 2421 | yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
| 2422 | ||
| 2423 | pkt = yahoo_packet_new(0, 0, 0); | |
| 2424 | ||
| 2425 | pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
| 3021 | 2426 | pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
| 15884 | 2427 | purple_debug(PURPLE_DEBUG_MISC, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2428 | "Yahoo Service: 0x%02x Status: %d\n", |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2429 | pkt->service, pkt->status); |
| 2681 | 2430 | pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
| 2431 | ||
| 2432 | yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
| 2433 | ||
| 2434 | yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
| 2435 | if (yd->rxlen) { | |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11303
diff
changeset
|
2436 | guchar *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); |
| 2681 | 2437 | g_free(yd->rxqueue); |
| 2438 | yd->rxqueue = tmp; | |
| 2439 | } else { | |
| 2440 | g_free(yd->rxqueue); | |
| 2441 | yd->rxqueue = NULL; | |
| 2442 | } | |
| 2443 | ||
| 2444 | yahoo_packet_process(gc, pkt); | |
| 2445 | ||
| 2446 | yahoo_packet_free(pkt); | |
| 2447 | } | |
| 2448 | } | |
| 2449 | ||
|
14182
517f4531b8a0
[gaim-migrate @ 16754]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
2450 | static void yahoo_got_connected(gpointer data, gint source, const gchar *error_message) |
| 2681 | 2451 | { |
| 15884 | 2452 | PurpleConnection *gc = data; |
| 2681 | 2453 | struct yahoo_data *yd; |
| 2454 | struct yahoo_packet *pkt; | |
|
11076
f6c4835e68ee
[gaim-migrate @ 13086]
Mark Doliner <markdoliner@pidgin.im>
parents:
11043
diff
changeset
|
2455 | |
| 15884 | 2456 | if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 2681 | 2457 | close(source); |
| 2458 | return; | |
| 2459 | } | |
| 2460 | ||
| 2461 | if (source < 0) { | |
|
17540
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2462 | gchar *tmp; |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2463 | tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2464 | error_message); |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2465 | purple_connection_error(gc, tmp); |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2466 | g_free(tmp); |
| 2681 | 2467 | return; |
| 2468 | } | |
| 2469 | ||
| 2470 | yd = gc->proto_data; | |
| 2471 | yd->fd = source; | |
|
11076
f6c4835e68ee
[gaim-migrate @ 13086]
Mark Doliner <markdoliner@pidgin.im>
parents:
11043
diff
changeset
|
2472 | |
|
11078
b611f3a7800c
[gaim-migrate @ 13088]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11077
diff
changeset
|
2473 | pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, 0); |
| 2681 | 2474 | |
| 15884 | 2475 | yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); |
| 10392 | 2476 | yahoo_packet_send_and_free(pkt, yd); |
| 2681 | 2477 | |
| 15884 | 2478 | gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); |
| 2681 | 2479 | } |
| 9370 | 2480 | |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2481 | #ifdef TRY_WEBMESSENGER_LOGIN |
|
14182
517f4531b8a0
[gaim-migrate @ 16754]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
2482 | static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message) |
| 7134 | 2483 | { |
| 15884 | 2484 | PurpleConnection *gc = data; |
| 7134 | 2485 | struct yahoo_data *yd; |
| 2486 | struct yahoo_packet *pkt; | |
| 2487 | ||
| 15884 | 2488 | if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 7134 | 2489 | close(source); |
| 2490 | return; | |
| 2491 | } | |
| 2492 | ||
| 2493 | if (source < 0) { | |
|
17540
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2494 | gchar *tmp; |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2495 | tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2496 | error_message); |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2497 | purple_connection_error(gc, tmp); |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2498 | g_free(tmp); |
| 7134 | 2499 | return; |
| 2500 | } | |
| 2501 | ||
| 2502 | yd = gc->proto_data; | |
| 2503 | yd->fd = source; | |
| 2504 | ||
| 2505 | pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); | |
| 2506 | ||
| 10394 | 2507 | yahoo_packet_hash(pkt, "sss", 0, |
| 15884 | 2508 | purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), |
| 2509 | 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), | |
| 10394 | 2510 | 6, yd->auth); |
| 10392 | 2511 | yahoo_packet_send_and_free(pkt, yd); |
| 2512 | ||
| 7134 | 2513 | g_free(yd->auth); |
| 15884 | 2514 | gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); |
| 7134 | 2515 | } |
| 2516 | ||
| 15884 | 2517 | static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond) |
| 7134 | 2518 | { |
| 15884 | 2519 | PurpleConnection *gc = data; |
| 2520 | PurpleAccount *account = purple_connection_get_account(gc); | |
| 7134 | 2521 | struct yahoo_data *yd = gc->proto_data; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2522 | char bufread[2048], *i = bufread, *buf = bufread; |
| 8161 | 2523 | int len; |
| 2524 | GString *s; | |
| 7134 | 2525 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2526 | len = read(source, bufread, sizeof(bufread) - 1); |
|
14488
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2527 | |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2528 | if (len < 0) { |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2529 | gchar *tmp; |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2530 | |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2531 | if (errno == EAGAIN) |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2532 | /* No worries */ |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2533 | return; |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2534 | |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2535 | tmp = g_strdup_printf(_("Lost connection with server:\n%s"), |
|
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2536 | strerror(errno)); |
| 15884 | 2537 | purple_connection_error(gc, tmp); |
|
14488
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2538 | g_free(tmp); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2539 | return; |
|
14488
17cf9193cc88
[gaim-migrate @ 17136]
Mark Doliner <markdoliner@pidgin.im>
parents:
14453
diff
changeset
|
2540 | } else if (len == 0) { |
| 15884 | 2541 | purple_connection_error(gc, _("Server closed the connection.")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2542 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2543 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2544 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2545 | if (yd->rxlen > 0 || !g_strstr_len(buf, len, "\r\n\r\n")) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2546 | yd->rxqueue = g_realloc(yd->rxqueue, yd->rxlen + len + 1); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2547 | memcpy(yd->rxqueue + yd->rxlen, buf, len); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2548 | yd->rxlen += len; |
| 14321 | 2549 | i = buf = (char *)yd->rxqueue; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2550 | len = yd->rxlen; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2551 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2552 | buf[len] = '\0'; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2553 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2554 | if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) && |
|
8216
9c4bc4d5a373
[gaim-migrate @ 8939]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
2555 | strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { |
| 15884 | 2556 | purple_connection_error(gc, _("Received unexpected HTTP response from server.")); |
| 7134 | 2557 | return; |
| 2558 | } | |
| 8161 | 2559 | |
| 2560 | s = g_string_sized_new(len); | |
| 2561 | ||
| 2562 | while ((i = strstr(i, "Set-Cookie: "))) { | |
| 2563 | i += strlen("Set-Cookie: "); | |
| 8243 | 2564 | for (;*i != ';' && *i != '\0'; i++) |
| 8161 | 2565 | g_string_append_c(s, *i); |
| 2566 | ||
| 2567 | g_string_append(s, "; "); | |
| 7134 | 2568 | } |
| 8161 | 2569 | |
| 2570 | yd->auth = g_string_free(s, FALSE); | |
| 15884 | 2571 | purple_input_remove(gc->inpa); |
| 7134 | 2572 | close(source); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2573 | g_free(yd->rxqueue); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2574 | yd->rxqueue = NULL; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2575 | yd->rxlen = 0; |
| 7134 | 2576 | /* Now we have our cookies to login with. I'll go get the milk. */ |
| 15884 | 2577 | if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com", |
| 2578 | purple_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
2579 | yahoo_got_web_connected, gc) == NULL) { |
| 15884 | 2580 | purple_connection_error(gc, _("Connection problem")); |
| 7134 | 2581 | return; |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
2582 | } |
| 7134 | 2583 | } |
| 2584 | ||
| 15884 | 2585 | static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond) |
| 7134 | 2586 | { |
| 15884 | 2587 | PurpleConnection *gc; |
|
14146
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2588 | struct yahoo_data *yd; |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2589 | int written, remaining; |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2590 | |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2591 | gc = data; |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2592 | yd = gc->proto_data; |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2593 | |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2594 | remaining = strlen(yd->auth) - yd->auth_written; |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2595 | written = write(source, yd->auth + yd->auth_written, remaining); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2596 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2597 | if (written < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2598 | written = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2599 | else if (written <= 0) { |
|
17540
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2600 | gchar *tmp; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2601 | g_free(yd->auth); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2602 | yd->auth = NULL; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2603 | if (gc->inpa) |
| 15884 | 2604 | purple_input_remove(gc->inpa); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2605 | gc->inpa = 0; |
|
17540
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2606 | tmp = g_strdup_printf(_("Lost connection with %s:\n%s"), |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2607 | "login.yahoo.com:80", strerror(errno)); |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2608 | purple_connection_error(gc, tmp); |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2609 | g_free(tmp); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2610 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2611 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2612 | |
|
14146
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2613 | if (written < remaining) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2614 | yd->auth_written += written; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2615 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2616 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2617 | |
| 7134 | 2618 | g_free(yd->auth); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2619 | yd->auth = NULL; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2620 | yd->auth_written = 0; |
| 15884 | 2621 | purple_input_remove(gc->inpa); |
| 2622 | gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, yahoo_web_pending, gc); | |
| 7134 | 2623 | } |
| 2624 | ||
|
14182
517f4531b8a0
[gaim-migrate @ 16754]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
2625 | static void yahoo_got_cookies(gpointer data, gint source, const gchar *error_message) |
|
14146
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2626 | { |
| 15884 | 2627 | PurpleConnection *gc = data; |
|
14146
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2628 | |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2629 | if (source < 0) { |
|
17540
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2630 | gchar *tmp; |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2631 | tmp = g_strdup_printf(_("Could not establish a connection with %s:\n%s"), |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2632 | "login.yahoo.com:80", error_message); |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2633 | purple_connection_error(gc, tmp); |
|
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2634 | g_free(tmp); |
|
14146
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2635 | return; |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2636 | } |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2637 | |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2638 | if (gc->inpa == 0) |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2639 | { |
| 15884 | 2640 | gc->inpa = purple_input_add(source, PURPLE_INPUT_WRITE, |
|
14146
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2641 | yahoo_got_cookies_send_cb, gc); |
| 15884 | 2642 | yahoo_got_cookies_send_cb(gc, source, PURPLE_INPUT_WRITE); |
|
14146
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2643 | } |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2644 | } |
|
4413802cb7a9
[gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents:
14133
diff
changeset
|
2645 | |
| 7134 | 2646 | static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url) |
| 2647 | { | |
| 2648 | if (!strcmp(key, "passwd")) | |
| 2649 | return; | |
|
13713
1ae8790174a4
[gaim-migrate @ 16115]
Richard Laager <rlaager@pidgin.im>
parents:
13707
diff
changeset
|
2650 | g_string_append_c(url, '&'); |
|
1ae8790174a4
[gaim-migrate @ 16115]
Richard Laager <rlaager@pidgin.im>
parents:
13707
diff
changeset
|
2651 | g_string_append(url, key); |
|
1ae8790174a4
[gaim-migrate @ 16115]
Richard Laager <rlaager@pidgin.im>
parents:
13707
diff
changeset
|
2652 | g_string_append_c(url, '='); |
| 7134 | 2653 | if (!strcmp(key, ".save") || !strcmp(key, ".js")) |
|
13713
1ae8790174a4
[gaim-migrate @ 16115]
Richard Laager <rlaager@pidgin.im>
parents:
13707
diff
changeset
|
2654 | g_string_append_c(url, '1'); |
| 7134 | 2655 | else if (!strcmp(key, ".challenge")) |
|
13713
1ae8790174a4
[gaim-migrate @ 16115]
Richard Laager <rlaager@pidgin.im>
parents:
13707
diff
changeset
|
2656 | g_string_append(url, val); |
| 7134 | 2657 | else |
| 15884 | 2658 | g_string_append(url, purple_url_encode(val)); |
| 7134 | 2659 | } |
| 2660 | ||
| 2661 | static GHashTable *yahoo_login_page_hash(const char *buf, size_t len) | |
| 2662 | { | |
| 2663 | 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
|
2664 | const char *c = buf; |
|
12b7979bce6e
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2665 | char *d; |
| 7134 | 2666 | char name[64], value[64]; |
|
11188
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2667 | int count; |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2668 | int input_len = strlen("<input "); |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2669 | int name_len = strlen("name=\""); |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2670 | int value_len = strlen("value=\""); |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2671 | while ((len > ((c - buf) + input_len)) |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2672 | && (c = strstr(c, "<input "))) { |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2673 | if (!(c = g_strstr_len(c, len - (c - buf), "name=\""))) |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2674 | continue; |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2675 | c += name_len; |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2676 | count = sizeof(name)-1; |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2677 | for (d = name; (len > ((c - buf) + 1)) && *c!='"' |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2678 | && count; c++, d++, count--) |
| 7134 | 2679 | *d = *c; |
| 2680 | *d = '\0'; | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
2681 | count = sizeof(value)-1; |
|
11188
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2682 | if (!(d = g_strstr_len(c, len - (c - buf), "value=\""))) |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2683 | continue; |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2684 | d += value_len; |
| 7134 | 2685 | if (strchr(c, '>') < d) |
| 2686 | break; | |
|
11188
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2687 | for (c = d, d = value; (len > ((c - buf) + 1)) |
|
71daefd15649
[gaim-migrate @ 13305]
Daniel Atallah <datallah@pidgin.im>
parents:
11183
diff
changeset
|
2688 | && *c!='"' && count; c++, d++, count--) |
| 7134 | 2689 | *d = *c; |
| 2690 | *d = '\0'; | |
| 2691 | g_hash_table_insert(hash, g_strdup(name), g_strdup(value)); | |
| 2692 | } | |
| 2693 | return hash; | |
| 2694 | } | |
| 2695 | ||
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2696 | static void |
| 15884 | 2697 | yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2698 | const gchar *url_text, size_t len, const gchar *error_message) |
| 7134 | 2699 | { |
| 15884 | 2700 | PurpleConnection *gc = (PurpleConnection *)user_data; |
| 2701 | PurpleAccount *account = purple_connection_get_account(gc); | |
| 7134 | 2702 | struct yahoo_data *yd = gc->proto_data; |
| 15884 | 2703 | const char *sn = purple_account_get_username(account); |
| 2704 | const char *pass = purple_connection_get_password(gc); | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2705 | GHashTable *hash = yahoo_login_page_hash(url_text, len); |
|
10575
f360d2dc8a1c
[gaim-migrate @ 11968]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10553
diff
changeset
|
2706 | GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); |
| 7134 | 2707 | char md5[33], *hashp = md5, *chal; |
| 2708 | int i; | |
| 15884 | 2709 | PurpleCipher *cipher; |
| 2710 | PurpleCipherContext *context; | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11180
diff
changeset
|
2711 | guchar digest[16]; |
|
7191
6c67ab87df26
[gaim-migrate @ 7760]
Herman Bloggs <herman@bluedigits.com>
parents:
7161
diff
changeset
|
2712 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2713 | yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2714 | |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2715 | if (error_message != NULL) |
|
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2716 | { |
|
17540
460543cd1004
Better error messages for Yahoo! login failures
Mark Doliner <markdoliner@pidgin.im>
parents:
17151
diff
changeset
|
2717 | purple_connection_error(gc, error_message); |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2718 | return; |
|
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2719 | } |
|
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2720 | |
|
7191
6c67ab87df26
[gaim-migrate @ 7760]
Herman Bloggs <herman@bluedigits.com>
parents:
7161
diff
changeset
|
2721 | url = g_string_append(url, sn); |
|
6c67ab87df26
[gaim-migrate @ 7760]
Herman Bloggs <herman@bluedigits.com>
parents:
7161
diff
changeset
|
2722 | url = g_string_append(url, "&passwd="); |
|
6c67ab87df26
[gaim-migrate @ 7760]
Herman Bloggs <herman@bluedigits.com>
parents:
7161
diff
changeset
|
2723 | |
| 15884 | 2724 | cipher = purple_ciphers_find_cipher("md5"); |
| 2725 | context = purple_cipher_context_new(cipher, NULL); | |
| 2726 | ||
| 2727 | purple_cipher_context_append(context, (const guchar *)pass, strlen(pass)); | |
| 2728 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); | |
| 7134 | 2729 | for (i = 0; i < 16; ++i) { |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2730 | g_snprintf(hashp, 3, "%02x", digest[i]); |
| 7134 | 2731 | hashp += 2; |
| 2732 | } | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2733 | |
| 7134 | 2734 | chal = g_strconcat(md5, g_hash_table_lookup(hash, ".challenge"), NULL); |
| 15884 | 2735 | purple_cipher_context_reset(context, NULL); |
| 2736 | purple_cipher_context_append(context, (const guchar *)chal, strlen(chal)); | |
| 2737 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); | |
| 7134 | 2738 | hashp = md5; |
| 2739 | for (i = 0; i < 16; ++i) { | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2740 | g_snprintf(hashp, 3, "%02x", digest[i]); |
| 7134 | 2741 | hashp += 2; |
| 2742 | } | |
| 2743 | /* | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2744 | * I dunno why this is here and commented out.. but in case it's needed |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2745 | * I updated it.. |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2746 | |
| 15884 | 2747 | purple_cipher_context_reset(context, NULL); |
| 2748 | purple_cipher_context_append(context, md5, strlen(md5)); | |
| 2749 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); | |
| 7134 | 2750 | hashp = md5; |
| 2751 | for (i = 0; i < 16; ++i) { | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2752 | g_snprintf(hashp, 3, "%02x", digest[i]); |
| 7134 | 2753 | hashp += 2; |
| 2754 | } | |
| 2755 | */ | |
| 2756 | g_free(chal); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
2757 | |
| 7134 | 2758 | url = g_string_append(url, md5); |
|
7138
12b7979bce6e
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2759 | g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url); |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
2760 | |
| 7134 | 2761 | url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" |
| 2762 | "Host: login.yahoo.com\r\n\r\n"); | |
| 2763 | g_hash_table_destroy(hash); | |
| 2764 | yd->auth = g_string_free(url, FALSE); | |
| 15884 | 2765 | if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) { |
| 2766 | purple_connection_error(gc, _("Connection problem")); | |
| 7134 | 2767 | return; |
| 2768 | } | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2769 | |
| 15884 | 2770 | purple_cipher_context_destroy(context); |
| 7134 | 2771 | } |
|
15807
a075bef0d8dd
Disable Yahoo! web authentication. It's failing right now because
Mark Doliner <markdoliner@pidgin.im>
parents:
15685
diff
changeset
|
2772 | #endif |
| 7134 | 2773 | |
| 15884 | 2774 | static void yahoo_server_check(PurpleAccount *account) |
| 7883 | 2775 | { |
| 2776 | const char *server; | |
| 2777 | ||
| 15884 | 2778 | server = purple_account_get_string(account, "server", YAHOO_PAGER_HOST); |
| 7883 | 2779 | |
| 2780 | if (strcmp(server, "scs.yahoo.com") == 0) | |
| 15884 | 2781 | purple_account_set_string(account, "server", YAHOO_PAGER_HOST); |
| 7883 | 2782 | } |
| 9306 | 2783 | |
| 15884 | 2784 | static void yahoo_picture_check(PurpleAccount *account) |
| 9306 | 2785 | { |
| 15884 | 2786 | PurpleConnection *gc = purple_account_get_connection(account); |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
2787 | PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
2788 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
2789 | yahoo_set_buddy_icon(gc, img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
2790 | purple_imgstore_unref(img); |
| 9306 | 2791 | } |
| 2792 | ||
| 15884 | 2793 | static int get_yahoo_status_from_purple_status(PurpleStatus *status) |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2794 | { |
| 15884 | 2795 | PurplePresence *presence; |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2796 | const char *status_id; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2797 | const char *msg; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2798 | |
| 15884 | 2799 | presence = purple_status_get_presence(status); |
| 2800 | status_id = purple_status_get_id(status); | |
| 2801 | msg = purple_status_get_attr_string(status, "message"); | |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2802 | |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2803 | if (!strcmp(status_id, YAHOO_STATUS_TYPE_AVAILABLE)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2804 | if ((msg != NULL) && (*msg != '\0')) |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2805 | return YAHOO_STATUS_CUSTOM; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2806 | else |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2807 | return YAHOO_STATUS_AVAILABLE; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2808 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_BRB)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2809 | return YAHOO_STATUS_BRB; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2810 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_BUSY)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2811 | return YAHOO_STATUS_BUSY; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2812 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_NOTATHOME)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2813 | return YAHOO_STATUS_NOTATHOME; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2814 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_NOTATDESK)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2815 | return YAHOO_STATUS_NOTATDESK; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2816 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_NOTINOFFICE)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2817 | return YAHOO_STATUS_NOTINOFFICE; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2818 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_ONPHONE)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2819 | return YAHOO_STATUS_ONPHONE; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2820 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_ONVACATION)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2821 | return YAHOO_STATUS_ONVACATION; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2822 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_OUTTOLUNCH)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2823 | return YAHOO_STATUS_OUTTOLUNCH; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2824 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_STEPPEDOUT)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2825 | return YAHOO_STATUS_STEPPEDOUT; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2826 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_INVISIBLE)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2827 | return YAHOO_STATUS_INVISIBLE; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2828 | } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_AWAY)) { |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2829 | return YAHOO_STATUS_CUSTOM; |
| 15884 | 2830 | } else if (purple_presence_is_idle(presence)) { |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2831 | return YAHOO_STATUS_IDLE; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2832 | } else { |
| 15884 | 2833 | purple_debug_error("yahoo", "Unexpected PurpleStatus!\n"); |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2834 | return YAHOO_STATUS_AVAILABLE; |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2835 | } |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2836 | } |
| 7883 | 2837 | |
| 15884 | 2838 | static void yahoo_login(PurpleAccount *account) { |
| 2839 | PurpleConnection *gc = purple_account_get_connection(account); | |
| 2681 | 2840 | struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
| 15884 | 2841 | PurpleStatus *status = purple_account_get_active_status(account); |
| 2842 | gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC; | |
| 2843 | ||
| 2844 | purple_connection_update_progress(gc, _("Connecting"), 1, 2); | |
| 2845 | ||
| 2846 | purple_connection_set_display_name(gc, purple_account_get_username(account)); | |
| 8235 | 2847 | |
| 2681 | 2848 | yd->fd = -1; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2849 | yd->txhandler = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2850 | /* TODO: Is there a good grow size for the buffer? */ |
| 15884 | 2851 | yd->txbuf = purple_circ_buffer_new(0); |
| 6784 | 2852 | yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
2853 | yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
| 6729 | 2854 | yd->confs = NULL; |
| 2855 | yd->conf_id = 2; | |
|
11076
f6c4835e68ee
[gaim-migrate @ 13086]
Mark Doliner <markdoliner@pidgin.im>
parents:
11043
diff
changeset
|
2856 | |
| 15884 | 2857 | yd->current_status = get_yahoo_status_from_purple_status(status); |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
2858 | |
| 7883 | 2859 | yahoo_server_check(account); |
| 9306 | 2860 | yahoo_picture_check(account); |
| 7883 | 2861 | |
| 15884 | 2862 | if (purple_account_get_bool(account, "yahoojp", FALSE)) { |
| 9164 | 2863 | yd->jp = TRUE; |
| 15884 | 2864 | if (purple_proxy_connect(gc, account, |
| 2865 | purple_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), | |
| 2866 | purple_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
2867 | yahoo_got_connected, gc) == NULL) |
| 9164 | 2868 | { |
| 15884 | 2869 | purple_connection_error(gc, _("Connection problem")); |
| 9164 | 2870 | return; |
| 2871 | } | |
| 2872 | } else { | |
| 2873 | yd->jp = FALSE; | |
| 15884 | 2874 | if (purple_proxy_connect(gc, account, |
| 2875 | purple_account_get_string(account, "server", YAHOO_PAGER_HOST), | |
| 2876 | purple_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
2877 | yahoo_got_connected, gc) == NULL) |
| 9164 | 2878 | { |
| 15884 | 2879 | purple_connection_error(gc, _("Connection problem")); |
| 9164 | 2880 | return; |
| 2881 | } | |
| 2681 | 2882 | } |
| 2883 | } | |
| 2884 | ||
| 15884 | 2885 | static void yahoo_close(PurpleConnection *gc) { |
| 2681 | 2886 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 9782 | 2887 | GSList *l; |
| 2888 | ||
| 11608 | 2889 | if (gc->inpa) |
| 15884 | 2890 | purple_input_remove(gc->inpa); |
| 11608 | 2891 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2892 | while (yd->url_datas) { |
| 15884 | 2893 | purple_util_fetch_url_cancel(yd->url_datas->data); |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2894 | yd->url_datas = g_slist_delete_link(yd->url_datas, yd->url_datas); |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2895 | } |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14378
diff
changeset
|
2896 | |
| 9782 | 2897 | for (l = yd->confs; l; l = l->next) { |
| 15884 | 2898 | PurpleConversation *conv = l->data; |
| 2899 | ||
| 2900 | yahoo_conf_leave(yd, purple_conversation_get_name(conv), | |
| 2901 | purple_connection_get_display_name(gc), | |
| 2902 | purple_conv_chat_get_users(PURPLE_CONV_CHAT(conv))); | |
| 9782 | 2903 | } |
| 2904 | g_slist_free(yd->confs); | |
| 6729 | 2905 | |
|
12841
939ceff2a3ba
[gaim-migrate @ 15189]
Richard Laager <rlaager@pidgin.im>
parents:
12798
diff
changeset
|
2906 | yd->chat_online = 0; |
|
939ceff2a3ba
[gaim-migrate @ 15189]
Richard Laager <rlaager@pidgin.im>
parents:
12798
diff
changeset
|
2907 | if (yd->in_chat) |
|
939ceff2a3ba
[gaim-migrate @ 15189]
Richard Laager <rlaager@pidgin.im>
parents:
12798
diff
changeset
|
2908 | yahoo_c_leave(gc, 1); /* 1 = YAHOO_CHAT_ID */ |
|
939ceff2a3ba
[gaim-migrate @ 15189]
Richard Laager <rlaager@pidgin.im>
parents:
12798
diff
changeset
|
2909 | |
| 6784 | 2910 | g_hash_table_destroy(yd->friends); |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
2911 | g_hash_table_destroy(yd->imvironments); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2912 | g_free(yd->chat_name); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2913 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2914 | g_free(yd->cookie_y); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2915 | g_free(yd->cookie_t); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2916 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2917 | if (yd->txhandler) |
| 15884 | 2918 | purple_input_remove(yd->txhandler); |
| 2919 | ||
| 2920 | purple_circ_buffer_destroy(yd->txbuf); | |
| 7651 | 2921 | |
| 2681 | 2922 | if (yd->fd >= 0) |
| 2923 | close(yd->fd); | |
|
3720
dbba62e0d603
[gaim-migrate @ 3853]
Herman Bloggs <herman@bluedigits.com>
parents:
3642
diff
changeset
|
2924 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2925 | g_free(yd->rxqueue); |
|
2687
664e22f507cf
[gaim-migrate @ 2700]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2686
diff
changeset
|
2926 | yd->rxlen = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2927 | g_free(yd->picture_url); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13107
diff
changeset
|
2928 | |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14604
diff
changeset
|
2929 | if (yd->buddy_icon_connect_data) |
| 15884 | 2930 | purple_proxy_connect_cancel(yd->buddy_icon_connect_data); |
| 9306 | 2931 | if (yd->picture_upload_todo) |
| 2932 | yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo); | |
| 9376 | 2933 | if (yd->ycht) |
| 2934 | ycht_connection_close(yd->ycht); | |
| 11608 | 2935 | |
| 2681 | 2936 | g_free(yd); |
|
13344
fde4e6dc84f8
[gaim-migrate @ 15713]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13297
diff
changeset
|
2937 | gc->proto_data = NULL; |
| 2681 | 2938 | } |
| 2939 | ||
| 15884 | 2940 | static const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b) |
| 2681 | 2941 | { |
| 4687 | 2942 | return "yahoo"; |
| 2681 | 2943 | } |
| 4916 | 2944 | |
| 15884 | 2945 | static const char *yahoo_list_emblem(PurpleBuddy *b) |
| 4916 | 2946 | { |
| 15884 | 2947 | PurpleAccount *account; |
| 2948 | PurpleConnection *gc; | |
| 6784 | 2949 | struct yahoo_data *yd; |
| 9278 | 2950 | YahooFriend *f; |
| 15884 | 2951 | PurplePresence *presence; |
| 2952 | ||
| 2953 | if (!b || !(account = b->account) || !(gc = purple_account_get_connection(account)) || | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
2954 | !(yd = gc->proto_data)) |
|
15558
6fb7a0ad8a0b
clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents:
15524
diff
changeset
|
2955 | return NULL; |
| 6784 | 2956 | |
| 9279 | 2957 | f = yahoo_friend_find(gc, b->name); |
| 6784 | 2958 | if (!f) { |
| 15524 | 2959 | return "not-authorized"; |
| 6784 | 2960 | } |
| 2961 | ||
| 15884 | 2962 | presence = purple_buddy_get_presence(b); |
| 2963 | ||
| 2964 | if (purple_presence_is_online(presence)) { | |
| 9283 | 2965 | if (yahoo_friend_get_game(f)) |
| 15524 | 2966 | return "game"; |
| 14366 | 2967 | if (f->protocol == 2) |
| 15524 | 2968 | return "msn"; |
| 4916 | 2969 | } |
| 15524 | 2970 | return NULL; |
| 4916 | 2971 | } |
| 2681 | 2972 | |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13041
diff
changeset
|
2973 | static const char *yahoo_get_status_string(enum yahoo_status a) |
| 2681 | 2974 | { |
| 2975 | switch (a) { | |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2976 | case YAHOO_STATUS_BRB: |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2977 | return _("Be Right Back"); |
|
12203
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
2978 | case YAHOO_STATUS_BUSY: |
|
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
2979 | return _("Busy"); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2980 | case YAHOO_STATUS_NOTATHOME: |
|
12467
94948d1eb8cf
[gaim-migrate @ 14777]
Richard Laager <rlaager@pidgin.im>
parents:
12417
diff
changeset
|
2981 | return _("Not at Home"); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2982 | case YAHOO_STATUS_NOTATDESK: |
|
12467
94948d1eb8cf
[gaim-migrate @ 14777]
Richard Laager <rlaager@pidgin.im>
parents:
12417
diff
changeset
|
2983 | return _("Not at Desk"); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2984 | case YAHOO_STATUS_NOTINOFFICE: |
|
12467
94948d1eb8cf
[gaim-migrate @ 14777]
Richard Laager <rlaager@pidgin.im>
parents:
12417
diff
changeset
|
2985 | return _("Not in Office"); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2986 | case YAHOO_STATUS_ONPHONE: |
|
12467
94948d1eb8cf
[gaim-migrate @ 14777]
Richard Laager <rlaager@pidgin.im>
parents:
12417
diff
changeset
|
2987 | return _("On the Phone"); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2988 | case YAHOO_STATUS_ONVACATION: |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2989 | return _("On Vacation"); |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
2990 | case YAHOO_STATUS_OUTTOLUNCH: |
|
12467
94948d1eb8cf
[gaim-migrate @ 14777]
Richard Laager <rlaager@pidgin.im>
parents:
12417
diff
changeset
|
2991 | return _("Out to Lunch"); |
|
12203
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
2992 | case YAHOO_STATUS_STEPPEDOUT: |
|
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
2993 | return _("Stepped Out"); |
|
2873
9e56887eeb06
[gaim-migrate @ 2886]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2856
diff
changeset
|
2994 | case YAHOO_STATUS_INVISIBLE: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2995 | return _("Invisible"); |
| 4730 | 2996 | case YAHOO_STATUS_IDLE: |
| 2997 | return _("Idle"); | |
| 6784 | 2998 | case YAHOO_STATUS_OFFLINE: |
| 2999 | return _("Offline"); | |
|
2879
e417cf7111c4
[gaim-migrate @ 2892]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2878
diff
changeset
|
3000 | default: |
|
12467
94948d1eb8cf
[gaim-migrate @ 14777]
Richard Laager <rlaager@pidgin.im>
parents:
12417
diff
changeset
|
3001 | return _("Available"); |
| 2681 | 3002 | } |
| 3003 | } | |
| 3004 | ||
| 15884 | 3005 | static void yahoo_initiate_conference(PurpleBlistNode *node, gpointer data) { |
| 3006 | ||
| 3007 | PurpleBuddy *buddy; | |
| 3008 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3009 | |
| 6729 | 3010 | GHashTable *components; |
| 3011 | struct yahoo_data *yd; | |
| 3012 | int id; | |
| 3013 | ||
| 15884 | 3014 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 3015 | ||
| 3016 | buddy = (PurpleBuddy *) node; | |
| 3017 | gc = purple_account_get_connection(buddy->account); | |
| 6729 | 3018 | yd = gc->proto_data; |
| 3019 | id = yd->conf_id; | |
| 3020 | ||
| 3021 | components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 3022 | g_hash_table_replace(components, g_strdup("room"), | |
| 15884 | 3023 | g_strdup_printf("%s-%d", purple_connection_get_display_name(gc), id)); |
| 6729 | 3024 | g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference...")); |
| 3025 | g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | |
| 3026 | yahoo_c_join(gc, components); | |
| 3027 | g_hash_table_destroy(components); | |
| 3028 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3029 | yahoo_c_invite(gc, id, "Join my conference...", buddy->name); |
| 6729 | 3030 | } |
| 3031 | ||
| 15884 | 3032 | static void yahoo_presence_settings(PurpleBlistNode *node, gpointer data) { |
| 3033 | PurpleBuddy *buddy; | |
| 3034 | PurpleConnection *gc; | |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3035 | int presence_val = GPOINTER_TO_INT(data); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3036 | |
| 15884 | 3037 | buddy = (PurpleBuddy *) node; |
| 3038 | gc = purple_account_get_connection(buddy->account); | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3039 | |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3040 | yahoo_friend_update_presence(gc, buddy->name, presence_val); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3041 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3042 | |
| 15884 | 3043 | static void yahoo_game(PurpleBlistNode *node, gpointer data) { |
| 3044 | ||
| 3045 | PurpleBuddy *buddy; | |
| 3046 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3047 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3048 | struct yahoo_data *yd; |
| 9283 | 3049 | const char *game; |
| 3050 | char *game2; | |
| 3019 | 3051 | char *t; |
| 3052 | char url[256]; | |
| 9278 | 3053 | YahooFriend *f; |
| 3019 | 3054 | |
| 15884 | 3055 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 3056 | ||
| 3057 | buddy = (PurpleBuddy *) node; | |
| 3058 | gc = purple_account_get_connection(buddy->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3059 | yd = (struct yahoo_data *) gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3060 | |
| 9279 | 3061 | f = yahoo_friend_find(gc, buddy->name); |
| 6784 | 3062 | if (!f) |
| 3063 | return; | |
| 3064 | ||
| 9283 | 3065 | game = yahoo_friend_get_game(f); |
| 3019 | 3066 | if (!game) |
| 3067 | return; | |
| 6784 | 3068 | |
| 9283 | 3069 | t = game2 = g_strdup(strstr(game, "ante?room=")); |
| 3070 | while (*t && *t != '\t') | |
| 3019 | 3071 | t++; |
| 3072 | *t = 0; | |
| 9283 | 3073 | g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game2); |
| 15884 | 3074 | purple_notify_uri(gc, url); |
| 9283 | 3075 | g_free(game2); |
| 3019 | 3076 | } |
| 4722 | 3077 | |
| 15884 | 3078 | static char *yahoo_status_text(PurpleBuddy *b) |
| 4722 | 3079 | { |
| 9278 | 3080 | YahooFriend *f = NULL; |
| 9283 | 3081 | const char *msg; |
|
11920
be80617ec59b
[gaim-migrate @ 14211]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11914
diff
changeset
|
3082 | char *msg2; |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
3083 | |
| 9279 | 3084 | f = yahoo_friend_find(b->account->gc, b->name); |
| 6784 | 3085 | if (!f) |
| 3086 | return g_strdup(_("Not on server list")); | |
| 3087 | ||
| 3088 | switch (f->status) { | |
| 3089 | case YAHOO_STATUS_AVAILABLE: | |
| 3090 | return NULL; | |
| 3091 | case YAHOO_STATUS_IDLE: | |
| 3092 | if (f->idle == -1) | |
| 3093 | return g_strdup(yahoo_get_status_string(f->status)); | |
| 3094 | return NULL; | |
| 3095 | case YAHOO_STATUS_CUSTOM: | |
| 9283 | 3096 | if (!(msg = yahoo_friend_get_status_message(f))) |
| 6784 | 3097 | return NULL; |
|
11920
be80617ec59b
[gaim-migrate @ 14211]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11914
diff
changeset
|
3098 | msg2 = g_markup_escape_text(msg, strlen(msg)); |
| 15884 | 3099 | purple_util_chrreplace(msg2, '\n', ' '); |
|
11920
be80617ec59b
[gaim-migrate @ 14211]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11914
diff
changeset
|
3100 | return msg2; |
| 9224 | 3101 | |
| 6784 | 3102 | default: |
| 3103 | return g_strdup(yahoo_get_status_string(f->status)); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
3104 | } |
| 4722 | 3105 | } |
| 3106 | ||
| 15884 | 3107 | void yahoo_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) |
| 4724 | 3108 | { |
| 9278 | 3109 | YahooFriend *f; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13041
diff
changeset
|
3110 | char *escaped; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13041
diff
changeset
|
3111 | char *status = NULL; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
13041
diff
changeset
|
3112 | const char *presence = NULL; |
| 6784 | 3113 | |
| 9279 | 3114 | f = yahoo_friend_find(b->account->gc, b->name); |
| 6784 | 3115 | if (!f) |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
3116 | status = g_strdup_printf("\n%s", _("Not on server list")); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3117 | else { |
| 6784 | 3118 | switch (f->status) { |
| 3119 | case YAHOO_STATUS_CUSTOM: | |
| 9283 | 3120 | if (!yahoo_friend_get_status_message(f)) |
|
12970
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12945
diff
changeset
|
3121 | return; |
| 9283 | 3122 | status = g_strdup(yahoo_friend_get_status_message(f)); |
| 6784 | 3123 | break; |
|
10992
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
3124 | case YAHOO_STATUS_OFFLINE: |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
3125 | break; |
| 6784 | 3126 | default: |
| 3127 | status = g_strdup(yahoo_get_status_string(f->status)); | |
| 3128 | break; | |
| 4745 | 3129 | } |
| 6784 | 3130 | |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3131 | switch (f->presence) { |
|
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3132 | case YAHOO_PRESENCE_ONLINE: |
|
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3133 | presence = _("Appear Online"); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3134 | break; |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3135 | case YAHOO_PRESENCE_PERM_OFFLINE: |
|
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3136 | presence = _("Appear Permanently Offline"); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3137 | break; |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3138 | case YAHOO_PRESENCE_DEFAULT: |
|
12945
69f429d29451
[gaim-migrate @ 15298]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
3139 | break; |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3140 | default: |
| 15884 | 3141 | purple_debug_error("yahoo", "Unknown presence in yahoo_tooltip_text\n"); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3142 | break; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3143 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3144 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3145 | |
|
10992
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
3146 | if (status != NULL) { |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
3147 | escaped = g_markup_escape_text(status, strlen(status)); |
| 15884 | 3148 | purple_notify_user_info_add_pair(user_info, _("Status"), escaped); |
|
10992
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
3149 | g_free(status); |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
3150 | g_free(escaped); |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
3151 | } |
| 6784 | 3152 | |
|
12945
69f429d29451
[gaim-migrate @ 15298]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
3153 | if (presence != NULL) |
| 15884 | 3154 | purple_notify_user_info_add_pair(user_info, _("Presence"), presence); |
| 4729 | 3155 | } |
| 3156 | ||
| 15884 | 3157 | static void yahoo_addbuddyfrommenu_cb(PurpleBlistNode *node, gpointer data) |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3158 | { |
| 15884 | 3159 | PurpleBuddy *buddy; |
| 3160 | PurpleConnection *gc; | |
| 3161 | ||
| 3162 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | |
| 3163 | ||
| 3164 | buddy = (PurpleBuddy *) node; | |
| 3165 | gc = purple_account_get_connection(buddy->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3166 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3167 | yahoo_add_buddy(gc, buddy, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3168 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3169 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3170 | |
| 15884 | 3171 | static void yahoo_chat_goto_menu(PurpleBlistNode *node, gpointer data) |
| 6796 | 3172 | { |
| 15884 | 3173 | PurpleBuddy *buddy; |
| 3174 | PurpleConnection *gc; | |
| 3175 | ||
| 3176 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | |
| 3177 | ||
| 3178 | buddy = (PurpleBuddy *) node; | |
| 3179 | gc = purple_account_get_connection(buddy->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3180 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3181 | yahoo_chat_goto(gc, buddy->name); |
| 6796 | 3182 | } |
| 3183 | ||
| 15884 | 3184 | static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) { |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3185 | GList *m = NULL; |
| 15884 | 3186 | PurpleMenuAction *act; |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3187 | struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3188 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3189 | if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3190 | if (f->presence != YAHOO_PRESENCE_ONLINE) { |
| 15884 | 3191 | act = purple_menu_action_new(_("Appear Online"), |
| 3192 | PURPLE_CALLBACK(yahoo_presence_settings), | |
| 13021 | 3193 | GINT_TO_POINTER(YAHOO_PRESENCE_ONLINE), |
| 3194 | NULL); | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3195 | m = g_list_append(m, act); |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3196 | } else if (f->presence != YAHOO_PRESENCE_DEFAULT) { |
| 15884 | 3197 | act = purple_menu_action_new(_("Appear Offline"), |
| 3198 | PURPLE_CALLBACK(yahoo_presence_settings), | |
| 13021 | 3199 | GINT_TO_POINTER(YAHOO_PRESENCE_DEFAULT), |
| 3200 | NULL); | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3201 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3202 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3203 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3204 | |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3205 | if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) { |
| 15884 | 3206 | act = purple_menu_action_new(_("Don't Appear Permanently Offline"), |
| 3207 | PURPLE_CALLBACK(yahoo_presence_settings), | |
| 13021 | 3208 | GINT_TO_POINTER(YAHOO_PRESENCE_DEFAULT), |
| 3209 | NULL); | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3210 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3211 | } else { |
| 15884 | 3212 | act = purple_menu_action_new(_("Appear Permanently Offline"), |
| 3213 | PURPLE_CALLBACK(yahoo_presence_settings), | |
| 13021 | 3214 | GINT_TO_POINTER(YAHOO_PRESENCE_PERM_OFFLINE), |
| 3215 | NULL); | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3216 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3217 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3218 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3219 | return m; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3220 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3221 | |
| 15884 | 3222 | static void yahoo_doodle_blist_node(PurpleBlistNode *node, gpointer data) |
|
11800
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3223 | { |
| 15884 | 3224 | PurpleBuddy *b = (PurpleBuddy *)node; |
| 3225 | PurpleConnection *gc = b->account->gc; | |
|
11800
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3226 | |
|
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3227 | yahoo_doodle_initiate(gc, b->name); |
|
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3228 | } |
|
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3229 | |
| 15884 | 3230 | static GList *yahoo_buddy_menu(PurpleBuddy *buddy) |
| 2681 | 3231 | { |
| 3232 | GList *m = NULL; | |
| 15884 | 3233 | PurpleMenuAction *act; |
| 3234 | ||
| 3235 | PurpleConnection *gc = purple_account_get_connection(buddy->account); | |
| 9370 | 3236 | struct yahoo_data *yd = gc->proto_data; |
| 3019 | 3237 | static char buf2[1024]; |
| 9278 | 3238 | YahooFriend *f; |
| 6784 | 3239 | |
| 9279 | 3240 | f = yahoo_friend_find(gc, buddy->name); |
| 6784 | 3241 | |
| 9370 | 3242 | if (!f && !yd->wm) { |
| 15884 | 3243 | act = purple_menu_action_new(_("Add Buddy"), |
| 3244 | PURPLE_CALLBACK(yahoo_addbuddyfrommenu_cb), | |
| 12919 | 3245 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3246 | m = g_list_append(m, act); |
| 6784 | 3247 | |
| 3248 | return m; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3249 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3250 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3251 | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3252 | if (f && f->status != YAHOO_STATUS_OFFLINE) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3253 | if (!yd->wm) { |
| 15884 | 3254 | act = purple_menu_action_new(_("Join in Chat"), |
| 3255 | PURPLE_CALLBACK(yahoo_chat_goto_menu), | |
| 12919 | 3256 | NULL, NULL); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3257 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3258 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3259 | |
| 15884 | 3260 | act = purple_menu_action_new(_("Initiate Conference"), |
| 3261 | PURPLE_CALLBACK(yahoo_initiate_conference), | |
| 12919 | 3262 | NULL, NULL); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3263 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3264 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3265 | if (yahoo_friend_get_game(f)) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3266 | const char *game = yahoo_friend_get_game(f); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3267 | char *room; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3268 | char *t; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3269 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3270 | if ((room = strstr(game, "&follow="))) {/* skip ahead to the url */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3271 | while (*room && *room != '\t') /* skip to the tab */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3272 | room++; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3273 | t = room++; /* room as now at the name */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3274 | while (*t != '\n') |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3275 | t++; /* replace the \n with a space */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3276 | *t = ' '; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3277 | g_snprintf(buf2, sizeof buf2, "%s", room); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3278 | |
| 15884 | 3279 | act = purple_menu_action_new(buf2, |
| 3280 | PURPLE_CALLBACK(yahoo_game), | |
| 12919 | 3281 | NULL, NULL); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3282 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3283 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3284 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3285 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3286 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3287 | if (f) { |
| 15884 | 3288 | act = purple_menu_action_new(_("Presence Settings"), NULL, NULL, |
| 12919 | 3289 | build_presence_submenu(f, gc)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3290 | m = g_list_append(m, act); |
| 3019 | 3291 | } |
| 6729 | 3292 | |
|
11800
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3293 | if (f) { |
| 15884 | 3294 | act = purple_menu_action_new(_("Start Doodling"), |
| 3295 | PURPLE_CALLBACK(yahoo_doodle_blist_node), | |
| 12919 | 3296 | NULL, NULL); |
|
11800
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3297 | m = g_list_append(m, act); |
|
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3298 | } |
|
622741e6201c
[gaim-migrate @ 14091]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11718
diff
changeset
|
3299 | |
| 2681 | 3300 | return m; |
| 3301 | } | |
| 3302 | ||
| 15884 | 3303 | static GList *yahoo_blist_node_menu(PurpleBlistNode *node) |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3304 | { |
| 15884 | 3305 | if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
| 3306 | return yahoo_buddy_menu((PurpleBuddy *) node); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3307 | } else { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3308 | return NULL; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3309 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3310 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3311 | |
| 15884 | 3312 | static void yahoo_act_id(PurpleConnection *gc, const char *entry) |
| 2681 | 3313 | { |
| 3314 | struct yahoo_data *yd = gc->proto_data; | |
| 3315 | ||
| 3316 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3317 | yahoo_packet_hash_str(pkt, 3, entry); |
| 10392 | 3318 | yahoo_packet_send_and_free(pkt, yd); |
| 2681 | 3319 | |
| 15884 | 3320 | purple_connection_set_display_name(gc, entry); |
| 2681 | 3321 | } |
| 3322 | ||
|
19038
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3323 | static void |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3324 | yahoo_get_inbox_token_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3325 | const gchar *token, size_t len, const gchar *error_message) |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3326 | { |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3327 | PurpleConnection *gc = user_data; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3328 | gboolean set_cookie = FALSE; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3329 | char *url; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3330 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3331 | g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3332 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3333 | if (error_message != NULL) |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3334 | purple_debug_error("yahoo", "Requesting mail login token failed: %s\n", error_message); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3335 | else if (len > 0 && token && *token) { |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3336 | /* Should we not be hardcoding the rd url? */ |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3337 | url = g_strdup_printf( |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3338 | "http://login.yahoo.com/config/reset_cookies_token?" |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3339 | ".token=%s" |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3340 | "&.done=http://us.rd.yahoo.com/messenger/client/%%3fhttp://mail.yahoo.com/", |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3341 | token); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3342 | set_cookie = TRUE; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3343 | } |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3344 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3345 | if (!set_cookie) { |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3346 | struct yahoo_data *yd = gc->proto_data; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3347 | purple_debug_error("yahoo", "No mail login token; forwarding to login screen."); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3348 | url = g_strdup(yd->jp ? YAHOOJP_MAIL_URL : YAHOO_MAIL_URL); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3349 | } |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3350 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3351 | /* Open the mailbox with the parsed url data */ |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3352 | purple_notify_uri(gc, url); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3353 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3354 | g_free(url); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3355 | } |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3356 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3357 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3358 | static void yahoo_show_inbox(PurplePluginAction *action) |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3359 | { |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3360 | /* Setup a cookie that can be used by the browser */ |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3361 | /* XXX I have no idea how this will work with Yahoo! Japan. */ |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3362 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3363 | PurpleConnection *gc = action->context; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3364 | struct yahoo_data *yd = gc->proto_data; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3365 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3366 | PurpleUtilFetchUrlData *url_data; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3367 | const char* base_url = "http://login.yahoo.com"; |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3368 | char *request = g_strdup_printf( |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3369 | "POST /config/cookie_token HTTP/1.0\r\n" |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3370 | "Cookie: T=%s; path=/; domain=.yahoo.com; Y=%s;\r\n" |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3371 | "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3372 | "Host: login.yahoo.com\r\n" |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3373 | "Content-Length: 0\r\n\r\n", |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3374 | yd->cookie_t, yd->cookie_y); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3375 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3376 | url_data = purple_util_fetch_url_request(base_url, FALSE, |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3377 | "Mozilla/4.0 (compatible; MSIE 5.5)", TRUE, request, FALSE, |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3378 | yahoo_get_inbox_token_cb, gc); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3379 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3380 | g_free(request); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3381 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3382 | if (url_data == NULL) { |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3383 | const char *yahoo_mail_url = (yd->jp ? YAHOOJP_MAIL_URL : YAHOO_MAIL_URL); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3384 | purple_debug_error("yahoo", |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3385 | "Unable to request mail login token; forwarding to login screen."); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3386 | purple_notify_uri(gc, yahoo_mail_url); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3387 | } |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3388 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3389 | } |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3390 | |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3391 | |
| 15884 | 3392 | static void yahoo_show_act_id(PurplePluginAction *action) |
| 2681 | 3393 | { |
| 15884 | 3394 | PurpleConnection *gc = (PurpleConnection *) action->context; |
|
19038
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3395 | purple_request_input(gc, NULL, _("Activate which ID?"), NULL, |
| 15884 | 3396 | purple_connection_get_display_name(gc), FALSE, FALSE, NULL, |
|
5493
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3397 | _("OK"), G_CALLBACK(yahoo_act_id), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
3398 | _("Cancel"), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
3399 | purple_connection_get_account(gc), NULL, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
3400 | gc); |
| 2681 | 3401 | } |
| 3402 | ||
| 15884 | 3403 | static void yahoo_show_chat_goto(PurplePluginAction *action) |
| 7878 | 3404 | { |
| 15884 | 3405 | PurpleConnection *gc = (PurpleConnection *) action->context; |
| 3406 | purple_request_input(gc, NULL, _("Join who in chat?"), NULL, | |
| 8697 | 3407 | "", FALSE, FALSE, NULL, |
| 7878 | 3408 | _("OK"), G_CALLBACK(yahoo_chat_goto), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
3409 | _("Cancel"), NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
3410 | purple_connection_get_account(gc), NULL, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16007
diff
changeset
|
3411 | gc); |
| 7878 | 3412 | } |
| 3413 | ||
| 15884 | 3414 | static GList *yahoo_actions(PurplePlugin *plugin, gpointer context) { |
| 2681 | 3415 | GList *m = NULL; |
| 15884 | 3416 | PurplePluginAction *act; |
| 3417 | ||
| 3418 | act = purple_plugin_action_new(_("Activate ID..."), | |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
3419 | yahoo_show_act_id); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
3420 | m = g_list_append(m, act); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
3421 | |
| 15884 | 3422 | act = purple_plugin_action_new(_("Join User in Chat..."), |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
3423 | yahoo_show_chat_goto); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
3424 | m = g_list_append(m, act); |
| 7878 | 3425 | |
|
19038
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3426 | m = g_list_append(m, NULL); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3427 | act = purple_plugin_action_new(_("Open Inbox"), |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3428 | yahoo_show_inbox); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3429 | m = g_list_append(m, act); |
|
e54f19f8521b
Add "Open Inbox" account action to the yahoo prpl that logs your browser into your yahoo account and opens your inbox.
Daniel Atallah <datallah@pidgin.im>
parents:
18946
diff
changeset
|
3430 | |
| 2681 | 3431 | return m; |
| 3432 | } | |
| 3433 | ||
| 15884 | 3434 | static int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) |
| 2681 | 3435 | { |
| 3436 | struct yahoo_data *yd = gc->proto_data; | |
| 3437 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
| 6629 | 3438 | char *msg = yahoo_html_to_codes(what); |
| 7827 | 3439 | char *msg2; |
| 3440 | gboolean utf8 = TRUE; | |
| 15884 | 3441 | PurpleWhiteboard *wb; |
| 9828 | 3442 | int ret = 1; |
| 14320 | 3443 | YahooFriend *f = NULL; |
| 7827 | 3444 | |
| 3445 | msg2 = yahoo_string_encode(gc, msg, &utf8); | |
| 2681 | 3446 | |
| 15884 | 3447 | yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who); |
| 14346 | 3448 | if ((f = yahoo_friend_find(gc, who)) && f->protocol) |
| 3449 | yahoo_packet_hash_int(pkt, 241, f->protocol); | |
| 14320 | 3450 | |
| 7827 | 3451 | if (utf8) |
| 10394 | 3452 | yahoo_packet_hash_str(pkt, 97, "1"); |
| 3453 | yahoo_packet_hash_str(pkt, 14, msg2); | |
| 3454 | ||
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3455 | /* |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3456 | * IMVironment. |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3457 | * |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3458 | * If this message is to a user who is also Doodling with the local user, |
|
11644
939411169d01
[gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11643
diff
changeset
|
3459 | * format the chat packet with the correct IMV information (thanks Yahoo!) |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3460 | * |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3461 | * Otherwise attempt to use the same IMVironment as the remote user, |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3462 | * just so that we don't inadvertantly reset their IMVironment back |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3463 | * to nothing. |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3464 | * |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3465 | * If they have no set an IMVironment, then use the default. |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3466 | */ |
| 15884 | 3467 | wb = purple_whiteboard_get_session(gc->account, who); |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
3468 | if (wb) |
|
19064
1680699bdbf4
Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents:
19058
diff
changeset
|
3469 | yahoo_packet_hash_str(pkt, 63, DOODLE_IMV_KEY); |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
3470 | else |
|
13851
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3471 | { |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3472 | const char *imv; |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3473 | imv = g_hash_table_lookup(yd->imvironments, who); |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3474 | if (imv != NULL) |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3475 | yahoo_packet_hash_str(pkt, 63, imv); |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3476 | else |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3477 | yahoo_packet_hash_str(pkt, 63, ";0"); |
|
27bc39ea07f8
[gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents:
13844
diff
changeset
|
3478 | } |
| 11608 | 3479 | |
| 10394 | 3480 | yahoo_packet_hash_str(pkt, 64, "0"); /* no idea */ |
| 3481 | yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */ | |
| 9306 | 3482 | if (!yd->picture_url) |
| 10394 | 3483 | yahoo_packet_hash_str(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */ |
| 9306 | 3484 | else |
| 10394 | 3485 | yahoo_packet_hash_str(pkt, 206, "2"); |
| 2681 | 3486 | |
| 9828 | 3487 | /* We may need to not send any packets over 2000 bytes, but I'm not sure yet. */ |
| 3488 | if ((YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt)) <= 2000) | |
| 10392 | 3489 | yahoo_packet_send(pkt, yd); |
| 9828 | 3490 | else |
| 3491 | ret = -E2BIG; | |
| 2681 | 3492 | |
| 3493 | yahoo_packet_free(pkt); | |
| 6629 | 3494 | |
| 3495 | g_free(msg); | |
| 7827 | 3496 | g_free(msg2); |
| 6629 | 3497 | |
| 9828 | 3498 | return ret; |
| 2681 | 3499 | } |
| 3500 | ||
| 15884 | 3501 | static unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) |
| 2993 | 3502 | { |
| 3503 | struct yahoo_data *yd = gc->proto_data; | |
| 3019 | 3504 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
| 15884 | 3505 | yahoo_packet_hash(pkt, "ssssss", 49, "TYPING", 1, purple_connection_get_display_name(gc), |
| 3506 | 14, " ", 13, state == PURPLE_TYPING ? "1" : "0", | |
| 10394 | 3507 | 5, who, 1002, "1"); |
| 2993 | 3508 | |
| 10392 | 3509 | yahoo_packet_send_and_free(pkt, yd); |
| 2993 | 3510 | |
| 3001 | 3511 | return 0; |
| 2993 | 3512 | } |
| 3513 | ||
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3514 | static void yahoo_session_presence_remove(gpointer key, gpointer value, gpointer data) |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3515 | { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3516 | YahooFriend *f = value; |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3517 | if (f && f->presence == YAHOO_PRESENCE_ONLINE) |
|
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3518 | f->presence = YAHOO_PRESENCE_DEFAULT; |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3519 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3520 | |
| 15884 | 3521 | static void yahoo_set_status(PurpleAccount *account, PurpleStatus *status) |
| 2681 | 3522 | { |
| 15884 | 3523 | PurpleConnection *gc; |
| 3524 | PurplePresence *presence; | |
| 10400 | 3525 | struct yahoo_data *yd; |
| 2681 | 3526 | struct yahoo_packet *pkt; |
| 10400 | 3527 | int old_status; |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3528 | const char *msg = NULL; |
|
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3529 | char *tmp = NULL; |
| 7827 | 3530 | char *conv_msg = NULL; |
|
19053
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
3531 | gboolean utf8 = TRUE; |
| 9984 | 3532 | |
| 15884 | 3533 | if (!purple_status_is_active(status)) |
| 10400 | 3534 | return; |
| 3535 | ||
| 15884 | 3536 | gc = purple_account_get_connection(account); |
| 3537 | presence = purple_status_get_presence(status); | |
| 10400 | 3538 | yd = (struct yahoo_data *)gc->proto_data; |
| 3539 | old_status = yd->current_status; | |
| 9984 | 3540 | |
| 15884 | 3541 | yd->current_status = get_yahoo_status_from_purple_status(status); |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
3542 | |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
3543 | if (yd->current_status == YAHOO_STATUS_CUSTOM) |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
3544 | { |
| 15884 | 3545 | msg = purple_status_get_attr_string(status, "message"); |
| 3546 | ||
| 3547 | if (purple_status_is_available(status)) { | |
|
19053
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
3548 | tmp = yahoo_string_encode(gc, msg, &utf8); |
| 15884 | 3549 | conv_msg = purple_markup_strip_html(tmp); |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
3550 | g_free(tmp); |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3551 | } else { |
|
11972
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
3552 | if ((msg == NULL) || (*msg == '\0')) |
|
23ac6d9de1fa
[gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents:
11970
diff
changeset
|
3553 | msg = _("Away"); |
|
19053
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
3554 | tmp = yahoo_string_encode(gc, msg, &utf8); |
| 15884 | 3555 | conv_msg = purple_markup_strip_html(tmp); |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3556 | g_free(tmp); |
|
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3557 | } |
| 2681 | 3558 | } |
| 3559 | ||
| 10373 | 3560 | if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
| 3561 | pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3562 | yahoo_packet_hash_str(pkt, 13, "2"); |
| 10392 | 3563 | yahoo_packet_send_and_free(pkt, yd); |
| 10373 | 3564 | |
| 3565 | return; | |
| 3566 | } | |
| 3567 | ||
| 3568 | pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3569 | yahoo_packet_hash_int(pkt, 10, yd->current_status); |
| 6847 | 3570 | |
| 9984 | 3571 | if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
|
19053
b667a7fdaa81
Did you know we didn't support i18n in Yahoo status messages? We do now! Fixes #2356
Sean Egan <seanegan@pidgin.im>
parents:
19038
diff
changeset
|
3572 | yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3573 | yahoo_packet_hash_str(pkt, 19, conv_msg); |
| 10373 | 3574 | } else { |
| 10394 | 3575 | yahoo_packet_hash_str(pkt, 19, ""); |
| 10373 | 3576 | } |
| 3577 | ||
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3578 | g_free(conv_msg); |
|
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3579 | |
| 15884 | 3580 | if (purple_presence_is_idle(presence)) |
| 10394 | 3581 | yahoo_packet_hash_str(pkt, 47, "2"); |
| 15884 | 3582 | else if (!purple_status_is_available(status)) |
| 10394 | 3583 | yahoo_packet_hash_str(pkt, 47, "1"); |
| 2681 | 3584 | |
| 10392 | 3585 | yahoo_packet_send_and_free(pkt, yd); |
| 9984 | 3586 | |
| 10373 | 3587 | if (old_status == YAHOO_STATUS_INVISIBLE) { |
| 3588 | pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3589 | yahoo_packet_hash_str(pkt, 13, "1"); |
| 10392 | 3590 | yahoo_packet_send_and_free(pkt, yd); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3591 | |
|
12010
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3592 | /* Any per-session presence settings are removed */ |
|
aa2f3b07ec09
[gaim-migrate @ 14303]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11985
diff
changeset
|
3593 | g_hash_table_foreach(yd->friends, yahoo_session_presence_remove, NULL); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3594 | |
| 10373 | 3595 | } |
| 2681 | 3596 | } |
| 3597 | ||
| 15884 | 3598 | static void yahoo_set_idle(PurpleConnection *gc, int idle) |
| 2681 | 3599 | { |
| 3600 | struct yahoo_data *yd = gc->proto_data; | |
| 3601 | struct yahoo_packet *pkt = NULL; | |
| 8503 | 3602 | char *msg = NULL, *msg2 = NULL; |
| 15884 | 3603 | PurpleStatus *status = NULL; |
|
13559
c7256daef931
[gaim-migrate @ 15937]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13462
diff
changeset
|
3604 | |
|
13688
240e5b90adb4
[gaim-migrate @ 16089]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13559
diff
changeset
|
3605 | if (idle && yd->current_status != YAHOO_STATUS_CUSTOM) |
| 2681 | 3606 | yd->current_status = YAHOO_STATUS_IDLE; |
|
13559
c7256daef931
[gaim-migrate @ 15937]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13462
diff
changeset
|
3607 | else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { |
| 15884 | 3608 | status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
| 3609 | yd->current_status = get_yahoo_status_from_purple_status(status); | |
|
13559
c7256daef931
[gaim-migrate @ 15937]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13462
diff
changeset
|
3610 | } |
| 10373 | 3611 | |
| 3612 | pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | |
| 3613 | ||
| 10394 | 3614 | yahoo_packet_hash_int(pkt, 10, yd->current_status); |
| 10373 | 3615 | if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3616 | const char *tmp; |
|
13559
c7256daef931
[gaim-migrate @ 15937]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13462
diff
changeset
|
3617 | if (status == NULL) |
| 15884 | 3618 | status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
| 3619 | tmp = purple_status_get_attr_string(status, "message"); | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3620 | if (tmp != NULL) { |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3621 | msg = yahoo_string_encode(gc, tmp, NULL); |
| 15884 | 3622 | msg2 = purple_markup_strip_html(msg); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3623 | yahoo_packet_hash_str(pkt, 19, msg2); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3624 | } else { |
| 15884 | 3625 | /* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for |
|
13559
c7256daef931
[gaim-migrate @ 15937]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13462
diff
changeset
|
3626 | * the generic away state (YAHOO_STATUS_TYPE_AWAY) with no message */ |
|
c7256daef931
[gaim-migrate @ 15937]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13462
diff
changeset
|
3627 | yahoo_packet_hash_str(pkt, 19, _("Away")); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3628 | } |
| 6847 | 3629 | } else { |
| 10394 | 3630 | yahoo_packet_hash_str(pkt, 19, ""); |
| 2681 | 3631 | } |
| 3632 | ||
| 10373 | 3633 | if (idle) |
| 10394 | 3634 | yahoo_packet_hash_str(pkt, 47, "2"); |
| 15884 | 3635 | else if (!purple_presence_is_available(purple_account_get_presence(purple_connection_get_account(gc)))) |
| 10394 | 3636 | yahoo_packet_hash_str(pkt, 47, "1"); |
| 10373 | 3637 | |
| 10392 | 3638 | yahoo_packet_send_and_free(pkt, yd); |
| 10373 | 3639 | |
| 3640 | g_free(msg); | |
| 3641 | g_free(msg2); | |
| 2681 | 3642 | } |
| 3643 | ||
| 15884 | 3644 | static GList *yahoo_status_types(PurpleAccount *account) |
| 2681 | 3645 | { |
| 15884 | 3646 | PurpleStatusType *type; |
| 9979 | 3647 | GList *types = NULL; |
| 3648 | ||
| 15884 | 3649 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, YAHOO_STATUS_TYPE_AVAILABLE, |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
3650 | NULL, TRUE, TRUE, FALSE, |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3651 | "message", _("Message"), |
| 15884 | 3652 | purple_value_new(PURPLE_TYPE_STRING), NULL); |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3653 | types = g_list_append(types, type); |
|
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3654 | |
| 15884 | 3655 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_AWAY, |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
3656 | NULL, TRUE, TRUE, FALSE, |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3657 | "message", _("Message"), |
| 15884 | 3658 | purple_value_new(PURPLE_TYPE_STRING), NULL); |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3659 | types = g_list_append(types, type); |
|
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3660 | |
| 15884 | 3661 | type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_BRB, _("Be Right Back"), TRUE); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3662 | types = g_list_append(types, type); |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3663 | |
| 15884 | 3664 | type = purple_status_type_new(PURPLE_STATUS_UNAVAILABLE, YAHOO_STATUS_TYPE_BUSY, _("Busy"), TRUE); |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3665 | types = g_list_append(types, type); |
|
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3666 | |
| 15884 | 3667 | type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTATHOME, _("Not at Home"), TRUE); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3668 | types = g_list_append(types, type); |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3669 | |
| 15884 | 3670 | type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTATDESK, _("Not at Desk"), TRUE); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3671 | types = g_list_append(types, type); |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3672 | |
| 15884 | 3673 | type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTINOFFICE, _("Not in Office"), TRUE); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3674 | types = g_list_append(types, type); |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3675 | |
| 15884 | 3676 | type = purple_status_type_new(PURPLE_STATUS_UNAVAILABLE, YAHOO_STATUS_TYPE_ONPHONE, _("On the Phone"), TRUE); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3677 | types = g_list_append(types, type); |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3678 | |
| 15884 | 3679 | type = purple_status_type_new(PURPLE_STATUS_EXTENDED_AWAY, YAHOO_STATUS_TYPE_ONVACATION, _("On Vacation"), TRUE); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3680 | types = g_list_append(types, type); |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3681 | |
| 15884 | 3682 | type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_OUTTOLUNCH, _("Out to Lunch"), TRUE); |
|
12206
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3683 | types = g_list_append(types, type); |
|
f59128c6d479
[gaim-migrate @ 14508]
Luke Schierer <lschiere@pidgin.im>
parents:
12203
diff
changeset
|
3684 | |
| 15884 | 3685 | type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_STEPPEDOUT, _("Stepped Out"), TRUE); |
|
12203
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
3686 | types = g_list_append(types, type); |
|
a8ac8491df3a
[gaim-migrate @ 14505]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12152
diff
changeset
|
3687 | |
|
11970
5160cebfa5e0
[gaim-migrate @ 14263]
Mark Doliner <markdoliner@pidgin.im>
parents:
11969
diff
changeset
|
3688 | |
| 15884 | 3689 | type = purple_status_type_new(PURPLE_STATUS_INVISIBLE, YAHOO_STATUS_TYPE_INVISIBLE, NULL, TRUE); |
| 9979 | 3690 | types = g_list_append(types, type); |
| 3691 | ||
| 15884 | 3692 | type = purple_status_type_new(PURPLE_STATUS_OFFLINE, YAHOO_STATUS_TYPE_OFFLINE, NULL, TRUE); |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
3693 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
3694 | |
| 15884 | 3695 | type = purple_status_type_new_full(PURPLE_STATUS_MOBILE, YAHOO_STATUS_TYPE_MOBILE, NULL, FALSE, FALSE, TRUE); |
| 15589 | 3696 | types = g_list_append(types, type); |
| 3697 | ||
| 9979 | 3698 | return types; |
| 2681 | 3699 | } |
| 3700 | ||
| 15884 | 3701 | static void yahoo_keepalive(PurpleConnection *gc) |
| 2681 | 3702 | { |
| 3703 | struct yahoo_data *yd = gc->proto_data; | |
| 3704 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
| 10392 | 3705 | yahoo_packet_send_and_free(pkt, yd); |
| 6729 | 3706 | |
| 3707 | if (!yd->chat_online) | |
| 3708 | return; | |
| 3709 | ||
| 9376 | 3710 | if (yd->wm) { |
| 3711 | ycht_chat_send_keepalive(yd->ycht); | |
| 3712 | return; | |
| 3713 | } | |
| 3714 | ||
| 6729 | 3715 | pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); |
| 15884 | 3716 | yahoo_packet_hash_str(pkt, 109, purple_connection_get_display_name(gc)); |
| 10394 | 3717 | yahoo_packet_send_and_free(pkt, yd); |
| 2681 | 3718 | } |
| 3719 | ||
| 15884 | 3720 | /* XXX - What's the deal with PurpleGroup *foo? */ |
| 3721 | static void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *foo) | |
| 2681 | 3722 | { |
| 3723 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 3724 | struct yahoo_packet *pkt; | |
| 15884 | 3725 | PurpleGroup *g; |
| 2681 | 3726 | char *group = NULL; |
| 7829 | 3727 | char *group2 = NULL; |
|
19411
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
3728 | YahooFriend *f; |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
3729 | |
| 2681 | 3730 | if (!yd->logged_in) |
| 3731 | return; | |
| 3732 | ||
| 15884 | 3733 | if (!yahoo_privacy_check(gc, purple_buddy_get_name(buddy))) |
|
10963
8011e6bc10b5
[gaim-migrate @ 12768]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10944
diff
changeset
|
3734 | return; |
|
8011e6bc10b5
[gaim-migrate @ 12768]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10944
diff
changeset
|
3735 | |
|
19411
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
3736 | f = yahoo_friend_find(gc, purple_buddy_get_name(buddy)); |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
3737 | |
| 6840 | 3738 | if (foo) |
| 3739 | group = foo->name; | |
| 3740 | if (!group) { | |
| 15884 | 3741 | g = purple_buddy_get_group(buddy); |
| 6840 | 3742 | if (g) |
| 3743 | group = g->name; | |
| 3744 | else | |
| 3745 | group = "Buddies"; | |
| 3746 | } | |
| 2681 | 3747 | |
| 7829 | 3748 | group2 = yahoo_string_encode(gc, group, NULL); |
| 2681 | 3749 | pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
|
19330
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3750 | yahoo_packet_hash(pkt, "ssssssssss", |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3751 | 14, "", |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3752 | 65, group2, |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3753 | 97, "1", |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3754 | 1, purple_connection_get_display_name(gc), |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3755 | 302, "319", |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3756 | 300, "319", |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3757 | 7, buddy->name, |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3758 | 334, "0", |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3759 | 301, "319", |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3760 | 303, "319" |
|
a2e7ef0cab90
Make adding buddies work again for yahoo.
Tim Ringenbach <marv@pidgin.im>
parents:
19329
diff
changeset
|
3761 | ); |
|
19411
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
3762 | if (f && f->protocol) |
|
450006e4bfc2
Allow you to authorize msn buddies to add your yahoo account.
Tim Ringenbach <marv@pidgin.im>
parents:
19339
diff
changeset
|
3763 | yahoo_packet_hash_int(pkt, 241, f->protocol); |
| 10392 | 3764 | yahoo_packet_send_and_free(pkt, yd); |
| 7829 | 3765 | g_free(group2); |
| 2681 | 3766 | } |
| 3767 | ||
| 15884 | 3768 | static void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 2681 | 3769 | { |
| 3770 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
|
6795
396b24cfeeb6
[gaim-migrate @ 7334]
Herman Bloggs <herman@bluedigits.com>
parents:
6793
diff
changeset
|
3771 | struct yahoo_packet *pkt; |
| 6840 | 3772 | GSList *buddies, *l; |
| 15884 | 3773 | PurpleGroup *g; |
| 6840 | 3774 | gboolean remove = TRUE; |
| 7827 | 3775 | char *cg; |
| 6784 | 3776 | |
|
13713
1ae8790174a4
[gaim-migrate @ 16115]
Richard Laager <rlaager@pidgin.im>
parents:
13707
diff
changeset
|
3777 | if (!(yahoo_friend_find(gc, buddy->name))) |
| 6784 | 3778 | return; |
| 3779 | ||
| 15884 | 3780 | buddies = purple_find_buddies(purple_connection_get_account(gc), buddy->name); |
| 6840 | 3781 | for (l = buddies; l; l = l->next) { |
| 15884 | 3782 | g = purple_buddy_get_group(l->data); |
| 3783 | if (purple_utf8_strcasecmp(group->name, g->name)) { | |
| 6840 | 3784 | remove = FALSE; |
| 3785 | break; | |
| 3786 | } | |
| 3787 | } | |
| 3788 | ||
| 3789 | g_slist_free(buddies); | |
| 3790 | ||
| 3791 | if (remove) | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3792 | g_hash_table_remove(yd->friends, buddy->name); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3793 | |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3794 | cg = yahoo_string_encode(gc, group->name, NULL); |
|
6795
396b24cfeeb6
[gaim-migrate @ 7334]
Herman Bloggs <herman@bluedigits.com>
parents:
6793
diff
changeset
|
3795 | pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
| 15884 | 3796 | yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
| 10394 | 3797 | 7, buddy->name, 65, cg); |
| 10392 | 3798 | yahoo_packet_send_and_free(pkt, yd); |
| 7827 | 3799 | g_free(cg); |
| 2681 | 3800 | } |
| 3801 | ||
| 15884 | 3802 | static void yahoo_add_deny(PurpleConnection *gc, const char *who) { |
| 6760 | 3803 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 3804 | struct yahoo_packet *pkt; | |
| 3805 | ||
| 3806 | if (!yd->logged_in) | |
| 3807 | return; | |
| 8057 | 3808 | /* It seems to work better without this */ |
| 3809 | ||
| 8113 | 3810 | /* if (gc->account->perm_deny != 4) |
| 3811 | return; */ | |
| 3812 | ||
| 3813 | if (!who || who[0] == '\0') | |
| 3814 | return; | |
| 3815 | ||
| 6760 | 3816 | pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); |
| 15884 | 3817 | yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
| 10394 | 3818 | 7, who, 13, "1"); |
| 10392 | 3819 | yahoo_packet_send_and_free(pkt, yd); |
| 6760 | 3820 | } |
| 3821 | ||
| 15884 | 3822 | static void yahoo_rem_deny(PurpleConnection *gc, const char *who) { |
| 6760 | 3823 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 3824 | struct yahoo_packet *pkt; | |
| 3825 | ||
| 3826 | if (!yd->logged_in) | |
| 3827 | return; | |
| 3828 | ||
| 3829 | if (!who || who[0] == '\0') | |
| 3830 | return; | |
| 3831 | ||
| 3832 | pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 15884 | 3833 | yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), 7, who, 13, "2"); |
| 10392 | 3834 | yahoo_packet_send_and_free(pkt, yd); |
| 6760 | 3835 | } |
| 3836 | ||
| 15884 | 3837 | static void yahoo_set_permit_deny(PurpleConnection *gc) { |
| 3838 | PurpleAccount *acct; | |
| 6760 | 3839 | GSList *deny; |
| 3840 | ||
| 3841 | acct = gc->account; | |
| 3842 | ||
| 3843 | switch (acct->perm_deny) { | |
| 10105 | 3844 | /* privacy 1 */ |
| 15884 | 3845 | case PURPLE_PRIVACY_ALLOW_ALL: |
| 10143 | 3846 | for (deny = acct->deny;deny;deny = deny->next) |
| 3847 | yahoo_rem_deny(gc, deny->data); | |
| 3848 | break; | |
| 10105 | 3849 | /* privacy 3 */ |
| 15884 | 3850 | case PURPLE_PRIVACY_ALLOW_USERS: |
| 6760 | 3851 | for (deny = acct->deny;deny;deny = deny->next) |
| 3852 | yahoo_rem_deny(gc, deny->data); | |
| 3853 | break; | |
| 10105 | 3854 | /* privacy 5 */ |
| 15884 | 3855 | case PURPLE_PRIVACY_ALLOW_BUDDYLIST: |
| 10105 | 3856 | /* privacy 4 */ |
| 15884 | 3857 | case PURPLE_PRIVACY_DENY_USERS: |
| 6760 | 3858 | for (deny = acct->deny;deny;deny = deny->next) |
| 3859 | yahoo_add_deny(gc, deny->data); | |
| 3860 | break; | |
| 10105 | 3861 | /* privacy 2 */ |
| 15884 | 3862 | case PURPLE_PRIVACY_DENY_ALL: |
| 6760 | 3863 | default: |
| 3864 | break; | |
| 3865 | } | |
| 3866 | } | |
| 3867 | ||
| 15884 | 3868 | static gboolean yahoo_unload_plugin(PurplePlugin *plugin) |
| 6513 | 3869 | { |
| 3870 | yahoo_dest_colorht(); | |
| 11033 | 3871 | |
| 6513 | 3872 | return TRUE; |
| 3873 | } | |
| 3874 | ||
| 15884 | 3875 | static void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, |
| 6793 | 3876 | const char *old_group, const char *new_group) |
| 3877 | { | |
| 3878 | struct yahoo_data *yd = gc->proto_data; | |
| 3879 | struct yahoo_packet *pkt; | |
| 7827 | 3880 | char *gpn, *gpo; |
| 6793 | 3881 | |
| 3882 | /* Step 0: If they aren't on the server list anyway, | |
| 3883 | * don't bother letting the server know. | |
| 3884 | */ | |
| 9279 | 3885 | if (!yahoo_friend_find(gc, who)) |
| 6793 | 3886 | return; |
| 3887 | ||
| 7827 | 3888 | /* If old and new are the same, we would probably |
| 3889 | * end up deleting the buddy, which would be bad. | |
| 3890 | * This might happen because of the charset conversation. | |
| 3891 | */ | |
| 3892 | gpn = yahoo_string_encode(gc, new_group, NULL); | |
| 3893 | gpo = yahoo_string_encode(gc, old_group, NULL); | |
| 3894 | if (!strcmp(gpn, gpo)) { | |
| 3895 | g_free(gpn); | |
| 3896 | g_free(gpo); | |
| 3897 | return; | |
| 3898 | } | |
| 3899 | ||
|
19329
2acabedbaa3e
Allow you to move your Yahoo! buddies between groups again.
Tim Ringenbach <marv@pidgin.im>
parents:
19064
diff
changeset
|
3900 | pkt = yahoo_packet_new(YAHOO_SERVICE_CHGRP_15, YAHOO_STATUS_AVAILABLE, 0); |
|
2acabedbaa3e
Allow you to move your Yahoo! buddies between groups again.
Tim Ringenbach <marv@pidgin.im>
parents:
19064
diff
changeset
|
3901 | yahoo_packet_hash(pkt, "ssssssss", 1, purple_connection_get_display_name(gc), |
|
2acabedbaa3e
Allow you to move your Yahoo! buddies between groups again.
Tim Ringenbach <marv@pidgin.im>
parents:
19064
diff
changeset
|
3902 | 302, "240", 300, "240", 7, who, 224, gpo, 264, gpn, 301, |
|
2acabedbaa3e
Allow you to move your Yahoo! buddies between groups again.
Tim Ringenbach <marv@pidgin.im>
parents:
19064
diff
changeset
|
3903 | "240", 303, "240"); |
| 10392 | 3904 | yahoo_packet_send_and_free(pkt, yd); |
| 6793 | 3905 | |
| 7827 | 3906 | g_free(gpn); |
| 3907 | g_free(gpo); | |
| 6793 | 3908 | } |
| 3909 | ||
| 15884 | 3910 | static void yahoo_rename_group(PurpleConnection *gc, const char *old_name, |
| 3911 | PurpleGroup *group, GList *moved_buddies) | |
| 6793 | 3912 | { |
| 3913 | struct yahoo_data *yd = gc->proto_data; | |
| 3914 | struct yahoo_packet *pkt; | |
| 7827 | 3915 | char *gpn, *gpo; |
| 3916 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3917 | gpn = yahoo_string_encode(gc, group->name, NULL); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3918 | gpo = yahoo_string_encode(gc, old_name, NULL); |
| 7827 | 3919 | if (!strcmp(gpn, gpo)) { |
| 3920 | g_free(gpn); | |
| 3921 | g_free(gpo); | |
| 3922 | return; | |
| 3923 | } | |
| 6793 | 3924 | |
| 3925 | pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); | |
| 15884 | 3926 | yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
| 10394 | 3927 | 65, gpo, 67, gpn); |
| 10392 | 3928 | yahoo_packet_send_and_free(pkt, yd); |
| 7827 | 3929 | g_free(gpn); |
| 3930 | g_free(gpo); | |
| 6793 | 3931 | } |
| 3932 | ||
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
3933 | /********************************* Commands **********************************/ |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
3934 | |
| 15884 | 3935 | static PurpleCmdRet |
| 3936 | yahoopurple_cmd_buzz(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) { | |
| 3937 | ||
| 3938 | PurpleAccount *account = purple_conversation_get_account(c); | |
| 3939 | const char *username = purple_account_get_username(account); | |
| 10119 | 3940 | |
| 3941 | if (*args && args[0]) | |
| 15884 | 3942 | return PURPLE_CMD_RET_FAILED; |
| 3943 | ||
| 3944 | purple_debug(PURPLE_DEBUG_INFO, "yahoo", | |
| 10119 | 3945 | "Sending <ding> on account %s to buddy %s.\n", username, c->name); |
| 15884 | 3946 | purple_conv_im_send(PURPLE_CONV_IM(c), "<ding>"); |
|
16007
3d954c38cf0c
Patch from Zac West which (1) adds a message flag, PURPLE_MESSAGE_NOTIFY, used to indicate that a message is a protocol-level notification from a user ('buzz' in yahoo, 'nudge' in msn, for example) and (2) uses it along with improving the text displayed when sending/receiving buzzes and nudges. The addition of this flag means that a plugin could implement custom behavior, such as playing a sound or triggerring some other event, reliably and easily.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
3947 | purple_conversation_write(c, NULL, _("You have just sent a Buzz!"), PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 15884 | 3948 | return PURPLE_CMD_RET_OK; |
| 10119 | 3949 | } |
| 3950 | ||
| 15884 | 3951 | static PurplePlugin *my_protocol = NULL; |
| 3952 | ||
| 3953 | static PurpleCmdRet | |
| 3954 | yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd, | |
| 10119 | 3955 | char **args, char **error, void *data) |
| 3956 | { | |
| 3957 | GHashTable *comp; | |
| 15884 | 3958 | PurpleConnection *gc; |
| 10119 | 3959 | struct yahoo_data *yd; |
| 3960 | int id; | |
| 3961 | ||
| 3962 | if (!args || !args[0]) | |
| 15884 | 3963 | return PURPLE_CMD_RET_FAILED; |
| 3964 | ||
| 3965 | gc = purple_conversation_get_gc(conv); | |
| 10119 | 3966 | yd = gc->proto_data; |
| 3967 | id = yd->conf_id; | |
| 15884 | 3968 | purple_debug(PURPLE_DEBUG_INFO, "yahoo", |
| 10119 | 3969 | "Trying to join %s \n", args[0]); |
| 3970 | ||
| 3971 | comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 3972 | g_hash_table_replace(comp, g_strdup("room"), | |
| 3973 | g_strdup_printf("%s", g_ascii_strdown(args[0], strlen(args[0])))); | |
|
11077
c189de76c00e
[gaim-migrate @ 13087]
Mark Doliner <markdoliner@pidgin.im>
parents:
11076
diff
changeset
|
3974 | g_hash_table_replace(comp, g_strdup("type"), g_strdup("Chat")); |
| 10119 | 3975 | |
| 3976 | yahoo_c_join(gc, comp); | |
| 3977 | ||
| 3978 | g_hash_table_destroy(comp); | |
| 15884 | 3979 | return PURPLE_CMD_RET_OK; |
| 10119 | 3980 | } |
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
3981 | |
| 15884 | 3982 | static PurpleCmdRet |
| 3983 | yahoopurple_cmd_chat_list(PurpleConversation *conv, const char *cmd, | |
|
13041
0eebc22048e6
[gaim-migrate @ 15400]
Peter Lawler <pidgin@bleeter.id.au>
parents:
13021
diff
changeset
|
3984 | char **args, char **error, void *data) |
|
0eebc22048e6
[gaim-migrate @ 15400]
Peter Lawler <pidgin@bleeter.id.au>
parents:
13021
diff
changeset
|
3985 | { |
| 15884 | 3986 | PurpleAccount *account = purple_conversation_get_account(conv); |
|
13041
0eebc22048e6
[gaim-migrate @ 15400]
Peter Lawler <pidgin@bleeter.id.au>
parents:
13021
diff
changeset
|
3987 | if (*args && args[0]) |
| 15884 | 3988 | return PURPLE_CMD_RET_FAILED; |
| 3989 | purple_roomlist_show_with_account(account); | |
| 3990 | return PURPLE_CMD_RET_OK; | |
|
13041
0eebc22048e6
[gaim-migrate @ 15400]
Peter Lawler <pidgin@bleeter.id.au>
parents:
13021
diff
changeset
|
3991 | } |
|
0eebc22048e6
[gaim-migrate @ 15400]
Peter Lawler <pidgin@bleeter.id.au>
parents:
13021
diff
changeset
|
3992 | |
| 15884 | 3993 | static gboolean yahoo_offline_message(const PurpleBuddy *buddy) |
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
3994 | { |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
3995 | return TRUE; |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
3996 | } |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
3997 | |
| 10119 | 3998 | /************************** Plugin Initialization ****************************/ |
| 3999 | static void | |
| 15884 | 4000 | yahoopurple_register_commands(void) |
| 10119 | 4001 | { |
| 15884 | 4002 | purple_cmd_register("join", "s", PURPLE_CMD_P_PRPL, |
| 4003 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | | |
| 4004 | PURPLE_CMD_FLAG_PRPL_ONLY, | |
| 4005 | "prpl-yahoo", yahoopurple_cmd_chat_join, | |
| 10119 | 4006 | _("join <room>: Join a chat room on the Yahoo network"), NULL); |
| 15884 | 4007 | purple_cmd_register("list", "", PURPLE_CMD_P_PRPL, |
| 4008 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | | |
| 4009 | PURPLE_CMD_FLAG_PRPL_ONLY, | |
| 4010 | "prpl-yahoo", yahoopurple_cmd_chat_list, | |
|
13041
0eebc22048e6
[gaim-migrate @ 15400]
Peter Lawler <pidgin@bleeter.id.au>
parents:
13021
diff
changeset
|
4011 | _("list: List rooms on the Yahoo network"), NULL); |
| 15884 | 4012 | purple_cmd_register("buzz", "", PURPLE_CMD_P_PRPL, |
| 4013 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY, | |
| 4014 | "prpl-yahoo", yahoopurple_cmd_buzz, | |
|
12318
942b7c089acb
[gaim-migrate @ 14622]
Richard Laager <rlaager@pidgin.im>
parents:
12243
diff
changeset
|
4015 | _("buzz: Buzz a user to get their attention"), NULL); |
| 15884 | 4016 | purple_cmd_register("doodle", "", PURPLE_CMD_P_PRPL, |
| 4017 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY, | |
| 4018 | "prpl-yahoo", yahoo_doodle_purple_cmd_start, | |
|
13041
0eebc22048e6
[gaim-migrate @ 15400]
Peter Lawler <pidgin@bleeter.id.au>
parents:
13021
diff
changeset
|
4019 | _("doodle: Request user to start a Doodle session"), NULL); |
| 10119 | 4020 | } |
| 4021 | ||
| 15884 | 4022 | static PurpleAccount *find_acct(const char *prpl, const char *acct_id) |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4023 | { |
| 15884 | 4024 | PurpleAccount *acct = NULL; |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4025 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4026 | /* If we have a specific acct, use it */ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4027 | if (acct_id) { |
| 15884 | 4028 | acct = purple_accounts_find(acct_id, prpl); |
| 4029 | if (acct && !purple_account_is_connected(acct)) | |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4030 | acct = NULL; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4031 | } else { /* Otherwise find an active account for the protocol */ |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
4032 | GList *l = purple_accounts_get_all(); |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4033 | while (l) { |
| 15884 | 4034 | if (!strcmp(prpl, purple_account_get_protocol_id(l->data)) |
| 4035 | && purple_account_is_connected(l->data)) { | |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4036 | acct = l->data; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4037 | break; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4038 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4039 | l = l->next; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4040 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4041 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4042 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4043 | return acct; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4044 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4045 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4046 | /* This may not be the best way to do this, but we find the first key w/o a value |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4047 | * and assume it is the screenname */ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4048 | static void yahoo_find_uri_novalue_param(gpointer key, gpointer value, gpointer user_data) |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4049 | { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4050 | char **retval = user_data; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4051 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4052 | if (value == NULL && *retval == NULL) { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4053 | *retval = key; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4054 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4055 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4056 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4057 | static gboolean yahoo_uri_handler(const char *proto, const char *cmd, GHashTable *params) |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4058 | { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4059 | char *acct_id = g_hash_table_lookup(params, "account"); |
| 15884 | 4060 | PurpleAccount *acct; |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4061 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4062 | if (g_ascii_strcasecmp(proto, "ymsgr")) |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4063 | return FALSE; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4064 | |
| 15884 | 4065 | acct = find_acct(purple_plugin_get_id(my_protocol), acct_id); |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4066 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4067 | if (!acct) |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4068 | return FALSE; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4069 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4070 | /* ymsgr:SendIM?screename&m=The+Message */ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4071 | if (!g_ascii_strcasecmp(cmd, "SendIM")) { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4072 | char *sname = NULL; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4073 | g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &sname); |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4074 | if (sname) { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4075 | char *message = g_hash_table_lookup(params, "m"); |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4076 | |
| 15884 | 4077 | PurpleConversation *conv = purple_find_conversation_with_account( |
| 4078 | PURPLE_CONV_TYPE_IM, sname, acct); | |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4079 | if (conv == NULL) |
| 15884 | 4080 | conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, sname); |
| 4081 | purple_conversation_present(conv); | |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4082 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4083 | if (message) { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4084 | /* Spaces are encoded as '+' */ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4085 | g_strdelimit(message, "+", ' '); |
|
18940
8a9341775495
Don't actually send messages using the protocol handlers (open the window and pre-populate the message, but require the user to actually send the message). Fixes #1961.
Daniel Atallah <datallah@pidgin.im>
parents:
18122
diff
changeset
|
4086 | purple_conv_send_confirm(conv, message); |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4087 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4088 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4089 | /*else |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4090 | **If pidgindialogs_im() was in the core, we could use it here. |
| 15884 | 4091 | * It is all purple_request_* based, but I'm not sure it really belongs in the core |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4092 | pidgindialogs_im();*/ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4093 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4094 | return TRUE; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4095 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4096 | /* ymsgr:Chat?roomname */ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4097 | else if (!g_ascii_strcasecmp(cmd, "Chat")) { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4098 | char *rname = NULL; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4099 | g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &rname); |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4100 | if (rname) { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4101 | /* This is somewhat hacky, but the params aren't useful after this command */ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4102 | g_hash_table_insert(params, g_strdup("room"), g_strdup(rname)); |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4103 | g_hash_table_insert(params, g_strdup("type"), g_strdup("Chat")); |
| 15884 | 4104 | serv_join_chat(purple_account_get_connection(acct), params); |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4105 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4106 | /*else |
| 15884 | 4107 | ** Same as above (except that this would have to be re-written using purple_request_*) |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4108 | pidgin_blist_joinchat_show(); */ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4109 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4110 | return TRUE; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4111 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4112 | /* ymsgr:AddFriend?name */ |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4113 | else if (!g_ascii_strcasecmp(cmd, "AddFriend")) { |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4114 | char *name = NULL; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4115 | g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &name); |
| 15884 | 4116 | purple_blist_request_add_buddy(acct, name, NULL, NULL); |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4117 | return TRUE; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4118 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4119 | |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4120 | return FALSE; |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4121 | } |
|
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4122 | |
| 15884 | 4123 | static PurpleWhiteboardPrplOps yahoo_whiteboard_prpl_ops = |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4124 | { |
|
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4125 | yahoo_doodle_start, |
|
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4126 | yahoo_doodle_end, |
|
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4127 | yahoo_doodle_get_dimensions, |
|
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4128 | NULL, |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11897
diff
changeset
|
4129 | yahoo_doodle_get_brush, |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11897
diff
changeset
|
4130 | yahoo_doodle_set_brush, |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4131 | yahoo_doodle_send_draw_list, |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4132 | yahoo_doodle_clear, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4133 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4134 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4135 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4136 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4137 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4138 | NULL |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4139 | }; |
|
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4140 | |
| 15884 | 4141 | static PurplePluginProtocolInfo prpl_info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4142 | { |
| 9308 | 4143 | OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, |
| 6729 | 4144 | NULL, /* user_splits */ |
| 4145 | NULL, /* protocol_options */ | |
| 15884 | 4146 | {"png,gif,jpeg", 96, 96, 96, 96, 0, PURPLE_ICON_SCALE_SEND}, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4147 | yahoo_list_icon, |
| 15524 | 4148 | yahoo_list_emblem, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4149 | yahoo_status_text, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4150 | yahoo_tooltip_text, |
| 9979 | 4151 | yahoo_status_types, |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
4152 | yahoo_blist_node_menu, |
| 6729 | 4153 | yahoo_c_info, |
| 9768 | 4154 | yahoo_c_info_defaults, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4155 | yahoo_login, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4156 | yahoo_close, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4157 | yahoo_send_im, |
| 6729 | 4158 | NULL, /* set info */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4159 | yahoo_send_typing, |
| 6514 | 4160 | yahoo_get_info, |
| 9984 | 4161 | yahoo_set_status, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4162 | yahoo_set_idle, |
| 6729 | 4163 | NULL, /* change_passwd*/ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4164 | yahoo_add_buddy, |
| 6729 | 4165 | NULL, /* add_buddies */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4166 | yahoo_remove_buddy, |
| 6729 | 4167 | NULL, /*remove_buddies */ |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
4168 | yahoo_add_permit, |
| 6760 | 4169 | yahoo_add_deny, |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
4170 | yahoo_rem_permit, |
| 6760 | 4171 | yahoo_rem_deny, |
| 4172 | yahoo_set_permit_deny, | |
| 6729 | 4173 | yahoo_c_join, |
|
8562
7e73676d1772
[gaim-migrate @ 9306]
Christopher O'Brien <siege@pidgin.im>
parents:
8503
diff
changeset
|
4174 | NULL, /* reject chat invite */ |
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9888
diff
changeset
|
4175 | yahoo_get_chat_name, |
| 6729 | 4176 | yahoo_c_invite, |
| 4177 | yahoo_c_leave, | |
| 4178 | NULL, /* chat whisper */ | |
| 4179 | yahoo_c_send, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4180 | yahoo_keepalive, |
| 6729 | 4181 | NULL, /* register_user */ |
| 4182 | NULL, /* get_cb_info */ | |
| 4183 | NULL, /* get_cb_away */ | |
|
19058
9facc10e1c01
Yahoo server-side aliases patch from John Moody. Fixes #1653 Thanks!
Sean Egan <seanegan@pidgin.im>
parents:
19053
diff
changeset
|
4184 | yahoo_update_alias, /* alias_buddy */ |
| 6793 | 4185 | yahoo_change_buddys_group, |
| 4186 | yahoo_rename_group, | |
| 6729 | 4187 | NULL, /* buddy_free */ |
| 4188 | NULL, /* convo_closed */ | |
| 15884 | 4189 | purple_normalize_nocase, /* normalize */ |
| 9306 | 4190 | yahoo_set_buddy_icon, |
| 15884 | 4191 | NULL, /* void (*remove_group)(PurpleConnection *gc, const char *group);*/ |
| 4192 | NULL, /* char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who); */ | |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
4193 | NULL, /* set_chat_topic */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
4194 | NULL, /* find_blist_chat */ |
| 8113 | 4195 | yahoo_roomlist_get_list, |
| 4196 | yahoo_roomlist_cancel, | |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9410
diff
changeset
|
4197 | yahoo_roomlist_expand_category, |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
4198 | NULL, /* can_receive_file */ |
|
11475
1e222e6e52a0
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11338
diff
changeset
|
4199 | yahoo_send_file, |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12138
diff
changeset
|
4200 | yahoo_new_xfer, |
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
4201 | yahoo_offline_message, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
4202 | &yahoo_whiteboard_prpl_ops, |
| 15185 | 4203 | NULL, /* send_raw */ |
| 4204 | NULL, /* roomlist_room_serialize */ | |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4205 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4206 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4207 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4208 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4209 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4210 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4211 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4212 | |
| 15884 | 4213 | static PurplePluginInfo info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4214 | { |
| 15884 | 4215 | PURPLE_PLUGIN_MAGIC, |
| 4216 | PURPLE_MAJOR_VERSION, | |
| 4217 | PURPLE_MINOR_VERSION, | |
| 4218 | PURPLE_PLUGIN_PROTOCOL, /**< type */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4219 | NULL, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4220 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4221 | NULL, /**< dependencies */ |
| 15884 | 4222 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4223 | "prpl-yahoo", /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4224 | "Yahoo", /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4225 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4226 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4227 | N_("Yahoo Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4228 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4229 | N_("Yahoo Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4230 | NULL, /**< author */ |
| 15884 | 4231 | PURPLE_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4232 | NULL, /**< load */ |
| 6513 | 4233 | yahoo_unload_plugin, /**< unload */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4234 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4235 | NULL, /**< ui_info */ |
| 8993 | 4236 | &prpl_info, /**< extra_info */ |
| 4237 | NULL, | |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4238 | yahoo_actions, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4239 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4240 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4241 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4242 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4243 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16606
diff
changeset
|
4244 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4245 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4246 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4247 | static void |
| 15884 | 4248 | init_plugin(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4249 | { |
| 15884 | 4250 | PurpleAccountOption *option; |
| 4251 | ||
| 4252 | option = purple_account_option_bool_new(_("Yahoo Japan"), "yahoojp", FALSE); | |
| 9164 | 4253 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4254 | ||
| 15884 | 4255 | option = purple_account_option_string_new(_("Pager server"), "server", YAHOO_PAGER_HOST); |
| 7827 | 4256 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4257 | ||
| 15884 | 4258 | option = purple_account_option_string_new(_("Japan Pager server"), "serverjp", YAHOOJP_PAGER_HOST); |
| 9164 | 4259 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4260 | ||
| 15884 | 4261 | option = purple_account_option_int_new(_("Pager port"), "port", YAHOO_PAGER_PORT); |
| 7827 | 4262 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 7651 | 4263 | |
| 15884 | 4264 | option = purple_account_option_string_new(_("File transfer server"), "xfer_host", YAHOO_XFER_HOST); |
| 7651 | 4265 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4266 | ||
| 15884 | 4267 | option = purple_account_option_string_new(_("Japan file transfer server"), "xferjp_host", YAHOOJP_XFER_HOST); |
| 9164 | 4268 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4269 | ||
| 15884 | 4270 | option = purple_account_option_int_new(_("File transfer port"), "xfer_port", YAHOO_XFER_PORT); |
| 7651 | 4271 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4272 | ||
| 15884 | 4273 | option = purple_account_option_string_new(_("Chat room locale"), "room_list_locale", YAHOO_ROOMLIST_LOCALE); |
|
11043
763427cecd21
[gaim-migrate @ 12957]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11033
diff
changeset
|
4274 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
12999
7479d16384c0
[gaim-migrate @ 15352]
Daniel Atallah <datallah@pidgin.im>
parents:
12994
diff
changeset
|
4275 | |
| 15884 | 4276 | option = purple_account_option_bool_new(_("Ignore conference and chatroom invitations"), "ignore_invites", FALSE); |
|
12999
7479d16384c0
[gaim-migrate @ 15352]
Daniel Atallah <datallah@pidgin.im>
parents:
12994
diff
changeset
|
4277 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
7479d16384c0
[gaim-migrate @ 15352]
Daniel Atallah <datallah@pidgin.im>
parents:
12994
diff
changeset
|
4278 | |
| 15884 | 4279 | option = purple_account_option_string_new(_("Encoding"), "local_charset", "ISO-8859-1"); |
| 14347 | 4280 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4281 | ||
| 4282 | ||
|
11043
763427cecd21
[gaim-migrate @ 12957]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11033
diff
changeset
|
4283 | #if 0 |
| 15884 | 4284 | option = purple_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL); |
| 8113 | 4285 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
11043
763427cecd21
[gaim-migrate @ 12957]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11033
diff
changeset
|
4286 | |
| 15884 | 4287 | option = purple_account_option_string_new(_("Yahoo Chat server"), "ycht-server", YAHOO_YCHT_HOST); |
| 9376 | 4288 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4289 | ||
| 15884 | 4290 | option = purple_account_option_int_new(_("Yahoo Chat port"), "ycht-port", YAHOO_YCHT_PORT); |
| 9376 | 4291 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 4292 | #endif | |
| 4293 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4294 | my_protocol = plugin; |
| 15884 | 4295 | yahoopurple_register_commands(); |
| 6513 | 4296 | yahoo_init_colorht(); |
|
15685
483b223d0b60
uri-handler support for AIM/ICQ, Yahoo and MSN
Daniel Atallah <datallah@pidgin.im>
parents:
15589
diff
changeset
|
4297 | |
| 15884 | 4298 | purple_signal_connect(purple_get_core(), "uri-handler", plugin, |
| 4299 | PURPLE_CALLBACK(yahoo_uri_handler), NULL); | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4300 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
4301 | |
| 15884 | 4302 | PURPLE_INIT_PLUGIN(yahoo, init_plugin, info); |