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