Mercurial > pidgin.yaz
annotate src/protocols/yahoo/yahoo.c @ 6729:7b878ee8f064
[gaim-migrate @ 7256]
Tim Ringenbach (marv_sf) writes:
" This adds Chat and Conference support to the Yahoo! prpl.
I think I got all the major bugs out, and it works
pretty good.
You can invite others, and accept inventations for both
chats and conferences, you can join a chat from the
Buddies menu in the buddy list, like you would for irc,
and you can initiate a conference by right clicking on
a buddy, like you would for msn. You can also attempt
to join user in chat, which will fail if they're not
actually in a chat. (Apparently the offical version
can't tell before hand either.)
Oh, and you can chat."
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 03 Sep 2003 12:45:17 +0000 |
parents | 0c5637b5462e |
children | e7e21e5d1d16 |
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" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
26 #include "debug.h" |
2681 | 27 #include "multi.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
28 #include "notify.h" |
2681 | 29 #include "prpl.h" |
30 #include "proxy.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
31 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
32 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
33 #include "util.h" |
6115
11bedb793a44
[gaim-migrate @ 6578]
Christian Hammond <chipx86@chipx86.com>
parents:
6069
diff
changeset
|
34 #include "html.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
35 |
6513 | 36 #include "yahoo.h" |
6729 | 37 #include "yahoochat.h" |
3147 | 38 #include "md5.h" |
2681 | 39 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
40 /* XXX */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
41 #include "gtkinternal.h" |
6546 | 42 #include "gaim.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
43 #include "ui.h" |
3630 | 44 |
5583 | 45 extern char *yahoo_crypt(const char *, const char *); |
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
46 |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
47 /* #define YAHOO_DEBUG */ |
2681 | 48 |
49 #define USEROPT_MAIL 0 | |
50 | |
3147 | 51 #define YAHOO_PAGER_HOST "scs.yahoo.com" |
2681 | 52 #define YAHOO_PAGER_PORT 5050 |
6514 | 53 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/" |
2681 | 54 |
3467 | 55 #define YAHOO_PROTO_VER 0x0900 |
56 | |
2681 | 57 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) |
58 | |
6729 | 59 struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) |
2681 | 60 { |
61 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); | |
62 | |
63 pkt->service = service; | |
64 pkt->status = status; | |
65 pkt->id = id; | |
66 | |
67 return pkt; | |
68 } | |
69 | |
6729 | 70 void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value) |
2681 | 71 { |
72 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
73 pair->key = key; | |
74 pair->value = g_strdup(value); | |
75 pkt->hash = g_slist_append(pkt->hash, pair); | |
76 } | |
77 | |
78 static int yahoo_packet_length(struct yahoo_packet *pkt) | |
79 { | |
80 GSList *l; | |
81 | |
82 int len = 0; | |
83 | |
84 l = pkt->hash; | |
85 while (l) { | |
86 struct yahoo_pair *pair = l->data; | |
87 int tmp = pair->key; | |
88 do { | |
89 tmp /= 10; | |
90 len++; | |
91 } while (tmp); | |
92 len += 2; | |
93 len += strlen(pair->value); | |
94 len += 2; | |
95 l = l->next; | |
96 } | |
97 | |
98 return len; | |
99 } | |
100 | |
101 /* sometimes i wish prpls could #include things from other prpls. then i could just | |
102 * use the routines from libfaim and not have to admit to knowing how they work. */ | |
103 #define yahoo_put16(buf, data) ( \ | |
104 (*(buf) = (u_char)((data)>>8)&0xff), \ | |
105 (*((buf)+1) = (u_char)(data)&0xff), \ | |
106 2) | |
107 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
108 #define yahoo_put32(buf, data) ( \ | |
109 (*((buf)) = (u_char)((data)>>24)&0xff), \ | |
110 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ | |
111 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ | |
112 (*((buf)+3) = (u_char)(data)&0xff), \ | |
113 4) | |
114 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
115 (((*((buf)+1))<<16)&0x00ff0000) + \ | |
116 (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
117 (((*((buf)+3) )&0x000000ff))) | |
118 | |
119 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) | |
120 { | |
121 int pos = 0; | |
122 | |
123 while (pos + 1 < len) { | |
6629 | 124 char key[64], *value = NULL, *esc; |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
125 int accept; |
2681 | 126 int x; |
127 | |
128 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
129 | |
130 x = 0; | |
131 while (pos + 1 < len) { | |
132 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
133 break; | |
134 key[x++] = data[pos++]; | |
135 } | |
136 key[x] = 0; | |
137 pos += 2; | |
138 pair->key = strtol(key, NULL, 10); | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
139 accept = x; /* if x is 0 there was no key, so don't accept it */ |
2681 | 140 |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
141 if (len - pos + 1 <= 0) { |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
142 /* Truncated. Garbage or something. */ |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
143 accept = 0; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
144 } |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
145 |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
146 if (accept) { |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
147 value = g_malloc(len - pos + 1); |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
148 x = 0; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
149 while (pos + 1 < len) { |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
150 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
151 break; |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
152 value[x++] = data[pos++]; |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
153 } |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
154 value[x] = 0; |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
155 pair->value = g_strdup(value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
156 g_free(value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
157 pkt->hash = g_slist_append(pkt->hash, pair); |
6629 | 158 esc = g_strescape(pair->value, NULL); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
159 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
6629 | 160 "Key: %d \tValue: %s\n", pair->key, esc); |
161 g_free(esc); | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
162 } else { |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
163 g_free(pair); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
164 } |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
165 pos += 2; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
166 |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
167 /* Skip over garbage we've noticed in the mail notifications */ |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
168 if (data[0] == '9' && data[pos] == 0x01) |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
169 pos++; |
2681 | 170 } |
171 } | |
172 | |
173 static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) | |
174 { | |
175 GSList *l = pkt->hash; | |
176 int pos = 0; | |
177 | |
178 while (l) { | |
179 struct yahoo_pair *pair = l->data; | |
180 guchar buf[100]; | |
181 | |
182 g_snprintf(buf, sizeof(buf), "%d", pair->key); | |
183 strcpy(data + pos, buf); | |
184 pos += strlen(buf); | |
185 data[pos++] = 0xc0; | |
186 data[pos++] = 0x80; | |
187 | |
188 strcpy(data + pos, pair->value); | |
189 pos += strlen(pair->value); | |
190 data[pos++] = 0xc0; | |
191 data[pos++] = 0x80; | |
192 | |
193 l = l->next; | |
194 } | |
195 } | |
196 | |
197 static void yahoo_packet_dump(guchar *data, int len) | |
198 { | |
199 #ifdef YAHOO_DEBUG | |
200 int i; | |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
201 |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
202 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
203 |
2681 | 204 for (i = 0; i + 1 < len; i += 2) { |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
205 if ((i % 16 == 0) && i) { |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
206 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
207 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
208 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
209 |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
210 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]); |
2681 | 211 } |
212 if (i < len) | |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
213 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]); |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
214 |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
215 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
216 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
217 |
2681 | 218 for (i = 0; i < len; i++) { |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
219 if ((i % 16 == 0) && i) { |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
220 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
221 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
222 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
223 |
6686 | 224 if (g_ascii_isprint(data[i])) |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
225 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]); |
2681 | 226 else |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
227 gaim_debug(GAIM_DEBUG_MISC, NULL, ". "); |
2681 | 228 } |
5216
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, "\n"); |
2681 | 231 #endif |
232 } | |
233 | |
6729 | 234 int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt) |
2681 | 235 { |
236 int pktlen = yahoo_packet_length(pkt); | |
237 int len = YAHOO_PACKET_HDRLEN + pktlen; | |
238 int ret; | |
239 | |
240 guchar *data; | |
241 int pos = 0; | |
242 | |
243 if (yd->fd < 0) | |
244 return -1; | |
245 | |
246 data = g_malloc0(len + 1); | |
247 | |
248 memcpy(data + pos, "YMSG", 4); pos += 4; | |
3467 | 249 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); |
2681 | 250 pos += yahoo_put16(data + pos, 0x0000); |
251 pos += yahoo_put16(data + pos, pktlen); | |
252 pos += yahoo_put16(data + pos, pkt->service); | |
253 pos += yahoo_put32(data + pos, pkt->status); | |
254 pos += yahoo_put32(data + pos, pkt->id); | |
255 | |
256 yahoo_packet_write(pkt, data + pos); | |
257 | |
258 yahoo_packet_dump(data, len); | |
259 ret = write(yd->fd, data, len); | |
260 g_free(data); | |
261 | |
262 return ret; | |
263 } | |
264 | |
6729 | 265 void yahoo_packet_free(struct yahoo_packet *pkt) |
2681 | 266 { |
267 while (pkt->hash) { | |
268 struct yahoo_pair *pair = pkt->hash->data; | |
269 g_free(pair->value); | |
270 g_free(pair); | |
271 pkt->hash = g_slist_remove(pkt->hash, pair); | |
272 } | |
273 g_free(pkt); | |
274 } | |
275 | |
5583 | 276 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 277 { |
278 struct yahoo_data *yd = gc->proto_data; | |
279 GSList *l = pkt->hash; | |
280 char *name = NULL; | |
281 int state = 0; | |
3019 | 282 int gamestate = 0; |
2681 | 283 char *msg = NULL; |
6686 | 284 int away = 0; |
285 int idle = 0; | |
286 | |
2681 | 287 while (l) { |
288 struct yahoo_pair *pair = l->data; | |
289 | |
290 switch (pair->key) { | |
291 case 0: /* we won't actually do anything with this */ | |
292 break; | |
293 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
|
294 if (!yd->logged_in) { |
5583 | 295 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
296 serv_finish_login(gc); |
5583 | 297 gaim_connection_set_display_name(gc, pair->value); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
298 yd->logged_in = TRUE; |
2681 | 299 |
3147 | 300 /* this requests the list. i have a feeling that this is very evil |
301 * | |
6686 | 302 * scs.yahoo.com sends you the list before this packet without it being |
3147 | 303 * requested |
304 * | |
305 * do_import(gc, NULL); | |
306 * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); | |
307 * yahoo_send_packet(yd, newpkt); | |
308 * yahoo_packet_free(newpkt); | |
309 */ | |
310 | |
311 } | |
2681 | 312 break; |
313 case 8: /* how many online buddies we have */ | |
314 break; | |
315 case 7: /* the current buddy */ | |
316 name = pair->value; | |
317 break; | |
318 case 10: /* state */ | |
319 state = strtol(pair->value, NULL, 10); | |
6686 | 320 if (state >= YAHOO_STATUS_BRB && state <= YAHOO_STATUS_STEPPEDOUT) |
321 away = 1; | |
2681 | 322 break; |
323 case 19: /* custom message */ | |
324 msg = pair->value; | |
325 break; | |
6686 | 326 case 11: /* this is the buddy's session id */ |
2681 | 327 break; |
328 case 17: /* in chat? */ | |
329 break; | |
6686 | 330 case 47: /* is custom status away or not? 2=idle?*/ |
331 away = strtol(pair->value, NULL, 10); | |
332 break; | |
333 case 137: | |
334 idle = time(NULL) - strtol(pair->value, NULL, 10); | |
335 break; | |
336 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ | |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
337 if (pkt->service == YAHOO_SERVICE_LOGOFF || |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
338 strtol(pair->value, NULL, 10) == 0) { |
4732 | 339 serv_got_update(gc, name, 0, 0, 0, 0, 0); |
2807
f01e6a425136
[gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2805
diff
changeset
|
340 break; |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
341 } |
3019 | 342 if (g_hash_table_lookup(yd->games, name)) |
343 gamestate = YAHOO_STATUS_GAME; | |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
344 if (state == YAHOO_STATUS_CUSTOM) { |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
345 gpointer val = g_hash_table_lookup(yd->hash, name); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
346 if (val) { |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
347 g_free(val); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
348 g_hash_table_insert(yd->hash, name, |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
349 msg ? g_strdup(msg) : g_malloc0(1)); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
350 } else |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
351 g_hash_table_insert(yd->hash, g_strdup(name), |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
352 msg ? g_strdup(msg) : g_malloc0(1)); |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
353 } |
4777 | 354 if (state == YAHOO_STATUS_AVAILABLE) |
355 serv_got_update(gc, name, 1, 0, 0, 0, gamestate); | |
5002 | 356 else if (state == YAHOO_STATUS_IDLE) |
6686 | 357 serv_got_update(gc, name, 1, 0, 0, (idle?idle:time(NULL)), (state << 2) | UC_UNAVAILABLE | gamestate); |
358 else { | |
359 if (away) | |
360 serv_got_update(gc, name, 1, 0, 0, idle, (state << 2) | UC_UNAVAILABLE | gamestate); | |
361 else | |
362 serv_got_update(gc, name, 1, 0, 0, 0, (state << 2) | gamestate); | |
363 } | |
364 away = 0; | |
365 idle = 0; | |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
366 break; |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
367 case 60: /* SMS, but comes after 13. but name hasnt been destroyed yet. */ |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
368 break; |
2979 | 369 case 16: /* Custom error message */ |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
370 gaim_notify_error(gc, NULL, pair->value, NULL); |
2951 | 371 break; |
2681 | 372 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
373 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
374 "Unknown status key %d\n", pair->key); |
2681 | 375 break; |
376 } | |
377 | |
378 l = l->next; | |
379 } | |
380 } | |
381 | |
5583 | 382 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 383 { |
384 GSList *l = pkt->hash; | |
385 gboolean export = FALSE; | |
6695 | 386 GaimBuddy *b; |
387 GaimGroup *g; | |
2681 | 388 |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
389 while (l) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
390 char **lines; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
391 char **split; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
392 char **buddies; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
393 char **tmp, **bud; |
2681 | 394 |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
395 struct yahoo_pair *pair = l->data; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
396 l = l->next; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
397 |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
398 if (pair->key != 87) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
399 continue; |
2681 | 400 |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
401 lines = g_strsplit(pair->value, "\n", -1); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
402 for (tmp = lines; *tmp; tmp++) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
403 split = g_strsplit(*tmp, ":", 2); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
404 if (!split) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
405 continue; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
406 if (!split[0] || !split[1]) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
407 g_strfreev(split); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
408 continue; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
409 } |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
410 buddies = g_strsplit(split[1], ",", -1); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
411 for (bud = buddies; bud && *bud; bud++) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
412 if (!(b = gaim_find_buddy(gc->account, *bud))) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
413 if (!(g = gaim_find_group(split[0]))) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
414 g = gaim_group_new(split[0]); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
415 gaim_blist_add_group(g, NULL); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
416 } |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
417 b = gaim_buddy_new(gc->account, *bud, NULL); |
6695 | 418 gaim_blist_add_buddy(b, NULL, g, NULL); |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
419 export = TRUE; |
6687 | 420 } |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
421 g_strfreev(buddies); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
422 g_strfreev(split); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
423 } |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
424 g_strfreev(lines); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
425 } |
2681 | 426 |
427 if (export) | |
4349 | 428 gaim_blist_save(); |
2681 | 429 } |
430 | |
5583 | 431 static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) |
2993 | 432 { |
433 char *msg = NULL; | |
434 char *from = NULL; | |
3019 | 435 char *stat = NULL; |
436 char *game = NULL; | |
2993 | 437 GSList *l = pkt->hash; |
3019 | 438 struct yahoo_data *yd = (struct yahoo_data*) gc->proto_data; |
2993 | 439 while (l) { |
440 struct yahoo_pair *pair = l->data; | |
441 if (pair->key == 4) | |
442 from = pair->value; | |
443 if (pair->key == 49) | |
444 msg = pair->value; | |
3001 | 445 if (pair->key == 13) |
3019 | 446 stat = pair->value; |
447 if (pair->key == 14) | |
448 game = pair->value; | |
2993 | 449 l = l->next; |
450 } | |
3640 | 451 |
452 if (!msg) | |
453 return; | |
6686 | 454 |
4793 | 455 if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) { |
3019 | 456 if (*stat == '1') |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
457 serv_got_typing(gc, from, 0, GAIM_TYPING); |
3019 | 458 else |
459 serv_got_typing_stopped(gc, from); | |
4793 | 460 } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) { |
6695 | 461 GaimBuddy *bud = gaim_find_buddy(gc->account, from); |
3019 | 462 void *free1=NULL, *free2=NULL; |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
463 if (!bud) { |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
464 gaim_debug(GAIM_DEBUG_WARNING, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
465 "%s is playing a game, and doesn't want " |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
466 "you to know.\n", from); |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
467 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
468 |
3019 | 469 if (*stat == '1') { |
470 if (g_hash_table_lookup_extended (yd->games, from, free1, free2)) { | |
471 g_free(free1); | |
472 g_free(free2); | |
473 } | |
474 g_hash_table_insert (yd->games, g_strdup(from), g_strdup(game)); | |
3020 | 475 if (bud) |
4732 | 476 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc | YAHOO_STATUS_GAME); |
3019 | 477 } else { |
478 if (g_hash_table_lookup_extended (yd->games, from, free1, free2)) { | |
479 g_free(free1); | |
480 g_free(free2); | |
481 g_hash_table_remove (yd->games, from); | |
482 } | |
3020 | 483 if (bud) |
4732 | 484 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc & ~YAHOO_STATUS_GAME); |
3019 | 485 } |
486 } | |
2993 | 487 } |
488 | |
5583 | 489 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 490 { |
491 char *msg = NULL; | |
492 char *from = NULL; | |
493 time_t tm = time(NULL); | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
494 GSList *l = pkt->hash; |
6069 | 495 |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
496 if (pkt->status <= 1 || pkt->status == 5) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
497 while (l) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
498 struct yahoo_pair *pair = l->data; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
499 if (pair->key == 4) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
500 from = pair->value; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
501 if (pair->key == 15) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
502 tm = strtol(pair->value, NULL, 10); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
503 if (pair->key == 14) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
504 char *m; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
505 |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
506 msg = pair->value; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
507 |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
508 strip_linefeed(msg); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
509 m = yahoo_codes_to_html(msg); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
510 serv_got_im(gc, from, m, 0, tm, -1); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
511 g_free(m); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
512 |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
513 tm = time(NULL); |
6687 | 514 } |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
515 l = l->next; |
6687 | 516 } |
2681 | 517 } else if (pkt->status == 2) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
518 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
519 _("Your Yahoo! message did not get sent."), NULL); |
2681 | 520 } |
521 } | |
522 | |
6686 | 523 static void yahoo_buddy_added_us(GaimConnection *gc, struct yahoo_packet *pkt) { |
2681 | 524 char *id = NULL; |
525 char *who = NULL; | |
526 char *msg = NULL; | |
527 GSList *l = pkt->hash; | |
528 | |
529 while (l) { | |
530 struct yahoo_pair *pair = l->data; | |
6686 | 531 |
532 switch (pair->key) { | |
533 case 1: | |
2681 | 534 id = pair->value; |
6686 | 535 break; |
536 case 3: | |
2681 | 537 who = pair->value; |
6686 | 538 break; |
539 case 15: /* time, for when they add us and we're offline */ | |
540 break; | |
541 case 14: | |
2681 | 542 msg = pair->value; |
6686 | 543 break; |
544 } | |
2681 | 545 l = l->next; |
546 } | |
547 | |
2682
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
548 if (id) |
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
549 show_got_added(gc, id, who, NULL, msg); |
6686 | 550 } |
551 | |
552 static void yahoo_buddy_denied_our_add(GaimConnection *gc, struct yahoo_packet *pkt) | |
553 { | |
554 char *who = NULL; | |
555 char *msg = NULL; | |
556 GSList *l = pkt->hash; | |
557 GString *buf = NULL; | |
558 | |
559 while (l) { | |
560 struct yahoo_pair *pair = l->data; | |
561 | |
562 switch (pair->key) { | |
563 case 3: | |
564 who = pair->value; | |
565 break; | |
566 case 14: | |
567 msg = pair->value; | |
568 break; | |
569 } | |
570 l = l->next; | |
571 } | |
572 | |
573 if (who) { | |
574 buf = g_string_sized_new(0); | |
575 if (!msg) | |
576 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
|
577 else |
6686 | 578 g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg); |
579 gaim_notify_info(gc, NULL, buf->str, NULL); | |
580 g_string_free(buf, TRUE); | |
581 } | |
582 } | |
583 | |
584 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt) | |
585 { | |
586 | |
587 | |
588 switch (pkt->status) { | |
589 case 1: | |
590 yahoo_process_status(gc, pkt); | |
591 return; | |
592 case 3: | |
593 yahoo_buddy_added_us(gc, pkt); | |
594 break; | |
595 case 7: | |
596 yahoo_buddy_denied_our_add(gc, pkt); | |
597 break; | |
598 default: | |
599 break; | |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
600 } |
2681 | 601 } |
602 | |
5583 | 603 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 604 { |
5583 | 605 GaimAccount *account = gaim_connection_get_account(gc); |
2681 | 606 char *who = NULL; |
607 char *email = NULL; | |
608 char *subj = NULL; | |
609 int count = 0; | |
610 GSList *l = pkt->hash; | |
611 | |
5583 | 612 if (!gaim_account_get_check_mail(account)) |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
613 return; |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
614 |
2681 | 615 while (l) { |
616 struct yahoo_pair *pair = l->data; | |
617 if (pair->key == 9) | |
618 count = strtol(pair->value, NULL, 10); | |
619 else if (pair->key == 43) | |
620 who = pair->value; | |
621 else if (pair->key == 42) | |
622 email = pair->value; | |
623 else if (pair->key == 18) | |
624 subj = pair->value; | |
625 l = l->next; | |
626 } | |
627 | |
4001 | 628 if (who && subj && email && *email) { |
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
629 char *from = g_strdup_printf("%s (%s)", who, email); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
630 |
5583 | 631 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
|
632 "http://mail.yahoo.com/", NULL, NULL); |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
633 |
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
634 g_free(from); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
635 } else if (count > 0) { |
5583 | 636 const char *to = gaim_account_get_username(account); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
637 const char *url = "http://mail.yahoo.com/"; |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
638 |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
639 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
640 NULL, NULL); |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
641 } |
2681 | 642 } |
3147 | 643 /* This is the y64 alphabet... it's like base64, but has a . and a _ */ |
644 char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; | |
645 | |
646 /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function | |
647 * in util.c, but it has a bug I don't feel like finding right now ;) */ | |
648 void to_y64(unsigned char *out, const unsigned char *in, int inlen) | |
649 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ | |
650 { | |
651 for (; inlen >= 3; inlen -= 3) | |
652 { | |
653 *out++ = base64digits[in[0] >> 2]; | |
654 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | |
655 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; | |
656 *out++ = base64digits[in[2] & 0x3f]; | |
657 in += 3; | |
658 } | |
659 if (inlen > 0) | |
660 { | |
661 unsigned char fragment; | |
662 | |
663 *out++ = base64digits[in[0] >> 2]; | |
664 fragment = (in[0] << 4) & 0x30; | |
665 if (inlen > 1) | |
666 fragment |= in[1] >> 4; | |
667 *out++ = base64digits[fragment]; | |
668 *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c]; | |
669 *out++ = '-'; | |
670 } | |
671 *out = '\0'; | |
672 } | |
673 | |
5583 | 674 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt) |
3147 | 675 { |
676 char *seed = NULL; | |
677 char *sn = NULL; | |
678 GSList *l = pkt->hash; | |
679 struct yahoo_data *yd = gc->proto_data; | |
680 | |
681 while (l) { | |
682 struct yahoo_pair *pair = l->data; | |
683 if (pair->key == 94) | |
684 seed = pair->value; | |
685 if (pair->key == 1) | |
686 sn = pair->value; | |
687 l = l->next; | |
688 } | |
689 | |
690 if (seed) { | |
691 struct yahoo_packet *pack; | |
5583 | 692 GaimAccount *account = gaim_connection_get_account(gc); |
5921 | 693 const char *name = normalize(gaim_account_get_username(account)); |
5583 | 694 const char *pass = gaim_account_get_password(account); |
695 | |
3147 | 696 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly |
697 * will soon do so in the rest of the world. | |
6686 | 698 * |
3147 | 699 * The new clients use this authentication method. I warn you in advance, it's |
700 * bizzare, convoluted, inordinately complicated. It's also no more secure than | |
701 * crypt() was. The only purpose this scheme could serve is to prevent third | |
702 * part clients from connecting to their servers. | |
703 * | |
704 * Sorry, Yahoo. | |
705 */ | |
706 | |
707 md5_byte_t result[16]; | |
708 md5_state_t ctx; | |
5583 | 709 |
3147 | 710 char *crypt_result; |
5583 | 711 char password_hash[25]; |
712 char crypt_hash[25]; | |
3147 | 713 char *hash_string_p = g_malloc(50 + strlen(sn)); |
714 char *hash_string_c = g_malloc(50 + strlen(sn)); | |
715 | |
716 char checksum; | |
717 | |
3157 | 718 int sv; |
3147 | 719 |
5583 | 720 char result6[25]; |
721 char result96[25]; | |
3147 | 722 |
723 sv = seed[15]; | |
3157 | 724 sv = sv % 8; |
3147 | 725 |
726 md5_init(&ctx); | |
5583 | 727 md5_append(&ctx, pass, strlen(pass)); |
3147 | 728 md5_finish(&ctx, result); |
729 to_y64(password_hash, result, 16); | |
730 | |
731 md5_init(&ctx); | |
5583 | 732 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
3147 | 733 md5_append(&ctx, crypt_result, strlen(crypt_result)); |
734 md5_finish(&ctx, result); | |
735 to_y64(crypt_hash, result, 16); | |
3157 | 736 |
737 switch (sv) { | |
3147 | 738 case 1: |
739 case 6: | |
3157 | 740 checksum = seed[seed[9] % 16]; |
3147 | 741 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 742 "%c%s%s%s", checksum, name, seed, password_hash); |
3157 | 743 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 744 "%c%s%s%s", checksum, name, seed, crypt_hash); |
3147 | 745 break; |
746 case 2: | |
747 case 7: | |
3157 | 748 checksum = seed[seed[15] % 16]; |
3147 | 749 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 750 "%c%s%s%s", checksum, seed, password_hash, name); |
3157 | 751 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 752 "%c%s%s%s", checksum, seed, crypt_hash, name); |
3157 | 753 break; |
3147 | 754 case 3: |
3157 | 755 checksum = seed[seed[1] % 16]; |
3147 | 756 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 757 "%c%s%s%s", checksum, name, password_hash, seed); |
3157 | 758 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 759 "%c%s%s%s", checksum, name, crypt_hash, seed); |
3157 | 760 break; |
761 case 4: | |
762 checksum = seed[seed[3] % 16]; | |
763 g_snprintf(hash_string_p, strlen(sn) + 50, | |
5583 | 764 "%c%s%s%s", checksum, password_hash, seed, name); |
3147 | 765 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 766 "%c%s%s%s", checksum, crypt_hash, seed, name); |
3157 | 767 break; |
3147 | 768 case 0: |
769 case 5: | |
3157 | 770 checksum = seed[seed[7] % 16]; |
3147 | 771 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 772 "%c%s%s%s", checksum, password_hash, name, seed); |
3157 | 773 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 774 "%c%s%s%s", checksum, crypt_hash, name, seed); |
3157 | 775 break; |
3147 | 776 } |
3157 | 777 |
3147 | 778 md5_init(&ctx); |
3157 | 779 md5_append(&ctx, hash_string_p, strlen(hash_string_p)); |
3147 | 780 md5_finish(&ctx, result); |
781 to_y64(result6, result, 16); | |
782 | |
783 md5_init(&ctx); | |
784 md5_append(&ctx, hash_string_c, strlen(hash_string_c)); | |
785 md5_finish(&ctx, result); | |
786 to_y64(result96, result, 16); | |
787 | |
788 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | |
5583 | 789 yahoo_packet_hash(pack, 0, name); |
3147 | 790 yahoo_packet_hash(pack, 6, result6); |
791 yahoo_packet_hash(pack, 96, result96); | |
5583 | 792 yahoo_packet_hash(pack, 1, name); |
3147 | 793 |
794 yahoo_send_packet(yd, pack); | |
795 | |
796 g_free(hash_string_p); | |
797 g_free(hash_string_c); | |
798 | |
799 yahoo_packet_free(pack); | |
800 } | |
801 } | |
2681 | 802 |
5583 | 803 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 804 { |
805 switch (pkt->service) | |
806 { | |
807 case YAHOO_SERVICE_LOGON: | |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
808 case YAHOO_SERVICE_LOGOFF: |
2681 | 809 case YAHOO_SERVICE_ISAWAY: |
2737
f61c1f3a6afa
[gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2724
diff
changeset
|
810 case YAHOO_SERVICE_ISBACK: |
3019 | 811 case YAHOO_SERVICE_GAMELOGON: |
812 case YAHOO_SERVICE_GAMELOGOFF: | |
6686 | 813 case YAHOO_SERVICE_CHATLOGON: |
814 case YAHOO_SERVICE_CHATLOGOFF: | |
2681 | 815 yahoo_process_status(gc, pkt); |
816 break; | |
3019 | 817 case YAHOO_SERVICE_NOTIFY: |
818 yahoo_process_notify(gc, pkt); | |
2993 | 819 break; |
2681 | 820 case YAHOO_SERVICE_MESSAGE: |
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
821 case YAHOO_SERVICE_GAMEMSG: |
5939 | 822 case YAHOO_SERVICE_CHATMSG: |
2681 | 823 yahoo_process_message(gc, pkt); |
824 break; | |
825 case YAHOO_SERVICE_NEWMAIL: | |
826 yahoo_process_mail(gc, pkt); | |
827 break; | |
828 case YAHOO_SERVICE_NEWCONTACT: | |
829 yahoo_process_contact(gc, pkt); | |
830 break; | |
831 case YAHOO_SERVICE_LIST: | |
832 yahoo_process_list(gc, pkt); | |
833 break; | |
3147 | 834 case YAHOO_SERVICE_AUTH: |
835 yahoo_process_auth(gc, pkt); | |
836 break; | |
6729 | 837 case YAHOO_SERVICE_CONFINVITE: |
838 case YAHOO_SERVICE_CONFADDINVITE: | |
839 yahoo_process_conference_invite(gc, pkt); | |
840 break; | |
841 case YAHOO_SERVICE_CONFDECLINE: | |
842 yahoo_process_conference_decline(gc, pkt); | |
843 break; | |
844 case YAHOO_SERVICE_CONFLOGON: | |
845 yahoo_process_conference_logon(gc, pkt); | |
846 break; | |
847 case YAHOO_SERVICE_CONFLOGOFF: | |
848 yahoo_process_conference_logoff(gc, pkt); | |
849 break; | |
850 case YAHOO_SERVICE_CONFMSG: | |
851 yahoo_process_conference_message(gc, pkt); | |
852 break; | |
853 case YAHOO_SERVICE_CHATONLINE: | |
854 yahoo_process_chat_online(gc, pkt); | |
855 break; | |
856 case YAHOO_SERVICE_CHATLOGOUT: | |
857 yahoo_process_chat_logout(gc, pkt); | |
858 break; | |
859 case YAHOO_SERVICE_CHATGOTO: | |
860 yahoo_process_chat_goto(gc, pkt); | |
861 break; | |
862 case YAHOO_SERVICE_CHATJOIN: | |
863 yahoo_process_chat_join(gc, pkt); | |
864 break; | |
865 case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */ | |
866 case YAHOO_SERVICE_CHATEXIT: | |
867 yahoo_process_chat_exit(gc, pkt); | |
868 break; | |
869 case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */ | |
870 case YAHOO_SERVICE_CHATADDINVITE: | |
871 yahoo_process_chat_addinvite(gc, pkt); | |
872 break; | |
873 case YAHOO_SERVICE_COMMENT: | |
874 yahoo_process_chat_message(gc, pkt); | |
875 break; | |
2681 | 876 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
877 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
878 "Unhandled service 0x%02x\n", pkt->service); |
2681 | 879 break; |
880 } | |
881 } | |
882 | |
883 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
884 { | |
5583 | 885 GaimConnection *gc = data; |
2681 | 886 struct yahoo_data *yd = gc->proto_data; |
887 char buf[1024]; | |
888 int len; | |
889 | |
890 len = read(yd->fd, buf, sizeof(buf)); | |
891 | |
892 if (len <= 0) { | |
6321 | 893 gaim_connection_error(gc, _("Unable to read")); |
2681 | 894 return; |
895 } | |
896 | |
897 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
898 memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
899 yd->rxlen += len; | |
900 | |
901 while (1) { | |
902 struct yahoo_packet *pkt; | |
903 int pos = 0; | |
904 int pktlen; | |
905 | |
906 if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
907 return; | |
908 | |
909 pos += 4; /* YMSG */ | |
910 pos += 2; | |
911 pos += 2; | |
912 | |
913 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
914 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
915 "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
2681 | 916 |
917 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
918 return; | |
919 | |
920 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
921 | |
922 pkt = yahoo_packet_new(0, 0, 0); | |
923 | |
924 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
3021 | 925 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
926 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
927 "Yahoo Service: 0x%02x Status: %d\n", |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
928 pkt->service, pkt->status); |
2681 | 929 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
930 | |
931 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
932 | |
933 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
934 if (yd->rxlen) { | |
935 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
936 g_free(yd->rxqueue); | |
937 yd->rxqueue = tmp; | |
938 } else { | |
939 g_free(yd->rxqueue); | |
940 yd->rxqueue = NULL; | |
941 } | |
942 | |
943 yahoo_packet_process(gc, pkt); | |
944 | |
945 yahoo_packet_free(pkt); | |
946 } | |
947 } | |
948 | |
949 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
950 { | |
5583 | 951 GaimConnection *gc = data; |
2681 | 952 struct yahoo_data *yd; |
953 struct yahoo_packet *pkt; | |
954 | |
5590
011a0a975060
[gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents:
5583
diff
changeset
|
955 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2681 | 956 close(source); |
957 return; | |
958 } | |
959 | |
960 if (source < 0) { | |
6321 | 961 gaim_connection_error(gc, _("Unable to connect")); |
2681 | 962 return; |
963 } | |
964 | |
965 yd = gc->proto_data; | |
966 yd->fd = source; | |
967 | |
3147 | 968 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); |
2681 | 969 |
5921 | 970 yahoo_packet_hash(pkt, 1, normalize(gaim_account_get_username(gaim_connection_get_account(gc)))); |
2681 | 971 yahoo_send_packet(yd, pkt); |
972 | |
973 yahoo_packet_free(pkt); | |
974 | |
975 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
976 } | |
977 | |
5583 | 978 static void yahoo_login(GaimAccount *account) { |
979 GaimConnection *gc = gaim_account_get_connection(account); | |
2681 | 980 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
981 | |
6629 | 982 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR; |
983 | |
5583 | 984 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
2681 | 985 |
986 yd->fd = -1; | |
987 yd->hash = g_hash_table_new(g_str_hash, g_str_equal); | |
3019 | 988 yd->games = g_hash_table_new(g_str_hash, g_str_equal); |
6729 | 989 yd->confs = NULL; |
990 yd->conf_id = 2; | |
2681 | 991 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
992 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), |
5583 | 993 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), |
994 yahoo_got_connected, gc) != 0) { | |
6321 | 995 gaim_connection_error(gc, _("Connection problem")); |
2681 | 996 return; |
997 } | |
998 | |
999 } | |
1000 | |
1001 static gboolean yahoo_destroy_hash(gpointer key, gpointer val, gpointer data) | |
1002 { | |
1003 g_free(key); | |
1004 g_free(val); | |
1005 return TRUE; | |
1006 } | |
1007 | |
5583 | 1008 static void yahoo_close(GaimConnection *gc) { |
2681 | 1009 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
1010 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); | |
1011 g_hash_table_destroy(yd->hash); | |
3019 | 1012 g_hash_table_foreach_remove(yd->games, yahoo_destroy_hash, NULL); |
1013 g_hash_table_destroy(yd->games); | |
6729 | 1014 |
1015 g_slist_free(yd->confs); | |
1016 | |
2681 | 1017 if (yd->fd >= 0) |
1018 close(yd->fd); | |
3720
34c95669952f
[gaim-migrate @ 3853]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3642
diff
changeset
|
1019 |
2681 | 1020 if (yd->rxqueue) |
1021 g_free(yd->rxqueue); | |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2686
diff
changeset
|
1022 yd->rxlen = 0; |
2681 | 1023 if (gc->inpa) |
1024 gaim_input_remove(gc->inpa); | |
1025 g_free(yd); | |
1026 } | |
1027 | |
6695 | 1028 static const char *yahoo_list_icon(GaimAccount *a, GaimBuddy *b) |
2681 | 1029 { |
4687 | 1030 return "yahoo"; |
2681 | 1031 } |
4916 | 1032 |
6695 | 1033 static void yahoo_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4916 | 1034 { |
1035 int i = 0; | |
1036 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
5068 | 1037 if (b->present == GAIM_BUDDY_OFFLINE) { |
4916 | 1038 *se = "offline"; |
1039 return; | |
1040 } else { | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1041 if (b->uc & UC_UNAVAILABLE) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1042 emblems[i++] = "away"; |
4916 | 1043 if (b->uc & YAHOO_STATUS_GAME) |
1044 emblems[i++] = "game"; | |
1045 } | |
1046 *se = emblems[0]; | |
1047 *sw = emblems[1]; | |
1048 *nw = emblems[2]; | |
1049 *ne = emblems[3]; | |
1050 } | |
2681 | 1051 |
1052 static char *yahoo_get_status_string(enum yahoo_status a) | |
1053 { | |
1054 switch (a) { | |
1055 case YAHOO_STATUS_BRB: | |
4596 | 1056 return _("Be Right Back"); |
2681 | 1057 case YAHOO_STATUS_BUSY: |
4596 | 1058 return _("Busy"); |
2681 | 1059 case YAHOO_STATUS_NOTATHOME: |
4596 | 1060 return _("Not At Home"); |
2681 | 1061 case YAHOO_STATUS_NOTATDESK: |
4596 | 1062 return _("Not At Desk"); |
2681 | 1063 case YAHOO_STATUS_NOTINOFFICE: |
4596 | 1064 return _("Not In Office"); |
2681 | 1065 case YAHOO_STATUS_ONPHONE: |
4606 | 1066 return _("On The Phone"); |
2681 | 1067 case YAHOO_STATUS_ONVACATION: |
4596 | 1068 return _("On Vacation"); |
2681 | 1069 case YAHOO_STATUS_OUTTOLUNCH: |
4596 | 1070 return _("Out To Lunch"); |
2681 | 1071 case YAHOO_STATUS_STEPPEDOUT: |
4596 | 1072 return _("Stepped Out"); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
1073 case YAHOO_STATUS_INVISIBLE: |
4596 | 1074 return _("Invisible"); |
4730 | 1075 case YAHOO_STATUS_IDLE: |
1076 return _("Idle"); | |
2879
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
1077 default: |
4596 | 1078 return _("Online"); |
2681 | 1079 } |
1080 } | |
1081 | |
6729 | 1082 static void yahoo_initiate_conference(GaimConnection *gc, const char *name) |
1083 { | |
1084 GHashTable *components; | |
1085 struct yahoo_data *yd; | |
1086 int id; | |
1087 | |
1088 yd = gc->proto_data; | |
1089 id = yd->conf_id; | |
1090 | |
1091 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
1092 g_hash_table_replace(components, g_strdup("room"), | |
1093 g_strdup_printf("%s-%d", gaim_connection_get_display_name(gc), id)); | |
1094 g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference...")); | |
1095 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | |
1096 yahoo_c_join(gc, components); | |
1097 g_hash_table_destroy(components); | |
1098 | |
1099 yahoo_c_invite(gc, id, "Join my conference...", name); | |
1100 } | |
1101 | |
5583 | 1102 static void yahoo_game(GaimConnection *gc, const char *name) { |
3019 | 1103 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
1104 char *game = g_hash_table_lookup(yd->games, name); | |
1105 char *t; | |
1106 char url[256]; | |
1107 | |
1108 if (!game) | |
1109 return; | |
1110 t = game = g_strdup(strstr(game, "ante?room=")); | |
1111 while (*t != '\t') | |
1112 t++; | |
1113 *t = 0; | |
1114 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
|
1115 gaim_notify_uri(gc, url); |
3019 | 1116 g_free(game); |
1117 } | |
4722 | 1118 |
6695 | 1119 static char *yahoo_status_text(GaimBuddy *b) |
4722 | 1120 { |
1121 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data; | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1122 |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1123 if ((b->uc & UC_UNAVAILABLE) && ((b->uc >> 2) != YAHOO_STATUS_CUSTOM) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1124 && ((b->uc >> 2) != YAHOO_STATUS_IDLE)) |
4732 | 1125 return g_strdup(yahoo_get_status_string(b->uc >> 2)); |
6686 | 1126 else if ((b->uc >> 2) == YAHOO_STATUS_CUSTOM) { |
1127 char *stripped = strip_html(g_hash_table_lookup(yd->hash, b->name)); | |
1128 if(stripped) { | |
1129 char *ret = g_markup_escape_text(stripped, strlen(stripped)); | |
1130 g_free(stripped); | |
1131 return ret; | |
4777 | 1132 } |
4722 | 1133 } |
4729 | 1134 return NULL; |
4722 | 1135 } |
1136 | |
6695 | 1137 static char *yahoo_tooltip_text(GaimBuddy *b) |
4724 | 1138 { |
1139 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data; | |
6686 | 1140 if ((b->uc & UC_UNAVAILABLE) || ((b->uc >> 2) == YAHOO_STATUS_CUSTOM)) { |
4745 | 1141 char *status; |
1142 char *ret; | |
4731 | 1143 if ((b->uc >> 2) != YAHOO_STATUS_CUSTOM) |
4745 | 1144 status = g_strdup(yahoo_get_status_string(b->uc >> 2)); |
4724 | 1145 else |
4745 | 1146 status = strip_html(g_hash_table_lookup(yd->hash, b->name)); |
1147 if(status) { | |
4777 | 1148 char *escaped = g_markup_escape_text(status, strlen(status)); |
1149 ret = g_strdup_printf(_("<b>Status:</b> %s"), escaped); | |
4745 | 1150 g_free(status); |
4777 | 1151 g_free(escaped); |
4745 | 1152 return ret; |
1153 } | |
4724 | 1154 } |
4729 | 1155 return NULL; |
1156 } | |
1157 | |
5583 | 1158 static GList *yahoo_buddy_menu(GaimConnection *gc, const char *who) |
2681 | 1159 { |
1160 GList *m = NULL; | |
1161 struct proto_buddy_menu *pbm; | |
1162 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
6695 | 1163 GaimBuddy *b = gaim_find_buddy(gc->account, who); /* this should never be null. if it is, |
2681 | 1164 segfault and get the bug report. */ |
3019 | 1165 static char buf2[1024]; |
4722 | 1166 |
6729 | 1167 pbm = g_new0(struct proto_buddy_menu, 1); |
1168 pbm->label = _("Join in Chat"); | |
1169 pbm->callback = yahoo_chat_goto; | |
1170 pbm->gc = gc; | |
1171 m = g_list_append(m, pbm); | |
1172 | |
1173 pbm = g_new0(struct proto_buddy_menu, 1); | |
1174 pbm->label = _("Initiate Conference"); | |
1175 pbm->callback = yahoo_initiate_conference; | |
1176 pbm->gc = gc; | |
1177 m = g_list_append(m, pbm); | |
1178 | |
3019 | 1179 if (b->uc | YAHOO_STATUS_GAME) { |
1180 char *game = g_hash_table_lookup(yd->games, b->name); | |
1181 char *room; | |
1182 if (!game) | |
1183 return m; | |
1184 if (game) { | |
1185 char *t; | |
1186 pbm = g_new0(struct proto_buddy_menu, 1); | |
1187 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ | |
6729 | 1188 return m; |
3019 | 1189 while (*room && *room != '\t') /* skip to the tab */ |
1190 room++; | |
1191 t = room++; /* room as now at the name */ | |
6729 | 1192 while (*t != '\n') |
3019 | 1193 t++; /* replace the \n with a space */ |
1194 *t = ' '; | |
1195 g_snprintf(buf2, sizeof buf2, "%s", room); | |
1196 pbm->label = buf2; | |
1197 pbm->callback = yahoo_game; | |
1198 pbm->gc = gc; | |
1199 m = g_list_append(m, pbm); | |
1200 } | |
1201 } | |
6729 | 1202 |
2681 | 1203 return m; |
1204 } | |
1205 | |
5583 | 1206 static void yahoo_act_id(GaimConnection *gc, const char *entry) |
2681 | 1207 { |
1208 struct yahoo_data *yd = gc->proto_data; | |
1209 | |
1210 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
1211 yahoo_packet_hash(pkt, 3, entry); | |
1212 yahoo_send_packet(yd, pkt); | |
1213 yahoo_packet_free(pkt); | |
1214 | |
5583 | 1215 gaim_connection_set_display_name(gc, entry); |
2681 | 1216 } |
1217 | |
5583 | 1218 static void yahoo_show_act_id(GaimConnection *gc) |
2681 | 1219 { |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1220 gaim_request_input(gc, NULL, _("Active which ID?"), NULL, |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
5939
diff
changeset
|
1221 gaim_connection_get_display_name(gc), FALSE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1222 _("OK"), G_CALLBACK(yahoo_act_id), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1223 _("Cancel"), NULL, gc); |
2681 | 1224 } |
1225 | |
5583 | 1226 static GList *yahoo_actions(GaimConnection *gc) { |
2681 | 1227 GList *m = NULL; |
4333 | 1228 struct proto_actions_menu *pam; |
2681 | 1229 |
4333 | 1230 pam = g_new0(struct proto_actions_menu, 1); |
1231 pam->label = _("Activate ID"); | |
1232 pam->callback = yahoo_show_act_id; | |
1233 pam->gc = gc; | |
1234 m = g_list_append(m, pam); | |
2681 | 1235 |
1236 return m; | |
1237 } | |
1238 | |
6622 | 1239 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, int len, GaimImFlags flags) |
2681 | 1240 { |
1241 struct yahoo_data *yd = gc->proto_data; | |
1242 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
6629 | 1243 char *msg = yahoo_html_to_codes(what); |
2681 | 1244 |
5583 | 1245 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1246 yahoo_packet_hash(pkt, 5, who); |
3493 | 1247 yahoo_packet_hash(pkt, 14, msg); |
6044 | 1248 yahoo_packet_hash(pkt, 97, "1"); |
2681 | 1249 |
1250 yahoo_send_packet(yd, pkt); | |
1251 | |
1252 yahoo_packet_free(pkt); | |
6629 | 1253 |
1254 g_free(msg); | |
1255 | |
2681 | 1256 return 1; |
1257 } | |
1258 | |
6059 | 1259 int yahoo_send_typing(GaimConnection *gc, const char *who, int typ) |
2993 | 1260 { |
1261 struct yahoo_data *yd = gc->proto_data; | |
3019 | 1262 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
2993 | 1263 yahoo_packet_hash(pkt, 49, "TYPING"); |
5583 | 1264 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2993 | 1265 yahoo_packet_hash(pkt, 14, " "); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
1266 yahoo_packet_hash(pkt, 13, typ == GAIM_TYPING ? "1" : "0"); |
2993 | 1267 yahoo_packet_hash(pkt, 5, who); |
1268 yahoo_packet_hash(pkt, 1002, "1"); | |
1269 | |
1270 yahoo_send_packet(yd, pkt); | |
1271 | |
1272 yahoo_packet_free(pkt); | |
1273 | |
3001 | 1274 return 0; |
2993 | 1275 } |
1276 | |
6059 | 1277 static void yahoo_set_away(GaimConnection *gc, const char *state, const char *msg) |
2681 | 1278 { |
1279 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1280 struct yahoo_packet *pkt; | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1281 int service; |
2681 | 1282 char s[4]; |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1283 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1284 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1285 g_free(gc->away); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1286 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1287 } |
2681 | 1288 |
1289 if (msg) { | |
1290 yd->current_status = YAHOO_STATUS_CUSTOM; | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1291 gc->away = g_strdup(msg); |
2681 | 1292 } else if (state) { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1293 gc->away = g_strdup(""); |
4596 | 1294 if (!strcmp(state, _("Available"))) { |
2681 | 1295 yd->current_status = YAHOO_STATUS_AVAILABLE; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1296 g_free(gc->away); |
2681 | 1297 gc->away = NULL; |
4596 | 1298 } else if (!strcmp(state, _("Be Right Back"))) { |
2681 | 1299 yd->current_status = YAHOO_STATUS_BRB; |
4596 | 1300 } else if (!strcmp(state, _("Busy"))) { |
2681 | 1301 yd->current_status = YAHOO_STATUS_BUSY; |
4596 | 1302 } else if (!strcmp(state, _("Not At Home"))) { |
2681 | 1303 yd->current_status = YAHOO_STATUS_NOTATHOME; |
4596 | 1304 } else if (!strcmp(state, _("Not At Desk"))) { |
2681 | 1305 yd->current_status = YAHOO_STATUS_NOTATDESK; |
4596 | 1306 } else if (!strcmp(state, _("Not In Office"))) { |
2681 | 1307 yd->current_status = YAHOO_STATUS_NOTINOFFICE; |
4606 | 1308 } else if (!strcmp(state, _("On The Phone"))) { |
2681 | 1309 yd->current_status = YAHOO_STATUS_ONPHONE; |
4596 | 1310 } else if (!strcmp(state, _("On Vacation"))) { |
2681 | 1311 yd->current_status = YAHOO_STATUS_ONVACATION; |
4596 | 1312 } else if (!strcmp(state, _("Out To Lunch"))) { |
2681 | 1313 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; |
4596 | 1314 } else if (!strcmp(state, _("Stepped Out"))) { |
2681 | 1315 yd->current_status = YAHOO_STATUS_STEPPEDOUT; |
4596 | 1316 } else if (!strcmp(state, _("Invisible"))) { |
2681 | 1317 yd->current_status = YAHOO_STATUS_INVISIBLE; |
1318 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { | |
1319 if (gc->is_idle) { | |
1320 yd->current_status = YAHOO_STATUS_IDLE; | |
1321 } else { | |
1322 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1323 } | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1324 g_free(gc->away); |
2681 | 1325 gc->away = NULL; |
1326 } | |
1327 } else if (gc->is_idle) { | |
1328 yd->current_status = YAHOO_STATUS_IDLE; | |
1329 } else { | |
1330 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1331 } | |
1332 | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1333 if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1334 service = YAHOO_SERVICE_ISBACK; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1335 else |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1336 service = YAHOO_SERVICE_ISAWAY; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1337 pkt = yahoo_packet_new(service, yd->current_status, 0); |
2681 | 1338 g_snprintf(s, sizeof(s), "%d", yd->current_status); |
1339 yahoo_packet_hash(pkt, 10, s); | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1340 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1341 yahoo_packet_hash(pkt, 47, "1"); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1342 yahoo_packet_hash(pkt, 19, msg); |
6686 | 1343 } |
2681 | 1344 |
1345 yahoo_send_packet(yd, pkt); | |
1346 yahoo_packet_free(pkt); | |
1347 } | |
1348 | |
5583 | 1349 static void yahoo_set_idle(GaimConnection *gc, int idle) |
2681 | 1350 { |
1351 struct yahoo_data *yd = gc->proto_data; | |
1352 struct yahoo_packet *pkt = NULL; | |
1353 | |
1354 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
1355 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0); | |
1356 yd->current_status = YAHOO_STATUS_IDLE; | |
1357 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
1358 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
1359 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1360 } | |
1361 | |
1362 if (pkt) { | |
1363 char buf[4]; | |
1364 g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
1365 yahoo_packet_hash(pkt, 10, buf); | |
1366 yahoo_send_packet(yd, pkt); | |
1367 yahoo_packet_free(pkt); | |
1368 } | |
1369 } | |
1370 | |
5583 | 1371 static GList *yahoo_away_states(GaimConnection *gc) |
2681 | 1372 { |
1373 GList *m = NULL; | |
1374 | |
4596 | 1375 m = g_list_append(m, _("Available")); |
1376 m = g_list_append(m, _("Be Right Back")); | |
1377 m = g_list_append(m, _("Busy")); | |
1378 m = g_list_append(m, _("Not At Home")); | |
1379 m = g_list_append(m, _("Not At Desk")); | |
1380 m = g_list_append(m, _("Not In Office")); | |
4606 | 1381 m = g_list_append(m, _("On The Phone")); |
4596 | 1382 m = g_list_append(m, _("On Vacation")); |
1383 m = g_list_append(m, _("Out To Lunch")); | |
1384 m = g_list_append(m, _("Stepped Out")); | |
1385 m = g_list_append(m, _("Invisible")); | |
2681 | 1386 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
1387 | |
1388 return m; | |
1389 } | |
1390 | |
5583 | 1391 static void yahoo_keepalive(GaimConnection *gc) |
2681 | 1392 { |
1393 struct yahoo_data *yd = gc->proto_data; | |
1394 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
1395 yahoo_send_packet(yd, pkt); | |
1396 yahoo_packet_free(pkt); | |
6729 | 1397 |
1398 if (!yd->chat_online) | |
1399 return; | |
1400 | |
1401 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); | |
1402 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); | |
1403 yahoo_send_packet(yd, pkt); | |
1404 yahoo_packet_free(pkt); | |
2681 | 1405 } |
1406 | |
5583 | 1407 static void yahoo_add_buddy(GaimConnection *gc, const char *who) |
2681 | 1408 { |
1409 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1410 struct yahoo_packet *pkt; | |
6695 | 1411 GaimGroup *g; |
2681 | 1412 char *group = NULL; |
1413 | |
1414 if (!yd->logged_in) | |
1415 return; | |
1416 | |
4687 | 1417 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, who)); |
2681 | 1418 if (g) |
1419 group = g->name; | |
1420 else | |
1421 group = "Buddies"; | |
1422 | |
1423 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
5583 | 1424 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1425 yahoo_packet_hash(pkt, 7, who); |
1426 yahoo_packet_hash(pkt, 65, group); | |
1427 yahoo_send_packet(yd, pkt); | |
1428 yahoo_packet_free(pkt); | |
1429 } | |
1430 | |
6059 | 1431 static void yahoo_remove_buddy(GaimConnection *gc, const char *who, const char *group) |
2681 | 1432 { |
1433 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1434 | |
1435 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
5583 | 1436 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1437 yahoo_packet_hash(pkt, 7, who); |
1438 yahoo_packet_hash(pkt, 65, group); | |
1439 yahoo_send_packet(yd, pkt); | |
1440 yahoo_packet_free(pkt); | |
1441 } | |
1442 | |
6513 | 1443 static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
1444 { | |
1445 yahoo_dest_colorht(); | |
1446 return TRUE; | |
1447 } | |
1448 | |
6514 | 1449 static void yahoo_got_info(gpointer data, char *url_text, unsigned long len) |
1450 { | |
1451 char *stripped,*p; | |
1452 char buf[1024]; | |
1453 | |
1454 /* we failed to grab the profile URL */ | |
1455 if (!url_text) { | |
1456 g_show_info_text(NULL, NULL, 2, | |
6573 | 1457 _("<html><body><b>Error retrieving profile</b></body></html>"), NULL); |
6514 | 1458 return; |
1459 } | |
1460 | |
1461 /* we don't yet support the multiple link level of the warning page for | |
1462 * 'adult' profiles, not to mention the fact that yahoo wants you to be | |
1463 * logged in (on the website) to be able to view an 'adult' profile. for | |
1464 * now, just tell them that we can't help them, and provide a link to the | |
1465 * profile if they want to do the web browser thing. | |
1466 */ | |
1467 p = strstr(url_text, "Adult Profiles Warning Message"); | |
1468 if (p) { | |
6573 | 1469 strcpy(buf, _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n")); |
6514 | 1470 info_extract_field(url_text, buf, ".idname=", 0, "%26", 0, NULL, |
6573 | 1471 _("If you wish to view this profile, you will need to visit this link in your web browser"), |
6514 | 1472 1, YAHOO_PROFILE_URL); |
1473 strcat(buf, "</body></html>\n"); | |
1474 g_show_info_text(NULL, NULL, 2, buf, NULL); | |
1475 return; | |
1476 } | |
1477 | |
6630 | 1478 /* at the moment we don't support profile pages with languages other than |
1479 * english. the problem is, that every user may choose his/her own profile | |
1480 * language. this language has nothing to do with the preferences of the | |
1481 * user which looks at the profile | |
1482 */ | |
1483 p = strstr(url_text, "Last Updated:"); | |
1484 if (!p) { | |
1485 strcpy(buf, _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n")); | |
1486 info_extract_field(url_text, buf, "<title>", 0, "'s Yahoo! Profile", 0, NULL, | |
1487 _("If you wish to view this profile, you will need to visit this link in your web browser"), | |
1488 1, YAHOO_PROFILE_URL); | |
1489 strcat(buf, "</body></html>\n"); | |
1490 g_show_info_text(NULL, NULL, 2, buf, NULL); | |
1491 return; | |
1492 } | |
1493 | |
6514 | 1494 /* strip_html() doesn't strip out character entities like and · |
1495 */ | |
1496 while ((p = strstr(url_text, " ")) != NULL) { | |
1497 memmove(p, p + 6, strlen(p + 6)); | |
1498 url_text[strlen(url_text) - 6] = '\0'; | |
1499 } | |
1500 while ((p = strstr(url_text, "·")) != NULL) { | |
1501 memmove(p, p + 6, strlen(p + 6)); | |
1502 url_text[strlen(url_text) - 6] = '\0'; | |
1503 } | |
1504 | |
1505 /* nuke the nasty \r's */ | |
1506 while ((p = strchr(url_text, '\r')) != NULL) { | |
1507 memmove(p, p + 1, strlen(p + 1)); | |
1508 url_text[strlen(url_text) - 1] = '\0'; | |
1509 } | |
1510 | |
1511 /* nuke the html, it's easier than trying to parse the horrid stuff */ | |
1512 stripped = strip_html(url_text); | |
1513 | |
1514 /* gonna re-use the memory we've already got for url_text */ | |
1515 strcpy(url_text, "<html><body>\n"); | |
1516 | |
1517 /* extract their Yahoo! ID and put it in */ | |
1518 info_extract_field(stripped, url_text, "Yahoo! ID:", 2, "\n", 0, | |
6573 | 1519 NULL, _("Yahoo! ID"), 0, NULL); |
6514 | 1520 |
1521 /* extract their Email address and put it in */ | |
1522 info_extract_field(stripped, url_text, "My Email", 5, "\n", 0, | |
6657 | 1523 "Private", _("Email"), 0, NULL); |
6514 | 1524 |
1525 /* extract the Nickname if it exists */ | |
1526 info_extract_field(stripped, url_text, "Nickname:", 1, "\n", '\n', | |
6573 | 1527 NULL, _("Nickname"), 0, NULL); |
6514 | 1528 |
1529 /* extract their RealName and put it in */ | |
1530 info_extract_field(stripped, url_text, "RealName:", 1, "\n", '\n', | |
6623 | 1531 NULL, _("Realname"), 0, NULL); |
6514 | 1532 |
1533 /* extract their Location and put it in */ | |
1534 info_extract_field(stripped, url_text, "Location:", 2, "\n", '\n', | |
6573 | 1535 NULL, _("Location"), 0, NULL); |
6514 | 1536 |
1537 /* extract their Age and put it in */ | |
1538 info_extract_field(stripped, url_text, "Age:", 3, "\n", '\n', | |
6573 | 1539 NULL, _("Age"), 0, NULL); |
6514 | 1540 |
1541 /* extract their MaritalStatus and put it in */ | |
1542 info_extract_field(stripped, url_text, "MaritalStatus:", 3, "\n", '\n', | |
6657 | 1543 "No Answer", _("Marital Status"), 0, NULL); |
6514 | 1544 |
1545 /* extract their Gender and put it in */ | |
1546 info_extract_field(stripped, url_text, "Gender:", 3, "\n", '\n', | |
6657 | 1547 "No Answer", _("Gender"), 0, NULL); |
6514 | 1548 |
1549 /* extract their Occupation and put it in */ | |
1550 info_extract_field(stripped, url_text, "Occupation:", 2, "\n", '\n', | |
6573 | 1551 NULL, _("Occupation"), 0, NULL); |
6514 | 1552 |
1553 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the | |
1554 * values can contain embedded newlines... but any or all of them can also | |
1555 * not appear. The way we delimit them is to successively look for the next | |
1556 * one that _could_ appear, and if all else fails, we end the section by | |
1557 * looking for the 'Links' heading, which is the next thing to follow this | |
1558 * bunch. | |
1559 */ | |
1560 if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Latest News", | |
6573 | 1561 '\n', NULL, _("Hobbies"), 0, NULL)) |
6514 | 1562 if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Favorite Quote", |
6573 | 1563 '\n', NULL, _("Hobbies"), 0, NULL)) |
6514 | 1564 info_extract_field(stripped, url_text, "Hobbies:", 1, "Links", |
6573 | 1565 '\n', NULL, _("Hobbies"), 0, NULL); |
6514 | 1566 if (!info_extract_field(stripped, url_text, "Latest News:", 1, "Favorite Quote", |
6573 | 1567 '\n', NULL, _("Latest News"), 0, NULL)) |
6514 | 1568 info_extract_field(stripped, url_text, "Latest News:", 1, "Links", |
6573 | 1569 '\n', NULL, _("Latest News"), 0, NULL); |
6514 | 1570 info_extract_field(stripped, url_text, "Favorite Quote:", 0, "Links", |
6573 | 1571 '\n', NULL, _("Favorite Quote"), 0, NULL); |
6514 | 1572 |
1573 /* Home Page will either be "No home page specified", | |
1574 * or "Home Page: " and a link. */ | |
1575 p = strstr(stripped, "No home page specified"); | |
1576 if (!p) | |
1577 info_extract_field(stripped, url_text, "Home Page:", 1, " ", 0, NULL, | |
6573 | 1578 _("Home Page"), 1, NULL); |
6514 | 1579 |
1580 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, | |
1581 * then we have none. If we have one however, we'll need to check and see if | |
1582 * we have a second one. If we have a second one, we have to check to see if | |
1583 * we have a third one. | |
1584 */ | |
1585 p = strstr(stripped,"No cool link specified"); | |
1586 if (!p) | |
1587 if (info_extract_field(stripped, url_text, "Cool Link 1:", 1, " ", 0, NULL, | |
6573 | 1588 _("Cool Link 1"), 1, NULL)) |
6514 | 1589 if (info_extract_field(stripped, url_text, "Cool Link 2:", 1, " ", 0, NULL, |
6573 | 1590 _("Cool Link 2"), 1, NULL)) |
6514 | 1591 info_extract_field(stripped, url_text, "Cool Link 3:", 1, " ", 0, NULL, |
6573 | 1592 _("Cool Link 3"), 1, NULL); |
6514 | 1593 |
1594 /* see if Member Since is there, and if so, extract it. */ | |
1595 info_extract_field(stripped, url_text, "Member Since:", 1, "Last Updated:", | |
6573 | 1596 '\n', NULL, _("Member Since"), 0, NULL); |
6514 | 1597 |
1598 /* extract the Last Updated date and put it in */ | |
1599 info_extract_field(stripped, url_text, "Last Updated:", 1, "\n", '\n', NULL, | |
6573 | 1600 _("Last Updated"), 0, NULL); |
6514 | 1601 |
1602 /* finish off the html */ | |
1603 strcat(url_text, "</body></html>\n"); | |
1604 g_free(stripped); | |
1605 | |
1606 /* show it to the user */ | |
1607 g_show_info_text(NULL, NULL, 2, url_text, NULL); | |
1608 } | |
1609 | |
1610 static void yahoo_get_info(GaimConnection *gc, const char *name) | |
1611 { | |
1612 /* struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; */ | |
1613 char url[256]; | |
1614 g_snprintf(url, sizeof url, "%s%s", YAHOO_PROFILE_URL, name); | |
6516 | 1615 grab_url(url, FALSE, yahoo_got_info, NULL, NULL, 0); |
6514 | 1616 } |
1617 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1618 static GaimPlugin *my_protocol = NULL; |
2681 | 1619 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1620 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1621 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1622 GAIM_PROTO_YAHOO, |
6729 | 1623 OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, |
1624 NULL, /* user_splits */ | |
1625 NULL, /* protocol_options */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1626 yahoo_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1627 yahoo_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1628 yahoo_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1629 yahoo_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1630 yahoo_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1631 yahoo_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1632 yahoo_buddy_menu, |
6729 | 1633 yahoo_c_info, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1634 yahoo_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1635 yahoo_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1636 yahoo_send_im, |
6729 | 1637 NULL, /* set info */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1638 yahoo_send_typing, |
6514 | 1639 yahoo_get_info, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1640 yahoo_set_away, |
6729 | 1641 NULL, /* get_away */ |
1642 NULL, /* set_dir */ | |
1643 NULL, /* get_dir */ | |
1644 NULL, /* dir_search */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1645 yahoo_set_idle, |
6729 | 1646 NULL, /* change_passwd*/ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1647 yahoo_add_buddy, |
6729 | 1648 NULL, /* add_buddies */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1649 yahoo_remove_buddy, |
6729 | 1650 NULL, /*remove_buddies */ |
1651 NULL, /* add_permit */ | |
1652 NULL, /* add_dey */ | |
1653 NULL, /* rem_permit */ | |
1654 NULL, /* rem_deny */ | |
1655 NULL, /* set_permit_deny */ | |
1656 NULL, /* warn */ | |
1657 yahoo_c_join, | |
1658 yahoo_c_invite, | |
1659 yahoo_c_leave, | |
1660 NULL, /* chat whisper */ | |
1661 yahoo_c_send, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1662 yahoo_keepalive, |
6729 | 1663 NULL, /* register_user */ |
1664 NULL, /* get_cb_info */ | |
1665 NULL, /* get_cb_away */ | |
1666 NULL, /* alias_buddy */ | |
1667 NULL, /* change group */ | |
1668 NULL, /* rename group */ | |
1669 NULL, /* buddy_free */ | |
1670 NULL, /* convo_closed */ | |
1671 NULL, /* normalize */ | |
1672 NULL /* set_buddy_icon */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1673 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1674 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1675 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1676 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1677 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1678 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1679 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1680 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1681 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1682 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1683 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1684 "prpl-yahoo", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1685 "Yahoo", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1686 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1687 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1688 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1689 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1690 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1691 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
1692 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1693 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1694 NULL, /**< load */ |
6513 | 1695 yahoo_unload_plugin, /**< unload */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1696 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1697 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1698 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1699 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1700 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1701 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1702 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1703 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1704 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1705 GaimAccountOption *option; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1706 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1707 option = gaim_account_option_string_new(_("Pager host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1708 YAHOO_PAGER_HOST); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1709 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1710 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1711 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1712 option = gaim_account_option_int_new(_("Pager port"), "port", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1713 YAHOO_PAGER_PORT); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1714 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1715 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1716 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1717 my_protocol = plugin; |
6513 | 1718 |
1719 yahoo_init_colorht(); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1720 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1721 |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1722 GAIM_INIT_PLUGIN(yahoo, init_plugin, info); |