2 * -----------------------------------------------------------
3 * ProtoFAIM: v1.xx.xxplxx
4 * -----------------------------------------------------------
6 * This is ProtoFAIM v1.xx.xxplxx!!! Its nearly completely
7 * different than that ugly thing called v0. This app is
8 * compatible with the latest version of the libfaim library.
11 * ProtoFAIM should only be used for two things...
12 * 1) Testing the libfaim backend.
13 * 2) For reference on the libfaim API when developing clients.
15 * Its very ugly. Probably always will be. Nothing is more
16 * ugly than the backend itself, however.
18 * -----------------------------------------------------------
20 * I'm releasing this code and all it's associated linkage
21 * under the GNU General Public License. For more information,
22 * please refer to http://www.fsf.org. For any questions,
23 * please contact me at the address below.
26 * (c) 1998 Adam Fritzler, PST, afritz@iname.com
28 * The password algorithms
29 * (c) 1998 Brock Wilcox, awwaiid@iname.com
31 * THERE IS NO CODE FROM AOL'S AIM IN THIS CODE, NOR
32 * WAS THERE ANY DISASSEMBLAGE TO DEFINE PROTOCOL. All
33 * information was gained through painstakingly comparing
34 * TCP dumps while the AIM Java client was running. Nothing
35 * more than that, except for a lot of experimenting.
37 * -----------------------------------------------------------
49 int faimtest_parse_oncoming(struct aim_session_t *, struct command_rx_struct *, ...);
50 int faimtest_parse_offgoing(struct aim_session_t *, struct command_rx_struct *, ...);
51 int faimtest_parse_login_phase3d_f(struct aim_session_t *, struct command_rx_struct *, ...);
52 int faimtest_parse_authresp(struct aim_session_t *, struct command_rx_struct *, ...);
53 int faimtest_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *command, ...);
54 int faimtest_parse_userinfo(struct aim_session_t *, struct command_rx_struct *command, ...);
55 int faimtest_handleredirect(struct aim_session_t *, struct command_rx_struct *command, ...);
56 int faimtest_authsvrready(struct aim_session_t *, struct command_rx_struct *command, ...);
57 int faimtest_pwdchngdone(struct aim_session_t *, struct command_rx_struct *command, ...);
58 int faimtest_serverready(struct aim_session_t *, struct command_rx_struct *command, ...);
59 int faimtest_parse_misses(struct aim_session_t *, struct command_rx_struct *command, ...);
60 int faimtest_parse_motd(struct aim_session_t *, struct command_rx_struct *command, ...);
61 int faimtest_parse_login(struct aim_session_t *, struct command_rx_struct *command, ...);
62 int faimtest_chatnav_info(struct aim_session_t *, struct command_rx_struct *command, ...);
63 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...);
64 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...);
65 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...);
66 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...);
67 int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
69 int faimtest_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...)
72 printf("aim: minimum report interval: %d (seconds?)\n", aimutil_get16(command->data+10));
74 printf("aim: NULL minimum report interval!\n");
78 static char *screenname,*password,*server=NULL;
82 struct aim_session_t aimsess;
83 struct aim_conn_t *authconn = NULL, *waitingconn = NULL;
84 int keepgoing = 1, stayconnected = 1;
87 /* Use something like this for AIM */
88 struct client_info_s info = {"Boo", 2, 1, 0, "us", "en"};
90 /* or something exactly like this for ICQ and AIM */
91 struct client_info_s info = {"Random String (libfaim)", 4, 30, 3141, "us", "en"};
95 aim_session_init(&aimsess);
97 if ( !(screenname = getenv("SCREENNAME")) ||
98 !(password = getenv("PASSWORD")))
100 printf("Must specify SCREENAME and PASSWORD in environment.\n");
104 server = getenv("AUTHSERVER");
107 * (I used a goto-based loop here because n wanted quick proof
108 * that reconnecting without restarting was actually possible...)
111 authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, server?server:FAIM_LOGIN_SERVER);
113 if (authconn == NULL) {
114 fprintf(stderr, "faimtest: internal connection error while in aim_login. bailing out.\n");
116 } else if (authconn->fd == -1) {
117 if (authconn->status & AIM_CONN_STATUS_RESOLVERR)
118 fprintf(stderr, "faimtest: could not resolve authorizer name\n");
119 else if (authconn->status & AIM_CONN_STATUS_CONNERR)
120 fprintf(stderr, "faimtest: could not connect to authorizer\n");
121 aim_conn_kill(&aimsess, &authconn);
125 /* new login code -- not default -- pending new password encryption algo */
126 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0);
127 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0);
129 aim_sendconnack(&aimsess, authconn);
130 aim_request_login(&aimsess, authconn, FAIMTEST_SCREENNAME);
132 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_AUTHSUCCESS, faimtest_parse_authresp, 0);
133 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_authsvrready, 0);
134 aim_send_login(&aimsess, authconn, screenname, password, &info);
139 waitingconn = aim_select(&aimsess, NULL, &selstat);
146 case 0: /* no events pending */
149 case 1: /* outgoing data pending */
150 aim_tx_flushqueue(&aimsess);
153 case 2: /* incoming data pending */
154 if (aim_get_command(&aimsess, waitingconn) < 0) {
155 printf("\afaimtest: connection error!\n");
157 aim_rxdispatch(&aimsess);
166 printf("AIM just decided we didn't need to be here anymore, closing up...\n");
168 /* close up all connections, dead or no */
169 aim_logoff(&aimsess);
172 printf("\nTrying to reconnect in 2 seconds...\n");
181 int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
183 switch (command->conn->type)
185 case AIM_CONN_TYPE_BOS:
187 aim_bos_reqrate(sess, command->conn); /* request rate info */
188 aim_bos_ackrateresp(sess, command->conn); /* ack rate info response -- can we say timing? */
189 aim_bos_setprivacyflags(sess, command->conn, 0x00000003);
192 aim_bos_reqpersonalinfo(sess, command->conn);
195 /* Request advertisement service -- see comment in handleredirect */
196 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS);
197 aim_setversions(sess, command->conn);
200 aim_bos_reqrights(sess, command->conn);
201 aim_bos_reqbuddyrights(sess, command->conn);
202 aim_bos_reqlocaterights(sess, command->conn);
203 aim_bos_reqicbmparaminfo(sess, command->conn);
206 /* set group permissions */
207 aim_bos_setgroupperm(sess, command->conn, 0x1f);
208 fprintf(stderr, "faimtest: done with BOS ServerReady\n");
211 case AIM_CONN_TYPE_CHATNAV:
212 fprintf(stderr, "faimtest: chatnav: got server ready\n");
213 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, faimtest_chatnav_info, 0);
214 aim_bos_reqrate(sess, command->conn);
215 aim_bos_ackrateresp(sess, command->conn);
216 aim_chatnav_clientready(sess, command->conn);
217 aim_chatnav_reqrights(sess, command->conn);
220 case AIM_CONN_TYPE_CHAT:
221 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0);
222 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0);
223 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0);
224 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0);
225 aim_bos_reqrate(sess, command->conn);
226 aim_bos_ackrateresp(sess, command->conn);
227 aim_chat_clientready(sess, command->conn);
230 fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
238 This, of course, handles Service Redirects from OSCAR.
240 Should get passed in the following:
241 struct command_rx_struct *command
244 the destination service ID
246 the IP address of the service's server
250 int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
257 /* this is the new buddy list */
258 char buddies[] = "Buddy1&Buddy2&ThisHereIsAName2&";
259 /* this is the new profile */
260 char profile[] = "Hello";
262 va_start(ap, command);
263 serviceid = va_arg(ap, int);
264 ip = va_arg(ap, char *);
265 cookie = va_arg(ap, char *);
269 case 0x0005: /* Advertisements */
271 * The craziest explanation yet as to why we finish logging in when
272 * we get the advertisements redirect, of which we don't use anyway....
276 /* send the buddy list and profile (required, even if empty) */
277 aim_bos_setbuddylist(sess, command->conn, buddies);
278 aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_VOICE | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE);
280 /* send final login command (required) */
281 aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */
283 /* you should now be ready to go */
284 printf("\nYou are now officially online.\n");
287 case 0x0007: /* Authorizer */
289 struct aim_conn_t *tstconn;
290 /* Open a connection to the Auth */
291 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip);
292 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR) )
293 fprintf(stderr, "faimtest: unable to reconnect with authorizer\n");
295 /* Send the cookie to the Auth */
296 aim_auth_sendcookie(sess, tstconn, cookie);
300 case 0x000d: /* ChatNav */
302 struct aim_conn_t *tstconn = NULL;
303 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip);
304 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR)) {
305 fprintf(stderr, "faimtest: unable to connect to chatnav server\n");
306 if (tstconn) aim_conn_kill(sess, &tstconn);
310 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_CTN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
311 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
313 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
314 aim_auth_sendcookie(sess, tstconn, cookie);
315 fprintf(stderr, "\achatnav: connected\n");
318 case 0x000e: /* Chat */
320 char *roomname = NULL;
321 struct aim_conn_t *tstconn = NULL;
323 roomname = va_arg(ap, char *);
325 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip);
326 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR))
328 fprintf(stderr, "faimtest: unable to connect to chat server\n");
329 if (tstconn) aim_conn_kill(sess, &tstconn);
332 printf("faimtest: chat: connected\n");
335 * We must do this to attach the stored name to the connection!
337 aim_chat_attachname(tstconn, roomname);
339 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
340 aim_auth_sendcookie(sess, tstconn, cookie);
344 printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
353 int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
355 struct aim_conn_t *bosconn = NULL;
358 printf("Screen name: %s\n", sess->logininfo.screen_name);
363 if (sess->logininfo.errorcode)
365 printf("Login Error Code 0x%04x\n", sess->logininfo.errorcode);
366 printf("Error URL: %s\n", sess->logininfo.errorurl);
367 aim_conn_kill(sess, &command->conn);
368 exit(0); /* XXX: should return in order to let the above things get free()'d. */
371 printf("Reg status: %2d\n", sess->logininfo.regstatus);
372 printf("Email: %s\n", sess->logininfo.email);
373 printf("BOS IP: %s\n", sess->logininfo.BOSIP);
375 printf("Closing auth connection...\n");
376 aim_conn_kill(sess, &command->conn);
377 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, sess->logininfo.BOSIP);
378 if (bosconn == NULL) {
379 fprintf(stderr, "faimtest: could not connect to BOS: internal error\n");
380 } else if (bosconn->status != 0) {
381 fprintf(stderr, "faimtest: could not connect to BOS\n");
382 aim_conn_kill(sess, &bosconn);
384 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0);
385 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0);
386 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0);
387 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0);
388 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, faimtest_reportinterval, 0);
389 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0);
390 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0);
391 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
392 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_misses, 0);
393 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0);
394 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_misses, 0);
395 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_misses, 0);
396 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0);
398 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0);
399 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
400 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0);
402 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, faimtest_parse_connerr, 0);
404 aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie);
409 int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct *command, ...)
411 struct aim_userinfo_s *userinfo;
412 char *prof_encoding = NULL;
414 unsigned short inforeq = 0;
417 va_start(ap, command);
418 userinfo = va_arg(ap, struct aim_userinfo_s *);
419 prof_encoding = va_arg(ap, char *);
420 prof = va_arg(ap, char *);
421 inforeq = va_arg(ap, unsigned short);
424 printf("faimtest: userinfo: sn: %s\n", userinfo->sn);
425 printf("faimtest: userinfo: warnlevel: 0x%04x\n", userinfo->warnlevel);
426 printf("faimtest: userinfo: class: 0x%04x = ", userinfo->class);
440 if (userinfo->class & 0x0001)
442 if (userinfo->class & 0x0002)
443 printf("UNKNOWN_BIT2 ");
444 if (userinfo->class & 0x0004)
446 if (userinfo->class & 0x0008)
447 printf("UNKNOWN_BIT4 ");
448 if (userinfo->class & 0x0010)
450 if (userinfo->class & 0x0040)
454 printf("faimtest: userinfo: membersince: %lu\n", userinfo->membersince);
455 printf("faimtest: userinfo: onlinesince: %lu\n", userinfo->onlinesince);
456 printf("faimtest: userinfo: idletime: 0x%04x\n", userinfo->idletime);
458 if (inforeq == AIM_GETINFO_GENERALINFO) {
459 printf("faimtest: userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
460 printf("faimtest: userinfo: prof: %s\n", prof ? prof : "[none]");
461 } else if (inforeq == AIM_GETINFO_AWAYMESSAGE) {
462 printf("faimtest: userinfo: awaymsg_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
463 printf("faimtest: userinfo: awaymsg: %s\n", prof ? prof : "[none]");
465 printf("faimtest: userinfo: unknown info request\n");
471 * The user-level Incoming ICBM callback.
474 * struct command_rx_struct * command if you feel like doing it yourself
475 * char * srcsn the source name
477 * int warnlevel warning/evil level
478 * int class user class
479 * ulong membersince time_t of date of signup
480 * ulong onsince time_t of date of singon
481 * int idletime min (sec?) idle
482 * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK}
485 int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...)
490 va_start(ap, command);
491 channel = va_arg(ap, int);
494 * Channel 1: Standard Message
497 struct aim_userinfo_s *userinfo;
501 u_short flag1, flag2;
503 userinfo = va_arg(ap, struct aim_userinfo_s *);
504 msg = va_arg(ap, char *);
505 icbmflags = va_arg(ap, u_int);
506 flag1 = va_arg(ap, u_short);
507 flag2 = va_arg(ap, u_short);
510 printf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn);
511 printf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel);
512 printf("faimtest: icbm: class = 0x%04x ", userinfo->class);
513 if (userinfo->class & 0x0010)
515 if (userinfo->class & 0x0001)
517 if (userinfo->class & 0x0004)
520 printf("faimtest: icbm: membersince = %lu\n", userinfo->membersince);
521 printf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince);
522 printf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime);
523 printf("faimtest: icbm: capabilities = 0x%04x\n", userinfo->capabilities);
525 printf("faimtest: icbm: icbmflags = ");
526 if (icbmflags & AIM_IMFLAGS_AWAY)
528 if (icbmflags & AIM_IMFLAGS_ACK)
529 printf("ackrequest ");
532 printf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2);
534 printf("faimtest: icbm: message: %s\n", msg);
539 while (msg[i] == '<') {
541 while (msg[i] != '>')
548 printf("tmpstr = %s\n", tmpstr);
550 if ( (strlen(tmpstr) >= 10) &&
551 (!strncmp(tmpstr, "disconnect", 10)) ) {
552 aim_send_im(sess, command->conn, "midendian", 0, "ta ta...");
554 } else if (strstr(tmpstr, "goodday")) {
555 printf("faimtest: icbm: sending response\n");
556 aim_send_im(sess, command->conn, userinfo->sn, 0, "Good day to you too.");
557 } else if (!strncmp(tmpstr, "open chatnav", 12)) {
558 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
559 //aim_chat_join(sess, command->conn, "thishereisaname2_chat85");
560 } else if (!strncmp(tmpstr, "create", 6)) {
561 aim_chatnav_createroom(sess, aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), "WorldDomination", 0x0004);
562 } else if (!strncmp(tmpstr, "close chatnav", 13)) {
563 struct aim_conn_t *chatnavconn;
564 chatnavconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV);
565 aim_conn_kill(sess, &chatnavconn);
566 } else if (!strncmp(tmpstr, "join", 4)) {
567 aim_chat_join(sess, command->conn, 0x0004, "worlddomination");
568 } else if (!strncmp(tmpstr, "leave", 5))
569 aim_chat_leaveroom(sess, "worlddomination");
570 else if (!strncmp(tmpstr, "getinfo", 7)) {
571 aim_getinfo(sess, command->conn, "75784102", AIM_GETINFO_GENERALINFO);
572 aim_getinfo(sess, command->conn, "15853637", AIM_GETINFO_AWAYMESSAGE);
573 } else if (!strncmp(tmpstr, "sendmsg", 7)) {
580 newbuf = malloc(i+1);
581 for (z = 0; z < i; z++) {
582 newbuf[z] = (z % 10)+0x30;
585 aim_send_im(sess, command->conn, userinfo->sn, 0, newbuf);
589 printf("unknown command.\n");
590 aim_add_buddy(sess, command->conn, userinfo->sn);
596 * Channel 2: Rendevous Request
598 else if (channel == 2) {
599 struct aim_userinfo_s *userinfo;
600 unsigned short reqclass;
602 reqclass = va_arg(ap, unsigned short);
604 case AIM_CAPS_VOICE: {
605 userinfo = va_arg(ap, struct aim_userinfo_s *);
608 printf("faimtest: voice invitation: source sn = %s\n", userinfo->sn);
609 printf("faimtest: voice invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
610 printf("faimtest: voice invitation: \tclass = 0x%04x ", userinfo->class);
611 if (userinfo->class & 0x0010)
613 if (userinfo->class & 0x0001)
615 if (userinfo->class & 0x0004)
618 /* we dont get membersince on chat invites! */
619 printf("faimtest: voice invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
620 printf("faimtest: voice invitation: \tidletime = 0x%04x\n", userinfo->idletime);
624 case AIM_CAPS_GETFILE: {
625 printf("faimtset: get file!\n");
628 case AIM_CAPS_SENDFILE: {
629 printf("faimtest: send file!\n");
632 case AIM_CAPS_CHAT: {
633 char *msg,*encoding,*lang;
634 struct aim_chat_roominfo *roominfo;
636 userinfo = va_arg(ap, struct aim_userinfo_s *);
637 roominfo = va_arg(ap, struct aim_chat_roominfo *);
638 msg = va_arg(ap, char *);
639 encoding = va_arg(ap, char *);
640 lang = va_arg(ap, char *);
643 printf("faimtest: chat invitation: source sn = %s\n", userinfo->sn);
644 printf("faimtest: chat invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
645 printf("faimtest: chat invitation: \tclass = 0x%04x ", userinfo->class);
646 if (userinfo->class & 0x0010)
648 if (userinfo->class & 0x0001)
650 if (userinfo->class & 0x0004)
653 /* we dont get membersince on chat invites! */
654 printf("faimtest: chat invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
655 printf("faimtest: chat invitation: \tidletime = 0x%04x\n", userinfo->idletime);
657 printf("faimtest: chat invitation: message = %s\n", msg);
658 printf("faimtest: chat invitation: room name = %s\n", roominfo->name);
659 printf("faimtest: chat invitation: encoding = %s\n", encoding);
660 printf("faimtest: chat invitation: language = %s\n", lang);
661 printf("faimtest: chat invitation: exchange = 0x%04x\n", roominfo->exchange);
662 printf("faimtest: chat invitation: instance = 0x%04x\n", roominfo->instance);
663 printf("faimtest: chat invitiation: autojoining %s...\n", roominfo->name);
665 * Automatically join room...
667 aim_chat_join(sess, command->conn, 0x0004, roominfo->name);
671 printf("faimtest: icbm: unknown reqclass (%d)\n", reqclass);
674 printf("faimtest does not support channels > 2 (chan = %02x)\n", channel);
675 printf("faimtest: icbm: done with ICBM handling\n");
680 int faimtest_authsvrready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
682 printf("faimtest_authsvrready: called (contype: %d)\n", command->conn->type);
684 /* should just be able to tell it we're ready too... */
685 aim_auth_clientready(sess, command->conn);
689 * This is where you'd really begin changing your password.
690 * However, this callback may get called for reasons other
691 * than you wanting to change your password. You should
692 * probably check that before actually doing it.
694 aim_auth_changepasswd(sess, command->conn, "PWD1", "PWD2");
700 int faimtest_pwdchngdone(struct aim_session_t *sess, struct command_rx_struct *command, ...)
702 printf("PASSWORD CHANGE SUCCESSFUL!!!\n");
706 int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
708 struct aim_userinfo_s *userinfo;
711 va_start(ap, command);
712 userinfo = va_arg(ap, struct aim_userinfo_s *);
715 printf("\n%s is now online (class: %04x = %s%s%s%s%s%s%s%s) (caps = 0x%04x)\n",
716 userinfo->sn, userinfo->class,
717 (userinfo->class&AIM_CLASS_TRIAL)?" TRIAL":"",
718 (userinfo->class&AIM_CLASS_UNKNOWN2)?" UNKNOWN2":"",
719 (userinfo->class&AIM_CLASS_AOL)?" AOL":"",
720 (userinfo->class&AIM_CLASS_UNKNOWN4)?" UNKNOWN4":"",
721 (userinfo->class&AIM_CLASS_FREE)?" FREE":"",
722 (userinfo->class&AIM_CLASS_AWAY)?" AWAY":"",
723 (userinfo->class&AIM_CLASS_UNKNOWN40)?" UNKNOWN40":"",
724 (userinfo->class&AIM_CLASS_UNKNOWN80)?" UNKNOWN80":"",
725 userinfo->capabilities);
729 int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
734 va_start(ap, command);
735 sn = va_arg(ap, char *);
738 printf("\n%s has left\n", sn);
743 int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...)
749 va_start(ap, command);
750 id = va_arg(ap, u_short);
751 msg = va_arg(ap, char *);
754 printf("faimtest: motd: %s\n", msg);
760 * Handles callbacks for: AIM_CB_RATECHANGE, AIM_CB_USERERROR,
761 * AIM_CB_MISSED_IM, and AIM_CB_MISSED_CALL.
763 int faimtest_parse_misses(struct aim_session_t *sess, struct command_rx_struct *command, ...)
768 family = aimutil_get16(command->data+0);
769 subtype= aimutil_get16(command->data+2);
774 if (subtype == 0x000a) /* or AIM_CB_RATECHANGE */
775 printf("\n****STOP SENDING/RECIEVING MESSAGES SO FAST!****\n\n");
778 if (subtype == 0x0001) /* or AIM_CB_USERERROR */
780 u_long snacid = 0x00000000;
782 snacid = aimutil_get32(&command->data[6]);
784 printf("Received unknown error in SNAC family 0x0002 (snacid = %08lx)\n", snacid);
788 if (subtype == 0x0001) /* or AIM_CB_MISSED_IM */
789 printf("\n***LAST IM DIDN\'T MAKE IT BECAUSE THE BUDDY IS NOT ONLINE***\n\n");
790 else if (subtype == 0x000a) /* or AIM_CB_MISSED_CALL */
791 printf("You missed some messages from %s because they were sent too fast\n", &(command->data[13]));
799 int faimtest_parse_login(struct aim_session_t *sess, struct command_rx_struct *command, ...)
801 struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"};
802 u_char authcookie[11];
805 for (i = 0; i < (int)command->data[11]; i++)
806 authcookie[i] = command->data[12+i];
807 authcookie[i] = '\0';
809 printf("faimtest: logincookie: %s\n", authcookie);
811 aim_send_login(sess, command->conn, FAIMTEST_SCREENNAME, FAIMTEST_PASSWORD, &info);
817 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...)
820 struct aim_userinfo_s *userinfo;
821 int count = 0, i = 0;
823 va_start(ap, command);
824 count = va_arg(ap, int);
825 userinfo = va_arg(ap, struct aim_userinfo_s *);
828 printf("faimtest: chat: %s: New occupants have joined:\n", (char *)command->conn->priv);
830 printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
835 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...)
838 struct aim_userinfo_s *userinfo;
839 int count = 0, i = 0;
841 va_start(ap, command);
842 count = va_arg(ap, int);
843 userinfo = va_arg(ap, struct aim_userinfo_s *);
846 printf("faimtest: chat: %s: Some occupants have left:\n", (char *)command->conn->priv);
848 printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
853 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
856 struct aim_userinfo_s *userinfo;
857 struct aim_chat_roominfo *roominfo;
861 unsigned short unknown_c9, unknown_d2, unknown_d5, maxmsglen;
862 unsigned long creationtime;
864 va_start(ap, command);
865 roominfo = va_arg(ap, struct aim_chat_roominfo *);
866 roomname = va_arg(ap, char *);
867 usercount= va_arg(ap, int);
868 userinfo = va_arg(ap, struct aim_userinfo_s *);
869 roomdesc = va_arg(ap, char *);
870 unknown_c9 = va_arg(ap, unsigned short);
871 creationtime = va_arg(ap, unsigned long);
872 maxmsglen = va_arg(ap, unsigned short);
873 unknown_d2 = va_arg(ap, unsigned short);
874 unknown_d5 = va_arg(ap, unsigned short);
877 printf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv);
878 printf("faimtest: chat: %s: \tRoominfo: {%04x, %s, %04x}\n",
879 (char *)command->conn->priv,
883 printf("faimtest: chat: %s: \tRoomname: %s\n", (char *)command->conn->priv, roomname);
884 printf("faimtest: chat: %s: \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc);
885 printf("faimtest: chat: %s: \tOccupants: (%d)\n", (char *)command->conn->priv, usercount);
888 while (i < usercount)
889 printf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
891 printf("faimtest: chat: %s: \tUnknown_c9: 0x%04x\n", (char *)command->conn->priv, unknown_c9);
892 printf("faimtest: chat: %s: \tCreation time: %lu (time_t)\n", (char *)command->conn->priv, creationtime);
893 printf("faimtest: chat: %s: \tMax message length: %d bytes\n", (char *)command->conn->priv, maxmsglen);
894 printf("faimtest: chat: %s: \tUnknown_d2: 0x%04x\n", (char *)command->conn->priv, unknown_d2);
895 printf("faimtest: chat: %s: \tUnknown_d5: 0x%02x\n", (char *)command->conn->priv, unknown_d5);
900 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...)
903 struct aim_userinfo_s *userinfo;
907 va_start(ap, command);
908 userinfo = va_arg(ap, struct aim_userinfo_s *);
909 msg = va_arg(ap, char *);
912 printf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg);
915 * Do an echo for testing purposes. But not for ourselves ("oops!")
917 if (strcmp(userinfo->sn, sess->logininfo.screen_name) != 0)
919 sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg);
920 aim_chat_send_im(sess, command->conn, tmpbuf);
926 int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct *command, ...)
931 ap = va_start(ap, command);
932 type = va_arg(ap, u_short);
939 struct aim_chat_exchangeinfo *exchanges;
940 int exchangecount,i = 0;
942 maxrooms = va_arg(ap, u_char);
943 exchangecount = va_arg(ap, int);
944 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
947 printf("faimtest: chat info: Chat Rights:\n");
948 printf("faimtest: chat info: \tMax Concurrent Rooms: %d\n", maxrooms);
950 printf("faimtest: chat info: \tExchange List: (%d total)\n", exchangecount);
951 while (i < exchangecount)
953 printf("faimtest: chat info: \t\t%x: %s (%s/%s)\n",
956 exchanges[i].charset1,
965 printf("faimtest: chatnav info: unknown type (%04x)\n", type);
970 int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
976 ap = va_start(ap, command);
977 code = va_arg(ap, unsigned short);
978 msg = va_arg(ap, char *);
981 printf("faimtest: connerr: Code 0x%04x: %s\n", code, msg);