src/protocols/oscar/bos.c

branch
gaim
changeset 20470
77693555855f
parent 13071
b98e72d4089a
parent 20469
b2836a24d81e
child 20471
1966704b3e42
equal deleted inserted replaced
13071:b98e72d4089a 20470:77693555855f
1 /*
2 * Family 0x0009 - Basic Oscar Service.
3 *
4 * The functionality of this family has been replaced by SSI.
5 */
6
7 #define FAIM_INTERNAL
8 #include <aim.h>
9
10 #include <string.h>
11
12 /* Subtype 0x0002 - Request BOS rights. */
13 faim_export int aim_bos_reqrights(aim_session_t *sess, aim_conn_t *conn)
14 {
15 return aim_genericreq_n_snacid(sess, conn, 0x0009, 0x0002);
16 }
17
18 /* Subtype 0x0003 - BOS Rights. */
19 static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
20 {
21 aim_rxcallback_t userfunc;
22 aim_tlvlist_t *tlvlist;
23 fu16_t maxpermits = 0, maxdenies = 0;
24 int ret = 0;
25
26 /*
27 * TLVs follow
28 */
29 tlvlist = aim_tlvlist_read(bs);
30
31 /*
32 * TLV type 0x0001: Maximum number of buddies on permit list.
33 */
34 if (aim_tlv_gettlv(tlvlist, 0x0001, 1))
35 maxpermits = aim_tlv_get16(tlvlist, 0x0001, 1);
36
37 /*
38 * TLV type 0x0002: Maximum number of buddies on deny list.
39 */
40 if (aim_tlv_gettlv(tlvlist, 0x0002, 1))
41 maxdenies = aim_tlv_get16(tlvlist, 0x0002, 1);
42
43 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
44 ret = userfunc(sess, rx, maxpermits, maxdenies);
45
46 aim_tlvlist_free(&tlvlist);
47
48 return ret;
49 }
50
51 /*
52 * Subtype 0x0004 - Set group permission mask.
53 *
54 * Normally 0x1f (all classes).
55 *
56 * The group permission mask allows you to keep users of a certain
57 * class or classes from talking to you. The mask should be
58 * a bitwise OR of all the user classes you want to see you.
59 *
60 */
61 faim_export int aim_bos_setgroupperm(aim_session_t *sess, aim_conn_t *conn, fu32_t mask)
62 {
63 return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask);
64 }
65
66 /*
67 * Stubtypes 0x0005, 0x0006, 0x0007, and 0x0008 - Modify permit/deny lists.
68 *
69 * Changes your visibility depending on changetype:
70 *
71 * AIM_VISIBILITYCHANGE_PERMITADD: Lets provided list of names see you
72 * AIM_VISIBILITYCHANGE_PERMIDREMOVE: Removes listed names from permit list
73 * AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names
74 * AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again
75 *
76 * list should be a list of
77 * screen names in the form "Screen Name One&ScreenNameTwo&" etc.
78 *
79 * Equivelents to options in WinAIM:
80 * - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD
81 * with only your name on it.
82 * - Allow only users on my Buddy List: Send an
83 * AIM_VISIBILITYCHANGE_PERMITADD with the list the same as your
84 * buddy list
85 * - Allow only the uesrs below: Send an AIM_VISIBILITYCHANGE_PERMITADD
86 * with everyone listed that you want to see you.
87 * - Block all users: Send an AIM_VISIBILITYCHANGE_PERMITADD with only
88 * yourself in the list
89 * - Block the users below: Send an AIM_VISIBILITYCHANGE_DENYADD with
90 * the list of users to be blocked
91 *
92 * XXX ye gods.
93 */
94 faim_export int aim_bos_changevisibility(aim_session_t *sess, aim_conn_t *conn, int changetype, const char *denylist)
95 {
96 aim_frame_t *fr;
97 int packlen = 0;
98 fu16_t subtype;
99 char *localcpy = NULL, *tmpptr = NULL;
100 int i;
101 int listcount;
102 aim_snacid_t snacid;
103
104 if (!denylist)
105 return -EINVAL;
106
107 if (changetype == AIM_VISIBILITYCHANGE_PERMITADD)
108 subtype = 0x05;
109 else if (changetype == AIM_VISIBILITYCHANGE_PERMITREMOVE)
110 subtype = 0x06;
111 else if (changetype == AIM_VISIBILITYCHANGE_DENYADD)
112 subtype = 0x07;
113 else if (changetype == AIM_VISIBILITYCHANGE_DENYREMOVE)
114 subtype = 0x08;
115 else
116 return -EINVAL;
117
118 localcpy = strdup(denylist);
119
120 listcount = aimutil_itemcnt(localcpy, '&');
121 packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
122
123 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, packlen))) {
124 free(localcpy);
125 return -ENOMEM;
126 }
127
128 snacid = aim_cachesnac(sess, 0x0009, subtype, 0x0000, NULL, 0);
129 aim_putsnac(&fr->data, 0x0009, subtype, 0x00, snacid);
130
131 for (i = 0; (i < (listcount - 1)) && (i < 99); i++) {
132 tmpptr = aimutil_itemindex(localcpy, i, '&');
133
134 aimbs_put8(&fr->data, strlen(tmpptr));
135 aimbs_putstr(&fr->data, tmpptr);
136
137 free(tmpptr);
138 }
139 free(localcpy);
140
141 aim_tx_enqueue(sess, fr);
142
143 return 0;
144 }
145
146 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
147 {
148
149 if (snac->subtype == 0x0003)
150 return rights(sess, mod, rx, snac, bs);
151
152 return 0;
153 }
154
155 faim_internal int bos_modfirst(aim_session_t *sess, aim_module_t *mod)
156 {
157
158 mod->family = 0x0009;
159 mod->version = 0x0001;
160 mod->toolid = 0x0110;
161 mod->toolversion = 0x0629;
162 mod->flags = 0;
163 strncpy(mod->name, "bos", sizeof(mod->name));
164 mod->snachandler = snachandler;
165
166 return 0;
167 }

mercurial