]> andersk Git - libfaim.git/commitdiff
- Wed Mar 28 21:20:08 PST 2001
authormid <mid>
Thu, 29 Mar 2001 05:28:00 +0000 (05:28 +0000)
committermid <mid>
Thu, 29 Mar 2001 05:28:00 +0000 (05:28 +0000)
  - 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
include/aim.h
src/chat.c
src/im.c
utils/faimtest/commands.c
utils/faimtest/faimtest.c

diff --git a/CHANGES b/CHANGES
index 96d26fd237e38f2718495d7775a1d64316994621..93073e3d3e0bcd79a5ec1c144a94e1545a8b9dec 100644 (file)
--- 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().
index a5e6e2970bc7f64a7f80b606e29c69ef20ae208e..885dce620319772e693fe25e6b974534d27af724 100644 (file)
@@ -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);
index 51af85bd4f46357a66f3c0c970e100d0fa60dd32..05f421f476260e6cec33b17fb5ab6883bcd99e54 100644 (file)
@@ -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.
index ed4bbc9b89b3af6b838b3479a593a9b3769959fd..52ce41315581c821c7e347b38052c08587071058 100644 (file)
--- 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.  
index f27a3df1064376774f4522cd4b0d1e1e5af011a7..f306d73169f5b61ddd5d327888202dcf99ee04d1 100644 (file)
@@ -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);
 
index 35ca6a224993e727bd3ae94a1a79a6f84f11eac3..ec10485303d857a72d91ade469c0d594deafc346 100644 (file)
@@ -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;
This page took 0.075609 seconds and 5 git commands to generate.