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