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