diff options
author | sin <sin@2f30.org> | 2014-09-24 13:07:30 +0100 |
---|---|---|
committer | sin <sin@2f30.org> | 2014-09-24 13:07:30 +0100 |
commit | 2940555e6279e9c2012fbef35d7611050b6fbf4c (patch) | |
tree | 0f1640226557b5fa945442aad7410d690ed08b77 | |
parent | f3c677af98cd91acd61f2ff8ec1a3d2df5ee0e84 (diff) |
Cancel pending transfers
-rw-r--r-- | ratox.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -552,9 +552,12 @@ cbfiledata(Tox *m, int32_t fid, uint8_t fnum, const uint8_t *data, uint16_t len, } } +/* T0D0: Might want to break this function into two separate ones for + * TX and RX to minimize code duplication when cancelling transfers */ static void canceltransfer(struct friend *f) { + /* Cancel TX transfers */ if (f->t.state != TRANSFER_NONE) { printout("Cancelling transfer to %s\n", f->namestr[0] == '\0' ? "Anonymous" : f->namestr); @@ -566,6 +569,14 @@ canceltransfer(struct friend *f) while (fiforead(f->dirfd, &f->fd[FFILE_IN], ffiles[FFILE_IN], toilet, sizeof(toilet))); } + /* Cancel RX transfers */ + if (f->recvfilepending == 1) { + tox_file_send_control(tox, f->fid, 1, 0, TOX_FILECONTROL_KILL, NULL, 0); + if (f->fd[FFILE_OUT] != -1) { + close(f->fd[FFILE_OUT]); + f->fd[FFILE_OUT] = -1; + } + } } static void |