summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2014-09-19 11:39:53 +0100
committersin <sin@2f30.org>2014-09-19 11:39:53 +0100
commitfa8e064db3d5d2d37ac9e333e0b7ae15fcac4f0d (patch)
tree4af4677dff2bc2361e3e242befa65fe276f7a0fa
parent74c488007be7376e43d09233633a874368621532 (diff)
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.
-rw-r--r--ratox.c26
1 files changed, 13 insertions, 13 deletions
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;