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