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