Sat, 23 Feb 2002 22:50:44 +0000
[gaim-migrate @ 2992]
I'll never tell...
| 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 | |
| 2951 | 56 | #define YAHOO_PAGER_HOST "cs.yahoo.com" |
| 2681 | 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; |
| 2979 | 408 | case 16: /* Custom error message */ |
| 409 | do_error_dialog(pair->value, "Gaim -- Yahoo! Error"); | |
| 2951 | 410 | break; |
| 2681 | 411 | default: |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
412 | debug_printf("unknown status key %d\n", pair->key); |
| 2681 | 413 | break; |
| 414 | } | |
| 415 | ||
| 416 | l = l->next; | |
| 417 | } | |
| 418 | } | |
| 419 | ||
| 420 | static void yahoo_process_list(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 421 | { | |
| 422 | GSList *l = pkt->hash; | |
| 423 | gboolean export = FALSE; | |
| 424 | ||
| 425 | while (l) { | |
| 426 | char **lines; | |
| 427 | char **split; | |
| 428 | char **buddies; | |
| 429 | char **tmp, **bud; | |
| 430 | ||
| 431 | struct yahoo_pair *pair = l->data; | |
| 432 | l = l->next; | |
| 433 | ||
| 434 | if (pair->key != 87) | |
| 435 | continue; | |
| 436 | ||
| 437 | lines = g_strsplit(pair->value, "\n", -1); | |
| 438 | for (tmp = lines; *tmp; tmp++) { | |
| 439 | split = g_strsplit(*tmp, ":", 2); | |
|
2697
3dc23ce1223f
[gaim-migrate @ 2710]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2688
diff
changeset
|
440 | if (!split) |
|
3dc23ce1223f
[gaim-migrate @ 2710]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2688
diff
changeset
|
441 | continue; |
|
2702
c647b4a9dc62
[gaim-migrate @ 2715]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2697
diff
changeset
|
442 | if (!split[0] || !split[1]) { |
|
2697
3dc23ce1223f
[gaim-migrate @ 2710]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2688
diff
changeset
|
443 | g_strfreev(split); |
|
3dc23ce1223f
[gaim-migrate @ 2710]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2688
diff
changeset
|
444 | continue; |
|
3dc23ce1223f
[gaim-migrate @ 2710]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2688
diff
changeset
|
445 | } |
| 2681 | 446 | buddies = g_strsplit(split[1], ",", -1); |
|
2697
3dc23ce1223f
[gaim-migrate @ 2710]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2688
diff
changeset
|
447 | for (bud = buddies; bud && *bud; bud++) |
| 2681 | 448 | if (!find_buddy(gc, *bud)) { |
| 449 | add_buddy(gc, split[0], *bud, *bud); | |
| 450 | export = TRUE; | |
| 451 | } | |
| 452 | g_strfreev(buddies); | |
| 453 | g_strfreev(split); | |
| 454 | } | |
| 455 | g_strfreev(lines); | |
| 456 | } | |
| 457 | ||
| 458 | if (export) | |
| 459 | do_export(gc); | |
| 460 | } | |
| 461 | ||
| 462 | static void yahoo_process_message(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 463 | { | |
| 464 | char *msg = NULL; | |
| 465 | char *from = NULL; | |
| 466 | time_t tm = time(NULL); | |
| 467 | GSList *l = pkt->hash; | |
| 468 | ||
| 469 | while (l) { | |
| 470 | struct yahoo_pair *pair = l->data; | |
| 471 | if (pair->key == 4) | |
| 472 | from = pair->value; | |
| 473 | if (pair->key == 14) | |
| 474 | msg = pair->value; | |
| 475 | if (pair->key == 15) | |
| 476 | tm = strtol(pair->value, NULL, 10); | |
| 477 | l = l->next; | |
| 478 | } | |
| 479 | ||
|
2878
ca3c372e1461
[gaim-migrate @ 2891]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2876
diff
changeset
|
480 | if (pkt->status <= 1) { |
|
2715
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
481 | char *m; |
|
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
482 | int i, j; |
| 2681 | 483 | strip_linefeed(msg); |
|
2715
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
484 | m = msg; |
|
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
485 | for (i = 0, j = 0; m[i]; i++) { |
|
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
486 | if (m[i] == 033) { |
|
2813
efdce60f3acc
[gaim-migrate @ 2826]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2807
diff
changeset
|
487 | while (m[i] && (m[i] != 'm')) |
|
2715
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
488 | i++; |
|
2813
efdce60f3acc
[gaim-migrate @ 2826]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2807
diff
changeset
|
489 | if (!m[i]) |
|
efdce60f3acc
[gaim-migrate @ 2826]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2807
diff
changeset
|
490 | i--; |
|
2715
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
491 | continue; |
|
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
492 | } |
|
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
493 | msg[j++] = m[i]; |
|
ffc250ace3ea
[gaim-migrate @ 2728]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2708
diff
changeset
|
494 | } |
|
2813
efdce60f3acc
[gaim-migrate @ 2826]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2807
diff
changeset
|
495 | msg[j] = 0; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2850
diff
changeset
|
496 | serv_got_im(gc, from, msg, 0, tm, -1); |
| 2681 | 497 | } else if (pkt->status == 2) { |
| 498 | do_error_dialog(_("Your message did not get sent."), _("Gaim - Error")); | |
| 499 | } | |
| 500 | } | |
| 501 | ||
| 502 | ||
| 503 | static void yahoo_process_contact(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 504 | { | |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
505 | struct yahoo_data *yd = gc->proto_data; |
| 2681 | 506 | char *id = NULL; |
| 507 | char *who = NULL; | |
| 508 | char *msg = NULL; | |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
509 | char *name = NULL; |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
510 | int state = YAHOO_STATUS_AVAILABLE; |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
511 | int online = FALSE; |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
512 | |
| 2681 | 513 | GSList *l = pkt->hash; |
| 514 | ||
| 515 | while (l) { | |
| 516 | struct yahoo_pair *pair = l->data; | |
| 517 | if (pair->key == 1) | |
| 518 | id = pair->value; | |
| 519 | else if (pair->key == 3) | |
| 520 | who = pair->value; | |
| 521 | else if (pair->key == 14) | |
| 522 | msg = pair->value; | |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
523 | else if (pair->key == 7) |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
524 | name = pair->value; |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
525 | else if (pair->key == 10) |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
526 | state = strtol(pair->value, NULL, 10); |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
527 | else if (pair->key == 13) |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
528 | online = strtol(pair->value, NULL, 10); |
| 2681 | 529 | l = l->next; |
| 530 | } | |
| 531 | ||
|
2682
49c15f67d4b1
[gaim-migrate @ 2695]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2681
diff
changeset
|
532 | if (id) |
|
49c15f67d4b1
[gaim-migrate @ 2695]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2681
diff
changeset
|
533 | show_got_added(gc, id, who, NULL, msg); |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
534 | if (name) { |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
535 | if (state == YAHOO_STATUS_AVAILABLE) |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
536 | serv_got_update(gc, name, 1, 0, 0, 0, 0, 0); |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
537 | else if (state == YAHOO_STATUS_IDLE) |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
538 | 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
|
539 | else |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
540 | 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
|
541 | if (state == YAHOO_STATUS_CUSTOM) { |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
542 | gpointer val = g_hash_table_lookup(yd->hash, name); |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
543 | if (val) { |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
544 | g_free(val); |
|
2873
9e56887eeb06
[gaim-migrate @ 2886]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2856
diff
changeset
|
545 | g_hash_table_insert(yd->hash, 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 | } else |
|
2873
9e56887eeb06
[gaim-migrate @ 2886]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2856
diff
changeset
|
548 | g_hash_table_insert(yd->hash, g_strdup(name), |
|
9e56887eeb06
[gaim-migrate @ 2886]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2856
diff
changeset
|
549 | msg ? g_strdup(msg) : g_malloc0(1)); |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
550 | } |
|
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
551 | } |
| 2681 | 552 | } |
| 553 | ||
| 554 | static void yahoo_process_mail(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 555 | { | |
| 556 | char *who = NULL; | |
| 557 | char *email = NULL; | |
| 558 | char *subj = NULL; | |
| 559 | int count = 0; | |
| 560 | GSList *l = pkt->hash; | |
| 561 | ||
| 562 | while (l) { | |
| 563 | struct yahoo_pair *pair = l->data; | |
| 564 | if (pair->key == 9) | |
| 565 | count = strtol(pair->value, NULL, 10); | |
| 566 | else if (pair->key == 43) | |
| 567 | who = pair->value; | |
| 568 | else if (pair->key == 42) | |
| 569 | email = pair->value; | |
| 570 | else if (pair->key == 18) | |
| 571 | subj = pair->value; | |
| 572 | l = l->next; | |
| 573 | } | |
| 574 | ||
| 2850 | 575 | if (who && email && subj) { |
| 576 | char *from = g_strdup_printf("%s (%s)", who, email); | |
| 577 | connection_has_mail(gc, -1, from, subj, "http://mail.yahoo.com/"); | |
| 578 | g_free(from); | |
| 579 | } else | |
| 580 | connection_has_mail(gc, count, NULL, NULL, "http://mail.yahoo.com/"); | |
| 2681 | 581 | } |
| 582 | ||
| 583 | static void yahoo_packet_process(struct gaim_connection *gc, struct yahoo_packet *pkt) | |
| 584 | { | |
| 585 | switch (pkt->service) | |
| 586 | { | |
| 587 | case YAHOO_SERVICE_LOGON: | |
|
2771
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
588 | case YAHOO_SERVICE_LOGOFF: |
| 2681 | 589 | case YAHOO_SERVICE_ISAWAY: |
|
2737
f7edb9c3f348
[gaim-migrate @ 2750]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2724
diff
changeset
|
590 | case YAHOO_SERVICE_ISBACK: |
| 2681 | 591 | yahoo_process_status(gc, pkt); |
| 592 | break; | |
| 593 | case YAHOO_SERVICE_MESSAGE: | |
| 2786 | 594 | case YAHOO_SERVICE_GAMEMSG: |
| 2681 | 595 | yahoo_process_message(gc, pkt); |
| 596 | break; | |
| 597 | case YAHOO_SERVICE_NEWMAIL: | |
| 598 | yahoo_process_mail(gc, pkt); | |
| 599 | break; | |
| 600 | case YAHOO_SERVICE_NEWCONTACT: | |
| 601 | yahoo_process_contact(gc, pkt); | |
| 602 | break; | |
| 603 | case YAHOO_SERVICE_LIST: | |
| 604 | yahoo_process_list(gc, pkt); | |
| 605 | break; | |
| 606 | default: | |
|
2741
a955e690580c
[gaim-migrate @ 2754]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2737
diff
changeset
|
607 | debug_printf("unhandled service 0x%02x\n", pkt->service); |
| 2681 | 608 | break; |
| 609 | } | |
| 610 | } | |
| 611 | ||
| 612 | static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
| 613 | { | |
| 614 | struct gaim_connection *gc = data; | |
| 615 | struct yahoo_data *yd = gc->proto_data; | |
| 616 | char buf[1024]; | |
| 617 | int len; | |
| 618 | ||
| 619 | len = read(yd->fd, buf, sizeof(buf)); | |
| 620 | ||
| 621 | if (len <= 0) { | |
| 622 | hide_login_progress(gc, "Unable to read"); | |
| 623 | signoff(gc); | |
| 624 | return; | |
| 625 | } | |
| 626 | ||
| 627 | yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
| 628 | memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
| 629 | yd->rxlen += len; | |
| 630 | ||
| 631 | while (1) { | |
| 632 | struct yahoo_packet *pkt; | |
| 633 | int pos = 0; | |
| 634 | int pktlen; | |
| 635 | ||
| 636 | if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
| 637 | return; | |
| 638 | ||
| 639 | pos += 4; /* YMSG */ | |
| 640 | pos += 2; | |
| 641 | pos += 2; | |
| 642 | ||
| 643 | pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
| 644 | debug_printf("%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); | |
| 645 | ||
| 646 | if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
| 647 | return; | |
| 648 | ||
| 649 | yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
| 650 | ||
| 651 | pkt = yahoo_packet_new(0, 0, 0); | |
| 652 | ||
| 653 | pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
|
2741
a955e690580c
[gaim-migrate @ 2754]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2737
diff
changeset
|
654 | debug_printf("Yahoo Service: 0x%02x Status: %d\n", pkt->service, pkt->status); |
| 2681 | 655 | pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
| 656 | pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; | |
| 657 | ||
| 658 | yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
| 659 | ||
| 660 | yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
| 661 | if (yd->rxlen) { | |
| 662 | char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
| 663 | g_free(yd->rxqueue); | |
| 664 | yd->rxqueue = tmp; | |
| 665 | } else { | |
| 666 | g_free(yd->rxqueue); | |
| 667 | yd->rxqueue = NULL; | |
| 668 | } | |
| 669 | ||
| 670 | yahoo_packet_process(gc, pkt); | |
| 671 | ||
| 672 | yahoo_packet_free(pkt); | |
| 673 | } | |
| 674 | } | |
| 675 | ||
| 676 | static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
| 677 | { | |
| 678 | struct gaim_connection *gc = data; | |
| 679 | struct yahoo_data *yd; | |
| 680 | struct yahoo_packet *pkt; | |
| 681 | ||
| 682 | if (!g_slist_find(connections, gc)) { | |
| 683 | close(source); | |
| 684 | return; | |
| 685 | } | |
| 686 | ||
| 687 | if (source < 0) { | |
| 688 | hide_login_progress(gc, "Unable to connect"); | |
| 689 | signoff(gc); | |
| 690 | return; | |
| 691 | } | |
| 692 | ||
| 693 | yd = gc->proto_data; | |
| 694 | yd->fd = source; | |
| 695 | ||
| 696 | pkt = yahoo_packet_new(YAHOO_SERVICE_LOGON, YAHOO_STATUS_AVAILABLE, 0); | |
| 697 | ||
| 698 | yahoo_packet_hash(pkt, 0, gc->username); | |
| 699 | yahoo_packet_hash(pkt, 1, gc->username); | |
|
2795
b2e15894ab75
[gaim-migrate @ 2808]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2786
diff
changeset
|
700 | yahoo_packet_hash(pkt, 6, yahoo_crypt(gc->password, "$1$_2S43d5f$")); |
| 2681 | 701 | |
| 702 | yahoo_send_packet(yd, pkt); | |
| 703 | ||
| 704 | yahoo_packet_free(pkt); | |
| 705 | ||
| 706 | gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
| 707 | } | |
| 708 | ||
| 709 | static void yahoo_login(struct aim_user *user) { | |
| 710 | struct gaim_connection *gc = new_gaim_conn(user); | |
| 711 | struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); | |
| 712 | ||
| 713 | set_login_progress(gc, 1, "Connecting"); | |
| 714 | ||
| 715 | yd->fd = -1; | |
| 716 | yd->hash = g_hash_table_new(g_str_hash, g_str_equal); | |
| 717 | ||
| 2951 | 718 | if (!g_strncasecmp(user->proto_opt[USEROPT_PAGERHOST], "scs.yahoo.com", strlen("scs.yahoo.com"))) { |
| 719 | /* As of this morning, Yahoo is no longer supporting its server at scs.yahoo.com | |
| 720 | * I don't like to edit the preferences in a prpl, but we'll keep this here | |
| 721 | * for a while until everybody's happy again. -5 Feb 2002*/ | |
| 722 | debug_printf("Setting new Yahoo! server.\n"); | |
| 723 | g_snprintf(user->proto_opt[USEROPT_PAGERHOST], strlen("cs.yahoo.com") + 1, "cs.yahoo.com"); | |
| 724 | save_prefs(); | |
| 725 | } | |
| 726 | ||
| 727 | if (proxy_connect(user->proto_opt[USEROPT_PAGERHOST][0] ? | |
| 2681 | 728 | user->proto_opt[USEROPT_PAGERHOST] : YAHOO_PAGER_HOST, |
| 729 | user->proto_opt[USEROPT_PAGERPORT][0] ? | |
| 730 | atoi(user->proto_opt[USEROPT_PAGERPORT]) : YAHOO_PAGER_PORT, | |
|
2688
f1f8c4ff8794
[gaim-migrate @ 2701]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2687
diff
changeset
|
731 | yahoo_got_connected, gc) < 0) { |
| 2681 | 732 | hide_login_progress(gc, "Connection problem"); |
| 733 | signoff(gc); | |
| 734 | return; | |
| 735 | } | |
| 736 | ||
| 737 | } | |
| 738 | ||
| 739 | static gboolean yahoo_destroy_hash(gpointer key, gpointer val, gpointer data) | |
| 740 | { | |
| 741 | g_free(key); | |
| 742 | g_free(val); | |
| 743 | return TRUE; | |
| 744 | } | |
| 745 | ||
| 746 | static void yahoo_close(struct gaim_connection *gc) { | |
| 747 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 748 | g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); | |
| 749 | g_hash_table_destroy(yd->hash); | |
| 750 | if (yd->fd >= 0) | |
| 751 | close(yd->fd); | |
| 752 | if (yd->rxqueue) | |
| 753 | g_free(yd->rxqueue); | |
|
2687
664e22f507cf
[gaim-migrate @ 2700]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2686
diff
changeset
|
754 | yd->rxlen = 0; |
| 2681 | 755 | if (gc->inpa) |
| 756 | gaim_input_remove(gc->inpa); | |
| 757 | g_free(yd); | |
| 758 | } | |
| 759 | ||
| 760 | static char **yahoo_list_icon(int uc) | |
| 761 | { | |
| 762 | if ((uc >> 1) == YAHOO_STATUS_IDLE) | |
| 763 | return status_idle_xpm; | |
| 764 | else if (uc == 0) | |
| 765 | return status_here_xpm; | |
| 766 | return status_away_xpm; | |
| 767 | } | |
| 768 | ||
| 769 | static char *yahoo_get_status_string(enum yahoo_status a) | |
| 770 | { | |
| 771 | switch (a) { | |
| 772 | case YAHOO_STATUS_BRB: | |
| 773 | return "Be Right Back"; | |
| 774 | case YAHOO_STATUS_BUSY: | |
| 775 | return "Busy"; | |
| 776 | case YAHOO_STATUS_NOTATHOME: | |
| 777 | return "Not At Home"; | |
| 778 | case YAHOO_STATUS_NOTATDESK: | |
| 779 | return "Not At Desk"; | |
| 780 | case YAHOO_STATUS_NOTINOFFICE: | |
| 781 | return "Not In Office"; | |
| 782 | case YAHOO_STATUS_ONPHONE: | |
| 783 | return "On Phone"; | |
| 784 | case YAHOO_STATUS_ONVACATION: | |
| 785 | return "On Vacation"; | |
| 786 | case YAHOO_STATUS_OUTTOLUNCH: | |
| 787 | return "Out To Lunch"; | |
| 788 | case YAHOO_STATUS_STEPPEDOUT: | |
| 789 | return "Stepped Out"; | |
|
2873
9e56887eeb06
[gaim-migrate @ 2886]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2856
diff
changeset
|
790 | case YAHOO_STATUS_INVISIBLE: |
|
9e56887eeb06
[gaim-migrate @ 2886]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2856
diff
changeset
|
791 | return "Invisible"; |
|
2879
e417cf7111c4
[gaim-migrate @ 2892]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2878
diff
changeset
|
792 | default: |
|
e417cf7111c4
[gaim-migrate @ 2892]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2878
diff
changeset
|
793 | return "Online"; |
| 2681 | 794 | } |
| 795 | } | |
| 796 | ||
| 797 | static GList *yahoo_buddy_menu(struct gaim_connection *gc, char *who) | |
| 798 | { | |
| 799 | GList *m = NULL; | |
| 800 | struct proto_buddy_menu *pbm; | |
| 801 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 802 | struct buddy *b = find_buddy(gc, who); /* this should never be null. if it is, | |
| 803 | segfault and get the bug report. */ | |
| 804 | static char buf[1024]; | |
| 805 | ||
| 806 | if (!(b->uc & UC_UNAVAILABLE)) | |
| 807 | return NULL; | |
|
2876
6ac301f5786d
[gaim-migrate @ 2889]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2873
diff
changeset
|
808 | if (b->uc >> 1 == YAHOO_STATUS_IDLE) |
|
6ac301f5786d
[gaim-migrate @ 2889]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2873
diff
changeset
|
809 | return NULL; |
| 2681 | 810 | |
| 811 | pbm = g_new0(struct proto_buddy_menu, 1); | |
| 812 | if ((b->uc >> 1) != YAHOO_STATUS_CUSTOM) | |
| 813 | g_snprintf(buf, sizeof buf, "Status: %s", yahoo_get_status_string(b->uc >> 1)); | |
| 814 | else | |
| 815 | g_snprintf(buf, sizeof buf, "Custom Status: %s", | |
| 816 | (char *)g_hash_table_lookup(yd->hash, b->name)); | |
| 817 | pbm->label = buf; | |
| 818 | pbm->callback = NULL; | |
| 819 | pbm->gc = gc; | |
| 820 | m = g_list_append(m, pbm); | |
| 821 | ||
| 822 | return m; | |
| 823 | } | |
| 824 | ||
| 825 | static GList *yahoo_user_opts() | |
| 826 | { | |
| 827 | GList *m = NULL; | |
| 828 | struct proto_user_opt *puo; | |
| 829 | ||
| 830 | puo = g_new0(struct proto_user_opt, 1); | |
| 831 | puo->label = "Pager Host:"; | |
| 832 | puo->def = YAHOO_PAGER_HOST; | |
| 833 | puo->pos = USEROPT_PAGERHOST; | |
| 834 | m = g_list_append(m, puo); | |
| 835 | ||
| 836 | puo = g_new0(struct proto_user_opt, 1); | |
| 837 | puo->label = "Pager Port:"; | |
| 838 | puo->def = "5050"; | |
| 839 | puo->pos = USEROPT_PAGERPORT; | |
| 840 | m = g_list_append(m, puo); | |
| 841 | ||
| 842 | return m; | |
| 843 | } | |
| 844 | ||
| 845 | static void yahoo_act_id(gpointer data, char *entry) | |
| 846 | { | |
| 847 | struct gaim_connection *gc = data; | |
| 848 | struct yahoo_data *yd = gc->proto_data; | |
| 849 | ||
| 850 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 851 | yahoo_packet_hash(pkt, 3, entry); | |
| 852 | yahoo_send_packet(yd, pkt); | |
| 853 | yahoo_packet_free(pkt); | |
| 854 | ||
| 855 | g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", entry); | |
| 856 | } | |
| 857 | ||
| 858 | static void yahoo_do_action(struct gaim_connection *gc, char *act) | |
| 859 | { | |
| 860 | if (!strcmp(act, "Activate ID")) { | |
| 861 | do_prompt_dialog("Activate which ID:", gc->displayname, gc, yahoo_act_id, NULL); | |
| 862 | } | |
| 863 | } | |
| 864 | ||
| 865 | static GList *yahoo_actions() { | |
| 866 | GList *m = NULL; | |
| 867 | ||
| 868 | m = g_list_append(m, "Activate ID"); | |
| 869 | ||
| 870 | return m; | |
| 871 | } | |
| 872 | ||
| 873 | static int yahoo_send_im(struct gaim_connection *gc, char *who, char *what, int flags) | |
| 874 | { | |
| 875 | struct yahoo_data *yd = gc->proto_data; | |
| 876 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
| 877 | ||
| 878 | yahoo_packet_hash(pkt, 1, gc->displayname); | |
| 879 | yahoo_packet_hash(pkt, 5, who); | |
| 880 | yahoo_packet_hash(pkt, 14, what); | |
| 881 | ||
| 882 | yahoo_send_packet(yd, pkt); | |
| 883 | ||
| 884 | yahoo_packet_free(pkt); | |
| 885 | ||
| 886 | return 1; | |
| 887 | } | |
| 888 | ||
| 889 | static void yahoo_set_away(struct gaim_connection *gc, char *state, char *msg) | |
| 890 | { | |
| 891 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 892 | struct yahoo_packet *pkt; | |
|
2772
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
893 | int service; |
| 2681 | 894 | char s[4]; |
| 895 | ||
| 896 | gc->away = NULL; | |
| 897 | ||
| 898 | if (msg) { | |
| 899 | yd->current_status = YAHOO_STATUS_CUSTOM; | |
| 900 | gc->away = ""; | |
| 901 | } else if (state) { | |
| 902 | gc->away = ""; | |
| 903 | if (!strcmp(state, "Available")) { | |
| 904 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 905 | gc->away = NULL; | |
| 906 | } else if (!strcmp(state, "Be Right Back")) { | |
| 907 | yd->current_status = YAHOO_STATUS_BRB; | |
| 908 | } else if (!strcmp(state, "Busy")) { | |
| 909 | yd->current_status = YAHOO_STATUS_BUSY; | |
| 910 | } else if (!strcmp(state, "Not At Home")) { | |
| 911 | yd->current_status = YAHOO_STATUS_NOTATHOME; | |
| 912 | } else if (!strcmp(state, "Not At Desk")) { | |
| 913 | yd->current_status = YAHOO_STATUS_NOTATDESK; | |
| 914 | } else if (!strcmp(state, "Not In Office")) { | |
| 915 | yd->current_status = YAHOO_STATUS_NOTINOFFICE; | |
| 916 | } else if (!strcmp(state, "On Phone")) { | |
| 917 | yd->current_status = YAHOO_STATUS_ONPHONE; | |
| 918 | } else if (!strcmp(state, "On Vacation")) { | |
| 919 | yd->current_status = YAHOO_STATUS_ONVACATION; | |
| 920 | } else if (!strcmp(state, "Out To Lunch")) { | |
| 921 | yd->current_status = YAHOO_STATUS_OUTTOLUNCH; | |
| 922 | } else if (!strcmp(state, "Stepped Out")) { | |
| 923 | yd->current_status = YAHOO_STATUS_STEPPEDOUT; | |
| 924 | } else if (!strcmp(state, "Invisible")) { | |
| 925 | yd->current_status = YAHOO_STATUS_INVISIBLE; | |
| 926 | } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { | |
| 927 | if (gc->is_idle) { | |
| 928 | yd->current_status = YAHOO_STATUS_IDLE; | |
| 929 | } else { | |
| 930 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 931 | } | |
| 932 | gc->away = NULL; | |
| 933 | } | |
| 934 | } else if (gc->is_idle) { | |
| 935 | yd->current_status = YAHOO_STATUS_IDLE; | |
| 936 | } else { | |
| 937 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 938 | } | |
| 939 | ||
|
2772
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
940 | if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
|
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
941 | service = YAHOO_SERVICE_ISBACK; |
|
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
942 | else |
|
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
943 | service = YAHOO_SERVICE_ISAWAY; |
|
f7659670fc0b
[gaim-migrate @ 2785]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2771
diff
changeset
|
944 | pkt = yahoo_packet_new(service, yd->current_status, 0); |
| 2681 | 945 | g_snprintf(s, sizeof(s), "%d", yd->current_status); |
| 946 | yahoo_packet_hash(pkt, 10, s); | |
| 947 | if (yd->current_status == YAHOO_STATUS_CUSTOM) | |
| 948 | yahoo_packet_hash(pkt, 19, msg); | |
| 949 | ||
| 950 | yahoo_send_packet(yd, pkt); | |
| 951 | yahoo_packet_free(pkt); | |
| 952 | } | |
| 953 | ||
| 954 | static void yahoo_set_idle(struct gaim_connection *gc, int idle) | |
| 955 | { | |
| 956 | struct yahoo_data *yd = gc->proto_data; | |
| 957 | struct yahoo_packet *pkt = NULL; | |
| 958 | ||
| 959 | if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
| 960 | pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0); | |
| 961 | yd->current_status = YAHOO_STATUS_IDLE; | |
| 962 | } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
| 963 | pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
| 964 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 965 | } | |
| 966 | ||
| 967 | if (pkt) { | |
| 968 | char buf[4]; | |
| 969 | g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
| 970 | yahoo_packet_hash(pkt, 10, buf); | |
| 971 | yahoo_send_packet(yd, pkt); | |
| 972 | yahoo_packet_free(pkt); | |
| 973 | } | |
| 974 | } | |
| 975 | ||
| 976 | static GList *yahoo_away_states(struct gaim_connection *gc) | |
| 977 | { | |
| 978 | GList *m = NULL; | |
| 979 | ||
| 980 | m = g_list_append(m, "Available"); | |
| 981 | m = g_list_append(m, "Be Right Back"); | |
| 982 | m = g_list_append(m, "Busy"); | |
| 983 | m = g_list_append(m, "Not At Home"); | |
| 984 | m = g_list_append(m, "Not At Desk"); | |
| 985 | m = g_list_append(m, "Not In Office"); | |
| 986 | m = g_list_append(m, "On Phone"); | |
| 987 | m = g_list_append(m, "On Vacation"); | |
| 988 | m = g_list_append(m, "Out To Lunch"); | |
| 989 | m = g_list_append(m, "Stepped Out"); | |
| 990 | m = g_list_append(m, "Invisible"); | |
| 991 | m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
| 992 | ||
| 993 | return m; | |
| 994 | } | |
| 995 | ||
| 996 | static void yahoo_keepalive(struct gaim_connection *gc) | |
| 997 | { | |
| 998 | struct yahoo_data *yd = gc->proto_data; | |
| 999 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
| 1000 | yahoo_send_packet(yd, pkt); | |
| 1001 | yahoo_packet_free(pkt); | |
| 1002 | } | |
| 1003 | ||
| 1004 | static void yahoo_add_buddy(struct gaim_connection *gc, char *who) | |
| 1005 | { | |
| 1006 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 1007 | struct yahoo_packet *pkt; | |
| 1008 | struct group *g; | |
| 1009 | char *group = NULL; | |
| 1010 | ||
| 1011 | if (!yd->logged_in) | |
| 1012 | return; | |
| 1013 | ||
| 1014 | g = find_group_by_buddy(gc, who); | |
| 1015 | if (g) | |
| 1016 | group = g->name; | |
| 1017 | else | |
| 1018 | group = "Buddies"; | |
| 1019 | ||
| 1020 | pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, 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 void yahoo_remove_buddy(struct gaim_connection *gc, char *who, char *group) | |
| 1029 | { | |
| 1030 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 1031 | ||
| 1032 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 1033 | yahoo_packet_hash(pkt, 1, gc->displayname); | |
| 1034 | yahoo_packet_hash(pkt, 7, who); | |
| 1035 | yahoo_packet_hash(pkt, 65, group); | |
| 1036 | yahoo_send_packet(yd, pkt); | |
| 1037 | yahoo_packet_free(pkt); | |
| 1038 | } | |
| 1039 | ||
| 1040 | static struct prpl *my_protocol = NULL; | |
| 1041 | ||
| 1042 | void yahoo_init(struct prpl *ret) { | |
| 1043 | ret->protocol = PROTO_YAHOO; | |
| 1044 | ret->options = OPT_PROTO_MAIL_CHECK; | |
| 1045 | ret->name = yahoo_name; | |
| 1046 | ret->user_opts = yahoo_user_opts; | |
| 1047 | ret->login = yahoo_login; | |
| 1048 | ret->close = yahoo_close; | |
| 1049 | ret->buddy_menu = yahoo_buddy_menu; | |
| 1050 | ret->list_icon = yahoo_list_icon; | |
| 1051 | ret->actions = yahoo_actions; | |
| 1052 | ret->do_action = yahoo_do_action; | |
| 1053 | ret->send_im = yahoo_send_im; | |
| 1054 | ret->away_states = yahoo_away_states; | |
| 1055 | ret->set_away = yahoo_set_away; | |
| 1056 | ret->set_idle = yahoo_set_idle; | |
| 1057 | ret->keepalive = yahoo_keepalive; | |
| 1058 | ret->add_buddy = yahoo_add_buddy; | |
| 1059 | ret->remove_buddy = yahoo_remove_buddy; | |
| 1060 | ||
| 1061 | my_protocol = ret; | |
| 1062 | } | |
| 1063 | ||
| 1064 | #ifndef STATIC | |
| 1065 | ||
| 1066 | char *gaim_plugin_init(GModule *handle) | |
| 1067 | { | |
| 1068 | load_protocol(yahoo_init, sizeof(struct prpl)); | |
| 1069 | return NULL; | |
| 1070 | } | |
| 1071 | ||
| 1072 | void gaim_plugin_remove() | |
| 1073 | { | |
| 1074 | struct prpl *p = find_prpl(PROTO_YAHOO); | |
| 1075 | if (p == my_protocol) | |
| 1076 | unload_protocol(p); | |
| 1077 | } | |
| 1078 | ||
| 1079 | char *name() | |
| 1080 | { | |
| 1081 | return "Yahoo"; | |
| 1082 | } | |
| 1083 | ||
| 1084 | char *description() | |
| 1085 | { | |
| 1086 | return PRPL_DESC("Yahoo"); | |
| 1087 | } | |
| 1088 | ||
| 1089 | #endif |