tMake the behaviour symetric. - ratox - FIFO based tox client
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f7a953ff973a632f4afa4914482052c2ad8ee300
 (DIR) parent 254e8e62498d0099bdf939624d7b9d4bc67ef49f
 (HTM) Author: pranomostro <pranomostro@posteo.net>
       Date:   Sun,  9 Jul 2017 13:39:34 +0200
       
       Make the behaviour symetric.
       
       Since ratox writes to text_out in friend conversations, this should also
       happen in conferences.
       
       Diffstat:
         M ratox.c                             |      17 +++++++++++++----
       
       1 file changed, 13 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/ratox.c b/ratox.c
       t@@ -1077,10 +1077,10 @@ sendfriendtext(struct friend *f)
                ssize_t n;
                time_t  t;
                char buft[64];
       -        uint8_t buf[TOX_MAX_MESSAGE_LENGTH];
       +        uint8_t buf[TOX_MAX_MESSAGE_LENGTH + 1];
                TOX_ERR_FRIEND_SEND_MESSAGE err;
        
       -        n = fiforead(f->dirfd, &f->fd[FTEXT_IN], ffiles[FTEXT_IN], buf, sizeof(buf));
       +        n = fiforead(f->dirfd, &f->fd[FTEXT_IN], ffiles[FTEXT_IN], buf, sizeof(buf) - 1);
                if (n <= 0)
                        return;
                if (buf[n - 1] == '\n' && n > 1)
       t@@ -1143,9 +1143,11 @@ static void
        sendconftext(struct conference *c)
        {
                ssize_t n;
       -        uint8_t buf[TOX_MAX_MESSAGE_LENGTH];
       +        time_t  t;
       +        char    buft[64];
       +        uint8_t buf[TOX_MAX_MESSAGE_LENGTH + 1], me[TOX_MAX_NAME_LENGTH + 1];
        
       -        n = fiforead(c->dirfd, &c->fd[CTEXT_IN], cfiles[CTEXT_IN], buf, sizeof(buf));
       +        n = fiforead(c->dirfd, &c->fd[CTEXT_IN], cfiles[CTEXT_IN], buf, sizeof(buf) - 1);
                if (n <= 0)
                        return;
                if (buf[n - 1] == '\n' && n > 1)
       t@@ -1153,6 +1155,13 @@ sendconftext(struct conference *c)
                if (!tox_conference_send_message(tox, c->num, TOX_MESSAGE_TYPE_NORMAL,
                    buf, n, NULL))
                        weprintf("Failed to send message to %s\n", c->numstr);
       +
       +        buf[n] = '\0';
       +        t = time(NULL);
       +        strftime(buft, sizeof(buft), "%F %R", localtime(&t));
       +        tox_self_get_name(tox, me);
       +        me[tox_self_get_name_size(tox)] = '\0';
       +        dprintf(c->fd[CTEXT_OUT], "%s <%s> %s\n", buft, me, buf);
        }
        
        static void