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