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, ...);
68 static char *screenname,*password;
72 struct aim_session_t aimsess;
73 struct aim_conn_t *authconn = NULL;
74 int stayconnected = 1;
75 struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"};
77 aim_session_init(&aimsess);
79 if ( !(screenname = getenv("SCREENNAME")) ||
80 !(password = getenv("PASSWORD")))
82 printf("Must specify SCREENAME and PASSWORD in environment.\n");
87 * (I used a goto-based loop here because n wanted quick proof
88 * that reconnecting without restarting was actually possible...)
91 authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, FAIM_LOGIN_SERVER);
95 fprintf(stderr, "faimtest: internal connection error while in aim_login. bailing out.\n");
98 else if (authconn->fd == -1)
100 if (authconn->status & AIM_CONN_STATUS_RESOLVERR)
101 fprintf(stderr, "faimtest: could not resolve authorizer name\n");
102 else if (authconn->status & AIM_CONN_STATUS_CONNERR)
103 fprintf(stderr, "faimtest: could not connect to authorizer\n");
109 /* new login code -- not default -- pending new password encryption algo */
110 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0);
111 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0);
113 aim_sendconnack(&aimsess, authconn);
114 aim_request_login(&aimsess, authconn, FAIMTEST_SCREENNAME);
116 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_AUTHSUCCESS, faimtest_parse_authresp, 0);
117 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_authsvrready, 0);
118 aim_send_login(&aimsess, authconn, screenname, password, &info);
123 while (aim_select(&aimsess, NULL) > (struct aim_conn_t *)0)
125 if (aimsess.queue_outgoing)
126 aim_tx_flushqueue(&aimsess);
128 if (aim_get_command(&aimsess) < 0)
130 printf("\afaimtest: connection error!\n");
133 aim_rxdispatch(&aimsess);
137 printf("AIM just decided we didn't need to be here anymore, closing up.,,\n");
139 /* close up all connections, dead or no */
140 aim_logoff(&aimsess);
144 printf("\nTrying to reconnect in 2 seconds...\n");
153 int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
155 switch (command->conn->type)
157 case AIM_CONN_TYPE_BOS:
159 aim_bos_reqrate(sess, command->conn); /* request rate info */
160 aim_bos_ackrateresp(sess, command->conn); /* ack rate info response -- can we say timing? */
161 aim_bos_setprivacyflags(sess, command->conn, 0x00000003);
164 aim_bos_reqpersonalinfo(sess, command->conn);
167 /* Request advertisement service -- see comment in handleredirect */
168 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS);
169 aim_setversions(sess, command->conn);
172 aim_bos_reqrights(sess, command->conn);
173 aim_bos_reqbuddyrights(sess, command->conn);
174 aim_bos_reqlocaterights(sess, command->conn);
175 aim_bos_reqicbmparaminfo(sess, command->conn);
178 /* set group permissions */
179 aim_bos_setgroupperm(sess, command->conn, 0x1f);
180 fprintf(stderr, "faimtest: done with BOS ServerReady\n");
183 case AIM_CONN_TYPE_CHATNAV:
184 fprintf(stderr, "faimtest: chatnav: got server ready\n");
185 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, faimtest_chatnav_info, 0);
186 aim_bos_reqrate(sess, command->conn);
187 aim_bos_ackrateresp(sess, command->conn);
188 aim_chatnav_clientready(sess, command->conn);
189 aim_chatnav_reqrights(sess, command->conn);
192 case AIM_CONN_TYPE_CHAT:
193 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0);
194 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0);
195 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0);
196 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0);
197 aim_bos_reqrate(sess, command->conn);
198 aim_bos_ackrateresp(sess, command->conn);
199 aim_chat_clientready(sess, command->conn);
202 fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
210 This, of course, handles Service Redirects from OSCAR.
212 Should get passed in the following:
213 struct command_rx_struct *command
216 the destination service ID
218 the IP address of the service's server
222 int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
229 /* this is the new buddy list */
230 char buddies[] = "Buddy1&Buddy2&ThisHereIsAName2&";
231 /* this is the new profile */
232 char profile[] = "Hello";
234 va_start(ap, command);
235 serviceid = va_arg(ap, int);
236 ip = va_arg(ap, char *);
237 cookie = va_arg(ap, char *);
241 case 0x0005: /* Advertisements */
243 * The craziest explanation yet as to why we finish logging in when
244 * we get the advertisements redirect, of which we don't use anyway....
248 /* send the buddy list and profile (required, even if empty) */
249 aim_bos_setbuddylist(sess, command->conn, buddies);
250 aim_bos_setprofile(sess, command->conn, profile, NULL);
252 /* send final login command (required) */
253 aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */
255 /* you should now be ready to go */
256 printf("\nYou are now officially online.\n");
259 case 0x0007: /* Authorizer */
261 struct aim_conn_t *tstconn;
262 /* Open a connection to the Auth */
263 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip);
264 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR) )
265 fprintf(stderr, "faimtest: unable to reconnect with authorizer\n");
267 /* Send the cookie to the Auth */
268 aim_auth_sendcookie(sess, tstconn, cookie);
272 case 0x000d: /* ChatNav */
274 struct aim_conn_t *tstconn = NULL;
275 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip);
276 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR))
278 fprintf(stderr, "faimtest: unable to connect to chatnav server\n");
282 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_CTN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
283 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
285 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
286 aim_auth_sendcookie(sess, tstconn, cookie);
287 fprintf(stderr, "\achatnav: connected\n");
290 case 0x000e: /* Chat */
292 char *roomname = NULL;
293 struct aim_conn_t *tstconn = NULL;
295 roomname = va_arg(ap, char *);
297 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip);
298 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR))
300 fprintf(stderr, "faimtest: unable to connect to chat server\n");
303 printf("faimtest: chat: connected\n");
306 * We must do this to attach the stored name to the connection!
308 aim_chat_attachname(tstconn, roomname);
310 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
311 aim_auth_sendcookie(sess, tstconn, cookie);
315 printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
324 int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
326 struct aim_conn_t *bosconn = NULL;
329 printf("Screen name: %s\n", sess->logininfo.screen_name);
334 if (sess->logininfo.errorcode)
336 printf("Login Error Code 0x%04x\n", sess->logininfo.errorcode);
337 printf("Error URL: %s\n", sess->logininfo.errorurl);
338 aim_conn_close(command->conn);
339 exit(0); /* XXX: should return in order to let the above things get free()'d. */
342 printf("Reg status: %2d\n", sess->logininfo.regstatus);
343 printf("Email: %s\n", sess->logininfo.email);
344 printf("BOS IP: %s\n", sess->logininfo.BOSIP);
346 printf("Closing auth connection...\n");
347 aim_conn_close(command->conn);
348 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, sess->logininfo.BOSIP);
351 fprintf(stderr, "faimtest: could not connect to BOS: internal error\n");
353 else if (bosconn->status != 0)
355 fprintf(stderr, "faimtest: could not connect to BOS\n");
359 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0);
360 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0);
361 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0);
362 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0);
363 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, NULL, 0);
364 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0);
365 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0);
366 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
367 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_misses, 0);
368 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0);
369 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_misses, 0);
370 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_misses, 0);
371 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0);
373 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0);
374 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
375 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0);
376 aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie);
381 int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct *command, ...)
383 struct aim_userinfo_s *userinfo;
384 char *prof_encoding = NULL;
388 va_start(ap, command);
389 userinfo = va_arg(ap, struct aim_userinfo_s *);
390 prof_encoding = va_arg(ap, char *);
391 prof = va_arg(ap, char *);
394 printf("faimtest: userinfo: sn: %s\n", userinfo->sn);
395 printf("faimtest: userinfo: warnlevel: 0x%04x\n", userinfo->warnlevel);
396 printf("faimtest: userinfo: class: 0x%04x = ", userinfo->class);
410 if (userinfo->class & 0x0001)
412 if (userinfo->class & 0x0002)
413 printf("UNKNOWN_BIT2 ");
414 if (userinfo->class & 0x0004)
416 if (userinfo->class & 0x0008)
417 printf("UNKNOWN_BIT4 ");
418 if (userinfo->class & 0x0010)
422 printf("faimtest: userinfo: membersince: %lu\n", userinfo->membersince);
423 printf("faimtest: userinfo: onlinesince: %lu\n", userinfo->onlinesince);
424 printf("faimtest: userinfo: idletime: 0x%04x\n", userinfo->idletime);
426 printf("faimtest: userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
427 printf("faimtest: userinfo: prof: %s\n", prof ? prof : "[none]");
433 * The user-level Incoming ICBM callback.
436 * struct command_rx_struct * command if you feel like doing it yourself
437 * char * srcsn the source name
439 * int warnlevel warning/evil level
440 * int class user class
441 * ulong membersince time_t of date of signup
442 * ulong onsince time_t of date of singon
443 * int idletime min (sec?) idle
444 * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK}
447 int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...)
452 va_start(ap, command);
453 channel = va_arg(ap, int);
456 * Channel 1: Standard Message
460 struct aim_userinfo_s *userinfo;
464 u_short flag1, flag2;
466 userinfo = va_arg(ap, struct aim_userinfo_s *);
467 msg = va_arg(ap, char *);
468 icbmflags = va_arg(ap, u_int);
469 flag1 = va_arg(ap, u_short);
470 flag2 = va_arg(ap, u_short);
473 printf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn);
474 printf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel);
475 printf("faimtest: icbm: class = 0x%04x ", userinfo->class);
476 if (userinfo->class & 0x0010)
478 if (userinfo->class & 0x0001)
480 if (userinfo->class & 0x0004)
483 printf("faimtest: icbm: membersince = %lu\n", userinfo->membersince);
484 printf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince);
485 printf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime);
487 printf("faimtest: icbm: icbmflags = ");
488 if (icbmflags & AIM_IMFLAGS_AWAY)
490 if (icbmflags & AIM_IMFLAGS_ACK)
491 printf("ackrequest ");
494 printf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2);
496 printf("faimtest: icbm: message: %s\n", msg);
500 tmpstr = index(msg, '>');
506 if ( (strlen(tmpstr) >= 10) &&
507 (!strncmp(tmpstr, "disconnect", 10)) )
509 aim_send_im(sess, command->conn, "midendian", 0, "ta ta...");
512 else if (strstr(tmpstr, "goodday"))
514 printf("faimtest: icbm: sending response\n");
515 aim_send_im(sess, command->conn, userinfo->sn, 0, "Good day to you too.");
517 else if (!strncmp(tmpstr, "open chatnav", 12))
519 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
520 //aim_chat_join(sess, command->conn, "thishereisaname2_chat85");
522 else if (!strncmp(tmpstr, "create", 6))
524 aim_chatnav_createroom(sess, aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), "WorldDomination", 0x0004);
526 else if (!strncmp(tmpstr, "close chatnav", 13))
527 aim_conn_close(aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV));
528 else if (!strncmp(tmpstr, "join", 4))
530 aim_chat_join(sess, command->conn, 0x0004, "worlddomination");
532 else if (!strncmp(tmpstr, "leave", 5))
533 aim_chat_leaveroom(sess, "worlddomination");
537 printf("faimtest: icbm: starting chat...\n");
538 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
540 aim_bos_setidle(sess, command->conn, 0x0ffffffe);
547 * Channel 2: Rendevous Request
549 else if (channel == 2)
551 struct aim_userinfo_s *userinfo;
554 rendtype = va_arg(ap, int);
557 char *msg,*encoding,*lang;
558 struct aim_chat_roominfo *roominfo;
560 userinfo = va_arg(ap, struct aim_userinfo_s *);
561 roominfo = va_arg(ap, struct aim_chat_roominfo *);
562 msg = va_arg(ap, char *);
563 encoding = va_arg(ap, char *);
564 lang = va_arg(ap, char *);
567 printf("faimtest: chat invitation: source sn = %s\n", userinfo->sn);
568 printf("faimtest: chat invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
569 printf("faimtest: chat invitation: \tclass = 0x%04x ", userinfo->class);
570 if (userinfo->class & 0x0010)
572 if (userinfo->class & 0x0001)
574 if (userinfo->class & 0x0004)
577 /* we dont get membersince on chat invites! */
578 printf("faimtest: chat invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
579 printf("faimtest: chat invitation: \tidletime = 0x%04x\n", userinfo->idletime);
581 printf("faimtest: chat invitation: message = %s\n", msg);
582 printf("faimtest: chat invitation: room name = %s\n", roominfo->name);
583 printf("faimtest: chat invitation: encoding = %s\n", encoding);
584 printf("faimtest: chat invitation: language = %s\n", lang);
585 printf("faimtest: chat invitation: exchange = 0x%04x\n", roominfo->exchange);
586 printf("faimtest: chat invitation: instance = 0x%04x\n", roominfo->instance);
587 printf("faimtest: chat invitiation: autojoining %s...\n", roominfo->name);
589 * Automatically join room...
591 aim_chat_join(sess, command->conn, 0x0004, roominfo->name);
593 else if (rendtype == 1)
595 userinfo = va_arg(ap, struct aim_userinfo_s *);
598 printf("faimtest: voice invitation: source sn = %s\n", userinfo->sn);
599 printf("faimtest: voice invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
600 printf("faimtest: voice invitation: \tclass = 0x%04x ", userinfo->class);
601 if (userinfo->class & 0x0010)
603 if (userinfo->class & 0x0001)
605 if (userinfo->class & 0x0004)
608 /* we dont get membersince on chat invites! */
609 printf("faimtest: voice invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
610 printf("faimtest: voice invitation: \tidletime = 0x%04x\n", userinfo->idletime);
614 printf("faimtest: icbm: unknown rendtype (%d)\n", rendtype);
617 printf("faimtest does not support channels > 2 (chan = %02x)\n", channel);
618 printf("faimtest: icbm: done with ICBM handling\n");
623 int faimtest_authsvrready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
625 printf("faimtest_authsvrready: called (contype: %d)\n", command->conn->type);
627 /* should just be able to tell it we're ready too... */
628 aim_auth_clientready(sess, command->conn);
632 * This is where you'd really begin changing your password.
633 * However, this callback may get called for reasons other
634 * than you wanting to change your password. You should
635 * probably check that before actually doing it.
637 aim_auth_changepasswd(sess, command->conn, "PWD1", "PWD2");
643 int faimtest_pwdchngdone(struct aim_session_t *sess, struct command_rx_struct *command, ...)
645 printf("PASSWORD CHANGE SUCCESSFUL!!!\n");
649 int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
651 struct aim_userinfo_s *userinfo;
654 va_start(ap, command);
655 userinfo = va_arg(ap, struct aim_userinfo_s *);
658 printf("\n%s is now online (class: %04x = %s%s%s%s%s%s%s%s)\n", userinfo->sn, userinfo->class,
659 (userinfo->class&AIM_CLASS_TRIAL)?" TRIAL":"",
660 (userinfo->class&AIM_CLASS_UNKNOWN2)?" UNKNOWN2":"",
661 (userinfo->class&AIM_CLASS_AOL)?" AOL":"",
662 (userinfo->class&AIM_CLASS_UNKNOWN4)?" UNKNOWN4":"",
663 (userinfo->class&AIM_CLASS_FREE)?" FREE":"",
664 (userinfo->class&AIM_CLASS_AWAY)?" AWAY":"",
665 (userinfo->class&AIM_CLASS_UNKNOWN40)?" UNKNOWN40":"",
666 (userinfo->class&AIM_CLASS_UNKNOWN80)?" UNKNOWN80":"");
671 int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
676 va_start(ap, command);
677 sn = va_arg(ap, char *);
680 printf("\n%s has left\n", sn);
685 int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...)
691 va_start(ap, command);
692 id = va_arg(ap, u_short);
693 msg = va_arg(ap, char *);
696 printf("faimtest: motd: %s\n", msg);
702 * Handles callbacks for: AIM_CB_RATECHANGE, AIM_CB_USERERROR,
703 * AIM_CB_MISSED_IM, and AIM_CB_MISSED_CALL.
705 int faimtest_parse_misses(struct aim_session_t *sess, struct command_rx_struct *command, ...)
710 family = aimutil_get16(command->data+0);
711 subtype= aimutil_get16(command->data+2);
716 if (subtype == 0x000a) /* or AIM_CB_RATECHANGE */
717 printf("\n****STOP SENDING/RECIEVING MESSAGES SO FAST!****\n\n");
720 if (subtype == 0x0001) /* or AIM_CB_USERERROR */
722 u_long snacid = 0x00000000;
724 snacid = aimutil_get32(&command->data[6]);
726 printf("Received unknown error in SNAC family 0x0002 (snacid = %08lx)\n", snacid);
730 if (subtype == 0x0001) /* or AIM_CB_MISSED_IM */
731 printf("\n***LAST IM DIDN\'T MAKE IT BECAUSE THE BUDDY IS NOT ONLINE***\n\n");
732 else if (subtype == 0x000a) /* or AIM_CB_MISSED_CALL */
733 printf("You missed some messages from %s because they were sent too fast\n", &(command->data[13]));
741 int faimtest_parse_login(struct aim_session_t *sess, struct command_rx_struct *command, ...)
743 struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"};
744 u_char authcookie[11];
747 for (i = 0; i < (int)command->data[11]; i++)
748 authcookie[i] = command->data[12+i];
749 authcookie[i] = '\0';
751 printf("faimtest: logincookie: %s\n", authcookie);
753 aim_send_login(sess, command->conn, FAIMTEST_SCREENNAME, FAIMTEST_PASSWORD, &info);
759 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...)
762 struct aim_userinfo_s *userinfo;
763 int count = 0, i = 0;
765 va_start(ap, command);
766 count = va_arg(ap, int);
767 userinfo = va_arg(ap, struct aim_userinfo_s *);
770 printf("faimtest: chat: %s: New occupants have joined:\n", (char *)command->conn->priv);
772 printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
777 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...)
780 struct aim_userinfo_s *userinfo;
781 int count = 0, i = 0;
783 va_start(ap, command);
784 count = va_arg(ap, int);
785 userinfo = va_arg(ap, struct aim_userinfo_s *);
788 printf("faimtest: chat: %s: Some occupants have left:\n", (char *)command->conn->priv);
790 printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
795 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
798 struct aim_userinfo_s *userinfo;
799 struct aim_chat_roominfo *roominfo;
804 va_start(ap, command);
805 roominfo = va_arg(ap, struct aim_chat_roominfo *);
806 roomname = va_arg(ap, char *);
807 usercount= va_arg(ap, int);
808 userinfo = va_arg(ap, struct aim_userinfo_s *);
809 roomdesc = va_arg(ap, char *);
812 printf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv);
813 printf("faimtest: chat: %s: \tRoominfo: {%04x, %s, %04x}\n",
814 (char *)command->conn->priv,
818 printf("faimtest: chat: %s: \tRoomname: %s\n", (char *)command->conn->priv, roomname);
819 printf("faimtest: chat: %s: \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc);
820 printf("faimtest: chat: %s: \tOccupants: (%d)\n", (char *)command->conn->priv, usercount);
823 while (i < usercount)
824 printf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
829 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...)
832 struct aim_userinfo_s *userinfo;
836 va_start(ap, command);
837 userinfo = va_arg(ap, struct aim_userinfo_s *);
838 msg = va_arg(ap, char *);
841 printf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg);
844 * Do an echo for testing purposes. But not for ourselves ("oops!")
846 if (strcmp(userinfo->sn, sess->logininfo.screen_name) != 0)
848 sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg);
849 aim_chat_send_im(sess, command->conn, tmpbuf);
855 int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct *command, ...)
860 ap = va_start(ap, command);
861 type = va_arg(ap, u_short);
868 struct aim_chat_exchangeinfo *exchanges;
869 int exchangecount,i = 0;
871 maxrooms = va_arg(ap, u_char);
872 exchangecount = va_arg(ap, int);
873 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
876 printf("faimtest: chat info: Chat Rights:\n");
877 printf("faimtest: chat info: \tMax Concurrent Rooms: %d\n", maxrooms);
879 printf("faimtest: chat info: \tExchange List: (%d total)\n", exchangecount);
880 while (i < exchangecount)
882 printf("faimtest: chat info: \t\t%x: %s (%s/%s)\n",
885 exchanges[i].charset1,
894 printf("faimtest: chatnav info: unknown type (%04x)\n", type);