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