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