From fa8e064db3d5d2d37ac9e333e0b7ae15fcac4f0d Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 19 Sep 2014 11:39:53 +0100 Subject: 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. --- ratox.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'ratox.c') diff --git a/ratox.c b/ratox.c index fff138e..1d983b9 100644 --- a/ratox.c +++ b/ratox.c @@ -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; -- cgit v1.2.3