From: mid Date: Thu, 23 Mar 2000 22:42:10 +0000 (+0000) Subject: - Thu Mar 23 08:45:40 UTC 2000 X-Git-Tag: rel_0_99_2~166 X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/commitdiff_plain/50443ea05d49f1e6f4629b5aca078c24763aca7f - Thu Mar 23 08:45:40 UTC 2000 - Removed aim_countconn() > 0 check in aim_select(), its logically redundent - Added aim_putuserinfo() (inverse of aim_extractuserinfo()) - Added aim_sendbuddyoncoming/offgoing() - Rearranged loop in rxdispatch() - Remove aim_conn_close() if connections dead in aim_get_command() --- diff --git a/CHANGES b/CHANGES index 17068a9..e10031f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,16 @@ No release numbers ------------------ + - Thu Mar 23 08:45:40 UTC 2000 + - Removed aim_countconn() > 0 check in aim_select(), its logically redundent + - Added aim_putuserinfo() (inverse of aim_extractuserinfo()) + - Added aim_sendbuddyoncoming/offgoing() + - Rearranged loop in rxdispatch() + - Remove aim_conn_close() if connections dead in aim_get_command() + + - Thu Mar 23 00:44:32 UTC 2000 + - Added a check to purge_rxqueue to skip handled commands + - Mon Mar 20 05:30:59 UTC 2000 - Added some server-only functions for login - Added aim_counttlvchain() diff --git a/aim_conn.c b/aim_conn.c index 5cb4a79..cb4d1b2 100644 --- a/aim_conn.c +++ b/aim_conn.c @@ -176,9 +176,6 @@ struct aim_conn_t *aim_select(struct aim_session_t *sess, fd_set fds; int i; - if (aim_countconn(sess) <= 0) - return 0; - /* * If we have data waiting to be sent, return immediatly */ diff --git a/aim_im.c b/aim_im.c index 3a777fa..8386992 100644 --- a/aim_im.c +++ b/aim_im.c @@ -185,7 +185,8 @@ int aim_parse_incoming_im_middle(struct aim_session_t *sess, * features of AIM2/3/3.5. * * Channel 0x0002 is the Rendevous channel, which - * is where Chat Invitiations come from. + * is where Chat Invitiations and various client-client + * connection negotiations come from. * */ channel = aimutil_get16(command->data+i); diff --git a/aim_info.c b/aim_info.c index 384c9ce..8ba5878 100644 --- a/aim_info.c +++ b/aim_info.c @@ -364,3 +364,98 @@ int aim_parse_userinfo_middle(struct aim_session_t *sess, return 1; } + +/* + * Inverse of aim_extractuserinfo() + */ +int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info) +{ + int i = 0; + struct aim_tlvlist_t *tlvlist = NULL; + + if (!buf || !info) + return 0; + + i += aimutil_put8(buf+i, strlen(info->sn)); + i += aimutil_putstr(buf+i, info->sn, strlen(info->sn)); + + i += aimutil_put16(buf+i, info->warnlevel); + + /* XXX: we only put down five */ + i += aimutil_put16(buf+i, 5); + aim_addtlvtochain16(&tlvlist, 0x0001, info->class); + aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); + aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); + aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); + /* XXX: should put caps here */ + aim_addtlvtochain32(&tlvlist, (info->class)&AIM_CLASS_AOL?0x0010:0x000f, info->sessionlen); + + i += aim_writetlvchain(buf+i, buflen-i, &tlvlist); + aim_freetlvchain(&tlvlist); + + return i; +} + +int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info) +{ + struct command_tx_struct tx; + int i = 0; + + if (!sess || !conn || !info) + return 0; + + tx.conn = conn; + + tx.commandlen = 1152; /* too big */ + tx.data = malloc(tx.commandlen); + memset(tx.data, 0x00, tx.commandlen); + + tx.lock = 1; + tx.type = 0x02; + + i += aimutil_put16(tx.data+i, 0x0003); + i += aimutil_put16(tx.data+i, 0x000b); + i += aimutil_put16(tx.data+i, 0x0000); + i += aimutil_put16(tx.data+i, 0x0000); + i += aimutil_put16(tx.data+i, 0x0000); + + i += aim_putuserinfo(tx.data+i, tx.commandlen-i, info); + + tx.commandlen = i; + tx.lock = 0; + aim_tx_enqueue(sess, &tx); + + return 0; +} + +int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn) +{ + struct command_tx_struct tx; + int i = 0; + + if (!sess || !conn || !sn) + return 0; + + tx.conn = conn; + + tx.commandlen = 10 + 1 + strlen(sn); + tx.data = malloc(tx.commandlen); + memset(tx.data, 0x00, tx.commandlen); + + tx.lock = 1; + tx.type = 0x02; + + i += aimutil_put16(tx.data+i, 0x0003); + i += aimutil_put16(tx.data+i, 0x000c); + i += aimutil_put16(tx.data+i, 0x0000); + i += aimutil_put16(tx.data+i, 0x0000); + i += aimutil_put16(tx.data+i, 0x0000); + + i += aimutil_put8(tx.data+i, strlen(sn)); + i += aimutil_putstr(tx.data+i, sn, strlen(sn)); + + tx.lock = 0; + aim_tx_enqueue(sess, &tx); + + return 0; +} diff --git a/aim_rxhandlers.c b/aim_rxhandlers.c index 7b0a0f9..5b2a149 100644 --- a/aim_rxhandlers.c +++ b/aim_rxhandlers.c @@ -304,10 +304,13 @@ int aim_rxdispatch(struct aim_session_t *sess) return 0; } else { workingPtr = sess->queue_incoming; - for (i = 0; workingPtr != NULL; i++) { + for (i = 0; workingPtr != NULL; workingPtr = workingPtr->next, i++) { /* * XXX: This is still fairly ugly. */ + if (workingPtr->handled) + continue; + switch(workingPtr->conn->type) { case -1: /* @@ -547,8 +550,6 @@ int aim_rxdispatch(struct aim_session_t *sess) workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_UNKNOWN, workingPtr); break; } - /* move to next command */ - workingPtr = workingPtr->next; } } diff --git a/aim_rxqueue.c b/aim_rxqueue.c index 88721c4..7ec7e13 100644 --- a/aim_rxqueue.c +++ b/aim_rxqueue.c @@ -94,7 +94,7 @@ int aim_get_command(struct aim_session_t *sess) if ((err = aim_failsaferead(s, &(generic[i]), 1)) < 0) { /* error is probably not recoverable...(must be a pessimistic day) */ - aim_conn_close(conn); + /* aim_conn_close(conn); */ return err; } diff --git a/faim/aim.h b/faim/aim.h index f67bbb8..dc82d19 100644 --- a/faim/aim.h +++ b/faim/aim.h @@ -396,6 +396,9 @@ int aim_extractuserinfo(u_char *, struct aim_userinfo_s *); int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *); int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *); int aim_parse_offgoing_middle(struct aim_session_t *, struct command_rx_struct *); +int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info); +int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info); +int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn); /* aim_auth.c */ int aim_auth_sendcookie(struct aim_session_t *, struct aim_conn_t *, u_char *);