X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/blobdiff_plain/0c20631fc9dd6411357abe57e146196087631010..aa6efcfde1e9630866e98b4987bf2d9e6aba02fc:/utils/faimtest/faimtest.c diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index 1456a0f..5c0fba7 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -65,15 +65,16 @@ int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struc int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...); int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...); -static char *screenname,*password; +static char *screenname,*password,*server=NULL; int main(void) { struct aim_session_t aimsess; - struct aim_conn_t *authconn = NULL; - int stayconnected = 1; + struct aim_conn_t *authconn = NULL, *waitingconn = NULL; + int keepgoing = 1, stayconnected = 1; struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"}; - + int selstat = 0; + aim_session_init(&aimsess); if ( !(screenname = getenv("SCREENNAME")) || @@ -83,12 +84,14 @@ int main(void) return -1; } + server = getenv("AUTHSERVER"); + /* * (I used a goto-based loop here because n wanted quick proof * that reconnecting without restarting was actually possible...) */ enter: - authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, FAIM_LOGIN_SERVER); + authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, server?server:FAIM_LOGIN_SERVER); if (authconn == NULL) { @@ -120,27 +123,40 @@ int main(void) #endif } - while (aim_select(&aimsess, NULL) > (struct aim_conn_t *)0) - { - if (aimsess.queue_outgoing) - aim_tx_flushqueue(&aimsess); + while (keepgoing) { + waitingconn = aim_select(&aimsess, NULL, &selstat); - if (aim_get_command(&aimsess) < 0) - { + switch(selstat) { + case -1: /* error */ + keepgoing = 0; + break; + + case 0: /* no events pending */ + break; + + case 1: /* outgoing data pending */ + aim_tx_flushqueue(&aimsess); + break; + + case 2: /* incoming data pending */ + if (aim_get_command(&aimsess, waitingconn) < 0) { printf("\afaimtest: connection error!\n"); - } - else + } else aim_rxdispatch(&aimsess); + break; + + default: + break; /* invalid */ } + } /* Close up */ - printf("AIM just decided we didn't need to be here anymore, closing up.,,\n"); + printf("AIM just decided we didn't need to be here anymore, closing up...\n"); /* close up all connections, dead or no */ aim_logoff(&aimsess); - if (stayconnected) - { + if (stayconnected) { printf("\nTrying to reconnect in 2 seconds...\n"); sleep(2); goto enter; @@ -247,7 +263,7 @@ int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct /* send the buddy list and profile (required, even if empty) */ aim_bos_setbuddylist(sess, command->conn, buddies); - aim_bos_setprofile(sess, command->conn, profile, NULL); + aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_CHAT); /* send final login command (required) */ aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */ @@ -531,7 +547,10 @@ int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_str } else if (!strncmp(tmpstr, "leave", 5)) aim_chat_leaveroom(sess, "worlddomination"); - else + else if (!strncmp(tmpstr, "getinfo", 7)) { + aim_getinfo(sess, command->conn, "midendian", AIM_GETINFO_GENERALINFO); + aim_getinfo(sess, command->conn, "midendian", AIM_GETINFO_AWAYMESSAGE); + } else { #if 0 printf("faimtest: icbm: starting chat...\n"); @@ -800,6 +819,8 @@ int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struc char *roomname; int usercount,i; char *roomdesc; + unsigned short unknown_c9, unknown_d2, unknown_d5, maxmsglen; + unsigned long creationtime; va_start(ap, command); roominfo = va_arg(ap, struct aim_chat_roominfo *); @@ -807,6 +828,11 @@ int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struc usercount= va_arg(ap, int); userinfo = va_arg(ap, struct aim_userinfo_s *); roomdesc = va_arg(ap, char *); + unknown_c9 = va_arg(ap, unsigned short); + creationtime = va_arg(ap, unsigned long); + maxmsglen = va_arg(ap, unsigned short); + unknown_d2 = va_arg(ap, unsigned short); + unknown_d5 = va_arg(ap, unsigned short); va_end(ap); printf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv); @@ -823,6 +849,12 @@ int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struc while (i < usercount) printf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn); + printf("faimtest: chat: %s: \tUnknown_c9: 0x%04x\n", (char *)command->conn->priv, unknown_c9); + printf("faimtest: chat: %s: \tCreation time: %lu (time_t)\n", (char *)command->conn->priv, creationtime); + printf("faimtest: chat: %s: \tMax message length: %d bytes\n", (char *)command->conn->priv, maxmsglen); + printf("faimtest: chat: %s: \tUnknown_d2: 0x%04x\n", (char *)command->conn->priv, unknown_d2); + printf("faimtest: chat: %s: \tUnknown_d5: 0x%02x\n", (char *)command->conn->priv, unknown_d5); + return 1; }