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,*server=NULL;
72 struct aim_session_t aimsess;
73 struct aim_conn_t *authconn = NULL, *waitingconn = NULL;
74 int keepgoing = 1, stayconnected = 1;
75 struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"};
78 aim_session_init(&aimsess);
80 if ( !(screenname = getenv("SCREENNAME")) ||
81 !(password = getenv("PASSWORD")))
83 printf("Must specify SCREENAME and PASSWORD in environment.\n");
87 server = getenv("AUTHSERVER");
90 * (I used a goto-based loop here because n wanted quick proof
91 * that reconnecting without restarting was actually possible...)
94 authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, server?server:FAIM_LOGIN_SERVER);
98 fprintf(stderr, "faimtest: internal connection error while in aim_login. bailing out.\n");
101 else if (authconn->fd == -1)
103 if (authconn->status & AIM_CONN_STATUS_RESOLVERR)
104 fprintf(stderr, "faimtest: could not resolve authorizer name\n");
105 else if (authconn->status & AIM_CONN_STATUS_CONNERR)
106 fprintf(stderr, "faimtest: could not connect to authorizer\n");
112 /* new login code -- not default -- pending new password encryption algo */
113 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0);
114 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0);
116 aim_sendconnack(&aimsess, authconn);
117 aim_request_login(&aimsess, authconn, FAIMTEST_SCREENNAME);
119 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_AUTHSUCCESS, faimtest_parse_authresp, 0);
120 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_authsvrready, 0);
121 aim_send_login(&aimsess, authconn, screenname, password, &info);
127 waitingconn = aim_select(&aimsess, NULL, &selstat);
134 case 0: /* no events pending */
137 case 1: /* outgoing data pending */
138 aim_tx_flushqueue(&aimsess);
141 case 2: /* incoming data pending */
142 if (aim_get_command(&aimsess, waitingconn) < 0) {
143 printf("\afaimtest: connection error!\n");
145 aim_rxdispatch(&aimsess);
154 printf("AIM just decided we didn't need to be here anymore, closing up...\n");
156 /* close up all connections, dead or no */
157 aim_logoff(&aimsess);
160 printf("\nTrying to reconnect in 2 seconds...\n");
169 int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
171 switch (command->conn->type)
173 case AIM_CONN_TYPE_BOS:
175 aim_bos_reqrate(sess, command->conn); /* request rate info */
176 aim_bos_ackrateresp(sess, command->conn); /* ack rate info response -- can we say timing? */
177 aim_bos_setprivacyflags(sess, command->conn, 0x00000003);
180 aim_bos_reqpersonalinfo(sess, command->conn);
183 /* Request advertisement service -- see comment in handleredirect */
184 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS);
185 aim_setversions(sess, command->conn);
188 aim_bos_reqrights(sess, command->conn);
189 aim_bos_reqbuddyrights(sess, command->conn);
190 aim_bos_reqlocaterights(sess, command->conn);
191 aim_bos_reqicbmparaminfo(sess, command->conn);
194 /* set group permissions */
195 aim_bos_setgroupperm(sess, command->conn, 0x1f);
196 fprintf(stderr, "faimtest: done with BOS ServerReady\n");
199 case AIM_CONN_TYPE_CHATNAV:
200 fprintf(stderr, "faimtest: chatnav: got server ready\n");
201 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, faimtest_chatnav_info, 0);
202 aim_bos_reqrate(sess, command->conn);
203 aim_bos_ackrateresp(sess, command->conn);
204 aim_chatnav_clientready(sess, command->conn);
205 aim_chatnav_reqrights(sess, command->conn);
208 case AIM_CONN_TYPE_CHAT:
209 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0);
210 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0);
211 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0);
212 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0);
213 aim_bos_reqrate(sess, command->conn);
214 aim_bos_ackrateresp(sess, command->conn);
215 aim_chat_clientready(sess, command->conn);
218 fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
226 This, of course, handles Service Redirects from OSCAR.
228 Should get passed in the following:
229 struct command_rx_struct *command
232 the destination service ID
234 the IP address of the service's server
238 int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
245 /* this is the new buddy list */
246 char buddies[] = "Buddy1&Buddy2&ThisHereIsAName2&";
247 /* this is the new profile */
248 char profile[] = "Hello";
250 va_start(ap, command);
251 serviceid = va_arg(ap, int);
252 ip = va_arg(ap, char *);
253 cookie = va_arg(ap, char *);
257 case 0x0005: /* Advertisements */
259 * The craziest explanation yet as to why we finish logging in when
260 * we get the advertisements redirect, of which we don't use anyway....
264 /* send the buddy list and profile (required, even if empty) */
265 aim_bos_setbuddylist(sess, command->conn, buddies);
266 aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_CHAT);
268 /* send final login command (required) */
269 aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */
271 /* you should now be ready to go */
272 printf("\nYou are now officially online.\n");
275 case 0x0007: /* Authorizer */
277 struct aim_conn_t *tstconn;
278 /* Open a connection to the Auth */
279 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip);
280 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR) )
281 fprintf(stderr, "faimtest: unable to reconnect with authorizer\n");
283 /* Send the cookie to the Auth */
284 aim_auth_sendcookie(sess, tstconn, cookie);
288 case 0x000d: /* ChatNav */
290 struct aim_conn_t *tstconn = NULL;
291 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip);
292 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR))
294 fprintf(stderr, "faimtest: unable to connect to chatnav server\n");
298 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_CTN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
299 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
301 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
302 aim_auth_sendcookie(sess, tstconn, cookie);
303 fprintf(stderr, "\achatnav: connected\n");
306 case 0x000e: /* Chat */
308 char *roomname = NULL;
309 struct aim_conn_t *tstconn = NULL;
311 roomname = va_arg(ap, char *);
313 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip);
314 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR))
316 fprintf(stderr, "faimtest: unable to connect to chat server\n");
319 printf("faimtest: chat: connected\n");
322 * We must do this to attach the stored name to the connection!
324 aim_chat_attachname(tstconn, roomname);
326 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
327 aim_auth_sendcookie(sess, tstconn, cookie);
331 printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
340 int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
342 struct aim_conn_t *bosconn = NULL;
345 printf("Screen name: %s\n", sess->logininfo.screen_name);
350 if (sess->logininfo.errorcode)
352 printf("Login Error Code 0x%04x\n", sess->logininfo.errorcode);
353 printf("Error URL: %s\n", sess->logininfo.errorurl);
354 aim_conn_close(command->conn);
355 exit(0); /* XXX: should return in order to let the above things get free()'d. */
358 printf("Reg status: %2d\n", sess->logininfo.regstatus);
359 printf("Email: %s\n", sess->logininfo.email);
360 printf("BOS IP: %s\n", sess->logininfo.BOSIP);
362 printf("Closing auth connection...\n");
363 aim_conn_close(command->conn);
364 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, sess->logininfo.BOSIP);
367 fprintf(stderr, "faimtest: could not connect to BOS: internal error\n");
369 else if (bosconn->status != 0)
371 fprintf(stderr, "faimtest: could not connect to BOS\n");
375 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0);
376 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0);
377 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0);
378 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0);
379 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, NULL, 0);
380 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0);
381 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0);
382 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
383 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_misses, 0);
384 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0);
385 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_misses, 0);
386 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_misses, 0);
387 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0);
389 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0);
390 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
391 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0);
392 aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie);
397 int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct *command, ...)
399 struct aim_userinfo_s *userinfo;
400 char *prof_encoding = NULL;
404 va_start(ap, command);
405 userinfo = va_arg(ap, struct aim_userinfo_s *);
406 prof_encoding = va_arg(ap, char *);
407 prof = va_arg(ap, char *);
410 printf("faimtest: userinfo: sn: %s\n", userinfo->sn);
411 printf("faimtest: userinfo: warnlevel: 0x%04x\n", userinfo->warnlevel);
412 printf("faimtest: userinfo: class: 0x%04x = ", userinfo->class);
426 if (userinfo->class & 0x0001)
428 if (userinfo->class & 0x0002)
429 printf("UNKNOWN_BIT2 ");
430 if (userinfo->class & 0x0004)
432 if (userinfo->class & 0x0008)
433 printf("UNKNOWN_BIT4 ");
434 if (userinfo->class & 0x0010)
438 printf("faimtest: userinfo: membersince: %lu\n", userinfo->membersince);
439 printf("faimtest: userinfo: onlinesince: %lu\n", userinfo->onlinesince);
440 printf("faimtest: userinfo: idletime: 0x%04x\n", userinfo->idletime);
442 printf("faimtest: userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
443 printf("faimtest: userinfo: prof: %s\n", prof ? prof : "[none]");
449 * The user-level Incoming ICBM callback.
452 * struct command_rx_struct * command if you feel like doing it yourself
453 * char * srcsn the source name
455 * int warnlevel warning/evil level
456 * int class user class
457 * ulong membersince time_t of date of signup
458 * ulong onsince time_t of date of singon
459 * int idletime min (sec?) idle
460 * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK}
463 int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...)
468 va_start(ap, command);
469 channel = va_arg(ap, int);
472 * Channel 1: Standard Message
476 struct aim_userinfo_s *userinfo;
480 u_short flag1, flag2;
482 userinfo = va_arg(ap, struct aim_userinfo_s *);
483 msg = va_arg(ap, char *);
484 icbmflags = va_arg(ap, u_int);
485 flag1 = va_arg(ap, u_short);
486 flag2 = va_arg(ap, u_short);
489 printf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn);
490 printf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel);
491 printf("faimtest: icbm: class = 0x%04x ", userinfo->class);
492 if (userinfo->class & 0x0010)
494 if (userinfo->class & 0x0001)
496 if (userinfo->class & 0x0004)
499 printf("faimtest: icbm: membersince = %lu\n", userinfo->membersince);
500 printf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince);
501 printf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime);
503 printf("faimtest: icbm: icbmflags = ");
504 if (icbmflags & AIM_IMFLAGS_AWAY)
506 if (icbmflags & AIM_IMFLAGS_ACK)
507 printf("ackrequest ");
510 printf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2);
512 printf("faimtest: icbm: message: %s\n", msg);
516 tmpstr = index(msg, '>');
522 if ( (strlen(tmpstr) >= 10) &&
523 (!strncmp(tmpstr, "disconnect", 10)) )
525 aim_send_im(sess, command->conn, "midendian", 0, "ta ta...");
528 else if (strstr(tmpstr, "goodday"))
530 printf("faimtest: icbm: sending response\n");
531 aim_send_im(sess, command->conn, userinfo->sn, 0, "Good day to you too.");
533 else if (!strncmp(tmpstr, "open chatnav", 12))
535 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
536 //aim_chat_join(sess, command->conn, "thishereisaname2_chat85");
538 else if (!strncmp(tmpstr, "create", 6))
540 aim_chatnav_createroom(sess, aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), "WorldDomination", 0x0004);
542 else if (!strncmp(tmpstr, "close chatnav", 13))
543 aim_conn_close(aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV));
544 else if (!strncmp(tmpstr, "join", 4))
546 aim_chat_join(sess, command->conn, 0x0004, "worlddomination");
548 else if (!strncmp(tmpstr, "leave", 5))
549 aim_chat_leaveroom(sess, "worlddomination");
553 printf("faimtest: icbm: starting chat...\n");
554 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
556 aim_bos_setidle(sess, command->conn, 0x0ffffffe);
563 * Channel 2: Rendevous Request
565 else if (channel == 2)
567 struct aim_userinfo_s *userinfo;
570 rendtype = va_arg(ap, int);
573 char *msg,*encoding,*lang;
574 struct aim_chat_roominfo *roominfo;
576 userinfo = va_arg(ap, struct aim_userinfo_s *);
577 roominfo = va_arg(ap, struct aim_chat_roominfo *);
578 msg = va_arg(ap, char *);
579 encoding = va_arg(ap, char *);
580 lang = va_arg(ap, char *);
583 printf("faimtest: chat invitation: source sn = %s\n", userinfo->sn);
584 printf("faimtest: chat invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
585 printf("faimtest: chat invitation: \tclass = 0x%04x ", userinfo->class);
586 if (userinfo->class & 0x0010)
588 if (userinfo->class & 0x0001)
590 if (userinfo->class & 0x0004)
593 /* we dont get membersince on chat invites! */
594 printf("faimtest: chat invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
595 printf("faimtest: chat invitation: \tidletime = 0x%04x\n", userinfo->idletime);
597 printf("faimtest: chat invitation: message = %s\n", msg);
598 printf("faimtest: chat invitation: room name = %s\n", roominfo->name);
599 printf("faimtest: chat invitation: encoding = %s\n", encoding);
600 printf("faimtest: chat invitation: language = %s\n", lang);
601 printf("faimtest: chat invitation: exchange = 0x%04x\n", roominfo->exchange);
602 printf("faimtest: chat invitation: instance = 0x%04x\n", roominfo->instance);
603 printf("faimtest: chat invitiation: autojoining %s...\n", roominfo->name);
605 * Automatically join room...
607 aim_chat_join(sess, command->conn, 0x0004, roominfo->name);
609 else if (rendtype == 1)
611 userinfo = va_arg(ap, struct aim_userinfo_s *);
614 printf("faimtest: voice invitation: source sn = %s\n", userinfo->sn);
615 printf("faimtest: voice invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
616 printf("faimtest: voice invitation: \tclass = 0x%04x ", userinfo->class);
617 if (userinfo->class & 0x0010)
619 if (userinfo->class & 0x0001)
621 if (userinfo->class & 0x0004)
624 /* we dont get membersince on chat invites! */
625 printf("faimtest: voice invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
626 printf("faimtest: voice invitation: \tidletime = 0x%04x\n", userinfo->idletime);
630 printf("faimtest: icbm: unknown rendtype (%d)\n", rendtype);
633 printf("faimtest does not support channels > 2 (chan = %02x)\n", channel);
634 printf("faimtest: icbm: done with ICBM handling\n");
639 int faimtest_authsvrready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
641 printf("faimtest_authsvrready: called (contype: %d)\n", command->conn->type);
643 /* should just be able to tell it we're ready too... */
644 aim_auth_clientready(sess, command->conn);
648 * This is where you'd really begin changing your password.
649 * However, this callback may get called for reasons other
650 * than you wanting to change your password. You should
651 * probably check that before actually doing it.
653 aim_auth_changepasswd(sess, command->conn, "PWD1", "PWD2");
659 int faimtest_pwdchngdone(struct aim_session_t *sess, struct command_rx_struct *command, ...)
661 printf("PASSWORD CHANGE SUCCESSFUL!!!\n");
665 int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
667 struct aim_userinfo_s *userinfo;
670 va_start(ap, command);
671 userinfo = va_arg(ap, struct aim_userinfo_s *);
674 printf("\n%s is now online (class: %04x = %s%s%s%s%s%s%s%s)\n", userinfo->sn, userinfo->class,
675 (userinfo->class&AIM_CLASS_TRIAL)?" TRIAL":"",
676 (userinfo->class&AIM_CLASS_UNKNOWN2)?" UNKNOWN2":"",
677 (userinfo->class&AIM_CLASS_AOL)?" AOL":"",
678 (userinfo->class&AIM_CLASS_UNKNOWN4)?" UNKNOWN4":"",
679 (userinfo->class&AIM_CLASS_FREE)?" FREE":"",
680 (userinfo->class&AIM_CLASS_AWAY)?" AWAY":"",
681 (userinfo->class&AIM_CLASS_UNKNOWN40)?" UNKNOWN40":"",
682 (userinfo->class&AIM_CLASS_UNKNOWN80)?" UNKNOWN80":"");
687 int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
692 va_start(ap, command);
693 sn = va_arg(ap, char *);
696 printf("\n%s has left\n", sn);
701 int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...)
707 va_start(ap, command);
708 id = va_arg(ap, u_short);
709 msg = va_arg(ap, char *);
712 printf("faimtest: motd: %s\n", msg);
718 * Handles callbacks for: AIM_CB_RATECHANGE, AIM_CB_USERERROR,
719 * AIM_CB_MISSED_IM, and AIM_CB_MISSED_CALL.
721 int faimtest_parse_misses(struct aim_session_t *sess, struct command_rx_struct *command, ...)
726 family = aimutil_get16(command->data+0);
727 subtype= aimutil_get16(command->data+2);
732 if (subtype == 0x000a) /* or AIM_CB_RATECHANGE */
733 printf("\n****STOP SENDING/RECIEVING MESSAGES SO FAST!****\n\n");
736 if (subtype == 0x0001) /* or AIM_CB_USERERROR */
738 u_long snacid = 0x00000000;
740 snacid = aimutil_get32(&command->data[6]);
742 printf("Received unknown error in SNAC family 0x0002 (snacid = %08lx)\n", snacid);
746 if (subtype == 0x0001) /* or AIM_CB_MISSED_IM */
747 printf("\n***LAST IM DIDN\'T MAKE IT BECAUSE THE BUDDY IS NOT ONLINE***\n\n");
748 else if (subtype == 0x000a) /* or AIM_CB_MISSED_CALL */
749 printf("You missed some messages from %s because they were sent too fast\n", &(command->data[13]));
757 int faimtest_parse_login(struct aim_session_t *sess, struct command_rx_struct *command, ...)
759 struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"};
760 u_char authcookie[11];
763 for (i = 0; i < (int)command->data[11]; i++)
764 authcookie[i] = command->data[12+i];
765 authcookie[i] = '\0';
767 printf("faimtest: logincookie: %s\n", authcookie);
769 aim_send_login(sess, command->conn, FAIMTEST_SCREENNAME, FAIMTEST_PASSWORD, &info);
775 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...)
778 struct aim_userinfo_s *userinfo;
779 int count = 0, i = 0;
781 va_start(ap, command);
782 count = va_arg(ap, int);
783 userinfo = va_arg(ap, struct aim_userinfo_s *);
786 printf("faimtest: chat: %s: New occupants have joined:\n", (char *)command->conn->priv);
788 printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
793 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...)
796 struct aim_userinfo_s *userinfo;
797 int count = 0, i = 0;
799 va_start(ap, command);
800 count = va_arg(ap, int);
801 userinfo = va_arg(ap, struct aim_userinfo_s *);
804 printf("faimtest: chat: %s: Some occupants have left:\n", (char *)command->conn->priv);
806 printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
811 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
814 struct aim_userinfo_s *userinfo;
815 struct aim_chat_roominfo *roominfo;
820 va_start(ap, command);
821 roominfo = va_arg(ap, struct aim_chat_roominfo *);
822 roomname = va_arg(ap, char *);
823 usercount= va_arg(ap, int);
824 userinfo = va_arg(ap, struct aim_userinfo_s *);
825 roomdesc = va_arg(ap, char *);
828 printf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv);
829 printf("faimtest: chat: %s: \tRoominfo: {%04x, %s, %04x}\n",
830 (char *)command->conn->priv,
834 printf("faimtest: chat: %s: \tRoomname: %s\n", (char *)command->conn->priv, roomname);
835 printf("faimtest: chat: %s: \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc);
836 printf("faimtest: chat: %s: \tOccupants: (%d)\n", (char *)command->conn->priv, usercount);
839 while (i < usercount)
840 printf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
845 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...)
848 struct aim_userinfo_s *userinfo;
852 va_start(ap, command);
853 userinfo = va_arg(ap, struct aim_userinfo_s *);
854 msg = va_arg(ap, char *);
857 printf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg);
860 * Do an echo for testing purposes. But not for ourselves ("oops!")
862 if (strcmp(userinfo->sn, sess->logininfo.screen_name) != 0)
864 sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg);
865 aim_chat_send_im(sess, command->conn, tmpbuf);
871 int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct *command, ...)
876 ap = va_start(ap, command);
877 type = va_arg(ap, u_short);
884 struct aim_chat_exchangeinfo *exchanges;
885 int exchangecount,i = 0;
887 maxrooms = va_arg(ap, u_char);
888 exchangecount = va_arg(ap, int);
889 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
892 printf("faimtest: chat info: Chat Rights:\n");
893 printf("faimtest: chat info: \tMax Concurrent Rooms: %d\n", maxrooms);
895 printf("faimtest: chat info: \tExchange List: (%d total)\n", exchangecount);
896 while (i < exchangecount)
898 printf("faimtest: chat info: \t\t%x: %s (%s/%s)\n",
901 exchanges[i].charset1,
910 printf("faimtest: chatnav info: unknown type (%04x)\n", type);