From a2244dd929b26cf2edac3cbfd5ed22678eb87051 Mon Sep 17 00:00:00 2001 From: mid Date: Thu, 29 Mar 2001 05:28:00 +0000 Subject: [PATCH] - Wed Mar 28 21:20:08 PST 2001 - Add flags arg to aim_chat_send_im() - Add msglen arg to aim_send_im and aim_chat_send_im - This will make more sense when I make the UNICODE commit (tomorrow?) --- CHANGES | 5 +++++ include/aim.h | 6 ++++-- src/chat.c | 37 ++++++++++++++++++++++++++++++------- src/im.c | 22 +++++++++++----------- utils/faimtest/commands.c | 4 ++-- utils/faimtest/faimtest.c | 12 ++++++------ 6 files changed, 58 insertions(+), 28 deletions(-) diff --git a/CHANGES b/CHANGES index 96d26fd..93073e3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@ No release numbers ------------------ + - Wed Mar 28 21:20:08 PST 2001 + - Add flags arg to aim_chat_send_im() + - Add msglen arg to aim_send_im and aim_chat_send_im + - This will make more sense when I make the UNICODE commit (tomorrow?) + - Wed Mar 28 16:51:25 PST 2001 - I decided it was a good day while I was figuring out that it was a bad day. - See faimtest and login.c::memrequest(). diff --git a/include/aim.h b/include/aim.h index a5e6e29..885dce6 100644 --- a/include/aim.h +++ b/include/aim.h @@ -637,7 +637,7 @@ struct aim_filetransfer_priv { #define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */ #define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */ -faim_export unsigned long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *); +faim_export unsigned long aim_send_im(struct aim_session_t *, struct aim_conn_t *, const char *destsn, unsigned short flags, const char *msg, int msglen); faim_export int aim_send_im_direct(struct aim_session_t *, struct aim_conn_t *, char *); faim_export struct aim_conn_t * aim_directim_initiate(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *, char *destsn); faim_export struct aim_conn_t *aim_directim_connect(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *); @@ -736,7 +736,9 @@ struct aim_chat_exchangeinfo { char *lang2; }; -faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, char *msg); +#define AIM_CHATFLAGS_NOREFLECT 0x0001 +#define AIM_CHATFLAGS_AWAY 0x0002 +faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned short flags, const char *msg, int msglen); faim_export unsigned 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_clientready(struct aim_session_t *sess, struct aim_conn_t *conn); faim_export int aim_chat_attachname(struct aim_conn_t *conn, char *roomname); diff --git a/src/chat.c b/src/chat.c index 51af85b..05f421f 100644 --- a/src/chat.c +++ b/src/chat.c @@ -51,17 +51,30 @@ faim_export int aim_chat_attachname(struct aim_conn_t *conn, char *roomname) return 0; } -/* XXX convert this to use tlvchains */ +/* + * Send a Chat Message. + * + * Possible flags: + * AIM_CHATFLAGS_NOREFLECT -- Unset the flag that requests messages + * should be sent to their sender. + * AIM_CHATFLAGS_AWAY -- Mark the message as an autoresponse + * (Note that WinAIM does not honor this, + * and displays the message as normal.) + * + * XXX convert this to use tlvchains + */ faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, - char *msg) + unsigned short flags, + const char *msg, + int msglen) { int curbyte,i; struct command_tx_struct *newpacket; struct aim_msgcookie_t *cookie; - if (!sess || !conn || !msg) + if (!sess || !conn || !msg || (msglen <= 0)) return 0; if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152))) @@ -90,16 +103,26 @@ faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003); /* - * Type 1: Unknown. Blank. + * Type 1: Flag meaning this message is destined to the room. */ curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); /* - * Type 6: Unknown. Blank. + * Type 6: Reflect */ - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0006); - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); + if (!(flags & AIM_CHATFLAGS_NOREFLECT)) { + curbyte += aimutil_put16(newpacket->data+curbyte, 0x0006); + curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); + } + + /* + * Type 7: Autoresponse + */ + if (flags & AIM_CHATFLAGS_AWAY) { + curbyte += aimutil_put16(newpacket->data+curbyte, 0x0007); + curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); + } /* * Type 5: Message block. Contains more TLVs. diff --git a/src/im.c b/src/im.c index ed4bbc9..52ce413 100644 --- a/src/im.c +++ b/src/im.c @@ -75,18 +75,18 @@ faim_export unsigned short aim_fingerprintclient(unsigned char *msghdr, int len) * when the message is received (of type 0x0004/0x000c) * */ -faim_export unsigned long aim_send_im(struct aim_session_t *sess, - struct aim_conn_t *conn, - char *destsn, u_int flags, char *msg) -{ - +faim_export unsigned long aim_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, const char *destsn, unsigned short flags, const char *msg, int msglen) +{ int curbyte,i; struct command_tx_struct *newpacket; - - if (strlen(msg) >= MAXMSGLEN) + + if (!msg || (msglen <= 0)) + return -1; + + if (msglen >= MAXMSGLEN) return -1; - if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, strlen(msg)+256))) + if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, msglen+256))) return -1; newpacket->lock = 1; /* lock struct */ @@ -122,7 +122,7 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess, * metaTLV start. */ curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); - curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x10); + curbyte += aimutil_put16(newpacket->data+curbyte, msglen + 0x10); /* * Flag data / ICBM Parameters? @@ -145,7 +145,7 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess, /* * Message block length. */ - curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x04); + curbyte += aimutil_put16(newpacket->data+curbyte, msglen + 0x04); /* * Character set data? @@ -156,7 +156,7 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess, /* * Message. Not terminated. */ - curbyte += aimutil_putstr(newpacket->data+curbyte,msg, strlen(msg)); + curbyte += aimutil_putstr(newpacket->data+curbyte,msg, msglen); /* * Set the Request Acknowledge flag. diff --git a/utils/faimtest/commands.c b/utils/faimtest/commands.c index f27a3df..f306d73 100644 --- a/utils/faimtest/commands.c +++ b/utils/faimtest/commands.c @@ -219,7 +219,7 @@ static int cmd_connlist(char *arg) static int cmd_goodday(char *arg) { if (arg && strlen(arg) && (strlen(arg) < MAXSNLEN)) - aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), arg, AIM_IMFLAGS_ACK, "Good day to you too."); + aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), arg, AIM_IMFLAGS_ACK, "Good day to you too.", strlen("Good day to you too.")); else printf("no one to say hello to!\n"); @@ -266,7 +266,7 @@ static int cmd_sendmsg(char *arg) newbuf[z] = (z % 10)+0x30; newbuf[len] = '\0'; - aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), sn, AIM_IMFLAGS_ACK, newbuf); + aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), sn, AIM_IMFLAGS_ACK, newbuf, strlen(newbuf)); free(newbuf); diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index 35ca6a2..ec10485 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -260,7 +260,7 @@ int logout(void) { if (ohcaptainmycaptain) - aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), ohcaptainmycaptain, 0, "ta ta..."); + aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), ohcaptainmycaptain, 0, "ta ta...", strlen("ta ta...")); aim_session_kill(&aimsess); @@ -1037,7 +1037,7 @@ static int faimtest_handlecmd(struct aim_session_t *sess, struct command_rx_stru } else if (strstr(tmpstr, "goodday")) { - aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too."); + aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too.", strlen("Good day to you too.")); } else if (strstr(tmpstr, "warnme")) { @@ -1063,7 +1063,7 @@ static int faimtest_handlecmd(struct aim_session_t *sess, struct command_rx_stru if (!ohcaptainmycaptain) { - aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "I have no owner!"); + aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "I have no owner!", strlen("I have no owner!")); } else { struct aim_conn_t *newconn; @@ -1117,7 +1117,7 @@ static int faimtest_handlecmd(struct aim_session_t *sess, struct command_rx_stru } else if (!strncmp(tmpstr, "reqsendmsg", 10)) { - aim_send_im(sess, command->conn, ohcaptainmycaptain, 0, "sendmsg 7900"); + aim_send_im(sess, command->conn, ohcaptainmycaptain, 0, "sendmsg 7900", strlen("sendmsg 7900")); } else if (!strncmp(tmpstr, "reqauth", 7)) { @@ -1151,7 +1151,7 @@ static int faimtest_handlecmd(struct aim_session_t *sess, struct command_rx_stru newbuf[z] = (z % 10)+0x30; } newbuf[i] = '\0'; - aim_send_im(sess, command->conn, userinfo->sn, 0, newbuf); + aim_send_im(sess, command->conn, userinfo->sn, 0, newbuf, strlen(newbuf)); free(newbuf); } @@ -1803,7 +1803,7 @@ int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_stru if (strcmp(userinfo->sn, sess->sn) != 0) { sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg); - aim_chat_send_im(sess, command->conn, tmpbuf); + aim_chat_send_im(sess, command->conn, 0, tmpbuf, strlen(tmpbuf)); } return 1; -- 2.45.1