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