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