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