diff --git a/src/core/core.h b/src/core/core.h index dce897727..ebf72265e 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -165,7 +165,7 @@ signals: * @deprecated prefer signals using ToxPk */ - void fileAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash); + void fileAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash, uint64_t filesize); void friendMessageReceived(uint32_t friendId, const QString& message, bool isAction); void friendAdded(uint32_t friendId, const ToxPk& friendPk); diff --git a/src/core/corefile.cpp b/src/core/corefile.cpp index 82ce93f08..583826774 100644 --- a/src/core/corefile.cpp +++ b/src/core/corefile.cpp @@ -344,7 +344,7 @@ void CoreFile::onFileReceiveCallback(Tox* tox, uint32_t friendId, uint32_t fileI tox_file_get_file_id(tox, friendId, fileId, avatarHash, nullptr); QByteArray avatarBytes{static_cast(static_cast(avatarHash)), TOX_HASH_LENGTH}; - emit core->fileAvatarOfferReceived(friendId, fileId, avatarBytes); + emit core->fileAvatarOfferReceived(friendId, fileId, avatarBytes, filesize); return; } } else { @@ -371,7 +371,7 @@ void CoreFile::onFileReceiveCallback(Tox* tox, uint32_t friendId, uint32_t fileI } // TODO(sudden6): This whole method is a mess but needed to get stuff working for now -void CoreFile::handleAvatarOffer(uint32_t friendId, uint32_t fileId, bool accept) +void CoreFile::handleAvatarOffer(uint32_t friendId, uint32_t fileId, bool accept, uint64_t filesize) { if (!accept) { // If it's an avatar but we already have it cached, cancel @@ -388,7 +388,7 @@ void CoreFile::handleAvatarOffer(uint32_t friendId, uint32_t fileId, bool accept .arg(fileId); tox_file_control(tox, friendId, fileId, TOX_FILE_CONTROL_RESUME, nullptr); - ToxFile file{fileId, friendId, "", "", 0, ToxFile::RECEIVING}; + ToxFile file{fileId, friendId, "", "", filesize, ToxFile::RECEIVING}; file.fileKind = TOX_FILE_KIND_AVATAR; file.resumeFileId.resize(TOX_FILE_ID_LENGTH); tox_file_get_file_id(tox, friendId, fileId, reinterpret_cast(file.resumeFileId.data()), diff --git a/src/core/corefile.h b/src/core/corefile.h index 3085ac007..e39464c2c 100644 --- a/src/core/corefile.h +++ b/src/core/corefile.h @@ -48,7 +48,7 @@ class CoreFile : public QObject Q_OBJECT public: - void handleAvatarOffer(uint32_t friendId, uint32_t fileId, bool accept); + void handleAvatarOffer(uint32_t friendId, uint32_t fileId, bool accept, uint64_t filesize); static CoreFilePtr makeCoreFile(Core* core, Tox* tox, CompatibleRecursiveMutex& coreLoopLock); void sendFile(uint32_t friendId, QString filename, QString filePath, diff --git a/src/persistence/profile.cpp b/src/persistence/profile.cpp index b7484aebe..0750add3d 100644 --- a/src/persistence/profile.cpp +++ b/src/persistence/profile.cpp @@ -472,11 +472,11 @@ void Profile::onSaveToxSave() } // TODO(sudden6): handle this better maybe? -void Profile::onAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash) +void Profile::onAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash, uint64_t filesize) { // accept if we don't have it already const bool accept = getAvatarHash(core->getFriendPublicKey(friendId)) != avatarHash; - core->getCoreFile()->handleAvatarOffer(friendId, fileId, accept); + core->getCoreFile()->handleAvatarOffer(friendId, fileId, accept, filesize); } /** diff --git a/src/persistence/profile.h b/src/persistence/profile.h index c7e9130d1..7897aa079 100644 --- a/src/persistence/profile.h +++ b/src/persistence/profile.h @@ -101,7 +101,7 @@ private slots: void removeAvatar(const ToxPk& owner); void onSaveToxSave(); // TODO(sudden6): use ToxPk instead of friendId - void onAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash); + void onAvatarOfferReceived(uint32_t friendId, uint32_t fileId, const QByteArray& avatarHash, uint64_t filesize); private: Profile(const QString& name, std::unique_ptr passkey, Paths& paths, Settings &settings_);