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")) ||
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)
{
#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;
/* 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 */
}
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");
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 *);
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);
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;
}