Mercurial > pidgin
annotate src/protocols/yahoo/yahoo.c @ 3033:1143524a2eaf
[gaim-migrate @ 3046]
Laying the ground work for image send. Also an IRC fix.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Tue, 12 Mar 2002 17:21:46 +0000 |
parents | 18f0e61a6caf |
children | 0f1766887ddd |
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 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include "config.h" | |
25 #endif | |
26 | |
27 | |
28 #include <netdb.h> | |
29 #include <unistd.h> | |
30 #include <errno.h> | |
31 #include <netinet/in.h> | |
32 #include <arpa/inet.h> | |
33 #include <string.h> | |
34 #include <stdlib.h> | |
35 #include <stdio.h> | |
36 #include <time.h> | |
37 #include <sys/socket.h> | |
38 #include <sys/stat.h> | |
39 #include <ctype.h> | |
40 #include "multi.h" | |
41 #include "prpl.h" | |
42 #include "gaim.h" | |
43 #include "proxy.h" | |
44 | |
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
45 extern char *yahoo_crypt(char *, char *); |
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
46 |
2681 | 47 #include "pixmaps/status-away.xpm" |
48 #include "pixmaps/status-here.xpm" | |
49 #include "pixmaps/status-idle.xpm" | |
3019 | 50 #include "pixmaps/status-game.xpm" |
2681 | 51 |
2993 | 52 #define YAHOO_DEBUG |
2681 | 53 |
54 #define USEROPT_MAIL 0 | |
55 | |
56 #define USEROPT_PAGERHOST 3 | |
2951 | 57 #define YAHOO_PAGER_HOST "cs.yahoo.com" |
2681 | 58 #define USEROPT_PAGERPORT 4 |
59 #define YAHOO_PAGER_PORT 5050 | |
60 | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
61 enum yahoo_service { /* these are easier to see in hex */ |
2681 | 62 YAHOO_SERVICE_LOGON = 1, |
63 YAHOO_SERVICE_LOGOFF, | |
64 YAHOO_SERVICE_ISAWAY, | |
65 YAHOO_SERVICE_ISBACK, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
66 YAHOO_SERVICE_IDLE, /* 5 (placemarker) */ |
2681 | 67 YAHOO_SERVICE_MESSAGE, |
68 YAHOO_SERVICE_IDACT, | |
69 YAHOO_SERVICE_IDDEACT, | |
70 YAHOO_SERVICE_MAILSTAT, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
71 YAHOO_SERVICE_USERSTAT, /* 0xa */ |
2681 | 72 YAHOO_SERVICE_NEWMAIL, |
73 YAHOO_SERVICE_CHATINVITE, | |
74 YAHOO_SERVICE_CALENDAR, | |
75 YAHOO_SERVICE_NEWPERSONALMAIL, | |
76 YAHOO_SERVICE_NEWCONTACT, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
77 YAHOO_SERVICE_ADDIDENT, /* 0x10 */ |
2681 | 78 YAHOO_SERVICE_ADDIGNORE, |
79 YAHOO_SERVICE_PING, | |
80 YAHOO_SERVICE_GROUPRENAME, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
81 YAHOO_SERVICE_SYSMESSAGE = 0x14, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
82 YAHOO_SERVICE_PASSTHROUGH2 = 0x16, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
83 YAHOO_SERVICE_CONFINVITE = 0x18, |
2681 | 84 YAHOO_SERVICE_CONFLOGON, |
85 YAHOO_SERVICE_CONFDECLINE, | |
86 YAHOO_SERVICE_CONFLOGOFF, | |
87 YAHOO_SERVICE_CONFADDINVITE, | |
88 YAHOO_SERVICE_CONFMSG, | |
89 YAHOO_SERVICE_CHATLOGON, | |
90 YAHOO_SERVICE_CHATLOGOFF, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
91 YAHOO_SERVICE_CHATMSG = 0x20, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
92 YAHOO_SERVICE_GAMELOGON = 0x28, |
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
93 YAHOO_SERVICE_GAMELOGOFF, |
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
94 YAHOO_SERVICE_GAMEMSG = 0x2a, |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
95 YAHOO_SERVICE_FILETRANSFER = 0x46, |
3019 | 96 YAHOO_SERVICE_NOTIFY = 0x4B, |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
97 YAHOO_SERVICE_LIST = 0x55, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
98 YAHOO_SERVICE_ADDBUDDY = 0x83, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
99 YAHOO_SERVICE_REMBUDDY = 0x84 |
2681 | 100 }; |
101 | |
102 enum yahoo_status { | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
103 YAHOO_STATUS_AVAILABLE = 0, |
2681 | 104 YAHOO_STATUS_BRB, |
105 YAHOO_STATUS_BUSY, | |
106 YAHOO_STATUS_NOTATHOME, | |
107 YAHOO_STATUS_NOTATDESK, | |
108 YAHOO_STATUS_NOTINOFFICE, | |
109 YAHOO_STATUS_ONPHONE, | |
110 YAHOO_STATUS_ONVACATION, | |
111 YAHOO_STATUS_OUTTOLUNCH, | |
112 YAHOO_STATUS_STEPPEDOUT, | |
113 YAHOO_STATUS_INVISIBLE = 12, | |
114 YAHOO_STATUS_CUSTOM = 99, | |
115 YAHOO_STATUS_IDLE = 999, | |
2993 | 116 YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */ |
117 YAHOO_STATUS_TYPING = 0x16 | |
2681 | 118 }; |
3019 | 119 #define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */ |
2681 | 120 |
121 struct yahoo_data { | |
122 int fd; | |
123 guchar *rxqueue; | |
124 int rxlen; | |
125 GHashTable *hash; | |
3019 | 126 GHashTable *games; |
2681 | 127 int current_status; |
128 gboolean logged_in; | |
129 }; | |
130 | |
131 struct yahoo_pair { | |
132 int key; | |
133 char *value; | |
134 }; | |
135 | |
136 struct yahoo_packet { | |
137 guint16 service; | |
138 guint32 status; | |
139 guint32 id; | |
140 GSList *hash; | |
141 }; | |
142 | |
143 static char *yahoo_name() { | |
144 return "Yahoo"; | |
145 } | |
146 | |
147 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) | |
148 | |
149 static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) | |
150 { | |
151 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); | |
152 | |
153 pkt->service = service; | |
154 pkt->status = status; | |
155 pkt->id = id; | |
156 | |
157 return pkt; | |
158 } | |
159 | |
160 static void yahoo_packet_hash(struct yahoo_packet *pkt, int key, char *value) | |
161 { | |
162 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
163 pair->key = key; | |
164 pair->value = g_strdup(value); | |
165 pkt->hash = g_slist_append(pkt->hash, pair); | |
166 } | |
167 | |
168 static int yahoo_packet_length(struct yahoo_packet *pkt) | |
169 { | |
170 GSList *l; | |
171 | |
172 int len = 0; | |
173 | |
174 l = pkt->hash; | |
175 while (l) { | |
176 struct yahoo_pair *pair = l->data; | |
177 int tmp = pair->key; | |
178 do { | |
179 tmp /= 10; | |
180 len++; | |
181 } while (tmp); | |
182 len += 2; | |
183 len += strlen(pair->value); | |
184 len += 2; | |
185 l = l->next; | |
186 } | |
187 | |
188 return len; | |
189 } | |
190 | |
191 /* sometimes i wish prpls could #include things from other prpls. then i could just | |
192 * use the routines from libfaim and not have to admit to knowing how they work. */ | |
193 #define yahoo_put16(buf, data) ( \ | |
194 (*(buf) = (u_char)((data)>>8)&0xff), \ | |
195 (*((buf)+1) = (u_char)(data)&0xff), \ | |
196 2) | |
197 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
198 #define yahoo_put32(buf, data) ( \ | |
199 (*((buf)) = (u_char)((data)>>24)&0xff), \ | |
200 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ | |
201 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ | |
202 (*((buf)+3) = (u_char)(data)&0xff), \ | |
203 4) | |
204 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
205 (((*((buf)+1))<<16)&0x00ff0000) + \ | |
206 (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
207 (((*((buf)+3) )&0x000000ff))) | |
208 | |
209 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) | |
210 { | |
211 int pos = 0; | |
212 | |
213 while (pos + 1 < len) { | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
214 char key[64], *value = NULL; |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
215 int accept; |
2681 | 216 int x; |
217 | |
218 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
219 | |
220 x = 0; | |
221 while (pos + 1 < len) { | |
222 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
223 break; | |
224 key[x++] = data[pos++]; | |
225 } | |
226 key[x] = 0; | |
227 pos += 2; | |
228 pair->key = strtol(key, NULL, 10); | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
229 accept = x; /* if x is 0 there was no key, so don't accept it */ |
2681 | 230 |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
231 if (accept) |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
232 value = g_malloc(len - pos + 1); |
2681 | 233 x = 0; |
234 while (pos + 1 < len) { | |
235 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
236 break; | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
237 if (accept) |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
238 value[x++] = data[pos++]; |
2681 | 239 } |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
240 if (accept) |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
241 value[x] = 0; |
2681 | 242 pos += 2; |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
243 if (accept) { |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
244 pair->value = g_strdup(value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
245 g_free(value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
246 pkt->hash = g_slist_append(pkt->hash, pair); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
247 debug_printf("Key: %d \tValue: %s\n", pair->key, pair->value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
248 } else { |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
249 g_free(pair); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
250 } |
2681 | 251 } |
252 } | |
253 | |
254 static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) | |
255 { | |
256 GSList *l = pkt->hash; | |
257 int pos = 0; | |
258 | |
259 while (l) { | |
260 struct yahoo_pair *pair = l->data; | |
261 guchar buf[100]; | |
262 | |
263 g_snprintf(buf, sizeof(buf), "%d", pair->key); | |
264 strcpy(data + pos, buf); | |
265 pos += strlen(buf); | |
266 data[pos++] = 0xc0; | |
267 data[pos++] = 0x80; | |
268 | |
269 strcpy(data + pos, pair->value); | |
270 pos += strlen(pair->value); | |
271 data[pos++] = 0xc0; | |
272 data[pos++] = 0x80; | |
273 | |
274 l = l->next; | |
275 } | |
276 } | |
277 | |
278 static void yahoo_packet_dump(guchar *data, int len) | |
279 { | |
280 #ifdef YAHOO_DEBUG | |
281 int i; | |
282 for (i = 0; i + 1 < len; i += 2) { | |
283 if ((i % 16 == 0) && i) | |
284 debug_printf("\n"); | |
285 debug_printf("%02x", data[i]); | |
286 debug_printf("%02x ", data[i+1]); | |
287 } | |
288 if (i < len) | |
289 debug_printf("%02x", data[i]); | |
290 debug_printf("\n"); | |
291 for (i = 0; i < len; i++) { | |
292 if ((i % 16 == 0) && i) | |
293 debug_printf("\n"); | |
294 if (isprint(data[i])) | |
295 debug_printf("%c ", data[i]); | |
296 else | |
297 debug_printf(". "); | |
298 } | |
299 debug_printf("\n"); | |
300 #endif | |
301 } | |
302 | |
303 static int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt) | |
304 { | |
305 int pktlen = yahoo_packet_length(pkt); | |
306 int len = YAHOO_PACKET_HDRLEN + pktlen; | |
307 int ret; | |
308 | |
309 guchar *data; | |
310 int pos = 0; | |
311 | |
312 if (yd->fd < 0) | |
313 return -1; | |
314 | |
315 data = g_malloc0(len + 1); | |
316 | |
317 memcpy(data + pos, "YMSG", 4); pos += 4; | |
318 pos += yahoo_put16(data + pos, 0x0600); | |
319 pos += yahoo_put16(data + pos, 0x0000); | |
320 pos += yahoo_put16(data + pos, pktlen); | |
321 pos += yahoo_put16(data + pos, pkt->service); | |
322 pos += yahoo_put32(data + pos, pkt->status); | |
323 pos += yahoo_put32(data + pos, pkt->id); | |
324 | |
325 yahoo_packet_write(pkt, data + pos); | |
326 | |
327 yahoo_packet_dump(data, len); | |
328 ret = write(yd->fd, data, len); | |
329 | |
330 g_free(data); | |
331 | |
332 return ret; | |
333 } | |
334 | |
335 static void yahoo_packet_free(struct yahoo_packet *pkt) | |
336 { | |
337 while (pkt->hash) { | |
338 struct yahoo_pair *pair = pkt->hash->data; | |
339 g_free(pair->value); | |
340 g_free(pair); | |
341 pkt->hash = g_slist_remove(pkt->hash, pair); | |
342 } | |
343 g_free(pkt); | |
344 } | |
345 | |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
346 static void yahoo_process_status(struct gaim_connection *gc, struct yahoo_packet *pkt) |
2681 | 347 { |
348 struct yahoo_data *yd = gc->proto_data; | |
349 GSList *l = pkt->hash; | |
350 struct yahoo_packet *newpkt; | |
351 char *name = NULL; | |
352 int state = 0; | |
3019 | 353 int gamestate = 0; |
2681 | 354 char *msg = NULL; |
3019 | 355 |
2681 | 356 while (l) { |
357 struct yahoo_pair *pair = l->data; | |
358 | |
359 switch (pair->key) { | |
360 case 0: /* we won't actually do anything with this */ | |
361 break; | |
362 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
|
363 if (!yd->logged_in) { |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
364 account_online(gc); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
365 serv_finish_login(gc); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
366 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", pair->value); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
367 do_import(gc, NULL); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
368 yd->logged_in = TRUE; |
2681 | 369 |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
370 /* this requests the list. i have a feeling that this is very evil */ |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
371 newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
372 yahoo_send_packet(yd, newpkt); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
373 yahoo_packet_free(newpkt); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
374 } |
2681 | 375 break; |
376 case 8: /* how many online buddies we have */ | |
377 break; | |
378 case 7: /* the current buddy */ | |
379 name = pair->value; | |
380 break; | |
381 case 10: /* state */ | |
382 state = strtol(pair->value, NULL, 10); | |
383 break; | |
384 case 19: /* custom message */ | |
385 msg = pair->value; | |
386 break; | |
387 case 11: /* i didn't know what this was in the old protocol either */ | |
388 break; | |
389 case 17: /* in chat? */ | |
390 break; | |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
391 case 13: /* in pager? */ |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
392 if (pkt->service == YAHOO_SERVICE_LOGOFF || |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
393 strtol(pair->value, NULL, 10) == 0) { |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
394 serv_got_update(gc, name, 0, 0, 0, 0, 0, 0); |
2807
f01e6a425136
[gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2805
diff
changeset
|
395 break; |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
396 } |
3019 | 397 if (g_hash_table_lookup(yd->games, name)) |
398 gamestate = YAHOO_STATUS_GAME; | |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
399 if (state == YAHOO_STATUS_AVAILABLE) |
3019 | 400 serv_got_update(gc, name, 1, 0, 0, 0, gamestate, 0); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
401 else |
3019 | 402 serv_got_update(gc, name, 1, 0, 0, 0, (state << 2) | UC_UNAVAILABLE | gamestate, 0); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
403 if (state == YAHOO_STATUS_CUSTOM) { |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
404 gpointer val = g_hash_table_lookup(yd->hash, name); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
405 if (val) { |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
406 g_free(val); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
407 g_hash_table_insert(yd->hash, name, |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
408 msg ? g_strdup(msg) : g_malloc0(1)); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
409 } else |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
410 g_hash_table_insert(yd->hash, g_strdup(name), |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
411 msg ? g_strdup(msg) : g_malloc0(1)); |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
412 } |
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
413 break; |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
414 case 60: /* no clue */ |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
415 break; |
2979 | 416 case 16: /* Custom error message */ |
417 do_error_dialog(pair->value, "Gaim -- Yahoo! Error"); | |
2951 | 418 break; |
2681 | 419 default: |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
420 debug_printf("unknown status key %d\n", pair->key); |
2681 | 421 break; |
422 } | |
423 | |
424 l = l->next; | |
425 } | |
426 } | |
427 | |
428 static void yahoo_process_list(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
429 { | |
430 GSList *l = pkt->hash; | |
431 gboolean export = FALSE; | |
432 | |
433 while (l) { | |
434 char **lines; | |
435 char **split; | |
436 char **buddies; | |
437 char **tmp, **bud; | |
438 | |
439 struct yahoo_pair *pair = l->data; | |
440 l = l->next; | |
441 | |
442 if (pair->key != 87) | |
443 continue; | |
444 | |
445 lines = g_strsplit(pair->value, "\n", -1); | |
446 for (tmp = lines; *tmp; tmp++) { | |
447 split = g_strsplit(*tmp, ":", 2); | |
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
448 if (!split) |
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
449 continue; |
2702
94b4271b9567
[gaim-migrate @ 2715]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2697
diff
changeset
|
450 if (!split[0] || !split[1]) { |
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
451 g_strfreev(split); |
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
452 continue; |
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
453 } |
2681 | 454 buddies = g_strsplit(split[1], ",", -1); |
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
455 for (bud = buddies; bud && *bud; bud++) |
2681 | 456 if (!find_buddy(gc, *bud)) { |
457 add_buddy(gc, split[0], *bud, *bud); | |
458 export = TRUE; | |
459 } | |
460 g_strfreev(buddies); | |
461 g_strfreev(split); | |
462 } | |
463 g_strfreev(lines); | |
464 } | |
465 | |
466 if (export) | |
467 do_export(gc); | |
468 } | |
469 | |
3019 | 470 static void yahoo_process_notify(struct gaim_connection *gc, struct yahoo_packet *pkt) |
2993 | 471 { |
472 char *msg = NULL; | |
473 char *from = NULL; | |
3019 | 474 char *stat = NULL; |
475 char *game = NULL; | |
2993 | 476 GSList *l = pkt->hash; |
3019 | 477 struct yahoo_data *yd = (struct yahoo_data*) gc->proto_data; |
2993 | 478 while (l) { |
479 struct yahoo_pair *pair = l->data; | |
480 if (pair->key == 4) | |
481 from = pair->value; | |
482 if (pair->key == 49) | |
483 msg = pair->value; | |
3001 | 484 if (pair->key == 13) |
3019 | 485 stat = pair->value; |
486 if (pair->key == 14) | |
487 game = pair->value; | |
2993 | 488 l = l->next; |
489 } | |
3019 | 490 |
491 if (!g_strncasecmp(msg, "TYPING", strlen("TYPING"))) { | |
492 if (*stat == '1') | |
493 serv_got_typing(gc, from, 0); | |
494 else | |
495 serv_got_typing_stopped(gc, from); | |
496 } else if (!g_strncasecmp(msg, "GAME", strlen("GAME"))) { | |
497 struct buddy *bud = find_buddy(gc, from); | |
498 void *free1=NULL, *free2=NULL; | |
3020 | 499 if (!bud) |
3019 | 500 debug_printf("%s is playing a game, and doesn't want you to know.\n"); |
501 if (*stat == '1') { | |
502 if (g_hash_table_lookup_extended (yd->games, from, free1, free2)) { | |
503 g_free(free1); | |
504 g_free(free2); | |
505 } | |
506 g_hash_table_insert (yd->games, g_strdup(from), g_strdup(game)); | |
3020 | 507 if (bud) |
508 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc | YAHOO_STATUS_GAME, 0); | |
3019 | 509 } else { |
510 if (g_hash_table_lookup_extended (yd->games, from, free1, free2)) { | |
511 g_free(free1); | |
512 g_free(free2); | |
513 g_hash_table_remove (yd->games, from); | |
514 } | |
3020 | 515 if (bud) |
516 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc & ~YAHOO_STATUS_GAME, 0); | |
3019 | 517 } |
518 } | |
2993 | 519 } |
520 | |
2681 | 521 static void yahoo_process_message(struct gaim_connection *gc, struct yahoo_packet *pkt) |
522 { | |
523 char *msg = NULL; | |
524 char *from = NULL; | |
525 time_t tm = time(NULL); | |
526 GSList *l = pkt->hash; | |
3021 | 527 |
2681 | 528 while (l) { |
529 struct yahoo_pair *pair = l->data; | |
530 if (pair->key == 4) | |
531 from = pair->value; | |
532 if (pair->key == 14) | |
533 msg = pair->value; | |
534 if (pair->key == 15) | |
535 tm = strtol(pair->value, NULL, 10); | |
536 l = l->next; | |
537 } | |
538 | |
3021 | 539 if (pkt->status <= 1 || pkt->status == 5) { |
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
540 char *m; |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
541 int i, j; |
2681 | 542 strip_linefeed(msg); |
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
543 m = msg; |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
544 for (i = 0, j = 0; m[i]; i++) { |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
545 if (m[i] == 033) { |
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
546 while (m[i] && (m[i] != 'm')) |
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
547 i++; |
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
548 if (!m[i]) |
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
549 i--; |
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
550 continue; |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
551 } |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
552 msg[j++] = m[i]; |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
553 } |
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
554 msg[j] = 0; |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2850
diff
changeset
|
555 serv_got_im(gc, from, msg, 0, tm, -1); |
2681 | 556 } else if (pkt->status == 2) { |
557 do_error_dialog(_("Your message did not get sent."), _("Gaim - Error")); | |
558 } | |
559 } | |
560 | |
561 | |
562 static void yahoo_process_contact(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
563 { | |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
564 struct yahoo_data *yd = gc->proto_data; |
2681 | 565 char *id = NULL; |
566 char *who = NULL; | |
567 char *msg = NULL; | |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
568 char *name = NULL; |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
569 int state = YAHOO_STATUS_AVAILABLE; |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
570 int online = FALSE; |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
571 |
2681 | 572 GSList *l = pkt->hash; |
573 | |
574 while (l) { | |
575 struct yahoo_pair *pair = l->data; | |
576 if (pair->key == 1) | |
577 id = pair->value; | |
578 else if (pair->key == 3) | |
579 who = pair->value; | |
580 else if (pair->key == 14) | |
581 msg = pair->value; | |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
582 else if (pair->key == 7) |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
583 name = pair->value; |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
584 else if (pair->key == 10) |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
585 state = strtol(pair->value, NULL, 10); |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
586 else if (pair->key == 13) |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
587 online = strtol(pair->value, NULL, 10); |
2681 | 588 l = l->next; |
589 } | |
590 | |
2682
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
591 if (id) |
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
592 show_got_added(gc, id, who, NULL, msg); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
593 if (name) { |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
594 if (state == YAHOO_STATUS_AVAILABLE) |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
595 serv_got_update(gc, name, 1, 0, 0, 0, 0, 0); |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
596 else if (state == YAHOO_STATUS_IDLE) |
3019 | 597 serv_got_update(gc, name, 1, 0, 0, time(NULL) - 600, (state << 2), 0); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
598 else |
3019 | 599 serv_got_update(gc, name, 1, 0, 0, 0, (state << 2) | UC_UNAVAILABLE, 0); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
600 if (state == YAHOO_STATUS_CUSTOM) { |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
601 gpointer val = g_hash_table_lookup(yd->hash, name); |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
602 if (val) { |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
603 g_free(val); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
604 g_hash_table_insert(yd->hash, name, |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
605 msg ? g_strdup(msg) : g_malloc0(1)); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
606 } else |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
607 g_hash_table_insert(yd->hash, g_strdup(name), |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
608 msg ? g_strdup(msg) : g_malloc0(1)); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
609 } |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
610 } |
2681 | 611 } |
612 | |
613 static void yahoo_process_mail(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
614 { | |
615 char *who = NULL; | |
616 char *email = NULL; | |
617 char *subj = NULL; | |
618 int count = 0; | |
619 GSList *l = pkt->hash; | |
620 | |
621 while (l) { | |
622 struct yahoo_pair *pair = l->data; | |
623 if (pair->key == 9) | |
624 count = strtol(pair->value, NULL, 10); | |
625 else if (pair->key == 43) | |
626 who = pair->value; | |
627 else if (pair->key == 42) | |
628 email = pair->value; | |
629 else if (pair->key == 18) | |
630 subj = pair->value; | |
631 l = l->next; | |
632 } | |
633 | |
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
634 if (who && email && subj) { |
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
635 char *from = g_strdup_printf("%s (%s)", who, email); |
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
636 connection_has_mail(gc, -1, from, subj, "http://mail.yahoo.com/"); |
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
637 g_free(from); |
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
638 } else |
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
639 connection_has_mail(gc, count, NULL, NULL, "http://mail.yahoo.com/"); |
2681 | 640 } |
641 | |
642 static void yahoo_packet_process(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
643 { | |
644 switch (pkt->service) | |
645 { | |
646 case YAHOO_SERVICE_LOGON: | |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
647 case YAHOO_SERVICE_LOGOFF: |
2681 | 648 case YAHOO_SERVICE_ISAWAY: |
2737
f61c1f3a6afa
[gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2724
diff
changeset
|
649 case YAHOO_SERVICE_ISBACK: |
3019 | 650 case YAHOO_SERVICE_GAMELOGON: |
651 case YAHOO_SERVICE_GAMELOGOFF: | |
2681 | 652 yahoo_process_status(gc, pkt); |
653 break; | |
3019 | 654 case YAHOO_SERVICE_NOTIFY: |
655 yahoo_process_notify(gc, pkt); | |
2993 | 656 break; |
2681 | 657 case YAHOO_SERVICE_MESSAGE: |
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
658 case YAHOO_SERVICE_GAMEMSG: |
2681 | 659 yahoo_process_message(gc, pkt); |
660 break; | |
661 case YAHOO_SERVICE_NEWMAIL: | |
662 yahoo_process_mail(gc, pkt); | |
663 break; | |
664 case YAHOO_SERVICE_NEWCONTACT: | |
665 yahoo_process_contact(gc, pkt); | |
666 break; | |
667 case YAHOO_SERVICE_LIST: | |
668 yahoo_process_list(gc, pkt); | |
669 break; | |
670 default: | |
2741
38cb5fa48bec
[gaim-migrate @ 2754]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2737
diff
changeset
|
671 debug_printf("unhandled service 0x%02x\n", pkt->service); |
2681 | 672 break; |
673 } | |
674 } | |
675 | |
676 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
677 { | |
678 struct gaim_connection *gc = data; | |
679 struct yahoo_data *yd = gc->proto_data; | |
680 char buf[1024]; | |
681 int len; | |
682 | |
683 len = read(yd->fd, buf, sizeof(buf)); | |
684 | |
685 if (len <= 0) { | |
686 hide_login_progress(gc, "Unable to read"); | |
687 signoff(gc); | |
688 return; | |
689 } | |
690 | |
691 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
692 memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
693 yd->rxlen += len; | |
694 | |
695 while (1) { | |
696 struct yahoo_packet *pkt; | |
697 int pos = 0; | |
698 int pktlen; | |
699 | |
700 if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
701 return; | |
702 | |
703 pos += 4; /* YMSG */ | |
704 pos += 2; | |
705 pos += 2; | |
706 | |
707 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
708 debug_printf("%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); | |
709 | |
710 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
711 return; | |
712 | |
713 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
714 | |
715 pkt = yahoo_packet_new(0, 0, 0); | |
716 | |
717 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
3021 | 718 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
2741
38cb5fa48bec
[gaim-migrate @ 2754]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2737
diff
changeset
|
719 debug_printf("Yahoo Service: 0x%02x Status: %d\n", pkt->service, pkt->status); |
2681 | 720 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
721 | |
722 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
723 | |
724 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
725 if (yd->rxlen) { | |
726 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
727 g_free(yd->rxqueue); | |
728 yd->rxqueue = tmp; | |
729 } else { | |
730 g_free(yd->rxqueue); | |
731 yd->rxqueue = NULL; | |
732 } | |
733 | |
734 yahoo_packet_process(gc, pkt); | |
735 | |
736 yahoo_packet_free(pkt); | |
737 } | |
738 } | |
739 | |
740 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
741 { | |
742 struct gaim_connection *gc = data; | |
743 struct yahoo_data *yd; | |
744 struct yahoo_packet *pkt; | |
745 | |
746 if (!g_slist_find(connections, gc)) { | |
747 close(source); | |
748 return; | |
749 } | |
750 | |
751 if (source < 0) { | |
752 hide_login_progress(gc, "Unable to connect"); | |
753 signoff(gc); | |
754 return; | |
755 } | |
756 | |
757 yd = gc->proto_data; | |
758 yd->fd = source; | |
759 | |
760 pkt = yahoo_packet_new(YAHOO_SERVICE_LOGON, YAHOO_STATUS_AVAILABLE, 0); | |
761 | |
762 yahoo_packet_hash(pkt, 0, gc->username); | |
763 yahoo_packet_hash(pkt, 1, gc->username); | |
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
764 yahoo_packet_hash(pkt, 6, yahoo_crypt(gc->password, "$1$_2S43d5f$")); |
2681 | 765 |
766 yahoo_send_packet(yd, pkt); | |
767 | |
768 yahoo_packet_free(pkt); | |
769 | |
770 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
771 } | |
772 | |
773 static void yahoo_login(struct aim_user *user) { | |
774 struct gaim_connection *gc = new_gaim_conn(user); | |
775 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); | |
776 | |
777 set_login_progress(gc, 1, "Connecting"); | |
778 | |
779 yd->fd = -1; | |
780 yd->hash = g_hash_table_new(g_str_hash, g_str_equal); | |
3019 | 781 yd->games = g_hash_table_new(g_str_hash, g_str_equal); |
2681 | 782 |
2951 | 783 if (!g_strncasecmp(user->proto_opt[USEROPT_PAGERHOST], "scs.yahoo.com", strlen("scs.yahoo.com"))) { |
784 /* As of this morning, Yahoo is no longer supporting its server at scs.yahoo.com | |
785 * I don't like to edit the preferences in a prpl, but we'll keep this here | |
786 * for a while until everybody's happy again. -5 Feb 2002*/ | |
787 debug_printf("Setting new Yahoo! server.\n"); | |
788 g_snprintf(user->proto_opt[USEROPT_PAGERHOST], strlen("cs.yahoo.com") + 1, "cs.yahoo.com"); | |
789 save_prefs(); | |
790 } | |
791 | |
792 if (proxy_connect(user->proto_opt[USEROPT_PAGERHOST][0] ? | |
2681 | 793 user->proto_opt[USEROPT_PAGERHOST] : YAHOO_PAGER_HOST, |
794 user->proto_opt[USEROPT_PAGERPORT][0] ? | |
795 atoi(user->proto_opt[USEROPT_PAGERPORT]) : YAHOO_PAGER_PORT, | |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2687
diff
changeset
|
796 yahoo_got_connected, gc) < 0) { |
2681 | 797 hide_login_progress(gc, "Connection problem"); |
798 signoff(gc); | |
799 return; | |
800 } | |
801 | |
802 } | |
803 | |
804 static gboolean yahoo_destroy_hash(gpointer key, gpointer val, gpointer data) | |
805 { | |
806 g_free(key); | |
807 g_free(val); | |
808 return TRUE; | |
809 } | |
810 | |
811 static void yahoo_close(struct gaim_connection *gc) { | |
812 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
813 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); | |
814 g_hash_table_destroy(yd->hash); | |
3019 | 815 g_hash_table_foreach_remove(yd->games, yahoo_destroy_hash, NULL); |
816 g_hash_table_destroy(yd->games); | |
2681 | 817 if (yd->fd >= 0) |
818 close(yd->fd); | |
819 if (yd->rxqueue) | |
820 g_free(yd->rxqueue); | |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2686
diff
changeset
|
821 yd->rxlen = 0; |
2681 | 822 if (gc->inpa) |
823 gaim_input_remove(gc->inpa); | |
824 g_free(yd); | |
825 } | |
826 | |
827 static char **yahoo_list_icon(int uc) | |
828 { | |
3019 | 829 if ((uc >> 2) == YAHOO_STATUS_IDLE) |
2681 | 830 return status_idle_xpm; |
3019 | 831 else if (uc & UC_UNAVAILABLE) |
832 return status_away_xpm; | |
833 else if (uc & YAHOO_STATUS_GAME) | |
834 return status_game_xpm; | |
835 return status_here_xpm; | |
2681 | 836 } |
837 | |
838 static char *yahoo_get_status_string(enum yahoo_status a) | |
839 { | |
840 switch (a) { | |
841 case YAHOO_STATUS_BRB: | |
842 return "Be Right Back"; | |
843 case YAHOO_STATUS_BUSY: | |
844 return "Busy"; | |
845 case YAHOO_STATUS_NOTATHOME: | |
846 return "Not At Home"; | |
847 case YAHOO_STATUS_NOTATDESK: | |
848 return "Not At Desk"; | |
849 case YAHOO_STATUS_NOTINOFFICE: | |
850 return "Not In Office"; | |
851 case YAHOO_STATUS_ONPHONE: | |
852 return "On Phone"; | |
853 case YAHOO_STATUS_ONVACATION: | |
854 return "On Vacation"; | |
855 case YAHOO_STATUS_OUTTOLUNCH: | |
856 return "Out To Lunch"; | |
857 case YAHOO_STATUS_STEPPEDOUT: | |
858 return "Stepped Out"; | |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
859 case YAHOO_STATUS_INVISIBLE: |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
860 return "Invisible"; |
2879
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
861 default: |
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
862 return "Online"; |
2681 | 863 } |
864 } | |
865 | |
3019 | 866 static void yahoo_game(struct gaim_connection *gc, char *name) { |
867 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
868 char *game = g_hash_table_lookup(yd->games, name); | |
869 char *t; | |
870 char url[256]; | |
871 | |
872 if (!game) | |
873 return; | |
874 t = game = g_strdup(strstr(game, "ante?room=")); | |
875 while (*t != '\t') | |
876 t++; | |
877 *t = 0; | |
878 g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game); | |
879 open_url(NULL, url); | |
880 g_free(game); | |
881 } | |
2681 | 882 static GList *yahoo_buddy_menu(struct gaim_connection *gc, char *who) |
883 { | |
884 GList *m = NULL; | |
885 struct proto_buddy_menu *pbm; | |
886 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
887 struct buddy *b = find_buddy(gc, who); /* this should never be null. if it is, | |
888 segfault and get the bug report. */ | |
889 static char buf[1024]; | |
3019 | 890 static char buf2[1024]; |
891 | |
892 if (b->uc & UC_UNAVAILABLE && b->uc >> 2 != YAHOO_STATUS_IDLE) { | |
893 pbm = g_new0(struct proto_buddy_menu, 1); | |
894 if ((b->uc >> 2) != YAHOO_STATUS_CUSTOM) | |
895 g_snprintf(buf, sizeof buf, | |
896 "Status: %s", yahoo_get_status_string(b->uc >> 2)); | |
897 else | |
898 g_snprintf(buf, sizeof buf, "Custom Status: %s", | |
899 (char *)g_hash_table_lookup(yd->hash, b->name)); | |
900 pbm->label = buf; | |
901 pbm->callback = NULL; | |
902 pbm->gc = gc; | |
903 m = g_list_append(m, pbm); | |
904 } | |
905 | |
906 if (b->uc | YAHOO_STATUS_GAME) { | |
907 char *game = g_hash_table_lookup(yd->games, b->name); | |
908 char *room; | |
909 if (!game) | |
910 return m; | |
911 if (game) { | |
912 char *t; | |
913 pbm = g_new0(struct proto_buddy_menu, 1); | |
914 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ | |
915 return NULL; | |
916 while (*room && *room != '\t') /* skip to the tab */ | |
917 room++; | |
918 t = room++; /* room as now at the name */ | |
919 while (*t != '\n') | |
920 t++; /* replace the \n with a space */ | |
921 *t = ' '; | |
922 g_snprintf(buf2, sizeof buf2, "%s", room); | |
923 pbm->label = buf2; | |
924 pbm->callback = yahoo_game; | |
925 pbm->gc = gc; | |
926 m = g_list_append(m, pbm); | |
927 } | |
928 } | |
2681 | 929 |
930 return m; | |
931 } | |
932 | |
933 static GList *yahoo_user_opts() | |
934 { | |
935 GList *m = NULL; | |
936 struct proto_user_opt *puo; | |
937 | |
938 puo = g_new0(struct proto_user_opt, 1); | |
939 puo->label = "Pager Host:"; | |
940 puo->def = YAHOO_PAGER_HOST; | |
941 puo->pos = USEROPT_PAGERHOST; | |
942 m = g_list_append(m, puo); | |
943 | |
944 puo = g_new0(struct proto_user_opt, 1); | |
945 puo->label = "Pager Port:"; | |
946 puo->def = "5050"; | |
947 puo->pos = USEROPT_PAGERPORT; | |
948 m = g_list_append(m, puo); | |
949 | |
950 return m; | |
951 } | |
952 | |
953 static void yahoo_act_id(gpointer data, char *entry) | |
954 { | |
955 struct gaim_connection *gc = data; | |
956 struct yahoo_data *yd = gc->proto_data; | |
957 | |
958 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
959 yahoo_packet_hash(pkt, 3, entry); | |
960 yahoo_send_packet(yd, pkt); | |
961 yahoo_packet_free(pkt); | |
962 | |
963 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", entry); | |
964 } | |
965 | |
966 static void yahoo_do_action(struct gaim_connection *gc, char *act) | |
967 { | |
968 if (!strcmp(act, "Activate ID")) { | |
969 do_prompt_dialog("Activate which ID:", gc->displayname, gc, yahoo_act_id, NULL); | |
970 } | |
971 } | |
972 | |
973 static GList *yahoo_actions() { | |
974 GList *m = NULL; | |
975 | |
976 m = g_list_append(m, "Activate ID"); | |
977 | |
978 return m; | |
979 } | |
980 | |
3033 | 981 static int yahoo_send_im(struct gaim_connection *gc, char *who, char *what, int len, int flags) |
2681 | 982 { |
983 struct yahoo_data *yd = gc->proto_data; | |
984 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
985 | |
986 yahoo_packet_hash(pkt, 1, gc->displayname); | |
987 yahoo_packet_hash(pkt, 5, who); | |
988 yahoo_packet_hash(pkt, 14, what); | |
989 | |
990 yahoo_send_packet(yd, pkt); | |
991 | |
992 yahoo_packet_free(pkt); | |
993 | |
994 return 1; | |
995 } | |
996 | |
3001 | 997 int yahoo_send_typing(struct gaim_connection *gc, char *who, int typ) |
2993 | 998 { |
999 struct yahoo_data *yd = gc->proto_data; | |
3019 | 1000 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
2993 | 1001 yahoo_packet_hash(pkt, 49, "TYPING"); |
1002 yahoo_packet_hash(pkt, 1, gc->displayname); | |
1003 yahoo_packet_hash(pkt, 14, " "); | |
3001 | 1004 yahoo_packet_hash(pkt, 13, typ ? "1" : "0"); |
2993 | 1005 yahoo_packet_hash(pkt, 5, who); |
1006 yahoo_packet_hash(pkt, 1002, "1"); | |
1007 | |
1008 yahoo_send_packet(yd, pkt); | |
1009 | |
1010 yahoo_packet_free(pkt); | |
1011 | |
3001 | 1012 return 0; |
2993 | 1013 } |
1014 | |
2681 | 1015 static void yahoo_set_away(struct gaim_connection *gc, char *state, char *msg) |
1016 { | |
1017 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1018 struct yahoo_packet *pkt; | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1019 int service; |
2681 | 1020 char s[4]; |
1021 | |
1022 gc->away = NULL; | |
1023 | |
1024 if (msg) { | |
1025 yd->current_status = YAHOO_STATUS_CUSTOM; | |
1026 gc->away = ""; | |
1027 } else if (state) { | |
1028 gc->away = ""; | |
1029 if (!strcmp(state, "Available")) { | |
1030 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1031 gc->away = NULL; | |
1032 } else if (!strcmp(state, "Be Right Back")) { | |
1033 yd->current_status = YAHOO_STATUS_BRB; | |
1034 } else if (!strcmp(state, "Busy")) { | |
1035 yd->current_status = YAHOO_STATUS_BUSY; | |
1036 } else if (!strcmp(state, "Not At Home")) { | |
1037 yd->current_status = YAHOO_STATUS_NOTATHOME; | |
1038 } else if (!strcmp(state, "Not At Desk")) { | |
1039 yd->current_status = YAHOO_STATUS_NOTATDESK; | |
1040 } else if (!strcmp(state, "Not In Office")) { | |
1041 yd->current_status = YAHOO_STATUS_NOTINOFFICE; | |
1042 } else if (!strcmp(state, "On Phone")) { | |
1043 yd->current_status = YAHOO_STATUS_ONPHONE; | |
1044 } else if (!strcmp(state, "On Vacation")) { | |
1045 yd->current_status = YAHOO_STATUS_ONVACATION; | |
1046 } else if (!strcmp(state, "Out To Lunch")) { | |
1047 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; | |
1048 } else if (!strcmp(state, "Stepped Out")) { | |
1049 yd->current_status = YAHOO_STATUS_STEPPEDOUT; | |
1050 } else if (!strcmp(state, "Invisible")) { | |
1051 yd->current_status = YAHOO_STATUS_INVISIBLE; | |
1052 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { | |
1053 if (gc->is_idle) { | |
1054 yd->current_status = YAHOO_STATUS_IDLE; | |
1055 } else { | |
1056 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1057 } | |
1058 gc->away = NULL; | |
1059 } | |
1060 } else if (gc->is_idle) { | |
1061 yd->current_status = YAHOO_STATUS_IDLE; | |
1062 } else { | |
1063 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1064 } | |
1065 | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1066 if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1067 service = YAHOO_SERVICE_ISBACK; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1068 else |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1069 service = YAHOO_SERVICE_ISAWAY; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1070 pkt = yahoo_packet_new(service, yd->current_status, 0); |
2681 | 1071 g_snprintf(s, sizeof(s), "%d", yd->current_status); |
1072 yahoo_packet_hash(pkt, 10, s); | |
1073 if (yd->current_status == YAHOO_STATUS_CUSTOM) | |
1074 yahoo_packet_hash(pkt, 19, msg); | |
1075 | |
1076 yahoo_send_packet(yd, pkt); | |
1077 yahoo_packet_free(pkt); | |
1078 } | |
1079 | |
1080 static void yahoo_set_idle(struct gaim_connection *gc, int idle) | |
1081 { | |
1082 struct yahoo_data *yd = gc->proto_data; | |
1083 struct yahoo_packet *pkt = NULL; | |
1084 | |
1085 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
1086 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0); | |
1087 yd->current_status = YAHOO_STATUS_IDLE; | |
1088 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
1089 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
1090 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1091 } | |
1092 | |
1093 if (pkt) { | |
1094 char buf[4]; | |
1095 g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
1096 yahoo_packet_hash(pkt, 10, buf); | |
1097 yahoo_send_packet(yd, pkt); | |
1098 yahoo_packet_free(pkt); | |
1099 } | |
1100 } | |
1101 | |
1102 static GList *yahoo_away_states(struct gaim_connection *gc) | |
1103 { | |
1104 GList *m = NULL; | |
1105 | |
1106 m = g_list_append(m, "Available"); | |
1107 m = g_list_append(m, "Be Right Back"); | |
1108 m = g_list_append(m, "Busy"); | |
1109 m = g_list_append(m, "Not At Home"); | |
1110 m = g_list_append(m, "Not At Desk"); | |
1111 m = g_list_append(m, "Not In Office"); | |
1112 m = g_list_append(m, "On Phone"); | |
1113 m = g_list_append(m, "On Vacation"); | |
1114 m = g_list_append(m, "Out To Lunch"); | |
1115 m = g_list_append(m, "Stepped Out"); | |
1116 m = g_list_append(m, "Invisible"); | |
1117 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
1118 | |
1119 return m; | |
1120 } | |
1121 | |
1122 static void yahoo_keepalive(struct gaim_connection *gc) | |
1123 { | |
1124 struct yahoo_data *yd = gc->proto_data; | |
1125 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
1126 yahoo_send_packet(yd, pkt); | |
1127 yahoo_packet_free(pkt); | |
1128 } | |
1129 | |
1130 static void yahoo_add_buddy(struct gaim_connection *gc, char *who) | |
1131 { | |
1132 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1133 struct yahoo_packet *pkt; | |
1134 struct group *g; | |
1135 char *group = NULL; | |
1136 | |
1137 if (!yd->logged_in) | |
1138 return; | |
1139 | |
1140 g = find_group_by_buddy(gc, who); | |
1141 if (g) | |
1142 group = g->name; | |
1143 else | |
1144 group = "Buddies"; | |
1145 | |
1146 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
1147 yahoo_packet_hash(pkt, 1, gc->displayname); | |
1148 yahoo_packet_hash(pkt, 7, who); | |
1149 yahoo_packet_hash(pkt, 65, group); | |
1150 yahoo_send_packet(yd, pkt); | |
1151 yahoo_packet_free(pkt); | |
1152 } | |
1153 | |
1154 static void yahoo_remove_buddy(struct gaim_connection *gc, char *who, char *group) | |
1155 { | |
1156 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1157 | |
1158 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
1159 yahoo_packet_hash(pkt, 1, gc->displayname); | |
1160 yahoo_packet_hash(pkt, 7, who); | |
1161 yahoo_packet_hash(pkt, 65, group); | |
1162 yahoo_send_packet(yd, pkt); | |
1163 yahoo_packet_free(pkt); | |
1164 } | |
1165 | |
1166 static struct prpl *my_protocol = NULL; | |
1167 | |
1168 void yahoo_init(struct prpl *ret) { | |
1169 ret->protocol = PROTO_YAHOO; | |
1170 ret->options = OPT_PROTO_MAIL_CHECK; | |
1171 ret->name = yahoo_name; | |
1172 ret->user_opts = yahoo_user_opts; | |
1173 ret->login = yahoo_login; | |
1174 ret->close = yahoo_close; | |
1175 ret->buddy_menu = yahoo_buddy_menu; | |
1176 ret->list_icon = yahoo_list_icon; | |
1177 ret->actions = yahoo_actions; | |
1178 ret->do_action = yahoo_do_action; | |
1179 ret->send_im = yahoo_send_im; | |
1180 ret->away_states = yahoo_away_states; | |
1181 ret->set_away = yahoo_set_away; | |
1182 ret->set_idle = yahoo_set_idle; | |
1183 ret->keepalive = yahoo_keepalive; | |
1184 ret->add_buddy = yahoo_add_buddy; | |
1185 ret->remove_buddy = yahoo_remove_buddy; | |
2993 | 1186 ret->send_typing = yahoo_send_typing; |
2681 | 1187 |
1188 my_protocol = ret; | |
1189 } | |
1190 | |
1191 #ifndef STATIC | |
1192 | |
1193 char *gaim_plugin_init(GModule *handle) | |
1194 { | |
1195 load_protocol(yahoo_init, sizeof(struct prpl)); | |
1196 return NULL; | |
1197 } | |
1198 | |
1199 void gaim_plugin_remove() | |
1200 { | |
1201 struct prpl *p = find_prpl(PROTO_YAHOO); | |
1202 if (p == my_protocol) | |
1203 unload_protocol(p); | |
1204 } | |
1205 | |
1206 char *name() | |
1207 { | |
1208 return "Yahoo"; | |
1209 } | |
1210 | |
1211 char *description() | |
1212 { | |
1213 return PRPL_DESC("Yahoo"); | |
1214 } | |
1215 | |
1216 #endif |