source: libfaim/bos.c @ aef17f2

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since aef17f2 was 5e53c4a, checked in by James M. Kretchmar <kretch@mit.edu>, 21 years ago
*** empty log message ***
  • Property mode set to 100644
File size: 4.3 KB
Line 
1
2#define FAIM_INTERNAL
3#include <aim.h>
4
5/* Request BOS rights (group 9, type 2) */
6faim_export int aim_bos_reqrights(aim_session_t *sess, aim_conn_t *conn)
7{
8        return aim_genericreq_n(sess, conn, 0x0009, 0x0002);
9}
10
11/* BOS Rights (group 9, type 3) */
12static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
13{
14        aim_rxcallback_t userfunc;
15        aim_tlvlist_t *tlvlist;
16        fu16_t maxpermits = 0, maxdenies = 0;
17        int ret = 0;
18
19        /*
20         * TLVs follow
21         */
22        tlvlist = aim_readtlvchain(bs);
23
24        /*
25         * TLV type 0x0001: Maximum number of buddies on permit list.
26         */
27        if (aim_gettlv(tlvlist, 0x0001, 1))
28                maxpermits = aim_gettlv16(tlvlist, 0x0001, 1);
29
30        /*
31         * TLV type 0x0002: Maximum number of buddies on deny list.
32         */
33        if (aim_gettlv(tlvlist, 0x0002, 1)) 
34                maxdenies = aim_gettlv16(tlvlist, 0x0002, 1);
35
36        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
37                ret = userfunc(sess, rx, maxpermits, maxdenies);
38
39        aim_freetlvchain(&tlvlist);
40
41        return ret; 
42}
43
44/*
45 * Set group permisson mask (group 9, type 4)
46 *
47 * Normally 0x1f (all classes).
48 *
49 * The group permission mask allows you to keep users of a certain
50 * class or classes from talking to you.  The mask should be
51 * a bitwise OR of all the user classes you want to see you.
52 *
53 */
54faim_export int aim_bos_setgroupperm(aim_session_t *sess, aim_conn_t *conn, fu32_t mask)
55{
56        return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask);
57}
58
59/*
60 * Modify permit/deny lists (group 9, types 5, 6, 7, and 8)
61 *
62 * Changes your visibility depending on changetype:
63 *
64 *  AIM_VISIBILITYCHANGE_PERMITADD: Lets provided list of names see you
65 *  AIM_VISIBILITYCHANGE_PERMIDREMOVE: Removes listed names from permit list
66 *  AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names
67 *  AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again
68 *
69 * list should be a list of
70 * screen names in the form "Screen Name One&ScreenNameTwo&" etc.
71 *
72 * Equivelents to options in WinAIM:
73 *   - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD
74 *      with only your name on it.
75 *   - Allow only users on my Buddy List: Send an
76 *      AIM_VISIBILITYCHANGE_PERMITADD with the list the same as your
77 *      buddy list
78 *   - Allow only the uesrs below: Send an AIM_VISIBILITYCHANGE_PERMITADD
79 *      with everyone listed that you want to see you.
80 *   - Block all users: Send an AIM_VISIBILITYCHANGE_PERMITADD with only
81 *      yourself in the list
82 *   - Block the users below: Send an AIM_VISIBILITYCHANGE_DENYADD with
83 *      the list of users to be blocked
84 *
85 * XXX ye gods.
86 */
87faim_export int aim_bos_changevisibility(aim_session_t *sess, aim_conn_t *conn, int changetype, const char *denylist)
88{
89        aim_frame_t *fr;
90        int packlen = 0;
91        fu16_t subtype;
92        char *localcpy = NULL, *tmpptr = NULL;
93        int i;
94        int listcount;
95        aim_snacid_t snacid;
96
97        if (!denylist)
98                return -EINVAL;
99
100        if (changetype == AIM_VISIBILITYCHANGE_PERMITADD)
101                subtype = 0x05;
102        else if (changetype == AIM_VISIBILITYCHANGE_PERMITREMOVE)
103                subtype = 0x06;
104        else if (changetype == AIM_VISIBILITYCHANGE_DENYADD)
105                subtype = 0x07;
106        else if (changetype == AIM_VISIBILITYCHANGE_DENYREMOVE)
107                subtype = 0x08;
108        else
109                return -EINVAL;
110
111        localcpy = strdup(denylist);
112
113        listcount = aimutil_itemcnt(localcpy, '&');
114        packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
115
116        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, packlen))) {
117                free(localcpy);
118                return -ENOMEM;
119        }
120
121        snacid = aim_cachesnac(sess, 0x0009, subtype, 0x0000, NULL, 0);
122        aim_putsnac(&fr->data, 0x0009, subtype, 0x00, snacid);
123
124        for (i = 0; (i < (listcount - 1)) && (i < 99); i++) {
125                tmpptr = aimutil_itemidx(localcpy, i, '&');
126
127                aimbs_put8(&fr->data, strlen(tmpptr));
128                aimbs_putraw(&fr->data, tmpptr, strlen(tmpptr));
129
130                free(tmpptr);
131        }
132        free(localcpy);
133
134        aim_tx_enqueue(sess, fr);
135
136        return 0;
137}
138
139static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
140{
141
142        if (snac->subtype == 0x0003)
143                return rights(sess, mod, rx, snac, bs);
144
145        return 0;
146}
147
148faim_internal int bos_modfirst(aim_session_t *sess, aim_module_t *mod)
149{
150
151        mod->family = 0x0009;
152        mod->version = 0x0001;
153        mod->toolid = 0x0110;
154        mod->toolversion = 0x047b;
155        mod->flags = 0;
156        strncpy(mod->name, "bos", sizeof(mod->name));
157        mod->snachandler = snachandler;
158
159        return 0;
160}
161
162
Note: See TracBrowser for help on using the repository browser.