X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/blobdiff_plain/040457cc47af3fd2ed743bda700e28a603d39eb6..be67fdd00ab2bb00bc6c7e5be8660909662d36e2:/aim_chat.c diff --git a/aim_chat.c b/aim_chat.c index 0543ade..ee40b0a 100644 --- a/aim_chat.c +++ b/aim_chat.c @@ -7,7 +7,7 @@ #include -char *aim_chat_getname(struct aim_conn_t *conn) +faim_export char *aim_chat_getname(struct aim_conn_t *conn) { if (!conn) return NULL; @@ -17,7 +17,7 @@ char *aim_chat_getname(struct aim_conn_t *conn) return (char *)conn->priv; /* yuck ! */ } -struct aim_conn_t *aim_chat_getconn(struct aim_session_t *sess, char *name) +faim_export struct aim_conn_t *aim_chat_getconn(struct aim_session_t *sess, char *name) { struct aim_conn_t *cur; @@ -33,7 +33,7 @@ struct aim_conn_t *aim_chat_getconn(struct aim_session_t *sess, char *name) return cur; } -int aim_chat_attachname(struct aim_conn_t *conn, char *roomname) +faim_export int aim_chat_attachname(struct aim_conn_t *conn, char *roomname) { if (!conn || !roomname) return -1; @@ -44,9 +44,9 @@ int aim_chat_attachname(struct aim_conn_t *conn, char *roomname) return 0; } -u_long aim_chat_send_im(struct aim_session_t *sess, - struct aim_conn_t *conn, - char *msg) +faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, + struct aim_conn_t *conn, + char *msg) { int curbyte,i; @@ -55,7 +55,7 @@ u_long aim_chat_send_im(struct aim_session_t *sess, if (!sess || !conn || !msg) return 0; - if (!(newpacket = aim_tx_new(0x0002, conn, 1152))) + if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) return -1; newpacket->lock = 1; /* lock struct */ @@ -68,7 +68,9 @@ u_long aim_chat_send_im(struct aim_session_t *sess, * Generate a random message cookie */ for (i=0;i<8;i++) - curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) random()); + curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) rand()); + + aim_cachecookie(sess, aim_mkcookie(newpacket->data+curbyte-8, AIM_COOKIETYPE_CHAT, NULL)); /* * metaTLV start. -- i assume this is a metaTLV. it could be the @@ -119,10 +121,10 @@ u_long aim_chat_send_im(struct aim_session_t *sess, * and room name. * */ -u_long aim_chat_join(struct aim_session_t *sess, - struct aim_conn_t *conn, - u_short exchange, - const char *roomname) +faim_export unsigned long aim_chat_join(struct aim_session_t *sess, + struct aim_conn_t *conn, + u_short exchange, + const char *roomname) { struct command_tx_struct *newpacket; int i; @@ -130,7 +132,7 @@ u_long aim_chat_join(struct aim_session_t *sess, if (!sess || !conn || !roomname) return 0; - if (!(newpacket = aim_tx_new(0x0002, conn, 10+9+strlen(roomname)+2))) + if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+9+strlen(roomname)+2))) return -1; newpacket->lock = 1; @@ -186,7 +188,7 @@ u_long aim_chat_join(struct aim_session_t *sess, return (sess->snac_nextid++); } -int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo) +faim_internal int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo) { int namelen = 0; int i = 0; @@ -209,7 +211,7 @@ int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo) i += 2; return i; -}; +} /* @@ -221,8 +223,8 @@ int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo) * * SNAC 000e/0002 */ -int aim_chat_parse_infoupdate(struct aim_session_t *sess, - struct command_rx_struct *command) +faim_internal int aim_chat_parse_infoupdate(struct aim_session_t *sess, + struct command_rx_struct *command) { struct aim_userinfo_s *userinfo = NULL; rxcallback_t userfunc=NULL; @@ -356,8 +358,8 @@ int aim_chat_parse_infoupdate(struct aim_session_t *sess, return ret; } -int aim_chat_parse_joined(struct aim_session_t *sess, - struct command_rx_struct *command) +faim_internal int aim_chat_parse_joined(struct aim_session_t *sess, + struct command_rx_struct *command) { struct aim_userinfo_s *userinfo = NULL; rxcallback_t userfunc=NULL; @@ -382,8 +384,8 @@ int aim_chat_parse_joined(struct aim_session_t *sess, return ret; } -int aim_chat_parse_leave(struct aim_session_t *sess, - struct command_rx_struct *command) +faim_internal int aim_chat_parse_leave(struct aim_session_t *sess, + struct command_rx_struct *command) { struct aim_userinfo_s *userinfo = NULL; @@ -414,8 +416,8 @@ int aim_chat_parse_leave(struct aim_session_t *sess, * code as channel 0x0003, however, since only the start * would be the same, we might as well do it here. */ -int aim_chat_parse_incoming(struct aim_session_t *sess, - struct command_rx_struct *command) +faim_internal int aim_chat_parse_incoming(struct aim_session_t *sess, + struct command_rx_struct *command) { struct aim_userinfo_s userinfo; rxcallback_t userfunc=NULL; @@ -430,11 +432,13 @@ int aim_chat_parse_incoming(struct aim_session_t *sess, i = 10; /* skip snac */ /* - * ICBM Cookie. Ignore it. + * ICBM Cookie. Cache it. */ for (z=0; z<8; z++,i++) cookie[z] = command->data[i]; + aim_cachecookie(sess, aim_mkcookie(cookie, AIM_COOKIETYPE_ICBM, NULL)); + /* * Channel ID * @@ -507,13 +511,13 @@ int aim_chat_parse_incoming(struct aim_session_t *sess, return ret; } -u_long aim_chat_clientready(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_chat_clientready(struct aim_session_t *sess, + struct aim_conn_t *conn) { struct command_tx_struct *newpacket; int i; - if (!(newpacket = aim_tx_new(0x0002, conn, 0x20))) + if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 0x20))) return -1; newpacket->lock = 1; @@ -538,7 +542,7 @@ u_long aim_chat_clientready(struct aim_session_t *sess, return (sess->snac_nextid++); } -int aim_chat_leaveroom(struct aim_session_t *sess, char *name) +faim_export int aim_chat_leaveroom(struct aim_session_t *sess, char *name) { struct aim_conn_t *conn; @@ -553,13 +557,13 @@ int aim_chat_leaveroom(struct aim_session_t *sess, char *name) /* * conn must be a BOS connection! */ -u_long aim_chat_invite(struct aim_session_t *sess, - struct aim_conn_t *conn, - char *sn, - char *msg, - u_short exchange, - char *roomname, - u_short instance) +faim_export unsigned long aim_chat_invite(struct aim_session_t *sess, + struct aim_conn_t *conn, + char *sn, + char *msg, + u_short exchange, + char *roomname, + u_short instance) { struct command_tx_struct *newpacket; int i,curbyte=0; @@ -567,7 +571,7 @@ u_long aim_chat_invite(struct aim_session_t *sess, if (!sess || !conn || !sn || !msg || !roomname) return 0; - if (!(newpacket = aim_tx_new(0x0002, conn, 1152+strlen(sn)+strlen(roomname)+strlen(msg)))) + if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152+strlen(sn)+strlen(roomname)+strlen(msg)))) return -1; newpacket->lock = 1; @@ -579,6 +583,7 @@ u_long aim_chat_invite(struct aim_session_t *sess, */ for (i=0;i<8;i++) curbyte += aimutil_put8(newpacket->data+curbyte, (u_char)rand()); + aim_cachecookie(sess, aim_mkcookie(newpacket->data+curbyte-8, AIM_COOKIETYPE_CHAT, NULL)); /* * Channel (2)