diff options
Diffstat (limited to 'ratox.c')
-rw-r--r-- | ratox.c | 46 |
1 files changed, 3 insertions, 43 deletions
@@ -197,8 +197,7 @@ static void cbstatusmessage(Tox *, uint32_t, const uint8_t *, size_t, void *); static void cbfriendstate(Tox *, uint32_t, TOX_USER_STATUS, void *); static void cbfilecontrol(Tox *, uint32_t, uint32_t, TOX_FILE_CONTROL, void *); static void cbfilesendreq(Tox *, uint32_t, uint32_t, uint32_t, uint64_t, const uint8_t *, size_t, void *); -static void cbfiledatareq(Tox *, uint32_t, uint32_t, uint64_t, size_t, void *); -static void cbfiledata(Tox *, uint32_t, uint32_t, uint64_t, const uint8_t *, size_t, void *); +static void cbfiledata(Tox *, int32_t, uint32_t, uint64_t, const uint8_t *, size_t, void *); static void canceltxtransfer(struct friend *); static void cancelrxtransfer(struct friend *); @@ -734,7 +733,7 @@ cbfilecontrol(Tox *m, uint32_t frnum, uint32_t fnum, TOX_FILE_CONTROL ctrltype, f->tx.state = TRANSFER_INPROGRESS; } else { f->tx.fnum = fnum; - f->tx.chunksz = TOX_MAX_CUSTOM_PACKET_SIZE; + f->tx.chunksz = tox_file_data_size(tox, fnum); f->tx.buf = malloc(f->tx.chunksz); if (!f->tx.buf) eprintf("malloc:"); @@ -770,44 +769,6 @@ cbfilecontrol(Tox *m, uint32_t frnum, uint32_t fnum, TOX_FILE_CONTROL ctrltype, } static void -cbfiledatareq(Tox *m, uint32_t frnum, uint32_t fnum, uint64_t pos, size_t flen, void *udata) -{ - struct friend *f; - ssize_t n; - - TAILQ_FOREACH(f, &friendhead, entry) - if (f->num == frnum) - break; - - /* Grab another buffer from the FIFO */ - if (!f->tx.pendingbuf) { - n = fiforead(f->dirfd, &f->fd[FFILE_IN], ffiles[FFILE_IN], f->tx.buf, - f->tx.chunksz); - f->tx.n = n; - f->tx.pendingbuf = 0; - } - - if (f->tx.n == 0) { - /* Signal transfer completion to other end */ - if (!tox_file_send_chunk(tox, f->num, f->tx.fnum, pos, NULL, 0, NULL)) - weprintf("Failed to signal transfer completion to the receiver\n"); - logmsg(": %s : Tx > Complete\n", f->name); - f->tx.state = TRANSFER_NONE; - free(f->tx.buf); - f->tx.buf = NULL; - return; - } - if (f->tx.n < 0) { - if (errno != EWOULDBLOCK) - weprintf("fiforead:"); - return; - } - - if (!tox_file_send_chunk(tox, f->num, f->tx.fnum, pos, f->tx.buf, f->tx.n, NULL)) - f->tx.pendingbuf = 1; -} - -static void cbfilesendreq(Tox *m, uint32_t frnum, uint32_t fnum, uint32_t kind, uint64_t fsz, const uint8_t *fname, size_t flen, void *udata) { @@ -840,7 +801,7 @@ cbfilesendreq(Tox *m, uint32_t frnum, uint32_t fnum, uint32_t kind, uint64_t fsz } static void -cbfiledata(Tox *m, uint32_t frnum, uint32_t fnum, uint64_t pos, const uint8_t *data, size_t len, void *udata) +cbfiledata(Tox *m, int32_t frnum, uint32_t fnum, uint64_t pos, const uint8_t *data, size_t len, void *udata) { struct friend *f; ssize_t n; @@ -1207,7 +1168,6 @@ toxinit(void) tox_callback_file_recv_control(tox, cbfilecontrol, NULL); tox_callback_file_recv(tox, cbfilesendreq, NULL); tox_callback_file_recv_chunk(tox, cbfiledata, NULL); - tox_callback_file_chunk_request(tox, cbfiledatareq, NULL); toxav_register_callstate_callback(toxav, cbcallinvite, av_OnInvite, NULL); toxav_register_callstate_callback(toxav, cbcallstart, av_OnStart, NULL); |