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