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