From cdb2bad7c3a07d4e8c1f534d8a7d10b776ccd74a Mon Sep 17 00:00:00 2001 From: tux3 Date: Sat, 25 Apr 2015 17:12:49 +0200 Subject: [PATCH] Signal broken file transfers --- src/core/core.cpp | 1 + src/core/corefile.cpp | 12 ++++++++++++ src/core/corefile.h | 1 + 3 files changed, 14 insertions(+) diff --git a/src/core/core.cpp b/src/core/core.cpp index f90d40417..7a458d6dc 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -484,6 +484,7 @@ void Core::onConnectionStatusChanged(Tox*/* tox*/, uint32_t friendId, TOX_CONNEC emit static_cast(core)->friendStatusChanged(friendId, friendStatus); if (friendStatus == Status::Offline) static_cast(core)->checkLastOnline(friendId); + CoreFile::onConnectionStatusChanged(static_cast(core), friendId, friendStatus != Status::Offline); } void Core::onGroupAction(Tox*, int groupnumber, int peernumber, const uint8_t *action, uint16_t length, void* _core) diff --git a/src/core/corefile.cpp b/src/core/corefile.cpp index 99cccf34f..299df352a 100644 --- a/src/core/corefile.cpp +++ b/src/core/corefile.cpp @@ -389,3 +389,15 @@ void CoreFile::onFileRecvChunkCallback(Tox *tox, uint32_t friendId, uint32_t fil if (file->fileKind != TOX_FILE_KIND_AVATAR) emit static_cast(core)->fileTransferInfo(*file); } + +void CoreFile::onConnectionStatusChanged(Core* core, uint32_t friendId, bool online) +{ + ToxFile::FileStatus status = online ? ToxFile::TRANSMITTING : ToxFile::BROKEN; + for (uint64_t key : fileMap.keys()) + { + if (key>>32 != friendId) + continue; + fileMap[key].status = status; + emit core->fileTransferBrokenUnbroken(fileMap[key], !online); + } +} diff --git a/src/core/corefile.h b/src/core/corefile.h index 1a7a03033..9588bb545 100644 --- a/src/core/corefile.h +++ b/src/core/corefile.h @@ -46,6 +46,7 @@ private: uint64_t pos, size_t length, void *core); static void onFileRecvChunkCallback(Tox *tox, uint32_t friendId, uint32_t fileId, uint64_t position, const uint8_t *data, size_t length, void *core); + static void onConnectionStatusChanged(Core* core, uint32_t friendId, bool online); private: static QMutex fileSendMutex;