tFix PAUSE/RESUME in file transfers - ratox - FIFO based tox client
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit fa8e064db3d5d2d37ac9e333e0b7ae15fcac4f0d
 (DIR) parent 74c488007be7376e43d09233633a874368621532
 (HTM) Author: sin <sin@2f30.org>
       Date:   Fri, 19 Sep 2014 11:39:53 +0100
       
       Fix PAUSE/RESUME in file transfers
       
       The doc lies, if the receiver resumes a transfer you get
       a control packet with send_receive == 1 and control_type == TOX_FILECONTROL_ACCEPT.
       
       We keep state locally and move from PAUSED to INPROGRESS when the
       above happens.
       
       Diffstat:
         M ratox.c                             |      26 +++++++++++++-------------
       
       1 file changed, 13 insertions(+), 13 deletions(-)
       ---
 (DIR) diff --git a/ratox.c b/ratox.c
       t@@ -371,21 +371,21 @@ cbfilecontrol(Tox *m, int32_t fid, uint8_t rec_sen, uint8_t fnum, uint8_t ctrlty
                switch (ctrltype) {
                case TOX_FILECONTROL_ACCEPT:
                        if (rec_sen == 1) {
       -                        f->t.fnum = fnum;
       -                        f->t.chunksz = tox_file_data_size(tox, fnum);
       -                        f->t.buf = malloc(f->t.chunksz);
       -                        if (!f->t.buf) {
       -                                perror("malloc");
       -                                exit(EXIT_FAILURE);
       -                        }
       -                        f->t.n = 0;
       -                        f->t.pending = 0;
       -                        f->t.state = TRANSFER_INPROGRESS;
       -                        printout("Transfer is in progress\n");
       -                } else {
                                if (f->t.state == TRANSFER_PAUSED) {
       -                                printf("Receiver resumed transfer\n");
       +                                printout("Receiver resumed transfer\n");
       +                                f->t.state = TRANSFER_INPROGRESS;
       +                        } else {
       +                                f->t.fnum = fnum;
       +                                f->t.chunksz = tox_file_data_size(tox, fnum);
       +                                f->t.buf = malloc(f->t.chunksz);
       +                                if (!f->t.buf) {
       +                                        perror("malloc");
       +                                        exit(EXIT_FAILURE);
       +                                }
       +                                f->t.n = 0;
       +                                f->t.pending = 0;
                                        f->t.state = TRANSFER_INPROGRESS;
       +                                printout("Transfer is in progress\n");
                                }
                        }
                        break;