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