Mercurial > pidgin.yaz
annotate src/protocols/yahoo/yahoo.c @ 9377:cefade93528a
[gaim-migrate @ 10185]
Just a simple little additional of a space.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 24 Jun 2004 09:06:18 +0000 |
parents | 3aa848ccf986 |
children | 37fd8a10f5fa |
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); | |
1499 shaUpdate(&ctx1, magic_key_char, 4); | |
1500 shaFinal(&ctx1, digest1); | |
1501 | |
8349 | 1502 /* |
1503 * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest | |
1504 * of the first context. | |
1505 */ | |
6986 | 1506 |
1507 shaUpdate(&ctx2, pass_hash_xor2, 64); | |
1508 shaUpdate(&ctx2, digest1, 20); | |
1509 shaFinal(&ctx2, digest2); | |
1510 | |
8349 | 1511 /* |
1512 * Now that we have digest2, use it to fetch characters from an alphabet to construct | |
1513 * our first authentication response. | |
1514 */ | |
1515 | |
6986 | 1516 for (x = 0; x < 20; x += 2) { |
8349 | 1517 unsigned int val = 0; |
1518 unsigned int lookup = 0; | |
6986 | 1519 |
8349 | 1520 char byte[6]; |
1521 | |
6986 | 1522 memset(&byte, 0, 6); |
8349 | 1523 |
1524 /* First two bytes of digest stuffed together. | |
6986 | 1525 */ |
9277 | 1526 |
6986 | 1527 val = digest2[x]; |
1528 val <<= 8; | |
1529 val += digest2[x+1]; | |
1530 | |
1531 lookup = (val >> 0x0b); | |
1532 lookup &= 0x1f; | |
1533 if (lookup >= strlen(alphabet1)) | |
1534 break; | |
1535 sprintf(byte, "%c", alphabet1[lookup]); | |
1536 strcat(resp_6, byte); | |
1537 strcat(resp_6, "="); | |
8349 | 1538 |
6986 | 1539 lookup = (val >> 0x06); |
1540 lookup &= 0x1f; | |
1541 if (lookup >= strlen(alphabet2)) | |
1542 break; | |
1543 sprintf(byte, "%c", alphabet2[lookup]); | |
1544 strcat(resp_6, byte); | |
1545 | |
1546 lookup = (val >> 0x01); | |
1547 lookup &= 0x1f; | |
1548 if (lookup >= strlen(alphabet2)) | |
1549 break; | |
1550 sprintf(byte, "%c", alphabet2[lookup]); | |
1551 strcat(resp_6, byte); | |
8349 | 1552 |
6986 | 1553 lookup = (val & 0x01); |
1554 if (lookup >= strlen(delimit_lookup)) | |
1555 break; | |
1556 sprintf(byte, "%c", delimit_lookup[lookup]); | |
1557 strcat(resp_6, byte); | |
1558 } | |
1559 | |
8349 | 1560 /* Our second authentication response is based off of the crypto hash. |
1561 */ | |
6986 | 1562 |
1563 cnt = 0; | |
1564 memset(&digest1, 0, 20); | |
1565 memset(&digest2, 0, 20); | |
1566 | |
1567 for (x = 0; x < (int)strlen(crypt_hash); x++) | |
1568 crypt_hash_xor1[cnt++] = crypt_hash[x] ^ 0x36; | |
1569 | |
1570 if (cnt < 64) | |
1571 memset(&(crypt_hash_xor1[cnt]), 0x36, 64-cnt); | |
8349 | 1572 |
6986 | 1573 cnt = 0; |
1574 | |
1575 for (x = 0; x < (int)strlen(crypt_hash); x++) | |
1576 crypt_hash_xor2[cnt++] = crypt_hash[x] ^ 0x5c; | |
1577 | |
1578 if (cnt < 64) | |
1579 memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt); | |
1580 | |
1581 shaInit(&ctx1); | |
1582 shaInit(&ctx2); | |
1583 | |
8349 | 1584 /* |
1585 * The first context gets the password hash XORed with 0x36 plus a magic value | |
1586 * which we previously extrapolated from our challenge. | |
1587 */ | |
6986 | 1588 |
1589 shaUpdate(&ctx1, crypt_hash_xor1, 64); | |
1590 shaUpdate(&ctx1, magic_key_char, 4); | |
1591 shaFinal(&ctx1, digest1); | |
1592 | |
8349 | 1593 /* |
1594 * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest | |
1595 * of the first context. | |
1596 */ | |
6986 | 1597 |
1598 shaUpdate(&ctx2, crypt_hash_xor2, 64); | |
1599 shaUpdate(&ctx2, digest1, 20); | |
1600 shaFinal(&ctx2, digest2); | |
1601 | |
8349 | 1602 /* |
1603 * Now that we have digest2, use it to fetch characters from an alphabet to construct | |
1604 * our first authentication response. | |
1605 */ | |
6986 | 1606 |
1607 for (x = 0; x < 20; x += 2) { | |
8349 | 1608 unsigned int val = 0; |
1609 unsigned int lookup = 0; | |
6986 | 1610 |
8349 | 1611 char byte[6]; |
6986 | 1612 |
1613 memset(&byte, 0, 6); | |
1614 | |
8349 | 1615 /* First two bytes of digest stuffed together. |
1616 */ | |
6986 | 1617 |
1618 val = digest2[x]; | |
1619 val <<= 8; | |
1620 val += digest2[x+1]; | |
8349 | 1621 |
6986 | 1622 lookup = (val >> 0x0b); |
1623 lookup &= 0x1f; | |
1624 if (lookup >= strlen(alphabet1)) | |
1625 break; | |
1626 sprintf(byte, "%c", alphabet1[lookup]); | |
1627 strcat(resp_96, byte); | |
1628 strcat(resp_96, "="); | |
1629 | |
1630 lookup = (val >> 0x06); | |
1631 lookup &= 0x1f; | |
1632 if (lookup >= strlen(alphabet2)) | |
1633 break; | |
1634 sprintf(byte, "%c", alphabet2[lookup]); | |
1635 strcat(resp_96, byte); | |
1636 | |
1637 lookup = (val >> 0x01); | |
1638 lookup &= 0x1f; | |
1639 if (lookup >= strlen(alphabet2)) | |
1640 break; | |
1641 sprintf(byte, "%c", alphabet2[lookup]); | |
1642 strcat(resp_96, byte); | |
1643 | |
1644 lookup = (val & 0x01); | |
1645 if (lookup >= strlen(delimit_lookup)) | |
1646 break; | |
1647 sprintf(byte, "%c", delimit_lookup[lookup]); | |
1648 strcat(resp_96, byte); | |
1649 } | |
1650 | |
1651 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | |
1652 yahoo_packet_hash(pack, 0, name); | |
1653 yahoo_packet_hash(pack, 6, resp_6); | |
1654 yahoo_packet_hash(pack, 96, resp_96); | |
1655 yahoo_packet_hash(pack, 1, name); | |
9306 | 1656 if (yd->picture_checksum) { |
1657 char *cksum = g_strdup_printf("%d", yd->picture_checksum); | |
1658 yahoo_packet_hash(pack, 192, cksum); | |
1659 g_free(cksum); | |
1660 } | |
6986 | 1661 yahoo_send_packet(yd, pack); |
1662 yahoo_packet_free(pack); | |
1663 | |
7424 | 1664 g_free(password_hash); |
1665 g_free(crypt_hash); | |
6986 | 1666 } |
1667 | |
5583 | 1668 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt) |
3147 | 1669 { |
1670 char *seed = NULL; | |
1671 char *sn = NULL; | |
1672 GSList *l = pkt->hash; | |
7010 | 1673 int m = 0; |
9277 | 1674 gchar *buf; |
1675 | |
1676 | |
3147 | 1677 while (l) { |
1678 struct yahoo_pair *pair = l->data; | |
1679 if (pair->key == 94) | |
1680 seed = pair->value; | |
1681 if (pair->key == 1) | |
1682 sn = pair->value; | |
6986 | 1683 if (pair->key == 13) |
1684 m = atoi(pair->value); | |
3147 | 1685 l = l->next; |
1686 } | |
9277 | 1687 |
3147 | 1688 if (seed) { |
6986 | 1689 switch (m) { |
1690 case 0: | |
1691 yahoo_process_auth_old(gc, seed); | |
1692 break; | |
3147 | 1693 case 1: |
6986 | 1694 yahoo_process_auth_new(gc, seed); |
3147 | 1695 break; |
6986 | 1696 default: |
7043 | 1697 buf = g_strdup_printf(_("The Yahoo server has requested the use of an unrecognized " |
7129 | 1698 "authentication method. This version of Gaim will likely not be able " |
7043 | 1699 "to successfully sign on to Yahoo. Check %s for updates."), GAIM_WEBSITE); |
6986 | 1700 gaim_notify_error(gc, "", _("Failed Yahoo! Authentication"), |
7043 | 1701 buf); |
1702 g_free(buf); | |
6986 | 1703 yahoo_process_auth_new(gc, seed); /* Can't hurt to try it anyway. */ |
3147 | 1704 } |
1705 } | |
1706 } | |
2681 | 1707 |
9285 | 1708 static void ignore_buddy(GaimBuddy *buddy) { |
1709 GaimGroup *group; | |
1710 GaimConversation *conv; | |
6760 | 1711 GaimAccount *account; |
1712 gchar *name; | |
1713 | |
9285 | 1714 if (!buddy) |
6792 | 1715 return; |
6760 | 1716 |
9285 | 1717 group = gaim_find_buddys_group(buddy); |
1718 name = g_strdup(buddy->name); | |
1719 account = buddy->account; | |
6760 | 1720 |
6792 | 1721 gaim_debug(GAIM_DEBUG_INFO, "blist", |
9285 | 1722 "Removing '%s' from buddy list.\n", buddy->name); |
1723 serv_remove_buddy(account->gc, buddy, group); | |
1724 gaim_blist_remove_buddy(buddy); | |
6760 | 1725 |
6792 | 1726 serv_add_deny(account->gc, name); |
9285 | 1727 |
1728 conv = gaim_find_conversation_with_account(name, account); | |
1729 | |
1730 if (conv != NULL) | |
1731 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
6760 | 1732 |
1733 g_free(name); | |
1734 } | |
1735 | |
1736 static void keep_buddy(GaimBuddy *b) { | |
1737 gaim_privacy_deny_remove(b->account, b->name, 1); | |
1738 } | |
1739 | |
1740 static void yahoo_process_ignore(GaimConnection *gc, struct yahoo_packet *pkt) { | |
1741 GaimBuddy *b; | |
1742 GSList *l; | |
1743 gchar *who = NULL; | |
1744 gchar *sn = NULL; | |
1745 gchar buf[BUF_LONG]; | |
1746 gint ignore = 0; | |
1747 gint status = 0; | |
1748 | |
1749 for (l = pkt->hash; l; l = l->next) { | |
1750 struct yahoo_pair *pair = l->data; | |
1751 switch (pair->key) { | |
1752 case 0: | |
1753 who = pair->value; | |
1754 break; | |
1755 case 1: | |
1756 sn = pair->value; | |
1757 break; | |
1758 case 13: | |
1759 ignore = strtol(pair->value, NULL, 10); | |
1760 break; | |
1761 case 66: | |
1762 status = strtol(pair->value, NULL, 10); | |
1763 break; | |
1764 default: | |
1765 break; | |
1766 } | |
1767 } | |
1768 | |
1769 switch (status) { | |
1770 case 12: | |
1771 b = gaim_find_buddy(gc->account, who); | |
1772 g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " | |
1773 "user is on your buddy list. Clicking \"Yes\" " | |
1774 "will remove and ignore the buddy."), who); | |
1775 gaim_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, b, | |
1776 G_CALLBACK(ignore_buddy), | |
1777 G_CALLBACK(keep_buddy)); | |
1778 break; | |
1779 case 2: | |
1780 case 3: | |
1781 case 0: | |
1782 default: | |
1783 break; | |
1784 } | |
1785 } | |
1786 | |
6761 | 1787 static void yahoo_process_authresp(GaimConnection *gc, struct yahoo_packet *pkt) |
1788 { | |
1789 GSList *l = pkt->hash; | |
1790 int err = 0; | |
1791 char *msg; | |
7865 | 1792 char *url = NULL; |
1793 char *fullmsg; | |
6761 | 1794 |
1795 while (l) { | |
1796 struct yahoo_pair *pair = l->data; | |
1797 | |
1798 if (pair->key == 66) | |
1799 err = strtol(pair->value, NULL, 10); | |
7865 | 1800 if (pair->key == 20) |
1801 url = pair->value; | |
6761 | 1802 |
1803 l = l->next; | |
1804 } | |
1805 | |
1806 switch (err) { | |
1807 case 3: | |
7865 | 1808 msg = g_strdup(_("Invalid username.")); |
6761 | 1809 break; |
1810 case 13: | |
7865 | 1811 msg = g_strdup(_("Incorrect password.")); |
1812 break; | |
1813 case 14: | |
9280 | 1814 msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website.")); |
6761 | 1815 break; |
1816 default: | |
9280 | 1817 msg = g_strdup_printf(_("Unknown error number %d. Logging into the Yahoo! website may fix this."), err); |
6761 | 1818 } |
7865 | 1819 |
1820 if (url) | |
1821 fullmsg = g_strdup_printf("%s\n%s", msg, url); | |
1822 else | |
1823 fullmsg = g_strdup(msg); | |
1824 | |
9280 | 1825 gc->wants_to_die = TRUE; |
7865 | 1826 gaim_connection_error(gc, fullmsg); |
1827 g_free(msg); | |
1828 g_free(fullmsg); | |
6761 | 1829 } |
1830 | |
6840 | 1831 static void yahoo_process_addbuddy(GaimConnection *gc, struct yahoo_packet *pkt) |
1832 { | |
1833 int err = 0; | |
1834 char *who = NULL; | |
1835 char *group = NULL; | |
7827 | 1836 char *decoded_group; |
6840 | 1837 char *buf; |
9278 | 1838 YahooFriend *f; |
6840 | 1839 GSList *l = pkt->hash; |
1840 | |
1841 while (l) { | |
1842 struct yahoo_pair *pair = l->data; | |
1843 | |
1844 switch (pair->key) { | |
1845 case 66: | |
1846 err = strtol(pair->value, NULL, 10); | |
1847 break; | |
1848 case 7: | |
1849 who = pair->value; | |
1850 break; | |
1851 case 65: | |
1852 group = pair->value; | |
1853 break; | |
1854 } | |
1855 | |
1856 l = l->next; | |
1857 } | |
1858 | |
1859 if (!who) | |
1860 return; | |
1861 if (!group) | |
1862 group = ""; | |
1863 | |
1864 if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */ | |
9279 | 1865 f = yahoo_friend_find_or_new(gc, who); |
1866 yahoo_update_status(gc, who, f); | |
6840 | 1867 return; |
1868 } | |
1869 | |
7827 | 1870 decoded_group = yahoo_string_decode(gc, group, FALSE); |
6840 | 1871 buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."), |
7827 | 1872 who, decoded_group, gaim_connection_get_display_name(gc)); |
6840 | 1873 gaim_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); |
1874 g_free(buf); | |
7827 | 1875 g_free(decoded_group); |
6840 | 1876 } |
1877 | |
9062 | 1878 static void yahoo_process_p2p(GaimConnection *gc, struct yahoo_packet *pkt) |
1879 { | |
1880 GSList *l = pkt->hash; | |
1881 char *who = NULL; | |
1882 char *base64 = NULL; | |
9277 | 1883 char *decoded; |
9062 | 1884 int len; |
1885 | |
1886 while (l) { | |
1887 struct yahoo_pair *pair = l->data; | |
1888 | |
1889 switch (pair->key) { | |
1890 case 5: | |
1891 /* our identity */ | |
1892 break; | |
1893 case 4: | |
1894 who = pair->value; | |
1895 break; | |
1896 case 1: | |
1897 /* who again, the master identity this time? */ | |
1898 break; | |
1899 case 12: | |
1900 base64 = pair->value; | |
1901 /* so, this is an ip address. in base64. decoded it's in ascii. | |
1902 after strtol, it's in reversed byte order. Who thought this up?*/ | |
1903 break; | |
1904 /* | |
1905 TODO: figure these out | |
1906 yahoo: Key: 61 Value: 0 | |
1907 yahoo: Key: 2 Value: | |
1908 yahoo: Key: 13 Value: 0 | |
1909 yahoo: Key: 49 Value: PEERTOPEER | |
1910 yahoo: Key: 140 Value: 1 | |
1911 yahoo: Key: 11 Value: -1786225828 | |
1912 */ | |
1913 | |
1914 } | |
1915 | |
1916 l = l->next; | |
1917 } | |
1918 | |
9277 | 1919 if (base64) { |
9281 | 1920 guint32 ip; |
1921 char *tmp2; | |
1922 YahooFriend *f; | |
1923 | |
9062 | 1924 gaim_base64_decode(base64, &decoded, &len); |
9277 | 1925 if (len) { |
1926 char *tmp = gaim_str_binary_to_ascii(decoded, len); | |
1927 gaim_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, tmp); | |
1928 g_free(tmp); | |
1929 } | |
9281 | 1930 |
1931 tmp2 = g_strndup(decoded, len); /* so its \0 terminated...*/ | |
1932 ip = strtol(tmp2, NULL, 10); | |
1933 g_free(tmp2); | |
9062 | 1934 g_free(decoded); |
9281 | 1935 tmp2 = g_strdup_printf("%u.%u.%u.%u", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, |
1936 (ip >> 24) & 0xff); | |
1937 f = yahoo_friend_find(gc, who); | |
1938 if (f) | |
1939 yahoo_friend_set_ip(f, tmp2); | |
1940 g_free(tmp2); | |
9062 | 1941 } |
1942 } | |
1943 | |
5583 | 1944 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 1945 { |
6760 | 1946 switch (pkt->service) { |
2681 | 1947 case YAHOO_SERVICE_LOGON: |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
1948 case YAHOO_SERVICE_LOGOFF: |
2681 | 1949 case YAHOO_SERVICE_ISAWAY: |
2737
f61c1f3a6afa
[gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2724
diff
changeset
|
1950 case YAHOO_SERVICE_ISBACK: |
3019 | 1951 case YAHOO_SERVICE_GAMELOGON: |
1952 case YAHOO_SERVICE_GAMELOGOFF: | |
6686 | 1953 case YAHOO_SERVICE_CHATLOGON: |
1954 case YAHOO_SERVICE_CHATLOGOFF: | |
2681 | 1955 yahoo_process_status(gc, pkt); |
1956 break; | |
3019 | 1957 case YAHOO_SERVICE_NOTIFY: |
1958 yahoo_process_notify(gc, pkt); | |
2993 | 1959 break; |
2681 | 1960 case YAHOO_SERVICE_MESSAGE: |
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
1961 case YAHOO_SERVICE_GAMEMSG: |
5939 | 1962 case YAHOO_SERVICE_CHATMSG: |
2681 | 1963 yahoo_process_message(gc, pkt); |
1964 break; | |
7865 | 1965 case YAHOO_SERVICE_SYSMESSAGE: |
1966 yahoo_process_sysmessage(gc, pkt); | |
1967 break; | |
2681 | 1968 case YAHOO_SERVICE_NEWMAIL: |
1969 yahoo_process_mail(gc, pkt); | |
1970 break; | |
1971 case YAHOO_SERVICE_NEWCONTACT: | |
1972 yahoo_process_contact(gc, pkt); | |
1973 break; | |
6784 | 1974 case YAHOO_SERVICE_AUTHRESP: |
1975 yahoo_process_authresp(gc, pkt); | |
1976 break; | |
2681 | 1977 case YAHOO_SERVICE_LIST: |
1978 yahoo_process_list(gc, pkt); | |
1979 break; | |
3147 | 1980 case YAHOO_SERVICE_AUTH: |
1981 yahoo_process_auth(gc, pkt); | |
1982 break; | |
6840 | 1983 case YAHOO_SERVICE_ADDBUDDY: |
1984 yahoo_process_addbuddy(gc, pkt); | |
1985 break; | |
6760 | 1986 case YAHOO_SERVICE_IGNORECONTACT: |
1987 yahoo_process_ignore(gc, pkt); | |
1988 break; | |
6729 | 1989 case YAHOO_SERVICE_CONFINVITE: |
1990 case YAHOO_SERVICE_CONFADDINVITE: | |
1991 yahoo_process_conference_invite(gc, pkt); | |
1992 break; | |
1993 case YAHOO_SERVICE_CONFDECLINE: | |
1994 yahoo_process_conference_decline(gc, pkt); | |
1995 break; | |
1996 case YAHOO_SERVICE_CONFLOGON: | |
1997 yahoo_process_conference_logon(gc, pkt); | |
1998 break; | |
1999 case YAHOO_SERVICE_CONFLOGOFF: | |
2000 yahoo_process_conference_logoff(gc, pkt); | |
2001 break; | |
2002 case YAHOO_SERVICE_CONFMSG: | |
2003 yahoo_process_conference_message(gc, pkt); | |
2004 break; | |
2005 case YAHOO_SERVICE_CHATONLINE: | |
2006 yahoo_process_chat_online(gc, pkt); | |
2007 break; | |
2008 case YAHOO_SERVICE_CHATLOGOUT: | |
2009 yahoo_process_chat_logout(gc, pkt); | |
2010 break; | |
2011 case YAHOO_SERVICE_CHATGOTO: | |
2012 yahoo_process_chat_goto(gc, pkt); | |
2013 break; | |
2014 case YAHOO_SERVICE_CHATJOIN: | |
2015 yahoo_process_chat_join(gc, pkt); | |
2016 break; | |
2017 case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */ | |
2018 case YAHOO_SERVICE_CHATEXIT: | |
2019 yahoo_process_chat_exit(gc, pkt); | |
2020 break; | |
2021 case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */ | |
2022 case YAHOO_SERVICE_CHATADDINVITE: | |
2023 yahoo_process_chat_addinvite(gc, pkt); | |
2024 break; | |
2025 case YAHOO_SERVICE_COMMENT: | |
2026 yahoo_process_chat_message(gc, pkt); | |
2027 break; | |
7651 | 2028 case YAHOO_SERVICE_P2PFILEXFER: |
2029 case YAHOO_SERVICE_FILETRANSFER: | |
2030 yahoo_process_filetransfer(gc, pkt); | |
2031 break; | |
9062 | 2032 case YAHOO_SERVICE_PEEPTOPEER: |
2033 yahoo_process_p2p(gc, pkt); | |
2034 break; | |
9284 | 2035 case YAHOO_SERVICE_PICTURE: |
2036 yahoo_process_picture(gc, pkt); | |
2037 break; | |
9292 | 2038 case YAHOO_SERVICE_PICTURE_UPDATE: |
2039 yahoo_process_picture_update(gc, pkt); | |
2040 break; | |
2041 case YAHOO_SERVICE_PICTURE_CHECKSUM: | |
2042 yahoo_process_picture_checksum(gc, pkt); | |
2043 break; | |
9306 | 2044 case YAHOO_SERVICE_PICTURE_UPLOAD: |
2045 yahoo_process_picture_upload(gc, pkt); | |
2046 break; | |
2681 | 2047 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2048 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2049 "Unhandled service 0x%02x\n", pkt->service); |
2681 | 2050 break; |
2051 } | |
2052 } | |
2053 | |
2054 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
2055 { | |
5583 | 2056 GaimConnection *gc = data; |
2681 | 2057 struct yahoo_data *yd = gc->proto_data; |
2058 char buf[1024]; | |
2059 int len; | |
2060 | |
2061 len = read(yd->fd, buf, sizeof(buf)); | |
2062 | |
2063 if (len <= 0) { | |
6321 | 2064 gaim_connection_error(gc, _("Unable to read")); |
2681 | 2065 return; |
2066 } | |
2067 | |
2068 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
2069 memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
2070 yd->rxlen += len; | |
2071 | |
2072 while (1) { | |
2073 struct yahoo_packet *pkt; | |
2074 int pos = 0; | |
2075 int pktlen; | |
2076 | |
2077 if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
2078 return; | |
2079 | |
2080 pos += 4; /* YMSG */ | |
2081 pos += 2; | |
2082 pos += 2; | |
2083 | |
2084 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2085 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2086 "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
2681 | 2087 |
2088 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
2089 return; | |
2090 | |
2091 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
2092 | |
2093 pkt = yahoo_packet_new(0, 0, 0); | |
2094 | |
2095 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
3021 | 2096 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2097 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2098 "Yahoo Service: 0x%02x Status: %d\n", |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2099 pkt->service, pkt->status); |
2681 | 2100 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
2101 | |
2102 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
2103 | |
2104 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
2105 if (yd->rxlen) { | |
2106 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
2107 g_free(yd->rxqueue); | |
2108 yd->rxqueue = tmp; | |
2109 } else { | |
2110 g_free(yd->rxqueue); | |
2111 yd->rxqueue = NULL; | |
2112 } | |
2113 | |
2114 yahoo_packet_process(gc, pkt); | |
2115 | |
2116 yahoo_packet_free(pkt); | |
2117 } | |
2118 } | |
2119 | |
2120 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
2121 { | |
5583 | 2122 GaimConnection *gc = data; |
2681 | 2123 struct yahoo_data *yd; |
2124 struct yahoo_packet *pkt; | |
2125 | |
5590
011a0a975060
[gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents:
5583
diff
changeset
|
2126 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2681 | 2127 close(source); |
2128 return; | |
2129 } | |
2130 | |
2131 if (source < 0) { | |
8057 | 2132 gaim_connection_error(gc, _("Unable to connect.")); |
2681 | 2133 return; |
2134 } | |
2135 | |
2136 yd = gc->proto_data; | |
2137 yd->fd = source; | |
2138 | |
3147 | 2139 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); |
2681 | 2140 |
7261 | 2141 yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); |
2681 | 2142 yahoo_send_packet(yd, pkt); |
2143 | |
2144 yahoo_packet_free(pkt); | |
2145 | |
2146 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
2147 } | |
9370 | 2148 |
7134 | 2149 static void yahoo_got_web_connected(gpointer data, gint source, GaimInputCondition cond) |
2150 { | |
2151 GaimConnection *gc = data; | |
2152 struct yahoo_data *yd; | |
2153 struct yahoo_packet *pkt; | |
2154 | |
2155 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
2156 close(source); | |
2157 return; | |
2158 } | |
2159 | |
2160 if (source < 0) { | |
8057 | 2161 gaim_connection_error(gc, _("Unable to connect.")); |
7134 | 2162 return; |
2163 } | |
2164 | |
2165 yd = gc->proto_data; | |
2166 yd->fd = source; | |
2167 | |
2168 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); | |
2169 | |
7261 | 2170 yahoo_packet_hash(pkt, 0, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); |
2171 yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); | |
7134 | 2172 yahoo_packet_hash(pkt, 6, yd->auth); |
2173 yahoo_send_packet(yd, pkt); | |
2174 | |
2175 yahoo_packet_free(pkt); | |
2176 g_free(yd->auth); | |
2177 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
2178 } | |
2179 | |
2180 static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond) | |
2181 { | |
2182 GaimConnection *gc = data; | |
2183 GaimAccount *account = gaim_connection_get_account(gc); | |
2184 struct yahoo_data *yd = gc->proto_data; | |
8243 | 2185 char buf[2048], *i = buf; |
8161 | 2186 int len; |
2187 GString *s; | |
7134 | 2188 |
8118 | 2189 len = read(source, buf, sizeof(buf)-1); |
8216
dcace041cfb8
[gaim-migrate @ 8939]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
2190 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
|
2191 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { |
7134 | 2192 gaim_connection_error(gc, _("Unable to read")); |
2193 return; | |
2194 } | |
8161 | 2195 |
2196 s = g_string_sized_new(len); | |
8118 | 2197 buf[sizeof(buf)-1] = '\0'; |
8161 | 2198 |
2199 while ((i = strstr(i, "Set-Cookie: "))) { | |
2200 i += strlen("Set-Cookie: "); | |
8243 | 2201 for (;*i != ';' && *i != '\0'; i++) |
8161 | 2202 g_string_append_c(s, *i); |
2203 | |
2204 g_string_append(s, "; "); | |
7134 | 2205 } |
8161 | 2206 |
2207 yd->auth = g_string_free(s, FALSE); | |
7134 | 2208 gaim_input_remove(gc->inpa); |
2209 close(source); | |
2210 /* Now we have our cookies to login with. I'll go get the milk. */ | |
8045 | 2211 if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", |
7134 | 2212 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), |
2213 yahoo_got_web_connected, gc) != 0) { | |
2214 gaim_connection_error(gc, _("Connection problem")); | |
2215 return; | |
2216 } | |
2217 } | |
2218 | |
2219 static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) | |
2220 { | |
2221 GaimConnection *gc = data; | |
2222 struct yahoo_data *yd = gc->proto_data; | |
2223 if (source < 0) { | |
8057 | 2224 gaim_connection_error(gc, _("Unable to connect.")); |
7134 | 2225 return; |
2226 } | |
2227 write(source, yd->auth, strlen(yd->auth)); | |
2228 g_free(yd->auth); | |
2229 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); | |
2230 } | |
2231 | |
2232 static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url) | |
2233 { | |
2234 if (!strcmp(key, "passwd")) | |
2235 return; | |
2236 url = g_string_append_c(url, '&'); | |
2237 url = g_string_append(url, key); | |
2238 url = g_string_append_c(url, '='); | |
2239 if (!strcmp(key, ".save") || !strcmp(key, ".js")) | |
2240 url = g_string_append_c(url, '1'); | |
2241 else if (!strcmp(key, ".challenge")) | |
2242 url = g_string_append(url, val); | |
2243 else | |
2244 url = g_string_append(url, gaim_url_encode(val)); | |
2245 } | |
2246 | |
2247 static GHashTable *yahoo_login_page_hash(const char *buf, size_t len) | |
2248 { | |
2249 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
|
2250 const char *c = buf; |
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2251 char *d; |
7134 | 2252 char name[64], value[64]; |
8118 | 2253 int count = sizeof(name)-1; |
7134 | 2254 while ((c < (buf + len)) && (c = strstr(c, "<input "))) { |
2255 c = strstr(c, "name=\"") + strlen("name=\""); | |
8118 | 2256 for (d = name; *c!='"' && count; c++, d++, count--) |
7134 | 2257 *d = *c; |
2258 *d = '\0'; | |
8118 | 2259 count = sizeof(value)-1; |
7134 | 2260 d = strstr(c, "value=\"") + strlen("value=\""); |
2261 if (strchr(c, '>') < d) | |
2262 break; | |
8118 | 2263 for (c = d, d = value; *c!='"' && count; c++, d++, count--) |
7134 | 2264 *d = *c; |
2265 *d = '\0'; | |
2266 g_hash_table_insert(hash, g_strdup(name), g_strdup(value)); | |
2267 } | |
2268 return hash; | |
2269 } | |
2270 | |
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2271 static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len) |
7134 | 2272 { |
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2273 GaimConnection *gc = (GaimConnection *)user_data; |
7134 | 2274 GaimAccount *account = gaim_connection_get_account(gc); |
2275 struct yahoo_data *yd = gc->proto_data; | |
2276 const char *sn = gaim_account_get_username(account); | |
2277 const char *pass = gaim_account_get_password(account); | |
2278 GHashTable *hash = yahoo_login_page_hash(buf, len); | |
2279 GString *url = g_string_new("GET /config/login?login="); | |
2280 char md5[33], *hashp = md5, *chal; | |
2281 int i; | |
2282 md5_byte_t result[16]; | |
2283 md5_state_t ctx; | |
7191
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2284 |
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2285 url = g_string_append(url, sn); |
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2286 url = g_string_append(url, "&passwd="); |
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2287 |
7134 | 2288 md5_init(&ctx); |
2289 md5_append(&ctx, pass, strlen(pass)); | |
2290 md5_finish(&ctx, result); | |
2291 for (i = 0; i < 16; ++i) { | |
2292 g_snprintf(hashp, 3, "%02x", result[i]); | |
2293 hashp += 2; | |
2294 } | |
2295 chal = g_strconcat(md5, g_hash_table_lookup(hash, ".challenge"), NULL); | |
2296 md5_init(&ctx); | |
2297 md5_append(&ctx, chal, strlen(chal)); | |
2298 md5_finish(&ctx, result); | |
2299 hashp = md5; | |
2300 for (i = 0; i < 16; ++i) { | |
2301 g_snprintf(hashp, 3, "%02x", result[i]); | |
2302 hashp += 2; | |
2303 } | |
2304 /* | |
2305 md5_init(&ctx); | |
2306 md5_append(&ctx, md5, strlen(md5)); | |
2307 md5_finish(&ctx, result); | |
2308 hashp = md5; | |
2309 for (i = 0; i < 16; ++i) { | |
2310 g_snprintf(hashp, 3, "%02x", result[i]); | |
2311 hashp += 2; | |
2312 } | |
2313 */ | |
2314 g_free(chal); | |
2315 | |
2316 url = g_string_append(url, md5); | |
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2317 g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url); |
7134 | 2318 |
2319 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" | |
2320 "Host: login.yahoo.com\r\n\r\n"); | |
2321 g_hash_table_destroy(hash); | |
2322 yd->auth = g_string_free(url, FALSE); | |
2323 if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) { | |
2324 gaim_connection_error(gc, _("Connection problem")); | |
2325 return; | |
2326 } | |
2327 } | |
2328 | |
7883 | 2329 static void yahoo_server_check(GaimAccount *account) |
2330 { | |
2331 const char *server; | |
2332 | |
2333 server = gaim_account_get_string(account, "server", YAHOO_PAGER_HOST); | |
2334 | |
2335 if (strcmp(server, "scs.yahoo.com") == 0) | |
2336 gaim_account_set_string(account, "server", YAHOO_PAGER_HOST); | |
2337 } | |
9306 | 2338 |
2339 static void yahoo_picture_check(GaimAccount *account) | |
2340 { | |
2341 GaimConnection *gc = gaim_account_get_connection(account); | |
2342 const char *buddyicon; | |
2343 | |
2344 buddyicon = gaim_account_get_buddy_icon(account); | |
2345 yahoo_set_buddy_icon(gc, buddyicon); | |
2346 } | |
2347 | |
7883 | 2348 |
5583 | 2349 static void yahoo_login(GaimAccount *account) { |
2350 GaimConnection *gc = gaim_account_get_connection(account); | |
2681 | 2351 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
2352 | |
9041 | 2353 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC; |
6629 | 2354 |
5583 | 2355 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
2681 | 2356 |
8235 | 2357 gaim_connection_set_display_name(gc, gaim_account_get_username(account)); |
2358 | |
2681 | 2359 yd->fd = -1; |
6784 | 2360 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
6729 | 2361 yd->confs = NULL; |
2362 yd->conf_id = 2; | |
2681 | 2363 |
7883 | 2364 yahoo_server_check(account); |
9306 | 2365 yahoo_picture_check(account); |
7883 | 2366 |
9164 | 2367 if (gaim_account_get_bool(account, "yahoojp", FALSE)) { |
2368 yd->jp = TRUE; | |
2369 if (gaim_proxy_connect(account, | |
2370 gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), | |
2371 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
2372 yahoo_got_connected, gc) != 0) | |
2373 { | |
2374 gaim_connection_error(gc, _("Connection problem")); | |
2375 return; | |
2376 } | |
2377 } else { | |
9370 | 2378 #ifndef YAHOO_WEBMESSENGER |
9164 | 2379 yd->jp = FALSE; |
2380 if (gaim_proxy_connect(account, | |
2381 gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), | |
2382 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
2383 yahoo_got_connected, gc) != 0) | |
2384 { | |
2385 gaim_connection_error(gc, _("Connection problem")); | |
2386 return; | |
2387 } | |
9370 | 2388 #else |
2389 yd->wm = TRUE; | |
2390 gaim_url_fetch(WEBMESSENGER_URL, TRUE, "Gaim/" VERSION, FALSE, | |
2391 yahoo_login_page_cb, gc); | |
2392 #endif | |
2681 | 2393 } |
9370 | 2394 |
2681 | 2395 |
2396 } | |
2397 | |
5583 | 2398 static void yahoo_close(GaimConnection *gc) { |
2681 | 2399 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
6729 | 2400 |
6784 | 2401 g_hash_table_destroy(yd->friends); |
6729 | 2402 g_slist_free(yd->confs); |
6784 | 2403 if (yd->chat_name) |
2404 g_free(yd->chat_name); | |
6729 | 2405 |
7651 | 2406 if (yd->cookie_y) |
2407 g_free(yd->cookie_y); | |
2408 if (yd->cookie_t) | |
2409 g_free(yd->cookie_t); | |
2410 | |
2681 | 2411 if (yd->fd >= 0) |
2412 close(yd->fd); | |
3720
34c95669952f
[gaim-migrate @ 3853]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3642
diff
changeset
|
2413 |
2681 | 2414 if (yd->rxqueue) |
2415 g_free(yd->rxqueue); | |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2686
diff
changeset
|
2416 yd->rxlen = 0; |
9306 | 2417 if (yd->picture_url) |
2418 g_free(yd->picture_url); | |
2419 if (yd->picture_upload_todo) | |
2420 yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo); | |
9376 | 2421 if (yd->ycht) |
2422 ycht_connection_close(yd->ycht); | |
2681 | 2423 if (gc->inpa) |
2424 gaim_input_remove(gc->inpa); | |
2425 g_free(yd); | |
2426 } | |
2427 | |
6695 | 2428 static const char *yahoo_list_icon(GaimAccount *a, GaimBuddy *b) |
2681 | 2429 { |
4687 | 2430 return "yahoo"; |
2681 | 2431 } |
4916 | 2432 |
6695 | 2433 static void yahoo_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4916 | 2434 { |
2435 int i = 0; | |
2436 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
6784 | 2437 GaimAccount *account; |
2438 GaimConnection *gc; | |
2439 struct yahoo_data *yd; | |
9278 | 2440 YahooFriend *f; |
6784 | 2441 |
2442 if (!b || !(account = b->account) || !(gc = gaim_account_get_connection(account)) || | |
2443 !(yd = gc->proto_data)) | |
2444 return; | |
2445 | |
9279 | 2446 f = yahoo_friend_find(gc, b->name); |
6784 | 2447 if (!f) { |
2448 *se = "notauthorized"; | |
2449 return; | |
2450 } | |
2451 | |
5068 | 2452 if (b->present == GAIM_BUDDY_OFFLINE) { |
4916 | 2453 *se = "offline"; |
2454 return; | |
2455 } else { | |
6784 | 2456 if (f->away) |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2457 emblems[i++] = "away"; |
6784 | 2458 if (f->sms) |
2459 emblems[i++] = "wireless"; | |
9283 | 2460 if (yahoo_friend_get_game(f)) |
4916 | 2461 emblems[i++] = "game"; |
2462 } | |
2463 *se = emblems[0]; | |
2464 *sw = emblems[1]; | |
2465 *nw = emblems[2]; | |
2466 *ne = emblems[3]; | |
2467 } | |
2681 | 2468 |
2469 static char *yahoo_get_status_string(enum yahoo_status a) | |
2470 { | |
2471 switch (a) { | |
2472 case YAHOO_STATUS_BRB: | |
4596 | 2473 return _("Be Right Back"); |
2681 | 2474 case YAHOO_STATUS_BUSY: |
4596 | 2475 return _("Busy"); |
2681 | 2476 case YAHOO_STATUS_NOTATHOME: |
4596 | 2477 return _("Not At Home"); |
2681 | 2478 case YAHOO_STATUS_NOTATDESK: |
4596 | 2479 return _("Not At Desk"); |
2681 | 2480 case YAHOO_STATUS_NOTINOFFICE: |
4596 | 2481 return _("Not In Office"); |
2681 | 2482 case YAHOO_STATUS_ONPHONE: |
4606 | 2483 return _("On The Phone"); |
2681 | 2484 case YAHOO_STATUS_ONVACATION: |
4596 | 2485 return _("On Vacation"); |
2681 | 2486 case YAHOO_STATUS_OUTTOLUNCH: |
4596 | 2487 return _("Out To Lunch"); |
2681 | 2488 case YAHOO_STATUS_STEPPEDOUT: |
4596 | 2489 return _("Stepped Out"); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
2490 case YAHOO_STATUS_INVISIBLE: |
4596 | 2491 return _("Invisible"); |
4730 | 2492 case YAHOO_STATUS_IDLE: |
2493 return _("Idle"); | |
6784 | 2494 case YAHOO_STATUS_OFFLINE: |
2495 return _("Offline"); | |
2879
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
2496 default: |
4596 | 2497 return _("Online"); |
2681 | 2498 } |
2499 } | |
2500 | |
9030 | 2501 static void yahoo_initiate_conference(GaimBlistNode *node, gpointer data) { |
2502 | |
2503 GaimBuddy *buddy; | |
2504 GaimConnection *gc; | |
2505 | |
6729 | 2506 GHashTable *components; |
2507 struct yahoo_data *yd; | |
2508 int id; | |
2509 | |
9030 | 2510 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
2511 | |
2512 buddy = (GaimBuddy *) node; | |
2513 gc = gaim_account_get_connection(buddy->account); | |
6729 | 2514 yd = gc->proto_data; |
2515 id = yd->conf_id; | |
2516 | |
2517 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
2518 g_hash_table_replace(components, g_strdup("room"), | |
2519 g_strdup_printf("%s-%d", gaim_connection_get_display_name(gc), id)); | |
2520 g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference...")); | |
2521 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | |
2522 yahoo_c_join(gc, components); | |
2523 g_hash_table_destroy(components); | |
2524 | |
9030 | 2525 yahoo_c_invite(gc, id, "Join my conference...", buddy->name); |
6729 | 2526 } |
2527 | |
9030 | 2528 static void yahoo_game(GaimBlistNode *node, gpointer data) { |
2529 | |
2530 GaimBuddy *buddy; | |
2531 GaimConnection *gc; | |
2532 | |
2533 struct yahoo_data *yd; | |
9283 | 2534 const char *game; |
2535 char *game2; | |
3019 | 2536 char *t; |
2537 char url[256]; | |
9278 | 2538 YahooFriend *f; |
3019 | 2539 |
9030 | 2540 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
2541 | |
2542 buddy = (GaimBuddy *) node; | |
2543 gc = gaim_account_get_connection(buddy->account); | |
2544 yd = (struct yahoo_data *) gc->proto_data; | |
2545 | |
9279 | 2546 f = yahoo_friend_find(gc, buddy->name); |
6784 | 2547 if (!f) |
2548 return; | |
2549 | |
9283 | 2550 game = yahoo_friend_get_game(f); |
3019 | 2551 if (!game) |
2552 return; | |
6784 | 2553 |
9283 | 2554 t = game2 = g_strdup(strstr(game, "ante?room=")); |
2555 while (*t && *t != '\t') | |
3019 | 2556 t++; |
2557 *t = 0; | |
9283 | 2558 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
|
2559 gaim_notify_uri(gc, url); |
9283 | 2560 g_free(game2); |
3019 | 2561 } |
4722 | 2562 |
6695 | 2563 static char *yahoo_status_text(GaimBuddy *b) |
4722 | 2564 { |
9278 | 2565 YahooFriend *f = NULL; |
9283 | 2566 const char *msg; |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2567 |
9279 | 2568 f = yahoo_friend_find(b->account->gc, b->name); |
6784 | 2569 if (!f) |
2570 return g_strdup(_("Not on server list")); | |
2571 | |
2572 switch (f->status) { | |
2573 case YAHOO_STATUS_AVAILABLE: | |
2574 return NULL; | |
2575 case YAHOO_STATUS_IDLE: | |
2576 if (f->idle == -1) | |
2577 return g_strdup(yahoo_get_status_string(f->status)); | |
2578 return NULL; | |
2579 case YAHOO_STATUS_CUSTOM: | |
9283 | 2580 if (!(msg = yahoo_friend_get_status_message(f))) |
6784 | 2581 return NULL; |
9283 | 2582 return g_markup_escape_text(msg, strlen(msg)); |
9224 | 2583 |
6784 | 2584 default: |
2585 return g_strdup(yahoo_get_status_string(f->status)); | |
2586 } | |
4722 | 2587 } |
2588 | |
9220 | 2589 char *yahoo_tooltip_text(GaimBuddy *b) |
4724 | 2590 { |
9278 | 2591 YahooFriend *f; |
6784 | 2592 char *escaped, *status, *ret; |
2593 | |
9279 | 2594 f = yahoo_friend_find(b->account->gc, b->name); |
6784 | 2595 if (!f) |
8591 | 2596 status = g_strdup_printf("\n%s", _("Not on server list")); |
6784 | 2597 else |
2598 switch (f->status) { | |
2599 case YAHOO_STATUS_IDLE: | |
2600 if (f->idle == -1) { | |
2601 status = g_strdup(yahoo_get_status_string(f->status)); | |
2602 break; | |
2603 } | |
2604 return NULL; | |
2605 case YAHOO_STATUS_CUSTOM: | |
9283 | 2606 if (!yahoo_friend_get_status_message(f)) |
6784 | 2607 return NULL; |
9283 | 2608 status = g_strdup(yahoo_friend_get_status_message(f)); |
6784 | 2609 break; |
2610 default: | |
2611 status = g_strdup(yahoo_get_status_string(f->status)); | |
2612 break; | |
4745 | 2613 } |
6784 | 2614 |
2615 escaped = g_markup_escape_text(status, strlen(status)); | |
8591 | 2616 ret = g_strdup_printf(_("\n<b>%s:</b> %s"), _("Status"), escaped); |
6784 | 2617 g_free(status); |
2618 g_free(escaped); | |
2619 | |
2620 return ret; | |
4729 | 2621 } |
2622 | |
9030 | 2623 static void yahoo_addbuddyfrommenu_cb(GaimBlistNode *node, gpointer data) |
2624 { | |
2625 GaimBuddy *buddy; | |
2626 GaimConnection *gc; | |
2627 | |
2628 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
2629 | |
2630 buddy = (GaimBuddy *) node; | |
2631 gc = gaim_account_get_connection(buddy->account); | |
2632 | |
9285 | 2633 yahoo_add_buddy(gc, buddy, NULL); |
9030 | 2634 } |
2635 | |
2636 | |
2637 static void yahoo_chat_goto_menu(GaimBlistNode *node, gpointer data) | |
6796 | 2638 { |
9030 | 2639 GaimBuddy *buddy; |
2640 GaimConnection *gc; | |
2641 | |
2642 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
2643 | |
2644 buddy = (GaimBuddy *) node; | |
2645 gc = gaim_account_get_connection(buddy->account); | |
2646 | |
2647 yahoo_chat_goto(gc, buddy->name); | |
6796 | 2648 } |
2649 | |
9030 | 2650 |
2651 static void yahoo_ask_send_file_menu(GaimBlistNode *node, gpointer data) | |
2652 { | |
2653 GaimBuddy *buddy; | |
2654 GaimConnection *gc; | |
2655 | |
2656 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
2657 | |
2658 buddy = (GaimBuddy *) node; | |
2659 gc = gaim_account_get_connection(buddy->account); | |
2660 | |
2661 yahoo_ask_send_file(gc, buddy->name); | |
2662 } | |
2663 | |
2664 | |
2665 static GList *yahoo_buddy_menu(GaimBuddy *buddy) | |
2681 | 2666 { |
2667 GList *m = NULL; | |
9030 | 2668 GaimBlistNodeAction *act; |
2669 | |
2670 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
9370 | 2671 struct yahoo_data *yd = gc->proto_data; |
3019 | 2672 static char buf2[1024]; |
9278 | 2673 YahooFriend *f; |
6784 | 2674 |
9279 | 2675 f = yahoo_friend_find(gc, buddy->name); |
6784 | 2676 |
9370 | 2677 if (!f && !yd->wm) { |
9030 | 2678 act = gaim_blist_node_action_new(_("Add Buddy"), |
2679 yahoo_addbuddyfrommenu_cb, NULL); | |
2680 m = g_list_append(m, act); | |
6784 | 2681 |
2682 return m; | |
9030 | 2683 |
2684 } else if (f->status == YAHOO_STATUS_OFFLINE) { | |
6784 | 2685 return NULL; |
9030 | 2686 } |
2687 | |
9370 | 2688 if (!yd->wm) { |
2689 act = gaim_blist_node_action_new(_("Join in Chat"), | |
2690 yahoo_chat_goto_menu, NULL); | |
2691 m = g_list_append(m, act); | |
2692 } | |
9030 | 2693 |
2694 act = gaim_blist_node_action_new(_("Initiate Conference"), | |
2695 yahoo_initiate_conference, NULL); | |
2696 m = g_list_append(m, act); | |
6729 | 2697 |
7651 | 2698 /* FIXME: remove this when the ui does it for us. */ |
9030 | 2699 act = gaim_blist_node_action_new(_("Send File"), |
2700 yahoo_ask_send_file_menu, NULL); | |
2701 m = g_list_append(m, act); | |
7651 | 2702 |
9283 | 2703 if (yahoo_friend_get_game(f)) { |
2704 const char *game = yahoo_friend_get_game(f); | |
3019 | 2705 char *room; |
6784 | 2706 char *t; |
2707 | |
2708 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ | |
2709 return m; | |
2710 while (*room && *room != '\t') /* skip to the tab */ | |
2711 room++; | |
2712 t = room++; /* room as now at the name */ | |
2713 while (*t != '\n') | |
2714 t++; /* replace the \n with a space */ | |
2715 *t = ' '; | |
2716 g_snprintf(buf2, sizeof buf2, "%s", room); | |
9030 | 2717 |
2718 act = gaim_blist_node_action_new(buf2, yahoo_game, NULL); | |
2719 m = g_list_append(m, act); | |
3019 | 2720 } |
6729 | 2721 |
2681 | 2722 return m; |
2723 } | |
2724 | |
9030 | 2725 |
2726 static GList *yahoo_blist_node_menu(GaimBlistNode *node) | |
2727 { | |
2728 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
2729 return yahoo_buddy_menu((GaimBuddy *) node); | |
2730 } else { | |
2731 return NULL; | |
2732 } | |
2733 } | |
2734 | |
2735 | |
5583 | 2736 static void yahoo_act_id(GaimConnection *gc, const char *entry) |
2681 | 2737 { |
2738 struct yahoo_data *yd = gc->proto_data; | |
2739 | |
2740 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
2741 yahoo_packet_hash(pkt, 3, entry); | |
2742 yahoo_send_packet(yd, pkt); | |
2743 yahoo_packet_free(pkt); | |
2744 | |
5583 | 2745 gaim_connection_set_display_name(gc, entry); |
2681 | 2746 } |
2747 | |
9015 | 2748 static void yahoo_show_act_id(GaimPluginAction *action) |
2681 | 2749 { |
9015 | 2750 GaimConnection *gc = (GaimConnection *) action->context; |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2751 gaim_request_input(gc, NULL, _("Active which ID?"), NULL, |
8697 | 2752 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2753 _("OK"), G_CALLBACK(yahoo_act_id), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2754 _("Cancel"), NULL, gc); |
2681 | 2755 } |
2756 | |
9015 | 2757 static void yahoo_show_chat_goto(GaimPluginAction *action) |
7878 | 2758 { |
9015 | 2759 GaimConnection *gc = (GaimConnection *) action->context; |
7878 | 2760 gaim_request_input(gc, NULL, _("Join who in chat?"), NULL, |
8697 | 2761 "", FALSE, FALSE, NULL, |
7878 | 2762 _("OK"), G_CALLBACK(yahoo_chat_goto), |
2763 _("Cancel"), NULL, gc); | |
2764 } | |
2765 | |
9015 | 2766 static GList *yahoo_actions(GaimPlugin *plugin, gpointer context) { |
2681 | 2767 GList *m = NULL; |
9015 | 2768 GaimPluginAction *act; |
2769 | |
2770 act = gaim_plugin_action_new(_("Activate ID..."), | |
2771 yahoo_show_act_id); | |
2772 m = g_list_append(m, act); | |
2773 | |
2774 act = gaim_plugin_action_new(_("Join user in chat..."), | |
2775 yahoo_show_chat_goto); | |
2776 m = g_list_append(m, act); | |
7878 | 2777 |
2681 | 2778 return m; |
2779 } | |
2780 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7112
diff
changeset
|
2781 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, GaimConvImFlags flags) |
2681 | 2782 { |
2783 struct yahoo_data *yd = gc->proto_data; | |
2784 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
6629 | 2785 char *msg = yahoo_html_to_codes(what); |
7827 | 2786 char *msg2; |
2787 gboolean utf8 = TRUE; | |
2788 | |
2789 msg2 = yahoo_string_encode(gc, msg, &utf8); | |
2681 | 2790 |
5583 | 2791 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 2792 yahoo_packet_hash(pkt, 5, who); |
7827 | 2793 if (utf8) |
2794 yahoo_packet_hash(pkt, 97, "1"); | |
2795 yahoo_packet_hash(pkt, 14, msg2); | |
2796 | |
9280 | 2797 yahoo_packet_hash(pkt, 63, ";0"); /* IMvironment */ |
2798 yahoo_packet_hash(pkt, 64, "0"); /* no idea */ | |
9062 | 2799 yahoo_packet_hash(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */ |
9306 | 2800 if (!yd->picture_url) |
2801 yahoo_packet_hash(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */ | |
2802 else | |
2803 yahoo_packet_hash(pkt, 206, "2"); | |
2681 | 2804 |
2805 yahoo_send_packet(yd, pkt); | |
2806 | |
2807 yahoo_packet_free(pkt); | |
6629 | 2808 |
2809 g_free(msg); | |
7827 | 2810 g_free(msg2); |
6629 | 2811 |
2681 | 2812 return 1; |
2813 } | |
2814 | |
6059 | 2815 int yahoo_send_typing(GaimConnection *gc, const char *who, int typ) |
2993 | 2816 { |
2817 struct yahoo_data *yd = gc->proto_data; | |
3019 | 2818 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
2993 | 2819 yahoo_packet_hash(pkt, 49, "TYPING"); |
5583 | 2820 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2993 | 2821 yahoo_packet_hash(pkt, 14, " "); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
2822 yahoo_packet_hash(pkt, 13, typ == GAIM_TYPING ? "1" : "0"); |
2993 | 2823 yahoo_packet_hash(pkt, 5, who); |
2824 yahoo_packet_hash(pkt, 1002, "1"); | |
2825 | |
2826 yahoo_send_packet(yd, pkt); | |
2827 | |
2828 yahoo_packet_free(pkt); | |
2829 | |
3001 | 2830 return 0; |
2993 | 2831 } |
2832 | |
6059 | 2833 static void yahoo_set_away(GaimConnection *gc, const char *state, const char *msg) |
2681 | 2834 { |
2835 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
2836 struct yahoo_packet *pkt; | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2837 int service; |
2681 | 2838 char s[4]; |
7827 | 2839 char *conv_msg = NULL; |
8503 | 2840 char *conv_msg2 = NULL; |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2841 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2842 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2843 g_free(gc->away); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2844 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2845 } |
2681 | 2846 |
2847 if (msg) { | |
2848 yd->current_status = YAHOO_STATUS_CUSTOM; | |
6847 | 2849 gc->away = g_strndup(msg, YAHOO_MAX_STATUS_MESSAGE_LENGTH); |
2681 | 2850 } else if (state) { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2851 gc->away = g_strdup(""); |
4596 | 2852 if (!strcmp(state, _("Available"))) { |
2681 | 2853 yd->current_status = YAHOO_STATUS_AVAILABLE; |
4596 | 2854 } else if (!strcmp(state, _("Be Right Back"))) { |
2681 | 2855 yd->current_status = YAHOO_STATUS_BRB; |
4596 | 2856 } else if (!strcmp(state, _("Busy"))) { |
2681 | 2857 yd->current_status = YAHOO_STATUS_BUSY; |
4596 | 2858 } else if (!strcmp(state, _("Not At Home"))) { |
2681 | 2859 yd->current_status = YAHOO_STATUS_NOTATHOME; |
4596 | 2860 } else if (!strcmp(state, _("Not At Desk"))) { |
2681 | 2861 yd->current_status = YAHOO_STATUS_NOTATDESK; |
4596 | 2862 } else if (!strcmp(state, _("Not In Office"))) { |
2681 | 2863 yd->current_status = YAHOO_STATUS_NOTINOFFICE; |
4606 | 2864 } else if (!strcmp(state, _("On The Phone"))) { |
2681 | 2865 yd->current_status = YAHOO_STATUS_ONPHONE; |
4596 | 2866 } else if (!strcmp(state, _("On Vacation"))) { |
2681 | 2867 yd->current_status = YAHOO_STATUS_ONVACATION; |
4596 | 2868 } else if (!strcmp(state, _("Out To Lunch"))) { |
2681 | 2869 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; |
4596 | 2870 } else if (!strcmp(state, _("Stepped Out"))) { |
2681 | 2871 yd->current_status = YAHOO_STATUS_STEPPEDOUT; |
4596 | 2872 } else if (!strcmp(state, _("Invisible"))) { |
2681 | 2873 yd->current_status = YAHOO_STATUS_INVISIBLE; |
6847 | 2874 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { /* this should never happen? */ |
2681 | 2875 if (gc->is_idle) { |
2876 yd->current_status = YAHOO_STATUS_IDLE; | |
2877 } else { | |
2878 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
2879 } | |
2880 } | |
2881 } else if (gc->is_idle) { | |
2882 yd->current_status = YAHOO_STATUS_IDLE; | |
2883 } else { | |
2884 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
2885 } | |
2886 | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2887 if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2888 service = YAHOO_SERVICE_ISBACK; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2889 else |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2890 service = YAHOO_SERVICE_ISAWAY; |
6847 | 2891 |
2892 pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, 0); | |
2681 | 2893 g_snprintf(s, sizeof(s), "%d", yd->current_status); |
2894 yahoo_packet_hash(pkt, 10, s); | |
6847 | 2895 |
7827 | 2896 if ((yd->current_status == YAHOO_STATUS_CUSTOM) && gc->away) { |
2897 conv_msg = yahoo_string_encode(gc, gc->away, NULL); | |
8503 | 2898 conv_msg2 = gaim_unescape_html(conv_msg); |
2899 yahoo_packet_hash(pkt, 19, conv_msg2); | |
7827 | 2900 } |
6847 | 2901 |
2902 if ((yd->current_status != YAHOO_STATUS_AVAILABLE) && | |
2903 (yd->current_status != YAHOO_STATUS_IDLE)) { | |
6784 | 2904 if (gc->is_idle) |
2905 yahoo_packet_hash(pkt, 47, "2"); | |
2906 else | |
2907 yahoo_packet_hash(pkt, 47, "1"); | |
6686 | 2908 } |
2681 | 2909 |
2910 yahoo_send_packet(yd, pkt); | |
2911 yahoo_packet_free(pkt); | |
7827 | 2912 if (conv_msg) |
2913 g_free(conv_msg); | |
8503 | 2914 if (conv_msg2) |
2915 g_free(conv_msg2); | |
2681 | 2916 } |
2917 | |
5583 | 2918 static void yahoo_set_idle(GaimConnection *gc, int idle) |
2681 | 2919 { |
2920 struct yahoo_data *yd = gc->proto_data; | |
2921 struct yahoo_packet *pkt = NULL; | |
8503 | 2922 char *msg = NULL, *msg2 = NULL; |
2681 | 2923 |
2924 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
6847 | 2925 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); |
2681 | 2926 yd->current_status = YAHOO_STATUS_IDLE; |
2927 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
2928 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
2929 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
6847 | 2930 } else { |
6784 | 2931 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); |
2681 | 2932 } |
2933 | |
2934 if (pkt) { | |
2935 char buf[4]; | |
2936 g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
2937 yahoo_packet_hash(pkt, 10, buf); | |
6784 | 2938 if (gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) { |
7827 | 2939 msg = yahoo_string_encode(gc, gc->away, NULL); |
8503 | 2940 msg2 = gaim_unescape_html(msg); |
2941 yahoo_packet_hash(pkt, 19, msg2); | |
6784 | 2942 if (idle) |
2943 yahoo_packet_hash(pkt, 47, "2"); | |
2944 else | |
2945 yahoo_packet_hash(pkt, 47, "1"); /* fixme when available messages are possible */ | |
6847 | 2946 } else if (idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) && |
2947 (yd->current_status != YAHOO_STATUS_IDLE)) { | |
2948 yahoo_packet_hash(pkt, 47, "2"); | |
2949 } else if (!idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) && | |
2950 (yd->current_status != YAHOO_STATUS_IDLE)) { | |
2951 yahoo_packet_hash(pkt, 47, "1"); | |
6784 | 2952 } |
6847 | 2953 |
2681 | 2954 yahoo_send_packet(yd, pkt); |
2955 yahoo_packet_free(pkt); | |
2956 } | |
7827 | 2957 if (msg) |
2958 g_free(msg); | |
8503 | 2959 if (msg2) |
2960 g_free(msg2); | |
2681 | 2961 } |
2962 | |
5583 | 2963 static GList *yahoo_away_states(GaimConnection *gc) |
2681 | 2964 { |
2965 GList *m = NULL; | |
9370 | 2966 struct yahoo_data *yd = gc->proto_data; |
2681 | 2967 |
4596 | 2968 m = g_list_append(m, _("Available")); |
9370 | 2969 if (!yd->wm) { |
2970 m = g_list_append(m, _("Be Right Back")); | |
2971 m = g_list_append(m, _("Busy")); | |
2972 m = g_list_append(m, _("Not At Home")); | |
2973 m = g_list_append(m, _("Not At Desk")); | |
2974 m = g_list_append(m, _("Not In Office")); | |
2975 m = g_list_append(m, _("On The Phone")); | |
2976 m = g_list_append(m, _("On Vacation")); | |
2977 m = g_list_append(m, _("Out To Lunch")); | |
2978 m = g_list_append(m, _("Stepped Out")); | |
2979 } | |
4596 | 2980 m = g_list_append(m, _("Invisible")); |
9370 | 2981 if (!yd->wm) |
2982 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
2681 | 2983 |
2984 return m; | |
2985 } | |
2986 | |
5583 | 2987 static void yahoo_keepalive(GaimConnection *gc) |
2681 | 2988 { |
2989 struct yahoo_data *yd = gc->proto_data; | |
2990 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
2991 yahoo_send_packet(yd, pkt); | |
2992 yahoo_packet_free(pkt); | |
6729 | 2993 |
2994 if (!yd->chat_online) | |
2995 return; | |
2996 | |
9376 | 2997 if (yd->wm) { |
2998 ycht_chat_send_keepalive(yd->ycht); | |
2999 return; | |
3000 } | |
3001 | |
6729 | 3002 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); |
3003 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); | |
3004 yahoo_send_packet(yd, pkt); | |
3005 yahoo_packet_free(pkt); | |
2681 | 3006 } |
3007 | |
9285 | 3008 /* XXX - What's the deal with GaimGroup *foo? */ |
3009 static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *foo) | |
2681 | 3010 { |
3011 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
3012 struct yahoo_packet *pkt; | |
6695 | 3013 GaimGroup *g; |
2681 | 3014 char *group = NULL; |
7829 | 3015 char *group2 = NULL; |
2681 | 3016 |
3017 if (!yd->logged_in) | |
3018 return; | |
3019 | |
6840 | 3020 if (foo) |
3021 group = foo->name; | |
3022 if (!group) { | |
9285 | 3023 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, buddy->name)); |
6840 | 3024 if (g) |
3025 group = g->name; | |
3026 else | |
3027 group = "Buddies"; | |
3028 } | |
2681 | 3029 |
7829 | 3030 group2 = yahoo_string_encode(gc, group, NULL); |
2681 | 3031 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
5583 | 3032 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
9285 | 3033 yahoo_packet_hash(pkt, 7, buddy->name); |
7829 | 3034 yahoo_packet_hash(pkt, 65, group2); |
6820 | 3035 yahoo_packet_hash(pkt, 14, ""); |
2681 | 3036 yahoo_send_packet(yd, pkt); |
3037 yahoo_packet_free(pkt); | |
7829 | 3038 g_free(group2); |
2681 | 3039 } |
3040 | |
9285 | 3041 static void yahoo_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
2681 | 3042 { |
3043 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
9278 | 3044 YahooFriend *f; |
6795
40ba19133882
[gaim-migrate @ 7334]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6793
diff
changeset
|
3045 struct yahoo_packet *pkt; |
6840 | 3046 GSList *buddies, *l; |
3047 GaimGroup *g; | |
3048 gboolean remove = TRUE; | |
7827 | 3049 char *cg; |
6784 | 3050 |
9285 | 3051 if (!(f = yahoo_friend_find(gc, buddy->name))) |
6784 | 3052 return; |
3053 | |
9285 | 3054 buddies = gaim_find_buddies(gaim_connection_get_account(gc), buddy->name); |
6840 | 3055 for (l = buddies; l; l = l->next) { |
3056 g = gaim_find_buddys_group(l->data); | |
9285 | 3057 if (gaim_utf8_strcasecmp(group->name, g->name)) { |
6840 | 3058 remove = FALSE; |
3059 break; | |
3060 } | |
3061 } | |
3062 | |
3063 g_slist_free(buddies); | |
3064 | |
3065 if (remove) | |
9285 | 3066 g_hash_table_remove(yd->friends, buddy->name); |
3067 | |
3068 cg = yahoo_string_encode(gc, group->name, NULL); | |
6795
40ba19133882
[gaim-migrate @ 7334]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6793
diff
changeset
|
3069 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
5583 | 3070 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
9285 | 3071 yahoo_packet_hash(pkt, 7, buddy->name); |
7827 | 3072 yahoo_packet_hash(pkt, 65, cg); |
2681 | 3073 yahoo_send_packet(yd, pkt); |
3074 yahoo_packet_free(pkt); | |
7827 | 3075 g_free(cg); |
2681 | 3076 } |
3077 | |
6760 | 3078 static void yahoo_add_deny(GaimConnection *gc, const char *who) { |
3079 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
3080 struct yahoo_packet *pkt; | |
3081 | |
3082 if (!yd->logged_in) | |
3083 return; | |
8057 | 3084 /* It seems to work better without this */ |
3085 | |
8113 | 3086 /* if (gc->account->perm_deny != 4) |
3087 return; */ | |
3088 | |
3089 if (!who || who[0] == '\0') | |
3090 return; | |
3091 | |
6760 | 3092 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); |
3093 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
3094 yahoo_packet_hash(pkt, 7, who); | |
3095 yahoo_packet_hash(pkt, 13, "1"); | |
3096 yahoo_send_packet(yd, pkt); | |
3097 yahoo_packet_free(pkt); | |
3098 } | |
3099 | |
3100 static void yahoo_rem_deny(GaimConnection *gc, const char *who) { | |
3101 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
3102 struct yahoo_packet *pkt; | |
3103 | |
3104 if (!yd->logged_in) | |
3105 return; | |
3106 | |
3107 if (!who || who[0] == '\0') | |
3108 return; | |
3109 | |
3110 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
3111 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
3112 yahoo_packet_hash(pkt, 7, who); | |
3113 yahoo_packet_hash(pkt, 13, "2"); | |
3114 yahoo_send_packet(yd, pkt); | |
3115 yahoo_packet_free(pkt); | |
3116 } | |
3117 | |
3118 static void yahoo_set_permit_deny(GaimConnection *gc) { | |
3119 GaimAccount *acct; | |
3120 GSList *deny; | |
3121 | |
3122 acct = gc->account; | |
3123 | |
3124 switch (acct->perm_deny) { | |
3125 case 1: | |
3126 case 3: | |
3127 case 5: | |
3128 for (deny = acct->deny;deny;deny = deny->next) | |
3129 yahoo_rem_deny(gc, deny->data); | |
3130 break; | |
3131 case 4: | |
3132 for (deny = acct->deny;deny;deny = deny->next) | |
3133 yahoo_add_deny(gc, deny->data); | |
3134 break; | |
3135 case 2: | |
3136 default: | |
3137 break; | |
3138 } | |
3139 } | |
3140 | |
6513 | 3141 static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
3142 { | |
3143 yahoo_dest_colorht(); | |
3144 return TRUE; | |
3145 } | |
3146 | |
6793 | 3147 static void yahoo_change_buddys_group(GaimConnection *gc, const char *who, |
3148 const char *old_group, const char *new_group) | |
3149 { | |
3150 struct yahoo_data *yd = gc->proto_data; | |
3151 struct yahoo_packet *pkt; | |
7827 | 3152 char *gpn, *gpo; |
6793 | 3153 |
3154 /* Step 0: If they aren't on the server list anyway, | |
3155 * don't bother letting the server know. | |
3156 */ | |
9279 | 3157 if (!yahoo_friend_find(gc, who)) |
6793 | 3158 return; |
3159 | |
7827 | 3160 /* If old and new are the same, we would probably |
3161 * end up deleting the buddy, which would be bad. | |
3162 * This might happen because of the charset conversation. | |
3163 */ | |
3164 gpn = yahoo_string_encode(gc, new_group, NULL); | |
3165 gpo = yahoo_string_encode(gc, old_group, NULL); | |
3166 if (!strcmp(gpn, gpo)) { | |
3167 g_free(gpn); | |
3168 g_free(gpo); | |
3169 return; | |
3170 } | |
3171 | |
6793 | 3172 /* Step 1: Add buddy to new group. */ |
3173 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
3174 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
3175 yahoo_packet_hash(pkt, 7, who); | |
7827 | 3176 yahoo_packet_hash(pkt, 65, gpn); |
6793 | 3177 yahoo_packet_hash(pkt, 14, ""); |
3178 yahoo_send_packet(yd, pkt); | |
3179 yahoo_packet_free(pkt); | |
3180 | |
3181 /* Step 2: Remove buddy from old group */ | |
3182 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
3183 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
3184 yahoo_packet_hash(pkt, 7, who); | |
7827 | 3185 yahoo_packet_hash(pkt, 65, gpo); |
6793 | 3186 yahoo_send_packet(yd, pkt); |
3187 yahoo_packet_free(pkt); | |
7827 | 3188 g_free(gpn); |
3189 g_free(gpo); | |
6793 | 3190 } |
3191 | |
9285 | 3192 static void yahoo_rename_group(GaimConnection *gc, const char *old_name, |
3193 GaimGroup *group, GList *moved_buddies) | |
6793 | 3194 { |
3195 struct yahoo_data *yd = gc->proto_data; | |
3196 struct yahoo_packet *pkt; | |
7827 | 3197 char *gpn, *gpo; |
3198 | |
9285 | 3199 gpn = yahoo_string_encode(gc, group->name, NULL); |
3200 gpo = yahoo_string_encode(gc, old_name, NULL); | |
7827 | 3201 if (!strcmp(gpn, gpo)) { |
3202 g_free(gpn); | |
3203 g_free(gpo); | |
3204 return; | |
3205 } | |
6793 | 3206 |
3207 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); | |
3208 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
7827 | 3209 yahoo_packet_hash(pkt, 65, gpo); |
3210 yahoo_packet_hash(pkt, 67, gpn); | |
6793 | 3211 yahoo_send_packet(yd, pkt); |
3212 yahoo_packet_free(pkt); | |
7827 | 3213 g_free(gpn); |
3214 g_free(gpo); | |
6793 | 3215 } |
3216 | |
7696 | 3217 #if 0 |
7651 | 3218 static gboolean yahoo_has_send_file(GaimConnection *gc, const char *who) |
3219 { | |
3220 return TRUE; | |
3221 } | |
7696 | 3222 #endif |
7651 | 3223 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3224 static GaimPlugin *my_protocol = NULL; |
2681 | 3225 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3226 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3227 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
3228 GAIM_PRPL_API_VERSION, |
9308 | 3229 OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, |
6729 | 3230 NULL, /* user_splits */ |
3231 NULL, /* protocol_options */ | |
9318 | 3232 {"png", 96, 96, 96, 96, GAIM_ICON_SCALE_SEND}, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3233 yahoo_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3234 yahoo_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3235 yahoo_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3236 yahoo_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3237 yahoo_away_states, |
9030 | 3238 yahoo_blist_node_menu, |
6729 | 3239 yahoo_c_info, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3240 yahoo_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3241 yahoo_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3242 yahoo_send_im, |
6729 | 3243 NULL, /* set info */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3244 yahoo_send_typing, |
6514 | 3245 yahoo_get_info, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3246 yahoo_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3247 yahoo_set_idle, |
6729 | 3248 NULL, /* change_passwd*/ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3249 yahoo_add_buddy, |
6729 | 3250 NULL, /* add_buddies */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3251 yahoo_remove_buddy, |
6729 | 3252 NULL, /*remove_buddies */ |
3253 NULL, /* add_permit */ | |
6760 | 3254 yahoo_add_deny, |
6729 | 3255 NULL, /* rem_permit */ |
6760 | 3256 yahoo_rem_deny, |
3257 yahoo_set_permit_deny, | |
6729 | 3258 NULL, /* warn */ |
3259 yahoo_c_join, | |
8562 | 3260 NULL, /* reject chat invite */ |
6729 | 3261 yahoo_c_invite, |
3262 yahoo_c_leave, | |
3263 NULL, /* chat whisper */ | |
3264 yahoo_c_send, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3265 yahoo_keepalive, |
6729 | 3266 NULL, /* register_user */ |
3267 NULL, /* get_cb_info */ | |
3268 NULL, /* get_cb_away */ | |
3269 NULL, /* alias_buddy */ | |
6793 | 3270 yahoo_change_buddys_group, |
3271 yahoo_rename_group, | |
6729 | 3272 NULL, /* buddy_free */ |
3273 NULL, /* convo_closed */ | |
3274 NULL, /* normalize */ | |
9306 | 3275 yahoo_set_buddy_icon, |
7651 | 3276 NULL, /* void (*remove_group)(GaimConnection *gc, const char *group);*/ |
3277 NULL, /* char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); */ | |
3278 #if 0 | |
3279 yahoo_ask_send_file, | |
3280 yahoo_send_file, | |
8113 | 3281 yahoo_has_send_file, |
7651 | 3282 #endif |
8113 | 3283 NULL, |
3284 NULL, | |
3285 yahoo_roomlist_get_list, | |
3286 yahoo_roomlist_cancel, | |
9030 | 3287 yahoo_roomlist_expand_category |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3288 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3289 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3290 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3291 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
3292 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3293 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3294 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3295 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3296 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3297 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3298 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3299 "prpl-yahoo", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3300 "Yahoo", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3301 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3302 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3303 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3304 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3305 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3306 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
3307 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3308 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3309 NULL, /**< load */ |
6513 | 3310 yahoo_unload_plugin, /**< unload */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3311 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3312 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3313 NULL, /**< ui_info */ |
8993 | 3314 &prpl_info, /**< extra_info */ |
3315 NULL, | |
9015 | 3316 yahoo_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3317 }; |
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 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
3320 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3321 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
3322 GaimAccountOption *option; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3323 |
9164 | 3324 option = gaim_account_option_bool_new(_("Yahoo Japan"), "yahoojp", FALSE); |
3325 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3326 | |
7827 | 3327 option = gaim_account_option_string_new(_("Pager host"), "server", YAHOO_PAGER_HOST); |
3328 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3329 | |
9164 | 3330 option = gaim_account_option_string_new(_("Japan Pager host"), "serverjp", YAHOOJP_PAGER_HOST); |
3331 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3332 | |
7827 | 3333 option = gaim_account_option_int_new(_("Pager port"), "port", YAHOO_PAGER_PORT); |
3334 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7651 | 3335 |
3336 option = gaim_account_option_string_new(_("File transfer host"), "xfer_host", YAHOO_XFER_HOST); | |
3337 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3338 | |
9164 | 3339 option = gaim_account_option_string_new(_("Japan File transfer host"), "xferjp_host", YAHOOJP_XFER_HOST); |
3340 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3341 | |
7651 | 3342 option = gaim_account_option_int_new(_("File transfer port"), "xfer_port", YAHOO_XFER_PORT); |
3343 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3344 | |
8113 | 3345 option = gaim_account_option_string_new(_("Chat Room List Url"), "room_list", YAHOO_ROOMLIST_URL); |
3346 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
9376 | 3347 #if 0 |
3348 option = gaim_account_option_string_new(_("YCHT Host"), "ycht-server", YAHOO_YCHT_HOST); | |
3349 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3350 | |
3351 option = gaim_account_option_int_new(_("YCHT Port"), "ycht-port", YAHOO_YCHT_PORT); | |
3352 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3353 #endif | |
3354 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3355 my_protocol = plugin; |
6513 | 3356 |
3357 yahoo_init_colorht(); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3358 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3359 |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
3360 GAIM_INIT_PLUGIN(yahoo, init_plugin, info); |