summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorz3bra <contactatz3bradotorg>2016-11-08 14:58:09 +0100
committerz3bra <contactatz3bradotorg>2016-11-08 16:47:52 +0100
commit31ee5a589ded07ce25d180566f8a6cb532e5ee96 (patch)
tree7414b7c89f6e9af94f03e0fe43df604c3126575b
parentf0862432026e32cc0e4a7bbd93a51509d507ac9e (diff)
Pass file number to tox_file_control()
-rw-r--r--ratox.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ratox.c b/ratox.c
index 1d74ee7..85dede1 100644
--- a/ratox.c
+++ b/ratox.c
@@ -771,11 +771,13 @@ cbfilesendreq(Tox *m, uint32_t frnum, uint32_t fnum, uint32_t kind, uint64_t fsz
if (f->rxstate == TRANSFER_INPROGRESS) {
logmsg(": %s : Rx > Rejected %s, already one in progress\n",
f->name, filename);
- if (!tox_file_control(tox, f->num, fnum, TOX_FILE_CONTROL_CANCEL, NULL))
+ if (!tox_file_control(tox, f->num, f->tx.fnum, TOX_FILE_CONTROL_CANCEL, NULL))
weprintf("Failed to kill new Rx transfer\n");
return;
}
+ f->tx.fnum = fnum;
+
ftruncate(f->fd[FFILE_STATE], 0);
lseek(f->fd[FFILE_STATE], 0, SEEK_SET);
dprintf(f->fd[FFILE_STATE], "%s\n", filename);
@@ -832,8 +834,9 @@ canceltxtransfer(struct friend *f)
if (f->tx.state == TRANSFER_NONE)
return;
logmsg(": %s : Tx > Cancelling\n", f->name);
- if (!tox_file_control(tox, f->num, 0, TOX_FILE_CONTROL_CANCEL, NULL))
+ if (!tox_file_control(tox, f->num, f->tx.fnum, TOX_FILE_CONTROL_CANCEL, NULL))
weprintf("Failed to kill Tx transfer\n");
+ f->tx.fnum = -1;
f->tx.state = TRANSFER_NONE;
free(f->tx.buf);
f->tx.buf = NULL;
@@ -846,7 +849,7 @@ cancelrxtransfer(struct friend *f)
if (f->rxstate == TRANSFER_NONE)
return;
logmsg(": %s : Rx > Cancelling\n", f->name);
- if (!tox_file_control(tox, f->num, 0, TOX_FILE_CONTROL_CANCEL, NULL))
+ if (!tox_file_control(tox, f->num, f->tx.fnum, TOX_FILE_CONTROL_CANCEL, NULL))
weprintf("Failed to kill Rx transfer\n");
if (f->fd[FFILE_OUT] != -1) {
close(f->fd[FFILE_OUT]);
@@ -1654,7 +1657,7 @@ loop(void)
if (r < 0)
continue;
f->fd[FFILE_OUT] = r;
- if (!tox_file_control(tox, f->num, 0, TOX_FILE_CONTROL_RESUME, NULL)) {
+ if (!tox_file_control(tox, f->num, f->tx.fnum, TOX_FILE_CONTROL_RESUME, NULL)) {
weprintf("Failed to accept transfer from receiver\n");
cancelrxtransfer(f);
} else {