]>
Commit | Line | Data |
---|---|---|
9de3ca7e | 1 | |
2 | /* | |
3 | * aim_misc.c | |
4 | * | |
5 | * TODO: Seperate a lot of this into an aim_bos.c. | |
6 | * | |
7 | * Other things... | |
8 | * | |
9 | * - Idle setting | |
10 | * | |
11 | * | |
12 | */ | |
13 | ||
37ee990e | 14 | #define FAIM_INTERNAL |
dd60ff8b | 15 | #include <aim.h> |
9de3ca7e | 16 | |
17 | /* | |
18 | * aim_bos_setidle() | |
19 | * | |
20 | * Should set your current idle time in seconds. Idealy, OSCAR should | |
21 | * do this for us. But, it doesn't. The client must call this to set idle | |
22 | * time. | |
23 | * | |
24 | */ | |
5ac21963 | 25 | faim_export unsigned long aim_bos_setidle(struct aim_session_t *sess, |
26 | struct aim_conn_t *conn, | |
27 | u_long idletime) | |
9de3ca7e | 28 | { |
a25832e6 | 29 | return aim_genericreq_l(sess, conn, 0x0001, 0x0011, &idletime); |
9de3ca7e | 30 | } |
31 | ||
32 | ||
33 | /* | |
34 | * aim_bos_changevisibility(conn, changtype, namelist) | |
35 | * | |
36 | * Changes your visibility depending on changetype: | |
37 | * | |
38 | * AIM_VISIBILITYCHANGE_PERMITADD: Lets provided list of names see you | |
39 | * AIM_VISIBILITYCHANGE_PERMIDREMOVE: Removes listed names from permit list | |
40 | * AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names | |
41 | * AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again | |
42 | * | |
43 | * list should be a list of | |
44 | * screen names in the form "Screen Name One&ScreenNameTwo&" etc. | |
45 | * | |
46 | * Equivelents to options in WinAIM: | |
47 | * - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD | |
48 | * with only your name on it. | |
49 | * - Allow only users on my Buddy List: Send an | |
50 | * AIM_VISIBILITYCHANGE_PERMITADD with the list the same as your | |
51 | * buddy list | |
52 | * - Allow only the uesrs below: Send an AIM_VISIBILITYCHANGE_PERMITADD | |
53 | * with everyone listed that you want to see you. | |
54 | * - Block all users: Send an AIM_VISIBILITYCHANGE_PERMITADD with only | |
55 | * yourself in the list | |
56 | * - Block the users below: Send an AIM_VISIBILITYCHANGE_DENYADD with | |
57 | * the list of users to be blocked | |
58 | * | |
59 | * | |
60 | */ | |
5ac21963 | 61 | faim_export unsigned long aim_bos_changevisibility(struct aim_session_t *sess, |
62 | struct aim_conn_t *conn, | |
63 | int changetype, | |
64 | char *denylist) | |
9de3ca7e | 65 | { |
5b79dc93 | 66 | struct command_tx_struct *newpacket; |
67 | int packlen = 0; | |
9de3ca7e | 68 | u_short subtype; |
69 | ||
70 | char *localcpy = NULL; | |
71 | char *tmpptr = NULL; | |
72 | int i,j; | |
73 | int listcount; | |
74 | ||
75 | if (!denylist) | |
76 | return 0; | |
77 | ||
9de3ca7e | 78 | localcpy = (char *) malloc(strlen(denylist)+1); |
79 | memcpy(localcpy, denylist, strlen(denylist)+1); | |
80 | ||
81 | listcount = aimutil_itemcnt(localcpy, '&'); | |
5b79dc93 | 82 | packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9; |
9de3ca7e | 83 | |
646c6b52 | 84 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen))) |
5b79dc93 | 85 | return -1; |
9de3ca7e | 86 | |
5b79dc93 | 87 | newpacket->lock = 1; |
9de3ca7e | 88 | |
89 | switch(changetype) | |
90 | { | |
91 | case AIM_VISIBILITYCHANGE_PERMITADD: subtype = 0x05; break; | |
92 | case AIM_VISIBILITYCHANGE_PERMITREMOVE: subtype = 0x06; break; | |
93 | case AIM_VISIBILITYCHANGE_DENYADD: subtype = 0x07; break; | |
94 | case AIM_VISIBILITYCHANGE_DENYREMOVE: subtype = 0x08; break; | |
95 | default: | |
5b79dc93 | 96 | free(newpacket->data); |
97 | free(newpacket); | |
9de3ca7e | 98 | return 0; |
99 | } | |
100 | ||
101 | /* We actually DO NOT send a SNAC ID with this one! */ | |
5b79dc93 | 102 | aim_putsnac(newpacket->data, 0x0009, subtype, 0x00, 0); |
9de3ca7e | 103 | |
104 | j = 10; /* the next byte */ | |
105 | ||
106 | for (i=0; (i < (listcount - 1)) && (i < 99); i++) | |
107 | { | |
108 | tmpptr = aimutil_itemidx(localcpy, i, '&'); | |
109 | ||
5b79dc93 | 110 | newpacket->data[j] = strlen(tmpptr); |
111 | memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr)); | |
9de3ca7e | 112 | j += strlen(tmpptr)+1; |
113 | free(tmpptr); | |
114 | } | |
115 | free(localcpy); | |
116 | ||
5b79dc93 | 117 | newpacket->lock = 0; |
9de3ca7e | 118 | |
5b79dc93 | 119 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 120 | |
a25832e6 | 121 | return (sess->snac_nextid); /* dont increment */ |
9de3ca7e | 122 | |
123 | } | |
124 | ||
125 | ||
126 | ||
127 | /* | |
128 | * aim_bos_setbuddylist(buddylist) | |
129 | * | |
130 | * This just builds the "set buddy list" command then queues it. | |
131 | * | |
132 | * buddy_list = "Screen Name One&ScreenNameTwo&"; | |
133 | * | |
5b79dc93 | 134 | * TODO: Clean this up. |
135 | * | |
136 | * XXX: I can't stress the TODO enough. | |
9de3ca7e | 137 | * |
138 | */ | |
5ac21963 | 139 | faim_export unsigned long aim_bos_setbuddylist(struct aim_session_t *sess, |
140 | struct aim_conn_t *conn, | |
141 | char *buddy_list) | |
9de3ca7e | 142 | { |
143 | int i, j; | |
144 | ||
5b79dc93 | 145 | struct command_tx_struct *newpacket; |
9de3ca7e | 146 | |
c78446b5 | 147 | int len = 0; |
9de3ca7e | 148 | |
149 | char *localcpy = NULL; | |
150 | char *tmpptr = NULL; | |
151 | ||
c78446b5 | 152 | len = 10; /* 10B SNAC headers */ |
9de3ca7e | 153 | |
c78446b5 | 154 | if (!buddy_list || !(localcpy = (char *) malloc(strlen(buddy_list)+1))) |
5b79dc93 | 155 | return -1; |
c78446b5 | 156 | strncpy(localcpy, buddy_list, strlen(buddy_list)+1); |
9de3ca7e | 157 | |
158 | i = 0; | |
159 | tmpptr = strtok(localcpy, "&"); | |
c78446b5 | 160 | while ((tmpptr != NULL) && (i < 150)) { |
646c6b52 | 161 | faimdprintf(sess, 2, "---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr)); |
c78446b5 | 162 | len += 1+strlen(tmpptr); |
163 | i++; | |
164 | tmpptr = strtok(NULL, "&"); | |
165 | } | |
646c6b52 | 166 | faimdprintf(sess, 2, "*** send buddy list len: %d (%x)\n", len, len); |
9de3ca7e | 167 | |
646c6b52 | 168 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, len))) |
5b79dc93 | 169 | return -1; |
9de3ca7e | 170 | |
5b79dc93 | 171 | newpacket->lock = 1; |
172 | ||
c78446b5 | 173 | aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, 0); |
9de3ca7e | 174 | |
175 | j = 10; /* the next byte */ | |
176 | ||
c78446b5 | 177 | strncpy(localcpy, buddy_list, strlen(buddy_list)+1); |
9de3ca7e | 178 | i = 0; |
c78446b5 | 179 | tmpptr = strtok(localcpy, "&"); |
180 | while ((tmpptr != NULL) & (i < 150)) { | |
646c6b52 | 181 | faimdprintf(sess, 2, "---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr)); |
c78446b5 | 182 | newpacket->data[j] = strlen(tmpptr); |
183 | memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr)); | |
184 | j += 1+strlen(tmpptr); | |
185 | i++; | |
186 | tmpptr = strtok(NULL, "&"); | |
187 | } | |
9de3ca7e | 188 | |
5b79dc93 | 189 | newpacket->lock = 0; |
9de3ca7e | 190 | |
5b79dc93 | 191 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 192 | |
c78446b5 | 193 | free(localcpy); |
194 | ||
195 | return (sess->snac_nextid); | |
9de3ca7e | 196 | } |
197 | ||
198 | /* | |
199 | * aim_bos_setprofile(profile) | |
200 | * | |
201 | * Gives BOS your profile. | |
202 | * | |
26af6789 | 203 | * |
9de3ca7e | 204 | */ |
5ac21963 | 205 | faim_export unsigned long aim_bos_setprofile(struct aim_session_t *sess, |
206 | struct aim_conn_t *conn, | |
207 | char *profile, | |
208 | char *awaymsg, | |
209 | unsigned short caps) | |
9de3ca7e | 210 | { |
5b79dc93 | 211 | struct command_tx_struct *newpacket; |
b69540e3 | 212 | int i = 0, tmp, caplen; |
0c20631f | 213 | |
646c6b52 | 214 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152+strlen(profile)+1+(awaymsg?strlen(awaymsg):0)))) |
5b79dc93 | 215 | return -1; |
9de3ca7e | 216 | |
5b79dc93 | 217 | i += aim_putsnac(newpacket->data, 0x0002, 0x004, 0x0000, sess->snac_nextid); |
218 | i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); | |
219 | i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(profile), profile); | |
26af6789 | 220 | /* why do we send this twice? */ |
5b79dc93 | 221 | i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); |
9de3ca7e | 222 | |
0c20631f | 223 | /* Away message -- we send this no matter what, even if its blank */ |
224 | if (awaymsg) | |
5b79dc93 | 225 | i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(awaymsg), awaymsg); |
0c20631f | 226 | else |
5b79dc93 | 227 | i += aim_puttlv_str(newpacket->data+i, 0x0004, 0x0000, NULL); |
26af6789 | 228 | |
229 | /* Capability information. */ | |
b69540e3 | 230 | |
231 | tmp = (i += aimutil_put16(newpacket->data+i, 0x0005)); | |
232 | i += aimutil_put16(newpacket->data+i, 0x0000); /* rewritten later */ | |
233 | i += (caplen = aim_putcap(newpacket->data+i, 512, caps)); | |
234 | aimutil_put16(newpacket->data+tmp, caplen); /* rewrite TLV size */ | |
235 | ||
5b79dc93 | 236 | newpacket->commandlen = i; |
237 | aim_tx_enqueue(sess, newpacket); | |
9de3ca7e | 238 | |
a25832e6 | 239 | return (sess->snac_nextid++); |
9de3ca7e | 240 | } |
241 | ||
9de3ca7e | 242 | /* |
243 | * aim_bos_clientready() | |
244 | * | |
245 | * Send Client Ready. | |
246 | * | |
9de3ca7e | 247 | */ |
5ac21963 | 248 | faim_export unsigned long aim_bos_clientready(struct aim_session_t *sess, |
249 | struct aim_conn_t *conn) | |
9de3ca7e | 250 | { |
64c78745 | 251 | struct aim_tool_version tools[] = { |
d6c9fcf0 | 252 | {0x0001, 0x0003, AIM_TOOL_WIN32, 0x0686}, |
253 | {0x0002, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
254 | {0x0003, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
255 | {0x0004, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
256 | {0x0006, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
257 | {0x0008, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
258 | {0x0009, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
259 | {0x000a, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
260 | {0x000b, 0x0001, AIM_TOOL_WIN32, 0x0001} | |
9de3ca7e | 261 | }; |
d6c9fcf0 | 262 | int i,j; |
5b79dc93 | 263 | struct command_tx_struct *newpacket; |
d6c9fcf0 | 264 | int toolcount = sizeof(tools)/sizeof(struct aim_tool_version); |
265 | ||
646c6b52 | 266 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152))) |
5b79dc93 | 267 | return -1; |
268 | ||
269 | newpacket->lock = 1; | |
270 | ||
d6c9fcf0 | 271 | i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid); |
272 | aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0); | |
273 | ||
274 | for (j = 0; j < toolcount; j++) { | |
275 | i += aimutil_put16(newpacket->data+i, tools[j].group); | |
276 | i += aimutil_put16(newpacket->data+i, tools[j].version); | |
277 | i += aimutil_put16(newpacket->data+i, tools[j].tool); | |
278 | i += aimutil_put16(newpacket->data+i, tools[j].toolversion); | |
279 | } | |
280 | ||
281 | newpacket->commandlen = i; | |
282 | newpacket->lock = 0; | |
9de3ca7e | 283 | |
5b79dc93 | 284 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 285 | |
d6c9fcf0 | 286 | return sess->snac_nextid; |
9de3ca7e | 287 | } |
288 | ||
289 | /* | |
9de3ca7e | 290 | * Request Rate Information. |
291 | * | |
9de3ca7e | 292 | */ |
5ac21963 | 293 | faim_export unsigned long aim_bos_reqrate(struct aim_session_t *sess, |
294 | struct aim_conn_t *conn) | |
9de3ca7e | 295 | { |
a25832e6 | 296 | return aim_genericreq_n(sess, conn, 0x0001, 0x0006); |
9de3ca7e | 297 | } |
298 | ||
299 | /* | |
9de3ca7e | 300 | * Rate Information Response Acknowledge. |
301 | * | |
302 | */ | |
5ac21963 | 303 | faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *sess, |
304 | struct aim_conn_t *conn) | |
9de3ca7e | 305 | { |
5b79dc93 | 306 | struct command_tx_struct *newpacket; |
c78446b5 | 307 | int packlen = 20, i=0; |
9de3ca7e | 308 | |
646c6b52 | 309 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen))) |
c78446b5 | 310 | return (sess->snac_nextid); |
5b79dc93 | 311 | |
312 | newpacket->lock = 1; | |
9de3ca7e | 313 | |
c78446b5 | 314 | i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0); |
5b79dc93 | 315 | i += aimutil_put16(newpacket->data+i, 0x0001); |
316 | i += aimutil_put16(newpacket->data+i, 0x0002); | |
317 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
318 | i += aimutil_put16(newpacket->data+i, 0x0004); | |
c78446b5 | 319 | i += aimutil_put16(newpacket->data+i, 0x0005); |
5925849b | 320 | |
321 | newpacket->commandlen = i; | |
322 | newpacket->lock = 0; | |
323 | ||
5b79dc93 | 324 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 325 | |
c78446b5 | 326 | return (sess->snac_nextid); |
9de3ca7e | 327 | } |
328 | ||
329 | /* | |
330 | * aim_bos_setprivacyflags() | |
331 | * | |
332 | * Sets privacy flags. Normally 0x03. | |
333 | * | |
334 | * Bit 1: Allows other AIM users to see how long you've been idle. | |
98c88242 | 335 | * Bit 2: Allows other AIM users to see how long you've been a member. |
9de3ca7e | 336 | * |
337 | */ | |
5ac21963 | 338 | faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *sess, |
339 | struct aim_conn_t *conn, | |
340 | u_long flags) | |
9de3ca7e | 341 | { |
a25832e6 | 342 | return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags); |
9de3ca7e | 343 | } |
344 | ||
345 | /* | |
346 | * aim_bos_reqpersonalinfo() | |
347 | * | |
348 | * Requests the current user's information. Can't go generic on this one | |
349 | * because aparently it uses SNAC flags. | |
350 | * | |
351 | */ | |
5ac21963 | 352 | faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *sess, |
353 | struct aim_conn_t *conn) | |
9de3ca7e | 354 | { |
c78446b5 | 355 | return aim_genericreq_n(sess, conn, 0x0001, 0x000e); |
9de3ca7e | 356 | } |
357 | ||
5ac21963 | 358 | faim_export unsigned long aim_setversions(struct aim_session_t *sess, |
359 | struct aim_conn_t *conn) | |
01b59e1e | 360 | { |
5b79dc93 | 361 | struct command_tx_struct *newpacket; |
0c20631f | 362 | int i; |
01b59e1e | 363 | |
646c6b52 | 364 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + (4*12)))) |
5b79dc93 | 365 | return -1; |
366 | ||
367 | newpacket->lock = 1; | |
01b59e1e | 368 | |
5b79dc93 | 369 | i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid); |
ee49b735 | 370 | aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0); |
01b59e1e | 371 | |
5b79dc93 | 372 | i += aimutil_put16(newpacket->data+i, 0x0001); |
373 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
26af6789 | 374 | |
ee49b735 | 375 | i += aimutil_put16(newpacket->data+i, 0x0013); |
376 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
377 | ||
5b79dc93 | 378 | i += aimutil_put16(newpacket->data+i, 0x0002); |
379 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 380 | |
5b79dc93 | 381 | i += aimutil_put16(newpacket->data+i, 0x0003); |
382 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 383 | |
5b79dc93 | 384 | i += aimutil_put16(newpacket->data+i, 0x0004); |
385 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 386 | |
5b79dc93 | 387 | i += aimutil_put16(newpacket->data+i, 0x0006); |
388 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 389 | |
5b79dc93 | 390 | i += aimutil_put16(newpacket->data+i, 0x0008); |
391 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 392 | |
5b79dc93 | 393 | i += aimutil_put16(newpacket->data+i, 0x0009); |
394 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 395 | |
5b79dc93 | 396 | i += aimutil_put16(newpacket->data+i, 0x000a); |
397 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 398 | |
5b79dc93 | 399 | i += aimutil_put16(newpacket->data+i, 0x000b); |
5b79dc93 | 400 | i += aimutil_put16(newpacket->data+i, 0x0001); |
26af6789 | 401 | |
ee49b735 | 402 | i += aimutil_put16(newpacket->data+i, 0x000c); |
5b79dc93 | 403 | i += aimutil_put16(newpacket->data+i, 0x0001); |
01b59e1e | 404 | |
5925849b | 405 | newpacket->commandlen = i; |
5b79dc93 | 406 | newpacket->lock = 0; |
407 | aim_tx_enqueue(sess, newpacket); | |
01b59e1e | 408 | |
ee49b735 | 409 | return sess->snac_nextid; |
01b59e1e | 410 | } |
411 | ||
412 | ||
9de3ca7e | 413 | /* |
414 | * aim_bos_reqservice(serviceid) | |
415 | * | |
416 | * Service request. | |
417 | * | |
418 | */ | |
5ac21963 | 419 | faim_export unsigned long aim_bos_reqservice(struct aim_session_t *sess, |
a25832e6 | 420 | struct aim_conn_t *conn, |
421 | u_short serviceid) | |
9de3ca7e | 422 | { |
a25832e6 | 423 | return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid); |
9de3ca7e | 424 | } |
425 | ||
f0a7908e | 426 | /* |
427 | * aim_bos_nop() | |
428 | * | |
429 | * No-op. WinAIM sends these every 4min or so to keep | |
98c88242 | 430 | * the connection alive. Its not real necessary. |
f0a7908e | 431 | * |
432 | */ | |
5ac21963 | 433 | faim_export unsigned long aim_bos_nop(struct aim_session_t *sess, |
434 | struct aim_conn_t *conn) | |
f0a7908e | 435 | { |
436 | return aim_genericreq_n(sess, conn, 0x0001, 0x0016); | |
437 | } | |
438 | ||
44d6f2dc | 439 | /* |
440 | * aim_flap_nop() | |
441 | * | |
442 | * No-op. WinAIM 4.x sends these _every minute_ to keep | |
443 | * the connection alive. | |
444 | */ | |
445 | faim_export unsigned long aim_flap_nop(struct aim_session_t *sess, | |
446 | struct aim_conn_t *conn) | |
447 | { | |
448 | struct command_tx_struct *newpacket; | |
449 | ||
646c6b52 | 450 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0005, 0))) |
44d6f2dc | 451 | return sess->snac_nextid; |
452 | ||
453 | newpacket->lock = 1; | |
454 | newpacket->commandlen = 0; | |
455 | newpacket->lock = 0; | |
456 | ||
457 | aim_tx_enqueue(sess, newpacket); | |
458 | ||
459 | return (sess->snac_nextid); | |
460 | } | |
461 | ||
9de3ca7e | 462 | /* |
463 | * aim_bos_reqrights() | |
464 | * | |
465 | * Request BOS rights. | |
466 | * | |
467 | */ | |
5ac21963 | 468 | faim_export unsigned long aim_bos_reqrights(struct aim_session_t *sess, |
469 | struct aim_conn_t *conn) | |
9de3ca7e | 470 | { |
a25832e6 | 471 | return aim_genericreq_n(sess, conn, 0x0009, 0x0002); |
9de3ca7e | 472 | } |
473 | ||
474 | /* | |
475 | * aim_bos_reqbuddyrights() | |
476 | * | |
477 | * Request Buddy List rights. | |
478 | * | |
479 | */ | |
5ac21963 | 480 | faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *sess, |
481 | struct aim_conn_t *conn) | |
9de3ca7e | 482 | { |
a25832e6 | 483 | return aim_genericreq_n(sess, conn, 0x0003, 0x0002); |
9de3ca7e | 484 | } |
485 | ||
98c88242 | 486 | /* |
487 | * aim_send_warning(struct aim_session_t *sess, | |
488 | * struct aim_conn_t *conn, char *destsn, int anon) | |
489 | * send a warning to destsn. | |
490 | * anon is anonymous or not; | |
491 | * AIM_WARN_ANON anonymous | |
492 | * | |
493 | * returns -1 on error (couldn't alloc packet), next snacid on success. | |
494 | * | |
495 | */ | |
5ac21963 | 496 | faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon) |
98c88242 | 497 | { |
498 | struct command_tx_struct *newpacket; | |
499 | int curbyte; | |
500 | ||
646c6b52 | 501 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, strlen(destsn)+13))) |
98c88242 | 502 | return -1; |
503 | ||
504 | newpacket->lock = 1; | |
505 | ||
506 | curbyte = 0; | |
507 | curbyte += aim_putsnac(newpacket->data+curbyte, | |
508 | 0x0004, 0x0008, 0x0000, sess->snac_nextid); | |
509 | ||
510 | curbyte += aimutil_put16(newpacket->data+curbyte, (anon & AIM_WARN_ANON)?1:0); | |
511 | ||
512 | curbyte += aimutil_put8(newpacket->data+curbyte, strlen(destsn)); | |
513 | ||
514 | curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn)); | |
515 | ||
516 | newpacket->commandlen = curbyte; | |
517 | newpacket->lock = 0; | |
518 | ||
519 | aim_tx_enqueue(sess, newpacket); | |
520 | ||
521 | return (sess->snac_nextid++); | |
522 | } | |
523 | ||
e5012450 | 524 | /* |
525 | * aim_debugconn_sendconnect() | |
526 | * | |
527 | * For aimdebugd. If you don't know what it is, you don't want to. | |
528 | */ | |
5ac21963 | 529 | faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess, |
530 | struct aim_conn_t *conn) | |
e5012450 | 531 | { |
532 | return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT); | |
533 | } | |
534 | ||
9de3ca7e | 535 | /* |
536 | * Generic routine for sending commands. | |
537 | * | |
538 | * | |
539 | * I know I can do this in a smarter way...but I'm not thinking straight | |
540 | * right now... | |
541 | * | |
542 | * I had one big function that handled all three cases, but then it broke | |
543 | * and I split it up into three. But then I fixed it. I just never went | |
544 | * back to the single. I don't see any advantage to doing it either way. | |
545 | * | |
546 | */ | |
5ac21963 | 547 | faim_internal unsigned long aim_genericreq_n(struct aim_session_t *sess, |
548 | struct aim_conn_t *conn, | |
549 | u_short family, u_short subtype) | |
9de3ca7e | 550 | { |
5b79dc93 | 551 | struct command_tx_struct *newpacket; |
9de3ca7e | 552 | |
646c6b52 | 553 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10))) |
5b79dc93 | 554 | return 0; |
9de3ca7e | 555 | |
5b79dc93 | 556 | newpacket->lock = 1; |
9de3ca7e | 557 | |
5b79dc93 | 558 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
ee49b735 | 559 | |
560 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); | |
561 | ||
5b79dc93 | 562 | aim_tx_enqueue(sess, newpacket); |
ee49b735 | 563 | return sess->snac_nextid; |
9de3ca7e | 564 | } |
565 | ||
566 | /* | |
567 | * | |
568 | * | |
569 | */ | |
5ac21963 | 570 | faim_internal unsigned long aim_genericreq_l(struct aim_session_t *sess, |
571 | struct aim_conn_t *conn, | |
572 | u_short family, u_short subtype, | |
573 | u_long *longdata) | |
9de3ca7e | 574 | { |
5b79dc93 | 575 | struct command_tx_struct *newpacket; |
9de3ca7e | 576 | u_long newlong; |
577 | ||
578 | /* If we don't have data, there's no reason to use this function */ | |
579 | if (!longdata) | |
a25832e6 | 580 | return aim_genericreq_n(sess, conn, family, subtype); |
9de3ca7e | 581 | |
646c6b52 | 582 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+sizeof(u_long)))) |
5b79dc93 | 583 | return -1; |
9de3ca7e | 584 | |
5b79dc93 | 585 | newpacket->lock = 1; |
9de3ca7e | 586 | |
5b79dc93 | 587 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
ee49b735 | 588 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); |
9de3ca7e | 589 | |
590 | /* copy in data */ | |
591 | newlong = htonl(*longdata); | |
5b79dc93 | 592 | memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long)); |
9de3ca7e | 593 | |
5b79dc93 | 594 | aim_tx_enqueue(sess, newpacket); |
ee49b735 | 595 | return sess->snac_nextid; |
9de3ca7e | 596 | } |
597 | ||
5ac21963 | 598 | faim_internal unsigned long aim_genericreq_s(struct aim_session_t *sess, |
599 | struct aim_conn_t *conn, | |
600 | u_short family, u_short subtype, | |
601 | u_short *shortdata) | |
9de3ca7e | 602 | { |
5b79dc93 | 603 | struct command_tx_struct *newpacket; |
9de3ca7e | 604 | u_short newshort; |
605 | ||
606 | /* If we don't have data, there's no reason to use this function */ | |
607 | if (!shortdata) | |
a25832e6 | 608 | return aim_genericreq_n(sess, conn, family, subtype); |
9de3ca7e | 609 | |
646c6b52 | 610 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+sizeof(u_short)))) |
5b79dc93 | 611 | return -1; |
9de3ca7e | 612 | |
5b79dc93 | 613 | newpacket->lock = 1; |
9de3ca7e | 614 | |
5b79dc93 | 615 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
ee49b735 | 616 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); |
9de3ca7e | 617 | |
618 | /* copy in data */ | |
619 | newshort = htons(*shortdata); | |
5b79dc93 | 620 | memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short)); |
9de3ca7e | 621 | |
5b79dc93 | 622 | aim_tx_enqueue(sess, newpacket); |
ee49b735 | 623 | return sess->snac_nextid; |
9de3ca7e | 624 | } |
625 | ||
626 | /* | |
627 | * aim_bos_reqlocaterights() | |
628 | * | |
629 | * Request Location services rights. | |
630 | * | |
631 | */ | |
5ac21963 | 632 | faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *sess, |
633 | struct aim_conn_t *conn) | |
9de3ca7e | 634 | { |
a25832e6 | 635 | return aim_genericreq_n(sess, conn, 0x0002, 0x0002); |
9de3ca7e | 636 | } |
637 | ||
638 | /* | |
e88ba395 | 639 | * aim_bos_reqicbmparaminfo() |
9de3ca7e | 640 | * |
641 | * Request ICBM parameter information. | |
642 | * | |
643 | */ | |
5ac21963 | 644 | faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *sess, |
645 | struct aim_conn_t *conn) | |
9de3ca7e | 646 | { |
a25832e6 | 647 | return aim_genericreq_n(sess, conn, 0x0004, 0x0004); |
9de3ca7e | 648 | } |
e88ba395 | 649 | |
c78446b5 | 650 | /* |
651 | * Add ICBM parameter? Huh? | |
652 | */ | |
5ac21963 | 653 | faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess, |
654 | struct aim_conn_t *conn) | |
c78446b5 | 655 | { |
656 | struct command_tx_struct *newpacket; | |
657 | int packlen = 10+16, i=0; | |
658 | ||
646c6b52 | 659 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen))) |
c78446b5 | 660 | return (sess->snac_nextid); |
661 | ||
662 | newpacket->lock = 1; | |
663 | ||
664 | i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid); | |
ee49b735 | 665 | aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0); |
666 | ||
c78446b5 | 667 | i += aimutil_put16(newpacket->data+i, 0x0000); |
668 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
669 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
670 | i += aimutil_put16(newpacket->data+i, 0x1f40); | |
671 | i += aimutil_put16(newpacket->data+i, 0x03e7); | |
672 | i += aimutil_put16(newpacket->data+i, 0x03e7); | |
673 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
674 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
675 | ||
676 | aim_tx_enqueue(sess, newpacket); | |
677 | ||
ee49b735 | 678 | return sess->snac_nextid; |
c78446b5 | 679 | } |
f2d214f9 | 680 | |
681 | /* | |
682 | * Set directory profile data (not the same as aim_bos_setprofile!) | |
683 | */ | |
684 | faim_export unsigned long aim_setdirectoryinfo(struct aim_session_t *sess, struct aim_conn_t *conn, char *first, char *middle, char *last, char *maiden, char *nickname, char *street, char *city, char *state, char *zip, int country, unsigned short privacy) | |
685 | { | |
686 | struct command_tx_struct *newpacket; | |
687 | int packlen = 0, i = 0; | |
688 | ||
689 | packlen += 2+2+2; | |
690 | ||
691 | if(first) /* TLV 0001 */ | |
692 | packlen += (strlen(first) + 4); | |
693 | if(middle) | |
694 | packlen += (strlen(middle) + 4); | |
695 | if(last) | |
696 | packlen += (strlen(last) + 4); | |
697 | if(maiden) | |
698 | packlen += (strlen(maiden) + 4); | |
699 | if(nickname) | |
700 | packlen += (strlen(nickname) + 4); | |
701 | if(street) | |
702 | packlen += (strlen(street) + 4); | |
703 | if(state) | |
704 | packlen += (strlen(state) + 4); | |
705 | if(city) | |
706 | packlen += (strlen(city) + 4); | |
707 | if(zip) | |
708 | packlen += (strlen(zip) + 4); | |
709 | ||
646c6b52 | 710 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen+10))) |
f2d214f9 | 711 | return -1; |
712 | ||
713 | newpacket->lock = 1; | |
714 | ||
715 | i = aim_putsnac(newpacket->data, 0x0002, 0x0009, 0x0000, 0); | |
716 | ||
717 | /* 000a/0002: privacy: 1 to allow search/disp, 0 to disallow */ | |
718 | i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy); | |
719 | ||
720 | ||
721 | if (first) | |
722 | i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen(first), first); | |
723 | if (middle) | |
724 | i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen(middle), middle); | |
725 | if (last) | |
726 | i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(last), last); | |
727 | if (maiden) | |
728 | i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(maiden), maiden); | |
729 | if (nickname) | |
730 | i += aim_puttlv_str(newpacket->data+i, 0x000c, strlen(nickname), nickname); | |
731 | if (street) | |
732 | i += aim_puttlv_str(newpacket->data+i, 0x0021, strlen(street), street); | |
733 | if (city) | |
734 | i += aim_puttlv_str(newpacket->data+i, 0x0008, strlen(city), city); | |
735 | if (state) | |
736 | i += aim_puttlv_str(newpacket->data+i, 0x0007, strlen(state), state); | |
737 | if (zip) | |
738 | i += aim_puttlv_str(newpacket->data+i, 0x000d, strlen(zip), zip); | |
739 | ||
740 | newpacket->commandlen = i; | |
741 | newpacket->lock = 0; | |
742 | ||
743 | aim_tx_enqueue(sess, newpacket); | |
744 | ||
745 | return(sess->snac_nextid); | |
746 | } | |
747 | ||
748 | faim_export unsigned long aim_setuserinterests(struct aim_session_t *sess, struct aim_conn_t *conn, char *interest1, char *interest2, char *interest3, char *interest4, char *interest5, unsigned short privacy) | |
749 | { | |
750 | struct command_tx_struct *newpacket; | |
751 | int packlen = 0, i = 0; | |
752 | ||
753 | packlen += 2+2+2; | |
754 | ||
755 | if(interest1) | |
756 | packlen += (strlen(interest1) + 4); | |
757 | if(interest2) | |
758 | packlen += (strlen(interest2) + 4); | |
759 | if(interest3) | |
760 | packlen += (strlen(interest3) + 4); | |
761 | if(interest4) | |
762 | packlen += (strlen(interest4) + 4); | |
763 | if(interest5) | |
764 | packlen += (strlen(interest5) + 4) ; | |
765 | ||
766 | ||
646c6b52 | 767 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen+10))) |
f2d214f9 | 768 | return -1; |
769 | ||
770 | newpacket->lock = 1; | |
771 | ||
772 | i = aim_putsnac(newpacket->data, 0x0002, 0x000f, 0x0000, 0); | |
773 | ||
774 | /* 000a/0002: 0000 ?? ?privacy? */ | |
775 | i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy); | |
776 | ||
777 | if(interest1) | |
778 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest1); | |
779 | if(interest2) | |
780 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest2), interest2); | |
781 | if(interest3) | |
782 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest3), interest3); | |
783 | if(interest4) | |
784 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest4), interest4); | |
785 | if(interest5) | |
786 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest5); | |
787 | ||
788 | newpacket->commandlen = i; | |
789 | newpacket->lock = 0; | |
790 | ||
791 | aim_tx_enqueue(sess, newpacket); | |
792 | ||
793 | return(sess->snac_nextid); | |
794 | } | |
ec6b8da8 | 795 | |
796 | faim_export unsigned long aim_icq_setstatus(struct aim_session_t *sess, | |
797 | struct aim_conn_t *conn, | |
798 | unsigned long status) | |
799 | { | |
800 | struct command_tx_struct *newpacket; | |
801 | int i; | |
802 | unsigned long data; | |
803 | ||
804 | data = 0x00030000 | status; /* yay for error checking ;^) */ | |
805 | ||
646c6b52 | 806 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + 4))) |
ec6b8da8 | 807 | return -1; |
808 | ||
809 | newpacket->lock = 1; | |
810 | ||
811 | i = aim_putsnac(newpacket->data, 0x0001, 0x001e, 0x0000, 0x0000001e); | |
812 | i += aim_puttlv_32(newpacket->data+i, 0x0006, data); | |
813 | ||
814 | newpacket->commandlen = i; | |
815 | newpacket->lock = 0; | |
816 | ||
817 | aim_tx_enqueue(sess, newpacket); | |
818 | ||
819 | return(sess->snac_nextid); | |
820 | } |