X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/blobdiff_plain/9f20a4e3d25b96996f9d07ee64dffc978ef0b769..24fbfcf349642bd1d140ce171c0fdd997ebedac2:/aim_chat.c diff --git a/aim_chat.c b/aim_chat.c index 85331ed..cf57449 100644 --- a/aim_chat.c +++ b/aim_chat.c @@ -5,6 +5,7 @@ * */ +#define FAIM_INTERNAL #include faim_export char *aim_chat_getname(struct aim_conn_t *conn) @@ -57,6 +58,7 @@ faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, int curbyte,i; struct command_tx_struct *newpacket; + struct aim_msgcookie_t *cookie; if (!sess || !conn || !msg) return 0; @@ -76,7 +78,10 @@ faim_export unsigned long aim_chat_send_im(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)); + cookie = aim_mkcookie(newpacket->data+curbyte-8, AIM_COOKIETYPE_CHAT, NULL); + cookie->data = strdup(conn->priv); /* chat hack dependent */ + + aim_cachecookie(sess, cookie); /* * metaTLV start. -- i assume this is a metaTLV. it could be the @@ -173,23 +178,9 @@ faim_export unsigned long aim_chat_join(struct aim_session_t *sess, newpacket->lock = 0; aim_tx_enqueue(sess, newpacket); -#if 0 - { - struct aim_snac_t snac; - - snac.id = sess->snac_nextid; - snac.family = 0x0001; - snac.type = 0x0004; - snac.flags = 0x0000; - - snac.data = malloc(strlen(roomname)+1); - strcpy(snac.data, roomname); + aim_cachesnac(sess, 0x0001, 0x0004, 0x0000, roomname, strlen(roomname)+1); - aim_newsnac(sess, &snac); - } - -#endif - return (sess->snac_nextid++); + return sess->snac_nextid; } faim_internal int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo) @@ -240,7 +231,6 @@ faim_internal int aim_chat_parse_infoupdate(struct aim_session_t *sess, u_short tlvcount = 0; struct aim_tlvlist_t *tlvlist; char *roomdesc = NULL; - struct aim_tlv_t *tmptlv; unsigned short unknown_c9 = 0; unsigned long creationtime = 0; unsigned short maxmsglen = 0; @@ -277,12 +267,8 @@ faim_internal int aim_chat_parse_infoupdate(struct aim_session_t *sess, /* * Type 0x006f: Number of occupants. */ - if (aim_gettlv(tlvlist, 0x006f, 1)) { - struct aim_tlv_t *tmptlv; - tmptlv = aim_gettlv(tlvlist, 0x006f, 1); - - usercount = aimutil_get16(tmptlv->value); - } + if (aim_gettlv(tlvlist, 0x006f, 1)) + usercount = aim_gettlv16(tlvlist, 0x006f, 1); /* * Type 0x0073: Occupant list. @@ -304,26 +290,26 @@ faim_internal int aim_chat_parse_infoupdate(struct aim_session_t *sess, /* * Type 0x00c9: Unknown. (2 bytes) */ - if ((tmptlv = aim_gettlv(tlvlist, 0x00c9, 1))) - unknown_c9 = aimutil_get16(tmptlv->value); + if (aim_gettlv(tlvlist, 0x00c9, 1)) + unknown_c9 = aim_gettlv16(tlvlist, 0x00c9, 1); /* * Type 0x00ca: Creation time (4 bytes) */ - if ((tmptlv = aim_gettlv(tlvlist, 0x00ca, 1))) - creationtime = aimutil_get32(tmptlv->value); + if (aim_gettlv(tlvlist, 0x00ca, 1)) + creationtime = aim_gettlv32(tlvlist, 0x00ca, 1); /* * Type 0x00d1: Maximum Message Length */ - if ((tmptlv = aim_gettlv(tlvlist, 0x00d1, 1))) - maxmsglen = aimutil_get16(tmptlv->value); + if (aim_gettlv(tlvlist, 0x00d1, 1)) + maxmsglen = aim_gettlv16(tlvlist, 0x00d1, 1); /* * Type 0x00d2: Unknown. (2 bytes) */ - if ((tmptlv = aim_gettlv(tlvlist, 0x00d2, 1))) - unknown_d2 = aimutil_get16(tmptlv->value);; + if (aim_gettlv(tlvlist, 0x00d2, 1)) + unknown_d2 = aim_gettlv16(tlvlist, 0x00d2, 1); /* * Type 0x00d3: Room Description @@ -334,12 +320,11 @@ faim_internal int aim_chat_parse_infoupdate(struct aim_session_t *sess, /* * Type 0x00d5: Unknown. (1 byte) */ - if ((tmptlv = aim_gettlv(tlvlist, 0x00d5, 1))) - unknown_d5 = aimutil_get8(tmptlv->value);; + if (aim_gettlv(tlvlist, 0x00d5, 1)) + unknown_d5 = aim_gettlv8(tlvlist, 0x00d5, 1); - userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE); - if (userfunc) { + if ((userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE))) { ret = userfunc(sess, command, &roominfo, @@ -375,8 +360,7 @@ faim_internal int aim_chat_parse_joined(struct aim_session_t *sess, i += aim_extractuserinfo(command->data+i, &userinfo[curcount-1]); } - userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN); - if (userfunc) { + if ((userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN))) { ret = userfunc(sess, command, curcount, @@ -402,8 +386,7 @@ faim_internal int aim_chat_parse_leave(struct aim_session_t *sess, i += aim_extractuserinfo(command->data+i, &userinfo[curcount-1]); } - userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE); - if (userfunc) { + if ((userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE))) { ret = userfunc(sess, command, curcount, @@ -576,6 +559,8 @@ faim_export unsigned long aim_chat_invite(struct aim_session_t *sess, { struct command_tx_struct *newpacket; int i,curbyte=0; + struct aim_msgcookie_t *cookie; + struct aim_invite_priv *priv; if (!sess || !conn || !sn || !msg || !roomname) return -1; @@ -597,7 +582,16 @@ faim_export unsigned long aim_chat_invite(struct aim_session_t *sess, curbyte += aimutil_put8(newpacket->data+curbyte, (u_char)rand()); /* XXX this should get uncached by the unwritten 'invite accept' handler */ - aim_cachecookie(sess, aim_mkcookie(newpacket->data+curbyte-8, AIM_COOKIETYPE_CHAT, NULL)); + if(!(priv = calloc(sizeof(struct aim_invite_priv), 1))) + return -1; + priv->sn = strdup(sn); + priv->roomname = strdup(roomname); + priv->exchange = exchange; + priv->instance = instance; + + if(!(cookie = aim_mkcookie(newpacket->data+curbyte-8, AIM_COOKIETYPE_INVITE, priv))) + return -1; + aim_cachecookie(sess, cookie); /* * Channel (2)