From 4dfa5a45c4b3973f47803a36f7f78e54c1eb8972 Mon Sep 17 00:00:00 2001 From: apprb Date: Mon, 29 Sep 2014 20:59:07 +0700 Subject: [PATCH] Core::onFileControlCallback: handle TOX_FILECONTROL_RESUME_BROKEN request --- core.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core.cpp b/core.cpp index 1b3eb4fc4..0361535a9 100644 --- a/core.cpp +++ b/core.cpp @@ -328,7 +328,7 @@ void Core::onFileSendRequestCallback(Tox*, int32_t friendnumber, uint8_t filenum emit static_cast(core)->fileReceiveRequested(fileRecvQueue.last()); } void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber, - uint8_t control_type, const uint8_t*, uint16_t, void *core) + uint8_t control_type, const uint8_t* data, uint16_t, void *core) { ToxFile* file{nullptr}; if (receive_send == 1) @@ -421,6 +421,21 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive { emit static_cast(core)->fileTransferRemotePausedUnpaused(*file, true); } + else if (receive_send == 1 && control_type == TOX_FILECONTROL_RESUME_BROKEN) + { + qDebug() << "Core::onFileControlCallback: TOX_FILECONTROL_RESUME_BROKEN"; + uint64_t resumePos = *(uint64_t*)data; + + if (resumePos >= file->filesize) + { + qWarning() << "Core::onFileControlCallback: invalid resume position"; + tox_file_send_control(tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_KILL, nullptr, 0); // don't sure about it + return; + } + + file->bytesSent = resumePos; + tox_file_send_control(tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_ACCEPT, nullptr, 0); + } else { qDebug() << QString("Core: File control callback, receive_send=%1, control_type=%2")