]>
Commit | Line | Data |
---|---|---|
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 | ||
14 | #define FAIM_INTERNAL | |
15 | #include <faim/aim.h> | |
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 | */ | |
25 | faim_export unsigned long aim_bos_setidle(struct aim_session_t *sess, | |
26 | struct aim_conn_t *conn, | |
27 | u_long idletime) | |
28 | { | |
29 | return aim_genericreq_l(sess, conn, 0x0001, 0x0011, &idletime); | |
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 | */ | |
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) | |
65 | { | |
66 | struct command_tx_struct *newpacket; | |
67 | int packlen = 0; | |
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 | ||
78 | localcpy = (char *) malloc(strlen(denylist)+1); | |
79 | memcpy(localcpy, denylist, strlen(denylist)+1); | |
80 | ||
81 | listcount = aimutil_itemcnt(localcpy, '&'); | |
82 | packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9; | |
83 | ||
84 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen))) | |
85 | return -1; | |
86 | ||
87 | newpacket->lock = 1; | |
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: | |
96 | free(newpacket->data); | |
97 | free(newpacket); | |
98 | return 0; | |
99 | } | |
100 | ||
101 | /* We actually DO NOT send a SNAC ID with this one! */ | |
102 | aim_putsnac(newpacket->data, 0x0009, subtype, 0x00, 0); | |
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 | ||
110 | newpacket->data[j] = strlen(tmpptr); | |
111 | memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr)); | |
112 | j += strlen(tmpptr)+1; | |
113 | free(tmpptr); | |
114 | } | |
115 | free(localcpy); | |
116 | ||
117 | newpacket->lock = 0; | |
118 | ||
119 | aim_tx_enqueue(sess, newpacket); | |
120 | ||
121 | return (sess->snac_nextid); /* dont increment */ | |
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 | * | |
134 | * TODO: Clean this up. | |
135 | * | |
136 | * XXX: I can't stress the TODO enough. | |
137 | * | |
138 | */ | |
139 | faim_export unsigned long aim_bos_setbuddylist(struct aim_session_t *sess, | |
140 | struct aim_conn_t *conn, | |
141 | char *buddy_list) | |
142 | { | |
143 | int i, j; | |
144 | ||
145 | struct command_tx_struct *newpacket; | |
146 | ||
147 | int len = 0; | |
148 | ||
149 | char *localcpy = NULL; | |
150 | char *tmpptr = NULL; | |
151 | ||
152 | len = 10; /* 10B SNAC headers */ | |
153 | ||
154 | if (!buddy_list || !(localcpy = (char *) malloc(strlen(buddy_list)+1))) | |
155 | return -1; | |
156 | strncpy(localcpy, buddy_list, strlen(buddy_list)+1); | |
157 | ||
158 | i = 0; | |
159 | tmpptr = strtok(localcpy, "&"); | |
160 | while ((tmpptr != NULL) && (i < 150)) { | |
161 | #if debug > 0 | |
162 | printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr)); | |
163 | #endif | |
164 | len += 1+strlen(tmpptr); | |
165 | i++; | |
166 | tmpptr = strtok(NULL, "&"); | |
167 | } | |
168 | #if debug > 0 | |
169 | printf("*** send buddy list len: %d (%x)\n", len, len); | |
170 | #endif | |
171 | ||
172 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, len))) | |
173 | return -1; | |
174 | ||
175 | newpacket->lock = 1; | |
176 | ||
177 | aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, 0); | |
178 | ||
179 | j = 10; /* the next byte */ | |
180 | ||
181 | strncpy(localcpy, buddy_list, strlen(buddy_list)+1); | |
182 | i = 0; | |
183 | tmpptr = strtok(localcpy, "&"); | |
184 | while ((tmpptr != NULL) & (i < 150)) { | |
185 | #if debug > 0 | |
186 | printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr)); | |
187 | #endif | |
188 | newpacket->data[j] = strlen(tmpptr); | |
189 | memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr)); | |
190 | j += 1+strlen(tmpptr); | |
191 | i++; | |
192 | tmpptr = strtok(NULL, "&"); | |
193 | } | |
194 | ||
195 | newpacket->lock = 0; | |
196 | ||
197 | aim_tx_enqueue(sess, newpacket); | |
198 | ||
199 | free(localcpy); | |
200 | ||
201 | return (sess->snac_nextid); | |
202 | } | |
203 | ||
204 | /* | |
205 | * aim_bos_setprofile(profile) | |
206 | * | |
207 | * Gives BOS your profile. | |
208 | * | |
209 | * | |
210 | */ | |
211 | faim_export unsigned long aim_bos_setprofile(struct aim_session_t *sess, | |
212 | struct aim_conn_t *conn, | |
213 | char *profile, | |
214 | char *awaymsg, | |
215 | unsigned short caps) | |
216 | { | |
217 | struct command_tx_struct *newpacket; | |
218 | int i = 0, tmp, caplen; | |
219 | ||
220 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152+strlen(profile)+1+(awaymsg?strlen(awaymsg):0)))) | |
221 | return -1; | |
222 | ||
223 | i += aim_putsnac(newpacket->data, 0x0002, 0x004, 0x0000, sess->snac_nextid); | |
224 | i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); | |
225 | i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(profile), profile); | |
226 | /* why do we send this twice? */ | |
227 | i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); | |
228 | ||
229 | /* Away message -- we send this no matter what, even if its blank */ | |
230 | if (awaymsg) | |
231 | i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(awaymsg), awaymsg); | |
232 | else | |
233 | i += aim_puttlv_str(newpacket->data+i, 0x0004, 0x0000, NULL); | |
234 | ||
235 | /* Capability information. */ | |
236 | ||
237 | tmp = (i += aimutil_put16(newpacket->data+i, 0x0005)); | |
238 | i += aimutil_put16(newpacket->data+i, 0x0000); /* rewritten later */ | |
239 | i += (caplen = aim_putcap(newpacket->data+i, 512, caps)); | |
240 | aimutil_put16(newpacket->data+tmp, caplen); /* rewrite TLV size */ | |
241 | ||
242 | newpacket->commandlen = i; | |
243 | aim_tx_enqueue(sess, newpacket); | |
244 | ||
245 | return (sess->snac_nextid++); | |
246 | } | |
247 | ||
248 | /* | |
249 | * aim_bos_setgroupperm(mask) | |
250 | * | |
251 | * Set group permisson mask. Normally 0x1f (all classes). | |
252 | * | |
253 | * The group permission mask allows you to keep users of a certain | |
254 | * class or classes from talking to you. The mask should be | |
255 | * a bitwise OR of all the user classes you want to see you. | |
256 | * | |
257 | */ | |
258 | faim_export unsigned long aim_bos_setgroupperm(struct aim_session_t *sess, | |
259 | struct aim_conn_t *conn, | |
260 | u_long mask) | |
261 | { | |
262 | return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask); | |
263 | } | |
264 | ||
265 | faim_internal int aim_parse_bosrights(struct aim_session_t *sess, | |
266 | struct command_rx_struct *command, ...) | |
267 | { | |
268 | rxcallback_t userfunc = NULL; | |
269 | int ret=1; | |
270 | struct aim_tlvlist_t *tlvlist; | |
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 (aim_gettlv(tlvlist, 0x0001, 1)) | |
283 | maxpermits = aim_gettlv16(tlvlist, 0x0001, 1); | |
284 | ||
285 | /* | |
286 | * TLV type 0x0002: Maximum number of buddies on deny list. | |
287 | * | |
288 | */ | |
289 | if (aim_gettlv(tlvlist, 0x0002, 1)) | |
290 | maxdenies = aim_gettlv16(tlvlist, 0x0002, 1); | |
291 | ||
292 | if ((userfunc = aim_callhandler(command->conn, 0x0009, 0x0003))) | |
293 | ret = userfunc(sess, command, maxpermits, maxdenies); | |
294 | ||
295 | aim_freetlvchain(&tlvlist); | |
296 | ||
297 | return ret; | |
298 | } | |
299 | ||
300 | /* | |
301 | * aim_bos_clientready() | |
302 | * | |
303 | * Send Client Ready. | |
304 | * | |
305 | */ | |
306 | faim_export unsigned long aim_bos_clientready(struct aim_session_t *sess, | |
307 | struct aim_conn_t *conn) | |
308 | { | |
309 | #define AIM_TOOL_JAVA 0x0001 | |
310 | #define AIM_TOOL_MAC 0x0002 | |
311 | #define AIM_TOOL_WIN16 0x0003 | |
312 | #define AIM_TOOL_WIN32 0x0004 | |
313 | #define AIM_TOOL_MAC68K 0x0005 | |
314 | #define AIM_TOOL_MACPPC 0x0006 | |
315 | struct aim_tool_version { | |
316 | unsigned short group; | |
317 | unsigned short version; | |
318 | unsigned short tool; | |
319 | unsigned short toolversion; | |
320 | } tools[] = { | |
321 | {0x0001, 0x0003, AIM_TOOL_WIN32, 0x0686}, | |
322 | {0x0002, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
323 | {0x0003, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
324 | {0x0004, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
325 | {0x0006, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
326 | {0x0008, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
327 | {0x0009, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
328 | {0x000a, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
329 | {0x000b, 0x0001, AIM_TOOL_WIN32, 0x0001} | |
330 | }; | |
331 | int i,j; | |
332 | struct command_tx_struct *newpacket; | |
333 | int toolcount = sizeof(tools)/sizeof(struct aim_tool_version); | |
334 | ||
335 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) | |
336 | return -1; | |
337 | ||
338 | newpacket->lock = 1; | |
339 | ||
340 | i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid); | |
341 | aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0); | |
342 | ||
343 | for (j = 0; j < toolcount; j++) { | |
344 | i += aimutil_put16(newpacket->data+i, tools[j].group); | |
345 | i += aimutil_put16(newpacket->data+i, tools[j].version); | |
346 | i += aimutil_put16(newpacket->data+i, tools[j].tool); | |
347 | i += aimutil_put16(newpacket->data+i, tools[j].toolversion); | |
348 | } | |
349 | ||
350 | newpacket->commandlen = i; | |
351 | newpacket->lock = 0; | |
352 | ||
353 | aim_tx_enqueue(sess, newpacket); | |
354 | ||
355 | return sess->snac_nextid; | |
356 | } | |
357 | ||
358 | /* | |
359 | * Request Rate Information. | |
360 | * | |
361 | */ | |
362 | faim_export unsigned long aim_bos_reqrate(struct aim_session_t *sess, | |
363 | struct aim_conn_t *conn) | |
364 | { | |
365 | return aim_genericreq_n(sess, conn, 0x0001, 0x0006); | |
366 | } | |
367 | ||
368 | /* | |
369 | * Rate Information Response Acknowledge. | |
370 | * | |
371 | */ | |
372 | faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *sess, | |
373 | struct aim_conn_t *conn) | |
374 | { | |
375 | struct command_tx_struct *newpacket; | |
376 | int packlen = 20, i=0; | |
377 | ||
378 | if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen))) | |
379 | return (sess->snac_nextid); | |
380 | ||
381 | newpacket->lock = 1; | |
382 | ||
383 | i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0); | |
384 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
385 | i += aimutil_put16(newpacket->data+i, 0x0002); | |
386 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
387 | i += aimutil_put16(newpacket->data+i, 0x0004); | |
388 | i += aimutil_put16(newpacket->data+i, 0x0005); | |
389 | ||
390 | newpacket->commandlen = i; | |
391 | newpacket->lock = 0; | |
392 | ||
393 | aim_tx_enqueue(sess, newpacket); | |
394 | ||
395 | return (sess->snac_nextid); | |
396 | } | |
397 | ||
398 | /* | |
399 | * aim_bos_setprivacyflags() | |
400 | * | |
401 | * Sets privacy flags. Normally 0x03. | |
402 | * | |
403 | * Bit 1: Allows other AIM users to see how long you've been idle. | |
404 | * Bit 2: Allows other AIM users to see how long you've been a member. | |
405 | * | |
406 | */ | |
407 | faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *sess, | |
408 | struct aim_conn_t *conn, | |
409 | u_long flags) | |
410 | { | |
411 | return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags); | |
412 | } | |
413 | ||
414 | /* | |
415 | * aim_bos_reqpersonalinfo() | |
416 | * | |
417 | * Requests the current user's information. Can't go generic on this one | |
418 | * because aparently it uses SNAC flags. | |
419 | * | |
420 | */ | |
421 | faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *sess, | |
422 | struct aim_conn_t *conn) | |
423 | { | |
424 | return aim_genericreq_n(sess, conn, 0x0001, 0x000e); | |
425 | } | |
426 | ||
427 | faim_export unsigned long aim_setversions(struct aim_session_t *sess, | |
428 | struct aim_conn_t *conn) | |
429 | { | |
430 | struct command_tx_struct *newpacket; | |
431 | int i; | |
432 | ||
433 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*12)))) | |
434 | return -1; | |
435 | ||
436 | newpacket->lock = 1; | |
437 | ||
438 | i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid); | |
439 | aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0); | |
440 | ||
441 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
442 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
443 | ||
444 | i += aimutil_put16(newpacket->data+i, 0x0013); | |
445 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
446 | ||
447 | i += aimutil_put16(newpacket->data+i, 0x0002); | |
448 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
449 | ||
450 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
451 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
452 | ||
453 | i += aimutil_put16(newpacket->data+i, 0x0004); | |
454 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
455 | ||
456 | i += aimutil_put16(newpacket->data+i, 0x0006); | |
457 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
458 | ||
459 | i += aimutil_put16(newpacket->data+i, 0x0008); | |
460 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
461 | ||
462 | i += aimutil_put16(newpacket->data+i, 0x0009); | |
463 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
464 | ||
465 | i += aimutil_put16(newpacket->data+i, 0x000a); | |
466 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
467 | ||
468 | i += aimutil_put16(newpacket->data+i, 0x000b); | |
469 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
470 | ||
471 | i += aimutil_put16(newpacket->data+i, 0x000c); | |
472 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
473 | ||
474 | newpacket->commandlen = i; | |
475 | newpacket->lock = 0; | |
476 | aim_tx_enqueue(sess, newpacket); | |
477 | ||
478 | return sess->snac_nextid; | |
479 | } | |
480 | ||
481 | ||
482 | /* | |
483 | * aim_bos_reqservice(serviceid) | |
484 | * | |
485 | * Service request. | |
486 | * | |
487 | */ | |
488 | faim_export unsigned long aim_bos_reqservice(struct aim_session_t *sess, | |
489 | struct aim_conn_t *conn, | |
490 | u_short serviceid) | |
491 | { | |
492 | return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid); | |
493 | } | |
494 | ||
495 | /* | |
496 | * aim_bos_nop() | |
497 | * | |
498 | * No-op. WinAIM sends these every 4min or so to keep | |
499 | * the connection alive. Its not real necessary. | |
500 | * | |
501 | */ | |
502 | faim_export unsigned long aim_bos_nop(struct aim_session_t *sess, | |
503 | struct aim_conn_t *conn) | |
504 | { | |
505 | return aim_genericreq_n(sess, conn, 0x0001, 0x0016); | |
506 | } | |
507 | ||
508 | /* | |
509 | * aim_flap_nop() | |
510 | * | |
511 | * No-op. WinAIM 4.x sends these _every minute_ to keep | |
512 | * the connection alive. | |
513 | */ | |
514 | faim_export unsigned long aim_flap_nop(struct aim_session_t *sess, | |
515 | struct aim_conn_t *conn) | |
516 | { | |
517 | struct command_tx_struct *newpacket; | |
518 | ||
519 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0005, conn, 0))) | |
520 | return sess->snac_nextid; | |
521 | ||
522 | newpacket->lock = 1; | |
523 | newpacket->commandlen = 0; | |
524 | newpacket->lock = 0; | |
525 | ||
526 | aim_tx_enqueue(sess, newpacket); | |
527 | ||
528 | return (sess->snac_nextid); | |
529 | } | |
530 | ||
531 | /* | |
532 | * aim_bos_reqrights() | |
533 | * | |
534 | * Request BOS rights. | |
535 | * | |
536 | */ | |
537 | faim_export unsigned long aim_bos_reqrights(struct aim_session_t *sess, | |
538 | struct aim_conn_t *conn) | |
539 | { | |
540 | return aim_genericreq_n(sess, conn, 0x0009, 0x0002); | |
541 | } | |
542 | ||
543 | /* | |
544 | * aim_bos_reqbuddyrights() | |
545 | * | |
546 | * Request Buddy List rights. | |
547 | * | |
548 | */ | |
549 | faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *sess, | |
550 | struct aim_conn_t *conn) | |
551 | { | |
552 | return aim_genericreq_n(sess, conn, 0x0003, 0x0002); | |
553 | } | |
554 | ||
555 | /* | |
556 | * aim_send_warning(struct aim_session_t *sess, | |
557 | * struct aim_conn_t *conn, char *destsn, int anon) | |
558 | * send a warning to destsn. | |
559 | * anon is anonymous or not; | |
560 | * AIM_WARN_ANON anonymous | |
561 | * | |
562 | * returns -1 on error (couldn't alloc packet), next snacid on success. | |
563 | * | |
564 | */ | |
565 | faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon) | |
566 | { | |
567 | struct command_tx_struct *newpacket; | |
568 | int curbyte; | |
569 | ||
570 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(destsn)+13))) | |
571 | return -1; | |
572 | ||
573 | newpacket->lock = 1; | |
574 | ||
575 | curbyte = 0; | |
576 | curbyte += aim_putsnac(newpacket->data+curbyte, | |
577 | 0x0004, 0x0008, 0x0000, sess->snac_nextid); | |
578 | ||
579 | curbyte += aimutil_put16(newpacket->data+curbyte, (anon & AIM_WARN_ANON)?1:0); | |
580 | ||
581 | curbyte += aimutil_put8(newpacket->data+curbyte, strlen(destsn)); | |
582 | ||
583 | curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn)); | |
584 | ||
585 | newpacket->commandlen = curbyte; | |
586 | newpacket->lock = 0; | |
587 | ||
588 | aim_tx_enqueue(sess, newpacket); | |
589 | ||
590 | return (sess->snac_nextid++); | |
591 | } | |
592 | ||
593 | /* | |
594 | * aim_debugconn_sendconnect() | |
595 | * | |
596 | * For aimdebugd. If you don't know what it is, you don't want to. | |
597 | */ | |
598 | faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess, | |
599 | struct aim_conn_t *conn) | |
600 | { | |
601 | return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT); | |
602 | } | |
603 | ||
604 | /* | |
605 | * Generic routine for sending commands. | |
606 | * | |
607 | * | |
608 | * I know I can do this in a smarter way...but I'm not thinking straight | |
609 | * right now... | |
610 | * | |
611 | * I had one big function that handled all three cases, but then it broke | |
612 | * and I split it up into three. But then I fixed it. I just never went | |
613 | * back to the single. I don't see any advantage to doing it either way. | |
614 | * | |
615 | */ | |
616 | faim_internal unsigned long aim_genericreq_n(struct aim_session_t *sess, | |
617 | struct aim_conn_t *conn, | |
618 | u_short family, u_short subtype) | |
619 | { | |
620 | struct command_tx_struct *newpacket; | |
621 | ||
622 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10))) | |
623 | return 0; | |
624 | ||
625 | newpacket->lock = 1; | |
626 | ||
627 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); | |
628 | ||
629 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); | |
630 | ||
631 | aim_tx_enqueue(sess, newpacket); | |
632 | return sess->snac_nextid; | |
633 | } | |
634 | ||
635 | /* | |
636 | * | |
637 | * | |
638 | */ | |
639 | faim_internal unsigned long aim_genericreq_l(struct aim_session_t *sess, | |
640 | struct aim_conn_t *conn, | |
641 | u_short family, u_short subtype, | |
642 | u_long *longdata) | |
643 | { | |
644 | struct command_tx_struct *newpacket; | |
645 | u_long newlong; | |
646 | ||
647 | /* If we don't have data, there's no reason to use this function */ | |
648 | if (!longdata) | |
649 | return aim_genericreq_n(sess, conn, family, subtype); | |
650 | ||
651 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_long)))) | |
652 | return -1; | |
653 | ||
654 | newpacket->lock = 1; | |
655 | ||
656 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); | |
657 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); | |
658 | ||
659 | /* copy in data */ | |
660 | newlong = htonl(*longdata); | |
661 | memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long)); | |
662 | ||
663 | aim_tx_enqueue(sess, newpacket); | |
664 | return sess->snac_nextid; | |
665 | } | |
666 | ||
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) | |
671 | { | |
672 | struct command_tx_struct *newpacket; | |
673 | u_short newshort; | |
674 | ||
675 | /* If we don't have data, there's no reason to use this function */ | |
676 | if (!shortdata) | |
677 | return aim_genericreq_n(sess, conn, family, subtype); | |
678 | ||
679 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_short)))) | |
680 | return -1; | |
681 | ||
682 | newpacket->lock = 1; | |
683 | ||
684 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); | |
685 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); | |
686 | ||
687 | /* copy in data */ | |
688 | newshort = htons(*shortdata); | |
689 | memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short)); | |
690 | ||
691 | aim_tx_enqueue(sess, newpacket); | |
692 | return sess->snac_nextid; | |
693 | } | |
694 | ||
695 | /* | |
696 | * aim_bos_reqlocaterights() | |
697 | * | |
698 | * Request Location services rights. | |
699 | * | |
700 | */ | |
701 | faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *sess, | |
702 | struct aim_conn_t *conn) | |
703 | { | |
704 | return aim_genericreq_n(sess, conn, 0x0002, 0x0002); | |
705 | } | |
706 | ||
707 | /* | |
708 | * aim_bos_reqicbmparaminfo() | |
709 | * | |
710 | * Request ICBM parameter information. | |
711 | * | |
712 | */ | |
713 | faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *sess, | |
714 | struct aim_conn_t *conn) | |
715 | { | |
716 | return aim_genericreq_n(sess, conn, 0x0004, 0x0004); | |
717 | } | |
718 | ||
719 | /* | |
720 | * Add ICBM parameter? Huh? | |
721 | */ | |
722 | faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess, | |
723 | struct aim_conn_t *conn) | |
724 | { | |
725 | struct command_tx_struct *newpacket; | |
726 | int packlen = 10+16, i=0; | |
727 | ||
728 | if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen))) | |
729 | return (sess->snac_nextid); | |
730 | ||
731 | newpacket->lock = 1; | |
732 | ||
733 | i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid); | |
734 | aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0); | |
735 | ||
736 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
737 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
738 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
739 | i += aimutil_put16(newpacket->data+i, 0x1f40); | |
740 | i += aimutil_put16(newpacket->data+i, 0x03e7); | |
741 | i += aimutil_put16(newpacket->data+i, 0x03e7); | |
742 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
743 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
744 | ||
745 | aim_tx_enqueue(sess, newpacket); | |
746 | ||
747 | return sess->snac_nextid; | |
748 | } | |
749 | ||
750 | /* | |
751 | * Set directory profile data (not the same as aim_bos_setprofile!) | |
752 | */ | |
753 | 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) | |
754 | { | |
755 | struct command_tx_struct *newpacket; | |
756 | int packlen = 0, i = 0; | |
757 | ||
758 | packlen += 2+2+2; | |
759 | ||
760 | if(first) /* TLV 0001 */ | |
761 | packlen += (strlen(first) + 4); | |
762 | if(middle) | |
763 | packlen += (strlen(middle) + 4); | |
764 | if(last) | |
765 | packlen += (strlen(last) + 4); | |
766 | if(maiden) | |
767 | packlen += (strlen(maiden) + 4); | |
768 | if(nickname) | |
769 | packlen += (strlen(nickname) + 4); | |
770 | if(street) | |
771 | packlen += (strlen(street) + 4); | |
772 | if(state) | |
773 | packlen += (strlen(state) + 4); | |
774 | if(city) | |
775 | packlen += (strlen(city) + 4); | |
776 | if(zip) | |
777 | packlen += (strlen(zip) + 4); | |
778 | ||
779 | if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen+10))) | |
780 | return -1; | |
781 | ||
782 | newpacket->lock = 1; | |
783 | ||
784 | i = aim_putsnac(newpacket->data, 0x0002, 0x0009, 0x0000, 0); | |
785 | ||
786 | /* 000a/0002: privacy: 1 to allow search/disp, 0 to disallow */ | |
787 | i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy); | |
788 | ||
789 | ||
790 | if (first) | |
791 | i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen(first), first); | |
792 | if (middle) | |
793 | i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen(middle), middle); | |
794 | if (last) | |
795 | i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(last), last); | |
796 | if (maiden) | |
797 | i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(maiden), maiden); | |
798 | if (nickname) | |
799 | i += aim_puttlv_str(newpacket->data+i, 0x000c, strlen(nickname), nickname); | |
800 | if (street) | |
801 | i += aim_puttlv_str(newpacket->data+i, 0x0021, strlen(street), street); | |
802 | if (city) | |
803 | i += aim_puttlv_str(newpacket->data+i, 0x0008, strlen(city), city); | |
804 | if (state) | |
805 | i += aim_puttlv_str(newpacket->data+i, 0x0007, strlen(state), state); | |
806 | if (zip) | |
807 | i += aim_puttlv_str(newpacket->data+i, 0x000d, strlen(zip), zip); | |
808 | ||
809 | newpacket->commandlen = i; | |
810 | newpacket->lock = 0; | |
811 | ||
812 | aim_tx_enqueue(sess, newpacket); | |
813 | ||
814 | return(sess->snac_nextid); | |
815 | } | |
816 | ||
817 | 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) | |
818 | { | |
819 | struct command_tx_struct *newpacket; | |
820 | int packlen = 0, i = 0; | |
821 | ||
822 | packlen += 2+2+2; | |
823 | ||
824 | if(interest1) | |
825 | packlen += (strlen(interest1) + 4); | |
826 | if(interest2) | |
827 | packlen += (strlen(interest2) + 4); | |
828 | if(interest3) | |
829 | packlen += (strlen(interest3) + 4); | |
830 | if(interest4) | |
831 | packlen += (strlen(interest4) + 4); | |
832 | if(interest5) | |
833 | packlen += (strlen(interest5) + 4) ; | |
834 | ||
835 | ||
836 | if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen+10))) | |
837 | return -1; | |
838 | ||
839 | newpacket->lock = 1; | |
840 | ||
841 | i = aim_putsnac(newpacket->data, 0x0002, 0x000f, 0x0000, 0); | |
842 | ||
843 | /* 000a/0002: 0000 ?? ?privacy? */ | |
844 | i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy); | |
845 | ||
846 | if(interest1) | |
847 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest1); | |
848 | if(interest2) | |
849 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest2), interest2); | |
850 | if(interest3) | |
851 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest3), interest3); | |
852 | if(interest4) | |
853 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest4), interest4); | |
854 | if(interest5) | |
855 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest5); | |
856 | ||
857 | newpacket->commandlen = i; | |
858 | newpacket->lock = 0; | |
859 | ||
860 | aim_tx_enqueue(sess, newpacket); | |
861 | ||
862 | return(sess->snac_nextid); | |
863 | } | |
864 | ||
865 | faim_export unsigned long aim_icq_setstatus(struct aim_session_t *sess, | |
866 | struct aim_conn_t *conn, | |
867 | unsigned long status) | |
868 | { | |
869 | struct command_tx_struct *newpacket; | |
870 | int i; | |
871 | unsigned long data; | |
872 | ||
873 | data = 0x00030000 | status; /* yay for error checking ;^) */ | |
874 | ||
875 | if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + 4))) | |
876 | return -1; | |
877 | ||
878 | newpacket->lock = 1; | |
879 | ||
880 | i = aim_putsnac(newpacket->data, 0x0001, 0x001e, 0x0000, 0x0000001e); | |
881 | i += aim_puttlv_32(newpacket->data+i, 0x0006, data); | |
882 | ||
883 | newpacket->commandlen = i; | |
884 | newpacket->lock = 0; | |
885 | ||
886 | aim_tx_enqueue(sess, newpacket); | |
887 | ||
888 | return(sess->snac_nextid); | |
889 | } |