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