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