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