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