Wed, 21 Mar 2001 07:25:43 +0000
[gaim-migrate @ 1635]
good stuff
| 1535 | 1 | |
| 2 | #define FAIM_INTERNAL | |
| 3 | #include <aim.h> | |
| 4 | ||
| 5 | /* | |
| 6 | * aim_add_buddy() | |
| 7 | * | |
| 8 | * Adds a single buddy to your buddy list after login. | |
| 9 | * | |
| 10 | * XXX this should just be an extension of setbuddylist() | |
| 11 | * | |
| 12 | */ | |
| 13 | faim_export unsigned long aim_add_buddy(struct aim_session_t *sess, | |
| 14 | struct aim_conn_t *conn, | |
| 15 | char *sn ) | |
| 16 | { | |
| 17 | struct command_tx_struct *newpacket; | |
| 18 | int i; | |
| 19 | ||
| 20 | if(!sn) | |
| 21 | return -1; | |
| 22 | ||
| 23 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+1+strlen(sn)))) | |
| 24 | return -1; | |
| 25 | ||
| 26 | newpacket->lock = 1; | |
| 27 | ||
| 28 | i = aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, sess->snac_nextid); | |
| 29 | i += aimutil_put8(newpacket->data+i, strlen(sn)); | |
| 30 | i += aimutil_putstr(newpacket->data+i, sn, strlen(sn)); | |
| 31 | ||
| 32 | aim_tx_enqueue(sess, newpacket ); | |
| 33 | ||
| 34 | aim_cachesnac(sess, 0x0003, 0x0004, 0x0000, sn, strlen(sn)+1); | |
| 35 | ||
| 36 | return sess->snac_nextid; | |
| 37 | } | |
| 38 | ||
| 39 | /* | |
| 40 | * XXX generalise to support removing multiple buddies (basically, its | |
| 41 | * the same as setbuddylist() but with a different snac subtype). | |
| 42 | * | |
| 43 | */ | |
| 44 | faim_export unsigned long aim_remove_buddy(struct aim_session_t *sess, | |
| 45 | struct aim_conn_t *conn, | |
| 46 | char *sn ) | |
| 47 | { | |
| 48 | struct command_tx_struct *newpacket; | |
| 49 | int i; | |
| 50 | ||
| 51 | if(!sn) | |
| 52 | return -1; | |
| 53 | ||
| 54 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+1+strlen(sn)))) | |
| 55 | return -1; | |
| 56 | ||
| 57 | newpacket->lock = 1; | |
| 58 | ||
| 59 | i = aim_putsnac(newpacket->data, 0x0003, 0x0005, 0x0000, sess->snac_nextid); | |
| 60 | ||
| 61 | i += aimutil_put8(newpacket->data+i, strlen(sn)); | |
| 62 | i += aimutil_putstr(newpacket->data+i, sn, strlen(sn)); | |
| 63 | ||
| 64 | aim_tx_enqueue(sess, newpacket); | |
| 65 | ||
| 66 | aim_cachesnac(sess, 0x0003, 0x0005, 0x0000, sn, strlen(sn)+1); | |
| 67 | ||
| 68 | return sess->snac_nextid; | |
| 69 | } | |
| 70 | ||
| 71 | faim_internal int aim_parse_buddyrights(struct aim_session_t *sess, | |
| 72 | struct command_rx_struct *command, ...) | |
| 73 | { | |
| 74 | rxcallback_t userfunc = NULL; | |
| 75 | int ret=1; | |
| 76 | struct aim_tlvlist_t *tlvlist; | |
| 77 | unsigned short maxbuddies = 0, maxwatchers = 0; | |
| 78 | ||
| 79 | /* | |
| 80 | * TLVs follow | |
| 81 | */ | |
| 82 | if (!(tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10))) | |
| 83 | return ret; | |
| 84 | ||
| 85 | /* | |
| 86 | * TLV type 0x0001: Maximum number of buddies. | |
| 87 | */ | |
| 88 | if (aim_gettlv(tlvlist, 0x0001, 1)) | |
| 89 | maxbuddies = aim_gettlv16(tlvlist, 0x0001, 1); | |
| 90 | ||
| 91 | /* | |
| 92 | * TLV type 0x0002: Maximum number of watchers. | |
| 93 | * | |
| 94 | * XXX: what the hell is a watcher? | |
| 95 | * | |
| 96 | */ | |
| 97 | if (aim_gettlv(tlvlist, 0x0002, 1)) | |
| 98 | maxwatchers = aim_gettlv16(tlvlist, 0x0002, 1); | |
| 99 | ||
| 100 | if ((userfunc = aim_callhandler(sess, command->conn, 0x0003, 0x0003))) | |
| 101 | ret = userfunc(sess, command, maxbuddies, maxwatchers); | |
| 102 | ||
| 103 | aim_freetlvchain(&tlvlist); | |
| 104 | ||
| 105 | return ret; | |
| 106 | } |