Mercurial > pidgin
comparison libgaim/protocols/oscar/family_bos.c @ 14192:60b1bc8dbf37
[gaim-migrate @ 16863]
Renamed 'core' to 'libgaim'
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Sat, 19 Aug 2006 01:50:10 +0000 |
parents | |
children | f3573d941d66 |
comparison
equal
deleted
inserted
replaced
14191:009db0b357b5 | 14192:60b1bc8dbf37 |
---|---|
1 /* | |
2 * Gaim's oscar protocol plugin | |
3 * This file is the legal property of its developers. | |
4 * Please see the AUTHORS file distributed alongside this file. | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
20 | |
21 /* | |
22 * Family 0x0009 - Basic Oscar Service. | |
23 * | |
24 * The functionality of this family has been replaced by SSI. | |
25 */ | |
26 | |
27 #include "oscar.h" | |
28 | |
29 #include <string.h> | |
30 | |
31 /* Subtype 0x0002 - Request BOS rights. */ | |
32 void | |
33 aim_bos_reqrights(OscarData *od, FlapConnection *conn) | |
34 { | |
35 aim_genericreq_n_snacid(od, conn, 0x0009, 0x0002); | |
36 } | |
37 | |
38 /* Subtype 0x0003 - BOS Rights. */ | |
39 static int rights(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
40 { | |
41 aim_rxcallback_t userfunc; | |
42 aim_tlvlist_t *tlvlist; | |
43 guint16 maxpermits = 0, maxdenies = 0; | |
44 int ret = 0; | |
45 | |
46 /* | |
47 * TLVs follow | |
48 */ | |
49 tlvlist = aim_tlvlist_read(bs); | |
50 | |
51 /* | |
52 * TLV type 0x0001: Maximum number of buddies on permit list. | |
53 */ | |
54 if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) | |
55 maxpermits = aim_tlv_get16(tlvlist, 0x0001, 1); | |
56 | |
57 /* | |
58 * TLV type 0x0002: Maximum number of buddies on deny list. | |
59 */ | |
60 if (aim_tlv_gettlv(tlvlist, 0x0002, 1)) | |
61 maxdenies = aim_tlv_get16(tlvlist, 0x0002, 1); | |
62 | |
63 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) | |
64 ret = userfunc(od, conn, frame, maxpermits, maxdenies); | |
65 | |
66 aim_tlvlist_free(&tlvlist); | |
67 | |
68 return ret; | |
69 } | |
70 | |
71 /* | |
72 * Subtype 0x0004 - Set group permission mask. | |
73 * | |
74 * Normally 0x1f (all classes). | |
75 * | |
76 * The group permission mask allows you to keep users of a certain | |
77 * class or classes from talking to you. The mask should be | |
78 * a bitwise OR of all the user classes you want to see you. | |
79 * | |
80 */ | |
81 int aim_bos_setgroupperm(OscarData *od, FlapConnection *conn, guint32 mask) | |
82 { | |
83 return aim_genericreq_l(od, conn, 0x0009, 0x0004, &mask); | |
84 } | |
85 | |
86 /* | |
87 * Stubtypes 0x0005, 0x0006, 0x0007, and 0x0008 - Modify permit/deny lists. | |
88 * | |
89 * Changes your visibility depending on changetype: | |
90 * | |
91 * AIM_VISIBILITYCHANGE_PERMITADD: Lets provided list of names see you | |
92 * AIM_VISIBILITYCHANGE_PERMIDREMOVE: Removes listed names from permit list | |
93 * AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names | |
94 * AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again | |
95 * | |
96 * list should be a list of | |
97 * screen names in the form "Screen Name One&ScreenNameTwo&" etc. | |
98 * | |
99 * Equivelents to options in WinAIM: | |
100 * - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD | |
101 * with only your name on it. | |
102 * - Allow only users on my Buddy List: Send an | |
103 * AIM_VISIBILITYCHANGE_PERMITADD with the list the same as your | |
104 * buddy list | |
105 * - Allow only the uesrs below: Send an AIM_VISIBILITYCHANGE_PERMITADD | |
106 * with everyone listed that you want to see you. | |
107 * - Block all users: Send an AIM_VISIBILITYCHANGE_PERMITADD with only | |
108 * yourself in the list | |
109 * - Block the users below: Send an AIM_VISIBILITYCHANGE_DENYADD with | |
110 * the list of users to be blocked | |
111 * | |
112 * XXX ye gods. | |
113 */ | |
114 int aim_bos_changevisibility(OscarData *od, FlapConnection *conn, int changetype, const char *denylist) | |
115 { | |
116 FlapFrame *frame; | |
117 int packlen = 0; | |
118 guint16 subtype; | |
119 char *localcpy = NULL, *tmpptr = NULL; | |
120 int i; | |
121 int listcount; | |
122 aim_snacid_t snacid; | |
123 | |
124 if (!denylist) | |
125 return -EINVAL; | |
126 | |
127 if (changetype == AIM_VISIBILITYCHANGE_PERMITADD) | |
128 subtype = 0x05; | |
129 else if (changetype == AIM_VISIBILITYCHANGE_PERMITREMOVE) | |
130 subtype = 0x06; | |
131 else if (changetype == AIM_VISIBILITYCHANGE_DENYADD) | |
132 subtype = 0x07; | |
133 else if (changetype == AIM_VISIBILITYCHANGE_DENYREMOVE) | |
134 subtype = 0x08; | |
135 else | |
136 return -EINVAL; | |
137 | |
138 localcpy = strdup(denylist); | |
139 | |
140 listcount = aimutil_itemcnt(localcpy, '&'); | |
141 packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9; | |
142 | |
143 frame = flap_frame_new(od, 0x02, packlen); | |
144 | |
145 snacid = aim_cachesnac(od, 0x0009, subtype, 0x0000, NULL, 0); | |
146 aim_putsnac(&frame->data, 0x0009, subtype, 0x00, snacid); | |
147 | |
148 for (i = 0; (i < (listcount - 1)) && (i < 99); i++) { | |
149 tmpptr = aimutil_itemindex(localcpy, i, '&'); | |
150 | |
151 byte_stream_put8(&frame->data, strlen(tmpptr)); | |
152 byte_stream_putstr(&frame->data, tmpptr); | |
153 | |
154 free(tmpptr); | |
155 } | |
156 free(localcpy); | |
157 | |
158 flap_connection_send(conn, frame); | |
159 | |
160 return 0; | |
161 } | |
162 | |
163 static int | |
164 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
165 { | |
166 if (snac->subtype == 0x0003) | |
167 return rights(od, conn, mod, frame, snac, bs); | |
168 | |
169 return 0; | |
170 } | |
171 | |
172 int | |
173 bos_modfirst(OscarData *od, aim_module_t *mod) | |
174 { | |
175 mod->family = 0x0009; | |
176 mod->version = 0x0001; | |
177 mod->toolid = 0x0110; | |
178 mod->toolversion = 0x0629; | |
179 mod->flags = 0; | |
180 strncpy(mod->name, "bos", sizeof(mod->name)); | |
181 mod->snachandler = snachandler; | |
182 | |
183 return 0; | |
184 } |