5 * TODO: Seperate a lot of this into an aim_bos.c.
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
25 faim_export unsigned long aim_bos_setidle(struct aim_session_t *sess,
26 struct aim_conn_t *conn,
29 return aim_genericreq_l(sess, conn, 0x0001, 0x0011, &idletime);
34 * aim_bos_changevisibility(conn, changtype, namelist)
36 * Changes your visibility depending on changetype:
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
43 * list should be a list of
44 * screen names in the form "Screen Name One&ScreenNameTwo&" etc.
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
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
61 faim_export unsigned long aim_bos_changevisibility(struct aim_session_t *sess,
62 struct aim_conn_t *conn,
66 struct command_tx_struct *newpacket;
70 char *localcpy = NULL;
78 localcpy = (char *) malloc(strlen(denylist)+1);
79 memcpy(localcpy, denylist, strlen(denylist)+1);
81 listcount = aimutil_itemcnt(localcpy, '&');
82 packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
84 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen)))
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;
96 free(newpacket->data);
101 /* We actually DO NOT send a SNAC ID with this one! */
102 aim_putsnac(newpacket->data, 0x0009, subtype, 0x00, 0);
104 j = 10; /* the next byte */
106 for (i=0; (i < (listcount - 1)) && (i < 99); i++)
108 tmpptr = aimutil_itemidx(localcpy, i, '&');
110 newpacket->data[j] = strlen(tmpptr);
111 memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
112 j += strlen(tmpptr)+1;
119 aim_tx_enqueue(sess, newpacket);
121 return (sess->snac_nextid); /* dont increment */
128 * aim_bos_setbuddylist(buddylist)
130 * This just builds the "set buddy list" command then queues it.
132 * buddy_list = "Screen Name One&ScreenNameTwo&";
134 * TODO: Clean this up.
136 * XXX: I can't stress the TODO enough.
139 faim_export unsigned long aim_bos_setbuddylist(struct aim_session_t *sess,
140 struct aim_conn_t *conn,
145 struct command_tx_struct *newpacket;
149 char *localcpy = NULL;
152 len = 10; /* 10B SNAC headers */
154 if (!buddy_list || !(localcpy = (char *) malloc(strlen(buddy_list)+1)))
156 strncpy(localcpy, buddy_list, strlen(buddy_list)+1);
159 tmpptr = strtok(localcpy, "&");
160 while ((tmpptr != NULL) && (i < 150)) {
161 faimdprintf(sess, 2, "---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr));
162 len += 1+strlen(tmpptr);
164 tmpptr = strtok(NULL, "&");
166 faimdprintf(sess, 2, "*** send buddy list len: %d (%x)\n", len, len);
168 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, len)))
173 aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, 0);
175 j = 10; /* the next byte */
177 strncpy(localcpy, buddy_list, strlen(buddy_list)+1);
179 tmpptr = strtok(localcpy, "&");
180 while ((tmpptr != NULL) & (i < 150)) {
181 faimdprintf(sess, 2, "---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr));
182 newpacket->data[j] = strlen(tmpptr);
183 memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
184 j += 1+strlen(tmpptr);
186 tmpptr = strtok(NULL, "&");
191 aim_tx_enqueue(sess, newpacket);
195 return (sess->snac_nextid);
199 * aim_bos_setprofile(profile)
201 * Gives BOS your profile.
205 faim_export unsigned long aim_bos_setprofile(struct aim_session_t *sess,
206 struct aim_conn_t *conn,
211 struct command_tx_struct *newpacket;
212 int i = 0, tmp, caplen;
213 static const char defencoding[] = {"text/aolrtf; charset=\"us-ascii\""};
217 i += 4+strlen(defencoding)+4+strlen(profile);
219 i += 4+strlen(defencoding)+4+strlen(awaymsg);
220 i += 4+512; /* for capabilities */
222 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, i)))
225 i = aim_putsnac(newpacket->data, 0x0002, 0x004, 0x0000, sess->snac_nextid);
228 i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen(defencoding), defencoding);
229 i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(profile), profile);
233 i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen(defencoding), defencoding);
234 i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(awaymsg), awaymsg);
237 /* Capability information. */
239 tmp = (i += aimutil_put16(newpacket->data+i, 0x0005));
240 i += aimutil_put16(newpacket->data+i, 0x0000); /* rewritten later */
241 i += (caplen = aim_putcap(newpacket->data+i, 512, caps));
242 aimutil_put16(newpacket->data+tmp, caplen); /* rewrite TLV size */
244 newpacket->commandlen = i;
245 aim_tx_enqueue(sess, newpacket);
247 return (sess->snac_nextid++);
251 * aim_bos_clientready()
256 faim_export unsigned long aim_bos_clientready(struct aim_session_t *sess,
257 struct aim_conn_t *conn)
259 struct aim_tool_version tools[] = {
260 {0x0001, 0x0003, AIM_TOOL_WIN32, 0x0686},
261 {0x0002, 0x0001, AIM_TOOL_WIN32, 0x0001},
262 {0x0003, 0x0001, AIM_TOOL_WIN32, 0x0001},
263 {0x0004, 0x0001, AIM_TOOL_WIN32, 0x0001},
264 {0x0006, 0x0001, AIM_TOOL_WIN32, 0x0001},
265 {0x0008, 0x0001, AIM_TOOL_WIN32, 0x0001},
266 {0x0009, 0x0001, AIM_TOOL_WIN32, 0x0001},
267 {0x000a, 0x0001, AIM_TOOL_WIN32, 0x0001},
268 {0x000b, 0x0001, AIM_TOOL_WIN32, 0x0001}
271 struct command_tx_struct *newpacket;
272 int toolcount = sizeof(tools)/sizeof(struct aim_tool_version);
274 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152)))
279 i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
280 aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
282 for (j = 0; j < toolcount; j++) {
283 i += aimutil_put16(newpacket->data+i, tools[j].group);
284 i += aimutil_put16(newpacket->data+i, tools[j].version);
285 i += aimutil_put16(newpacket->data+i, tools[j].tool);
286 i += aimutil_put16(newpacket->data+i, tools[j].toolversion);
289 newpacket->commandlen = i;
292 aim_tx_enqueue(sess, newpacket);
294 return sess->snac_nextid;
298 * Request Rate Information.
301 faim_export unsigned long aim_bos_reqrate(struct aim_session_t *sess,
302 struct aim_conn_t *conn)
304 return aim_genericreq_n(sess, conn, 0x0001, 0x0006);
308 * Rate Information Response Acknowledge.
311 faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *sess,
312 struct aim_conn_t *conn)
314 struct command_tx_struct *newpacket;
315 int packlen = 20, i=0;
317 if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen)))
318 return (sess->snac_nextid);
322 i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0);
323 i += aimutil_put16(newpacket->data+i, 0x0001);
324 i += aimutil_put16(newpacket->data+i, 0x0002);
325 i += aimutil_put16(newpacket->data+i, 0x0003);
326 i += aimutil_put16(newpacket->data+i, 0x0004);
327 i += aimutil_put16(newpacket->data+i, 0x0005);
329 newpacket->commandlen = i;
332 aim_tx_enqueue(sess, newpacket);
334 return (sess->snac_nextid);
338 * aim_bos_setprivacyflags()
340 * Sets privacy flags. Normally 0x03.
342 * Bit 1: Allows other AIM users to see how long you've been idle.
343 * Bit 2: Allows other AIM users to see how long you've been a member.
346 faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *sess,
347 struct aim_conn_t *conn,
350 return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags);
354 * aim_bos_reqpersonalinfo()
356 * Requests the current user's information. Can't go generic on this one
357 * because aparently it uses SNAC flags.
360 faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *sess,
361 struct aim_conn_t *conn)
363 return aim_genericreq_n(sess, conn, 0x0001, 0x000e);
366 faim_export unsigned long aim_setversions(struct aim_session_t *sess,
367 struct aim_conn_t *conn)
369 struct command_tx_struct *newpacket;
372 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + (4*16))))
377 i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid);
378 aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
380 i += aimutil_put16(newpacket->data+i, 0x0001);
381 i += aimutil_put16(newpacket->data+i, 0x0003);
383 i += aimutil_put16(newpacket->data+i, 0x0002);
384 i += aimutil_put16(newpacket->data+i, 0x0001);
386 i += aimutil_put16(newpacket->data+i, 0x0003);
387 i += aimutil_put16(newpacket->data+i, 0x0001);
389 i += aimutil_put16(newpacket->data+i, 0x0004);
390 i += aimutil_put16(newpacket->data+i, 0x0001);
392 i += aimutil_put16(newpacket->data+i, 0x0006);
393 i += aimutil_put16(newpacket->data+i, 0x0001);
395 i += aimutil_put16(newpacket->data+i, 0x0008);
396 i += aimutil_put16(newpacket->data+i, 0x0001);
398 i += aimutil_put16(newpacket->data+i, 0x0009);
399 i += aimutil_put16(newpacket->data+i, 0x0001);
401 i += aimutil_put16(newpacket->data+i, 0x000a);
402 i += aimutil_put16(newpacket->data+i, 0x0001);
404 i += aimutil_put16(newpacket->data+i, 0x000b);
405 i += aimutil_put16(newpacket->data+i, 0x0002);
407 i += aimutil_put16(newpacket->data+i, 0x000c);
408 i += aimutil_put16(newpacket->data+i, 0x0001);
410 i += aimutil_put16(newpacket->data+i, 0x0013);
411 i += aimutil_put16(newpacket->data+i, 0x0001);
413 i += aimutil_put16(newpacket->data+i, 0x0015);
414 i += aimutil_put16(newpacket->data+i, 0x0001);
416 newpacket->commandlen = i;
418 aim_tx_enqueue(sess, newpacket);
420 return sess->snac_nextid;
425 * aim_bos_reqservice(serviceid)
430 faim_export unsigned long aim_bos_reqservice(struct aim_session_t *sess,
431 struct aim_conn_t *conn,
434 return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid);
440 * No-op. WinAIM sends these every 4min or so to keep
441 * the connection alive. Its not real necessary.
444 faim_export unsigned long aim_bos_nop(struct aim_session_t *sess,
445 struct aim_conn_t *conn)
447 return aim_genericreq_n(sess, conn, 0x0001, 0x0016);
453 * No-op. WinAIM 4.x sends these _every minute_ to keep
454 * the connection alive.
456 faim_export unsigned long aim_flap_nop(struct aim_session_t *sess,
457 struct aim_conn_t *conn)
459 struct command_tx_struct *newpacket;
461 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0005, 0)))
462 return sess->snac_nextid;
465 newpacket->commandlen = 0;
468 aim_tx_enqueue(sess, newpacket);
470 return (sess->snac_nextid);
474 * aim_bos_reqrights()
476 * Request BOS rights.
479 faim_export unsigned long aim_bos_reqrights(struct aim_session_t *sess,
480 struct aim_conn_t *conn)
482 return aim_genericreq_n(sess, conn, 0x0009, 0x0002);
486 * aim_bos_reqbuddyrights()
488 * Request Buddy List rights.
491 faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *sess,
492 struct aim_conn_t *conn)
494 return aim_genericreq_n(sess, conn, 0x0003, 0x0002);
498 * Send a warning to destsn.
501 * AIM_WARN_ANON Send as an anonymous (doesn't count as much)
503 * returns -1 on error (couldn't alloc packet), 0 on success.
506 faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, const char *destsn, unsigned long flags)
508 struct command_tx_struct *newpacket;
510 unsigned short outflags = 0x0000;
512 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002,
519 curbyte += aim_putsnac(newpacket->data+curbyte,
520 0x0004, 0x0008, 0x0000, sess->snac_nextid);
522 if (flags & AIM_WARN_ANON)
525 curbyte += aimutil_put16(newpacket->data+curbyte, outflags);
526 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(destsn));
527 curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn));
529 newpacket->commandlen = curbyte;
532 aim_tx_enqueue(sess, newpacket);
534 aim_cachesnac(sess, 0x0004, 0x0008, 0x0000, destsn, strlen(destsn)+1);
540 * aim_debugconn_sendconnect()
542 * For aimdebugd. If you don't know what it is, you don't want to.
544 faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess,
545 struct aim_conn_t *conn)
547 return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT);
551 * Generic routine for sending commands.
554 * I know I can do this in a smarter way...but I'm not thinking straight
557 * I had one big function that handled all three cases, but then it broke
558 * and I split it up into three. But then I fixed it. I just never went
559 * back to the single. I don't see any advantage to doing it either way.
562 faim_internal unsigned long aim_genericreq_n(struct aim_session_t *sess,
563 struct aim_conn_t *conn,
564 u_short family, u_short subtype)
566 struct command_tx_struct *newpacket;
568 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10)))
573 aim_putsnac(newpacket->data, family, subtype, 0x0000, 0x00000000);
575 aim_tx_enqueue(sess, newpacket);
577 return sess->snac_nextid;
580 faim_internal unsigned long aim_genericreq_n_snacid(struct aim_session_t *sess,
581 struct aim_conn_t *conn,
582 unsigned short family,
583 unsigned short subtype)
585 struct command_tx_struct *newpacket;
587 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10)))
592 aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
593 aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
595 aim_tx_enqueue(sess, newpacket);
597 return sess->snac_nextid++;
604 faim_internal unsigned long aim_genericreq_l(struct aim_session_t *sess,
605 struct aim_conn_t *conn,
606 u_short family, u_short subtype,
609 struct command_tx_struct *newpacket;
612 /* If we don't have data, there's no reason to use this function */
614 return aim_genericreq_n(sess, conn, family, subtype);
616 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+sizeof(u_long))))
621 aim_putsnac(newpacket->data, family, subtype, 0x0000, 0x00000000);
624 newlong = htonl(*longdata);
625 memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long));
627 aim_tx_enqueue(sess, newpacket);
629 return sess->snac_nextid;
632 faim_internal unsigned long aim_genericreq_s(struct aim_session_t *sess,
633 struct aim_conn_t *conn,
634 u_short family, u_short subtype,
637 struct command_tx_struct *newpacket;
640 /* If we don't have data, there's no reason to use this function */
642 return aim_genericreq_n(sess, conn, family, subtype);
644 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+sizeof(u_short))))
649 aim_putsnac(newpacket->data, family, subtype, 0x0000, 0x00000000);
652 newshort = htons(*shortdata);
653 memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short));
655 aim_tx_enqueue(sess, newpacket);
657 return sess->snac_nextid;
661 * aim_bos_reqlocaterights()
663 * Request Location services rights.
666 faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *sess,
667 struct aim_conn_t *conn)
669 return aim_genericreq_n(sess, conn, 0x0002, 0x0002);
673 * aim_bos_reqicbmparaminfo()
675 * Request ICBM parameter information.
678 faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *sess,
679 struct aim_conn_t *conn)
681 return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
685 * Add ICBM parameter? Huh?
687 faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess,
688 struct aim_conn_t *conn)
690 struct command_tx_struct *newpacket;
691 int packlen = 10+16, i=0;
693 if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen)))
694 return (sess->snac_nextid);
698 i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, 0x00000000);
700 i += aimutil_put16(newpacket->data+i, 0x0000);
701 i += aimutil_put16(newpacket->data+i, 0x0000);
702 i += aimutil_put16(newpacket->data+i, 0x0003);
703 i += aimutil_put16(newpacket->data+i, 0x1f40);
704 i += aimutil_put16(newpacket->data+i, 0x03e7);
705 i += aimutil_put16(newpacket->data+i, 0x03e7);
706 i += aimutil_put16(newpacket->data+i, 0x0000);
707 i += aimutil_put16(newpacket->data+i, 0x0000);
709 aim_tx_enqueue(sess, newpacket);
711 return sess->snac_nextid;
715 * Set directory profile data (not the same as aim_bos_setprofile!)
717 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)
719 struct command_tx_struct *newpacket;
720 int packlen = 0, i = 0;
724 if(first) /* TLV 0001 */
725 packlen += (strlen(first) + 4);
727 packlen += (strlen(middle) + 4);
729 packlen += (strlen(last) + 4);
731 packlen += (strlen(maiden) + 4);
733 packlen += (strlen(nickname) + 4);
735 packlen += (strlen(street) + 4);
737 packlen += (strlen(state) + 4);
739 packlen += (strlen(city) + 4);
741 packlen += (strlen(zip) + 4);
743 if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen+10)))
748 i = aim_putsnac(newpacket->data, 0x0002, 0x0009, 0x0000, 0);
750 /* 000a/0002: privacy: 1 to allow search/disp, 0 to disallow */
751 i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy);
755 i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen(first), first);
757 i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen(middle), middle);
759 i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(last), last);
761 i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(maiden), maiden);
763 i += aim_puttlv_str(newpacket->data+i, 0x000c, strlen(nickname), nickname);
765 i += aim_puttlv_str(newpacket->data+i, 0x0021, strlen(street), street);
767 i += aim_puttlv_str(newpacket->data+i, 0x0008, strlen(city), city);
769 i += aim_puttlv_str(newpacket->data+i, 0x0007, strlen(state), state);
771 i += aim_puttlv_str(newpacket->data+i, 0x000d, strlen(zip), zip);
773 newpacket->commandlen = i;
776 aim_tx_enqueue(sess, newpacket);
778 return(sess->snac_nextid);
781 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)
783 struct command_tx_struct *newpacket;
784 int packlen = 0, i = 0;
789 packlen += (strlen(interest1) + 4);
791 packlen += (strlen(interest2) + 4);
793 packlen += (strlen(interest3) + 4);
795 packlen += (strlen(interest4) + 4);
797 packlen += (strlen(interest5) + 4) ;
800 if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen+10)))
805 i = aim_putsnac(newpacket->data, 0x0002, 0x000f, 0x0000, 0);
807 /* 000a/0002: 0000 ?? ?privacy? */
808 i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy);
811 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest1);
813 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest2), interest2);
815 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest3), interest3);
817 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest4), interest4);
819 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest5);
821 newpacket->commandlen = i;
824 aim_tx_enqueue(sess, newpacket);
826 return(sess->snac_nextid);
829 faim_export unsigned long aim_icq_setstatus(struct aim_session_t *sess,
830 struct aim_conn_t *conn,
831 unsigned long status)
833 struct command_tx_struct *newpacket;
837 data = 0x00030000 | status; /* yay for error checking ;^) */
839 if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + 4)))
844 i = aim_putsnac(newpacket->data, 0x0001, 0x001e, 0x0000, 0x0000001e);
845 i += aim_puttlv_32(newpacket->data+i, 0x0006, data);
847 newpacket->commandlen = i;
850 aim_tx_enqueue(sess, newpacket);
852 return(sess->snac_nextid);
856 * Should be generic enough to handle the errors for all families...
859 static int generror(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
863 aim_rxcallback_t userfunc;
864 struct aim_snac_t *snac2;
866 snac2 = aim_remsnac(sess, snac->id);
869 error = aimutil_get16(data);
871 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
872 ret = userfunc(sess, rx, error, snac2?snac2->data:NULL);
881 static int snachandler(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
884 if (snac->subtype == 0x0001)
885 return generror(sess, mod, rx, snac, data, datalen);
886 else if ((snac->family == 0xffff) && (snac->subtype == 0xffff)) {
887 aim_rxcallback_t userfunc;
889 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
890 return userfunc(sess, rx);
896 faim_internal int misc_modfirst(struct aim_session_t *sess, aim_module_t *mod)
899 mod->family = 0xffff;
900 mod->version = 0x0000;
901 mod->flags = AIM_MODFLAG_MULTIFAMILY;
902 strncpy(mod->name, "misc", sizeof(mod->name));
903 mod->snachandler = snachandler;