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