X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/blobdiff_plain/00ef5271216e3bea9b233ce26a3c0f21fbca931f..d32954e7c6dedab32fc72c6f2f301a8530fd36cc:/utils/faimtest/faimtest.c diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index 96d993d..76fc179 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -319,6 +319,8 @@ int main(int argc, char **argv) int i; int selstat = 0; static int faimtest_mode = 0; + struct timeval tv; + time_t lastnop = 0; screenname = getenv("SCREENNAME"); password = getenv("PASSWORD"); @@ -398,12 +400,22 @@ int main(int argc, char **argv) } while (keepgoing) { - waitingconn = aim_select(&aimsess, NULL, &selstat); + + tv.tv_sec = 5; + tv.tv_usec = 0; + + waitingconn = aim_select(&aimsess, &tv, &selstat); + + if (connected && ((time(NULL) - lastnop) > 30)) { + lastnop = time(NULL); + dprintf("sending NOP\n"); + aim_flap_nop(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)); + } if (selstat == -1) { /* error */ keepgoing = 0; /* fall through */ } else if (selstat == 0) { /* no events pending */ - keepgoing = 0; + ; } else if (selstat == 1) { /* outgoing data pending */ aim_tx_flushqueue(&aimsess); } else if (selstat == 2) { /* incoming data pending */ @@ -466,7 +478,7 @@ int faimtest_rateresp(struct aim_session_t *sess, struct command_rx_struct *comm aim_bos_ackrateresp(sess, command->conn); /* ack rate info response */ aim_bos_reqpersonalinfo(sess, command->conn); aim_bos_reqlocaterights(sess, command->conn); - 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 | AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS); + 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 /*| AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS*/); aim_bos_reqbuddyrights(sess, command->conn); /* send the buddy list and profile (required, even if empty) */ @@ -479,7 +491,7 @@ int faimtest_rateresp(struct aim_session_t *sess, struct command_rx_struct *comm aim_bos_reqrights(sess, command->conn); /* set group permissions -- all user classes */ aim_bos_setgroupperm(sess, command->conn, AIM_FLAG_ALLUSERS); - aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE|AIM_PRIVFLAGS_ALLOWMEMBERSINCE); + aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE); break; } @@ -693,98 +705,91 @@ int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct ip = va_arg(ap, char *); cookie = va_arg(ap, unsigned char *); - switch(serviceid) - { - case 0x0005: /* Adverts */ - { - struct aim_conn_t *tstconn; + switch(serviceid) { + case 0x0005: { /* Adverts */ + struct aim_conn_t *tstconn; - tstconn = aim_newconn(sess, AIM_CONN_TYPE_ADS, ip); - if ((tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { - dprintf("faimtest: unable to reconnect with authorizer\n"); - } else { - aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0); - aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); - aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); - aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, faimtest_rateresp, 0); /* rate info */ - aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, 0x0018, faimtest_hostversions, 0); - aim_auth_sendcookie(sess, tstconn, cookie); - dprintf("sent cookie to adverts host\n"); - } + tstconn = aim_newconn(sess, AIM_CONN_TYPE_ADS, ip); + if ((tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { + dprintf("faimtest: unable to reconnect with authorizer\n"); + } else { + aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0); + aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); + aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); + aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, faimtest_rateresp, 0); /* rate info */ + aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, 0x0018, faimtest_hostversions, 0); + aim_auth_sendcookie(sess, tstconn, cookie); + dprintf("sent cookie to adverts host\n"); + } + break; + } + case 0x0007: { /* Authorizer */ + struct aim_conn_t *tstconn; + /* Open a connection to the Auth */ + tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); + if ((tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { + dprintf("faimtest: unable to reconnect with authorizer\n"); + } else { + aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0); + aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); + aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); + aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, faimtest_rateresp, 0); /* rate info */ + aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, 0x0018, faimtest_hostversions, 0); + aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, faimtest_accountconfirm, 0); + aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, faimtest_infochange, 0); + aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, faimtest_infochange, 0); + /* Send the cookie to the Auth */ + aim_auth_sendcookie(sess, tstconn, cookie); + dprintf("sent cookie to authorizer host\n"); + } + break; + } + case 0x000d: { /* ChatNav */ + struct aim_conn_t *tstconn = NULL; + tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip); + if ( (tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { + dprintf("faimtest: unable to connect to chatnav server\n"); + if (tstconn) aim_conn_kill(sess, &tstconn); + return 1; + } - } - break; - case 0x0007: /* Authorizer */ - { - struct aim_conn_t *tstconn; - /* Open a connection to the Auth */ - tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); - if ((tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { - dprintf("faimtest: unable to reconnect with authorizer\n"); - } else { - aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0); - aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); - aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); - aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, faimtest_rateresp, 0); /* rate info */ - aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, 0x0018, faimtest_hostversions, 0); - aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, faimtest_accountconfirm, 0); - aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, faimtest_infochange, 0); - aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, faimtest_infochange, 0); - /* Send the cookie to the Auth */ - aim_auth_sendcookie(sess, tstconn, cookie); - dprintf("sent cookie to authorizer host\n"); - } + aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); + aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); + aim_auth_sendcookie(sess, tstconn, cookie); + dprintf("\achatnav: connected\n"); + break; + } + case 0x000e: { /* Chat */ + char *roomname = NULL; + int exchange; + struct aim_conn_t *tstconn = NULL; - } - break; - case 0x000d: /* ChatNav */ - { - struct aim_conn_t *tstconn = NULL; - tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip); - if ( (tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { - dprintf("faimtest: unable to connect to chatnav server\n"); - if (tstconn) aim_conn_kill(sess, &tstconn); - return 1; - } + roomname = va_arg(ap, char *); + exchange = va_arg(ap, int); - aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); - aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); - aim_auth_sendcookie(sess, tstconn, cookie); - dprintf("\achatnav: connected\n"); - } - break; - case 0x000e: /* Chat */ - { - char *roomname = NULL; - int exchange; - struct aim_conn_t *tstconn = NULL; - - roomname = va_arg(ap, char *); - exchange = va_arg(ap, int); - - tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip); - if ( (tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) - { - dprintf("faimtest: unable to connect to chat server\n"); - if (tstconn) aim_conn_kill(sess, &tstconn); - return 1; - } - dvprintf("faimtest: chat: connected to %s on exchange %d\n", roomname, exchange); - - /* - * We must do this to attach the stored name to the connection! - */ - aim_chat_attachname(tstconn, roomname); - - aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); - aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); - aim_auth_sendcookie(sess, tstconn, cookie); - } - break; - default: - dvprintf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid); - /* dunno */ - } + tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip); + if ( (tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { + dprintf("faimtest: unable to connect to chat server\n"); + if (tstconn) aim_conn_kill(sess, &tstconn); + return 1; + } + dvprintf("faimtest: chat: connected to %s on exchange %d\n", roomname, exchange); + + /* + * We must do this to attach the stored name to the connection! + */ + aim_chat_attachname(tstconn, roomname); + + aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); + aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); + aim_auth_sendcookie(sess, tstconn, cookie); + + break; + } + default: + dvprintf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid); + /* dunno */ + } va_end(ap); @@ -888,7 +893,7 @@ int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, faimtest_parse_genericerr, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, faimtest_parse_connerr, 0); - + aim_conn_addhandler(sess, bosconn, 0xffff, 0xffff, faimtest_parse_unknown, 0); aim_auth_sendcookie(sess, bosconn, cookie); @@ -1479,15 +1484,25 @@ int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - char *sn; + struct aim_userinfo_s *userinfo; + va_list ap; - va_start(ap, command); - sn = va_arg(ap, char *); + userinfo = va_arg(ap, struct aim_userinfo_s *); va_end(ap); - dvprintf("\n%s has left\n", sn); - + dvprintf("%ld %s is now offline (flags: %04x = %s%s%s%s%s%s%s%s) (caps = 0x%04x)\n", + time(NULL), + userinfo->sn, userinfo->flags, + (userinfo->flags&AIM_FLAG_UNCONFIRMED)?" UNCONFIRMED":"", + (userinfo->flags&AIM_FLAG_ADMINISTRATOR)?" ADMINISTRATOR":"", + (userinfo->flags&AIM_FLAG_AOL)?" AOL":"", + (userinfo->flags&AIM_FLAG_OSCAR_PAY)?" OSCAR_PAY":"", + (userinfo->flags&AIM_FLAG_FREE)?" FREE":"", + (userinfo->flags&AIM_FLAG_AWAY)?" AWAY":"", + (userinfo->flags&AIM_FLAG_UNKNOWN40)?" UNKNOWN40":"", + (userinfo->flags&AIM_FLAG_UNKNOWN80)?" UNKNOWN80":"", + userinfo->capabilities); return 1; } @@ -1516,6 +1531,19 @@ int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *co if (!connected) connected++; +#if 0 + aim_bos_reqservice(sess, command->conn, 0x0005); /* adverts */ + aim_bos_reqservice(sess, command->conn, 0x000f); /* user directory */ + + /* Don't know what this does... */ + /* XXX sess->sn should be normalized by the 0001/000f handler */ + aim_0002_000b(sess, command->conn, sess->sn); +#endif + + /* As of 26 Mar 2001 you need to send this to keep from getting kicked off */ + aim_0001_0020(sess, command->conn); + + return 1; } @@ -1791,6 +1819,8 @@ int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct dvprintf("faimtest: connerr: Code 0x%04x: %s\n", code, msg); aim_conn_kill(sess, &command->conn); /* this will break the main loop */ + connected = 0; + return 1; }