From 1438f8f766407e40d2cb25c13bafe1e1ac097dee Mon Sep 17 00:00:00 2001 From: Brandon Mosher Date: Fri, 15 Oct 2021 01:26:40 -0400 Subject: [PATCH] refactor: Provide a Virtual Method Anchor for Classes in Headers Define at least one virtual method in polymorphic class cpp files to improve link efficiency. Do so by defining a defaulted destructor or another overridden virtual method in the class cpp file. Also add explicitly defaulted copy/move constructors and assignment operators to follow the rule of five and to avoid compiler suppression of these functions due to the addition of a user-provided destructor. Where neccessary, create new cpp files and add them to CMakeLists and Testing.cmake. Set the -Wweak-vtables by default when compiling with clang to issue warnings for new classes that do not comply with this pattern. See http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers. Fixes #6036. --- CMakeLists.txt | 32 +++++++++ audio/CMakeLists.txt | 2 + audio/include/audio/iaudiosettings.h | 7 +- audio/include/audio/iaudiosink.h | 8 ++- audio/src/iaudiosettings.cpp | 22 ++++++ audio/src/iaudiosink.cpp | 22 ++++++ cmake/Testing.cmake | 9 ++- src/chatlog/chatmessage.cpp | 2 + src/chatlog/chatmessage.h | 4 ++ src/core/contactid.cpp | 1 + src/core/contactid.h | 8 ++- src/core/icoreextpacket.cpp | 25 +++++++ src/core/icoreextpacket.h | 10 ++- src/core/icorefriendmessagesender.cpp | 22 ++++++ src/core/icorefriendmessagesender.h | 7 +- src/core/icoregroupmessagesender.cpp | 22 ++++++ src/core/icoregroupmessagesender.h | 8 ++- src/core/icoregroupquery.cpp | 22 ++++++ src/core/icoregroupquery.h | 8 ++- src/core/icoreidhandler.cpp | 22 ++++++ src/core/icoreidhandler.h | 8 ++- src/core/icoresettings.cpp | 22 ++++++ src/core/icoresettings.h | 7 +- src/model/about/iaboutfriend.cpp | 22 ++++++ src/model/about/iaboutfriend.h | 8 ++- src/model/chatroom/chatroom.cpp | 22 ++++++ src/model/chatroom/chatroom.h | 7 ++ src/model/dialogs/idialogs.cpp | 22 ++++++ src/model/dialogs/idialogs.h | 8 ++- src/model/dialogs/idialogsmanager.cpp | 22 ++++++ src/model/dialogs/idialogsmanager.h | 8 ++- src/model/friendlist/ifriendlistitem.cpp | 22 ++++++ src/model/friendlist/ifriendlistitem.h | 8 ++- src/model/ibootstraplistgenerator.cpp | 22 ++++++ src/model/ibootstraplistgenerator.h | 8 ++- src/model/notificationgenerator.cpp | 2 + src/model/notificationgenerator.h | 5 ++ src/model/profile/iprofileinfo.cpp | 22 ++++++ src/model/profile/iprofileinfo.h | 8 ++- src/persistence/ifriendsettings.cpp | 22 ++++++ src/persistence/ifriendsettings.h | 7 +- src/persistence/igroupsettings.cpp | 22 ++++++ src/persistence/igroupsettings.h | 8 ++- src/persistence/inotificationsettings.cpp | 22 ++++++ src/persistence/inotificationsettings.h | 7 +- src/video/ivideosettings.cpp | 22 ++++++ src/video/ivideosettings.h | 7 +- src/widget/imagepreviewwidget.cpp | 2 + src/widget/imagepreviewwidget.h | 5 ++ test/core/core_test.cpp | 8 ++- test/mock/mockcoreidhandler.cpp | 22 ++++++ test/mock/mockcoreidhandler.h | 7 ++ test/mock/mockgroupquery.cpp | 22 ++++++ test/mock/mockgroupquery.h | 7 ++ test/model/friendmessagedispatcher_test.cpp | 75 ++++++++++++--------- test/model/groupmessagedispatcher_test.cpp | 40 ++++++----- 56 files changed, 744 insertions(+), 77 deletions(-) create mode 100644 audio/src/iaudiosettings.cpp create mode 100644 audio/src/iaudiosink.cpp create mode 100644 src/core/icoreextpacket.cpp create mode 100644 src/core/icorefriendmessagesender.cpp create mode 100644 src/core/icoregroupmessagesender.cpp create mode 100644 src/core/icoregroupquery.cpp create mode 100644 src/core/icoreidhandler.cpp create mode 100644 src/core/icoresettings.cpp create mode 100644 src/model/about/iaboutfriend.cpp create mode 100644 src/model/chatroom/chatroom.cpp create mode 100644 src/model/dialogs/idialogs.cpp create mode 100644 src/model/dialogs/idialogsmanager.cpp create mode 100644 src/model/friendlist/ifriendlistitem.cpp create mode 100644 src/model/ibootstraplistgenerator.cpp create mode 100644 src/model/profile/iprofileinfo.cpp create mode 100644 src/persistence/ifriendsettings.cpp create mode 100644 src/persistence/igroupsettings.cpp create mode 100644 src/persistence/inotificationsettings.cpp create mode 100644 src/video/ivideosettings.cpp create mode 100644 test/mock/mockcoreidhandler.cpp create mode 100644 test/mock/mockgroupquery.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a0ef510a8..68cee355c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") # Hardening flags (ASLR, warnings, etc) set(POSITION_INDEPENDENT_CODE True) + +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG(-Wweak-vtables COMPILER_SUPPORTS_WARNING_WEAK_VTABLES) +if(COMPILER_SUPPORTS_WARNING_WEAK_VTABLES) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wweak-vtables") +endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-overflow") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-aliasing") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast") @@ -232,7 +239,18 @@ set(${PROJECT_NAME}_SOURCES src/core/core.h src/core/dhtserver.cpp src/core/dhtserver.h + src/core/icoreextpacket.cpp + src/core/icoreextpacket.h + src/core/icoresettings.cpp src/core/icoresettings.h + src/core/icorefriendmessagesender.cpp + src/core/icorefriendmessagesender.h + src/core/icoregroupmessagesender.cpp + src/core/icoregroupmessagesender.h + src/core/icoregroupquery.cpp + src/core/icoregroupquery.h + src/core/icoreidhandler.cpp + src/core/icoreidhandler.h src/core/toxcall.cpp src/core/toxcall.h src/core/toxencrypt.cpp @@ -262,11 +280,13 @@ set(${PROJECT_NAME}_SOURCES src/ipc.h src/model/about/aboutfriend.cpp src/model/about/aboutfriend.h + src/model/about/iaboutfriend.cpp src/model/about/iaboutfriend.h src/model/chathistory.cpp src/model/chathistory.h src/model/chatlogitem.cpp src/model/chatlogitem.h + src/model/chatroom/chatroom.cpp src/model/chatroom/chatroom.h src/model/chatroom/friendchatroom.cpp src/model/chatroom/friendchatroom.h @@ -274,11 +294,15 @@ set(${PROJECT_NAME}_SOURCES src/model/chatroom/groupchatroom.h src/model/contact.cpp src/model/contact.h + src/model/dialogs/idialogs.cpp src/model/dialogs/idialogs.h + src/model/dialogs/idialogsmanager.h + src/model/dialogs/idialogsmanager.cpp src/model/exiftransform.cpp src/model/exiftransform.h src/model/friendlist/friendlistmanager.cpp src/model/friendlist/friendlistmanager.h + src/model/friendlist/ifriendlistitem.cpp src/model/friendlist/ifriendlistitem.h src/model/friendmessagedispatcher.cpp src/model/friendmessagedispatcher.h @@ -290,6 +314,7 @@ set(${PROJECT_NAME}_SOURCES src/model/groupmessagedispatcher.h src/model/group.cpp src/model/group.h + src/model/ibootstraplistgenerator.cpp src/model/ibootstraplistgenerator.h src/model/ichatlog.h src/model/imessagedispatcher.h @@ -297,6 +322,7 @@ set(${PROJECT_NAME}_SOURCES src/model/message.h src/model/notificationgenerator.cpp src/model/notificationgenerator.h + src/model/profile/iprofileinfo.cpp src/model/profile/iprofileinfo.h src/model/profile/profileinfo.cpp src/model/profile/profileinfo.h @@ -317,7 +343,12 @@ set(${PROJECT_NAME}_SOURCES src/persistence/db/rawdatabase.h src/persistence/history.cpp src/persistence/history.h + src/persistence/ifriendsettings.cpp src/persistence/ifriendsettings.h + src/persistence/igroupsettings.cpp + src/persistence/igroupsettings.h + src/persistence/inotificationsettings.cpp + src/persistence/inotificationsettings.h src/persistence/offlinemsgengine.cpp src/persistence/offlinemsgengine.h src/persistence/paths.cpp @@ -342,6 +373,7 @@ set(${PROJECT_NAME}_SOURCES src/video/camerasource.h src/video/corevideosource.cpp src/video/corevideosource.h + src/video/ivideosettings.cpp src/video/ivideosettings.h src/video/netcamview.cpp src/video/netcamview.h diff --git a/audio/CMakeLists.txt b/audio/CMakeLists.txt index fcffd92d5..9d659e579 100644 --- a/audio/CMakeLists.txt +++ b/audio/CMakeLists.txt @@ -20,6 +20,8 @@ set(SOURCE_FILES "include/audio/iaudiosettings.h" "include/audio/iaudiosink.h" "include/audio/iaudiosource.h" + "src/iaudiosettings.cpp" + "src/iaudiosink.cpp" "src/audio.cpp" "src/backend/alsink.cpp" "src/backend/alsink.h" diff --git a/audio/include/audio/iaudiosettings.h b/audio/include/audio/iaudiosettings.h index 84f70a74a..25ed9c112 100644 --- a/audio/include/audio/iaudiosettings.h +++ b/audio/include/audio/iaudiosettings.h @@ -25,7 +25,12 @@ class IAudioSettings { public: - virtual ~IAudioSettings() = default; + IAudioSettings() = default; + virtual ~IAudioSettings(); + IAudioSettings(const IAudioSettings&) = default; + IAudioSettings& operator=(const IAudioSettings&) = default; + IAudioSettings(IAudioSettings&&) = default; + IAudioSettings& operator=(IAudioSettings&&) = default; virtual QString getInDev() const = 0; virtual void setInDev(const QString& deviceSpecifier) = 0; diff --git a/audio/include/audio/iaudiosink.h b/audio/include/audio/iaudiosink.h index 24a4d3e5b..848a7be0f 100644 --- a/audio/include/audio/iaudiosink.h +++ b/audio/include/audio/iaudiosink.h @@ -96,7 +96,13 @@ public: return {}; } - virtual ~IAudioSink() = default; + IAudioSink() = default; + virtual ~IAudioSink(); + IAudioSink(const IAudioSink&) = default; + IAudioSink& operator=(const IAudioSink&) = default; + IAudioSink(IAudioSink&&) = default; + IAudioSink& operator=(IAudioSink&&) = default; + virtual void playAudioBuffer(const int16_t* data, int samples, unsigned channels, int sampleRate) const = 0; virtual void playMono16Sound(const Sound& sound) = 0; diff --git a/audio/src/iaudiosettings.cpp b/audio/src/iaudiosettings.cpp new file mode 100644 index 000000000..7b862861a --- /dev/null +++ b/audio/src/iaudiosettings.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "audio/iaudiosettings.h" + +IAudioSettings::~IAudioSettings() = default; diff --git a/audio/src/iaudiosink.cpp b/audio/src/iaudiosink.cpp new file mode 100644 index 000000000..63e6e5a8d --- /dev/null +++ b/audio/src/iaudiosink.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "audio/iaudiosink.h" + +IAudioSink::~IAudioSink() = default; diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 0d9988806..53ef9544c 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -34,6 +34,11 @@ function(auto_test subsystem module extra_deps) COMMAND ${TEST_CROSSCOMPILING_EMULATOR} test_${module}) endfunction() +set(MOCK_SOURCES + test/mock/mockcoreidhandler.cpp + test/mock/mockgroupquery.cpp +) + auto_test(core core "${${PROJECT_NAME}_RESOURCES}") auto_test(core contactid "") auto_test(core toxid "") @@ -45,11 +50,11 @@ auto_test(persistence dbschema "") auto_test(persistence offlinemsgengine "") auto_test(persistence smileypack "${${PROJECT_NAME}_RESOURCES}") # needs emojione auto_test(model friendmessagedispatcher "") -auto_test(model groupmessagedispatcher "") +auto_test(model groupmessagedispatcher "${MOCK_SOURCES}") auto_test(model messageprocessor "") auto_test(model sessionchatlog "") auto_test(model exiftransform "") -auto_test(model notificationgenerator "") +auto_test(model notificationgenerator "${MOCK_SOURCES}") if (UNIX) auto_test(platform posixsignalnotifier "") diff --git a/src/chatlog/chatmessage.cpp b/src/chatlog/chatmessage.cpp index e2482b1e7..cc028dafc 100644 --- a/src/chatlog/chatmessage.cpp +++ b/src/chatlog/chatmessage.cpp @@ -45,6 +45,8 @@ ChatMessage::ChatMessage() { } +ChatMessage::~ChatMessage() = default; + ChatMessage::Ptr ChatMessage::createChatMessage(const QString& sender, const QString& rawMessage, MessageType type, bool isMe, MessageState state, const QDateTime& date, bool colorizeName) diff --git a/src/chatlog/chatmessage.h b/src/chatlog/chatmessage.h index abdce7ee5..892fd0e25 100644 --- a/src/chatlog/chatmessage.h +++ b/src/chatlog/chatmessage.h @@ -48,6 +48,10 @@ public: }; ChatMessage(); + ~ChatMessage(); + ChatMessage(const ChatMessage&) = default; + ChatMessage& operator=(const ChatMessage&) = default; + ChatMessage(ChatMessage&&) = default; static ChatMessage::Ptr createChatMessage(const QString& sender, const QString& rawMessage, MessageType type, bool isMe, MessageState state, diff --git a/src/core/contactid.cpp b/src/core/contactid.cpp index 6ee16ecd8..1646aaf14 100644 --- a/src/core/contactid.cpp +++ b/src/core/contactid.cpp @@ -30,6 +30,7 @@ ContactId::ContactId() : id() { } +ContactId::~ContactId() = default; /** * @brief Constructs a ContactId from bytes. diff --git a/src/core/contactid.h b/src/core/contactid.h index 61a96e8d4..6d1f13221 100644 --- a/src/core/contactid.h +++ b/src/core/contactid.h @@ -28,9 +28,11 @@ class ContactId { public: - virtual ~ContactId() = default; - ContactId& operator=(const ContactId& other) = default; - ContactId& operator=(ContactId&& other) = default; + virtual ~ContactId(); + ContactId(const ContactId&) = default; + ContactId& operator=(const ContactId&) = default; + ContactId(ContactId&&) = default; + ContactId& operator=(ContactId&&) = default; bool operator==(const ContactId& other) const; bool operator!=(const ContactId& other) const; bool operator<(const ContactId& other) const; diff --git a/src/core/icoreextpacket.cpp b/src/core/icoreextpacket.cpp new file mode 100644 index 000000000..25c8f15b7 --- /dev/null +++ b/src/core/icoreextpacket.cpp @@ -0,0 +1,25 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "icoreextpacket.h" + + +ICoreExtPacket::~ICoreExtPacket() = default; + +ICoreExtPacketAllocator::~ICoreExtPacketAllocator() = default; diff --git a/src/core/icoreextpacket.h b/src/core/icoreextpacket.h index efa344a01..32e1eca68 100644 --- a/src/core/icoreextpacket.h +++ b/src/core/icoreextpacket.h @@ -36,8 +36,12 @@ class ICoreExtPacket { public: - virtual ~ICoreExtPacket() = default; - + ICoreExtPacket() = default; + virtual ~ICoreExtPacket(); + ICoreExtPacket(const ICoreExtPacket&) = default; + ICoreExtPacket& operator=(const ICoreExtPacket&) = default; + ICoreExtPacket(ICoreExtPacket&&) = default; + ICoreExtPacket& operator=(ICoreExtPacket&&) = default; /** * @brief Adds message to packet * @return Extended message receipt, UINT64_MAX on failure @@ -59,7 +63,7 @@ public: class ICoreExtPacketAllocator { public: - virtual ~ICoreExtPacketAllocator() = default; + virtual ~ICoreExtPacketAllocator(); /** * @brief Gets a new packet builder for friend with core friend id friendId diff --git a/src/core/icorefriendmessagesender.cpp b/src/core/icorefriendmessagesender.cpp new file mode 100644 index 000000000..4c0b0b6bb --- /dev/null +++ b/src/core/icorefriendmessagesender.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "icorefriendmessagesender.h" + +ICoreFriendMessageSender::~ICoreFriendMessageSender() = default; diff --git a/src/core/icorefriendmessagesender.h b/src/core/icorefriendmessagesender.h index 5ce7b4dd8..c929a1457 100644 --- a/src/core/icorefriendmessagesender.h +++ b/src/core/icorefriendmessagesender.h @@ -27,7 +27,12 @@ class ICoreFriendMessageSender { public: - virtual ~ICoreFriendMessageSender() = default; + ICoreFriendMessageSender() = default; + virtual ~ICoreFriendMessageSender(); + ICoreFriendMessageSender(const ICoreFriendMessageSender&) = default; + ICoreFriendMessageSender& operator=(const ICoreFriendMessageSender&) = default; + ICoreFriendMessageSender(ICoreFriendMessageSender&&) = default; + ICoreFriendMessageSender& operator=(ICoreFriendMessageSender&&) = default; virtual bool sendAction(uint32_t friendId, const QString& action, ReceiptNum& receipt) = 0; virtual bool sendMessage(uint32_t friendId, const QString& message, ReceiptNum& receipt) = 0; }; diff --git a/src/core/icoregroupmessagesender.cpp b/src/core/icoregroupmessagesender.cpp new file mode 100644 index 000000000..ff0ae570f --- /dev/null +++ b/src/core/icoregroupmessagesender.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "icoregroupmessagesender.h" + +ICoreGroupMessageSender::~ICoreGroupMessageSender() = default; diff --git a/src/core/icoregroupmessagesender.h b/src/core/icoregroupmessagesender.h index 40edf432c..36c2a5cd6 100644 --- a/src/core/icoregroupmessagesender.h +++ b/src/core/icoregroupmessagesender.h @@ -24,7 +24,13 @@ class ICoreGroupMessageSender { public: - virtual ~ICoreGroupMessageSender() = default; + ICoreGroupMessageSender() = default; + virtual ~ICoreGroupMessageSender(); + ICoreGroupMessageSender(const ICoreGroupMessageSender&) = default; + ICoreGroupMessageSender& operator=(const ICoreGroupMessageSender&) = default; + ICoreGroupMessageSender(ICoreGroupMessageSender&&) = default; + ICoreGroupMessageSender& operator=(ICoreGroupMessageSender&&) = default; + virtual void sendGroupAction(int groupId, const QString& message) = 0; virtual void sendGroupMessage(int groupId, const QString& message) = 0; }; diff --git a/src/core/icoregroupquery.cpp b/src/core/icoregroupquery.cpp new file mode 100644 index 000000000..d049575de --- /dev/null +++ b/src/core/icoregroupquery.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "icoregroupquery.h" + +ICoreGroupQuery::~ICoreGroupQuery() = default; diff --git a/src/core/icoregroupquery.h b/src/core/icoregroupquery.h index 51a3b678e..9fbcfdcc9 100644 --- a/src/core/icoregroupquery.h +++ b/src/core/icoregroupquery.h @@ -31,7 +31,13 @@ class ICoreGroupQuery { public: - virtual ~ICoreGroupQuery() = default; + ICoreGroupQuery() = default; + virtual ~ICoreGroupQuery(); + ICoreGroupQuery(const ICoreGroupQuery&) = default; + ICoreGroupQuery& operator=(const ICoreGroupQuery&) = default; + ICoreGroupQuery(ICoreGroupQuery&&) = default; + ICoreGroupQuery& operator=(ICoreGroupQuery&&) = default; + virtual GroupId getGroupPersistentId(uint32_t groupNumber) const = 0; virtual uint32_t getGroupNumberPeers(int groupId) const = 0; virtual QString getGroupPeerName(int groupId, int peerId) const = 0; diff --git a/src/core/icoreidhandler.cpp b/src/core/icoreidhandler.cpp new file mode 100644 index 000000000..9d15c3352 --- /dev/null +++ b/src/core/icoreidhandler.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "icoreidhandler.h" + +ICoreIdHandler::~ICoreIdHandler() = default; diff --git a/src/core/icoreidhandler.h b/src/core/icoreidhandler.h index e8884f842..6dc2f2e70 100644 --- a/src/core/icoreidhandler.h +++ b/src/core/icoreidhandler.h @@ -26,7 +26,13 @@ class ICoreIdHandler { public: - virtual ~ICoreIdHandler() = default; + ICoreIdHandler() = default; + virtual ~ICoreIdHandler(); + ICoreIdHandler(const ICoreIdHandler&) = default; + ICoreIdHandler& operator=(const ICoreIdHandler&) = default; + ICoreIdHandler(ICoreIdHandler&&) = default; + ICoreIdHandler& operator=(ICoreIdHandler&&) = default; + virtual ToxId getSelfId() const = 0; virtual ToxPk getSelfPublicKey() const = 0; virtual QString getUsername() const = 0; diff --git a/src/core/icoresettings.cpp b/src/core/icoresettings.cpp new file mode 100644 index 000000000..fa8e12124 --- /dev/null +++ b/src/core/icoresettings.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "icoresettings.h" + +ICoreSettings::~ICoreSettings() = default; diff --git a/src/core/icoresettings.h b/src/core/icoresettings.h index 58dd36268..2e7875d1d 100644 --- a/src/core/icoresettings.h +++ b/src/core/icoresettings.h @@ -34,7 +34,12 @@ public: ptSOCKS5 = 1, ptHTTP = 2 }; - virtual ~ICoreSettings() = default; + ICoreSettings() = default; + virtual ~ICoreSettings(); + ICoreSettings(const ICoreSettings&) = default; + ICoreSettings& operator=(const ICoreSettings&) = default; + ICoreSettings(ICoreSettings&&) = default; + ICoreSettings& operator=(ICoreSettings&&) = default; virtual bool getEnableIPv6() const = 0; virtual void setEnableIPv6(bool enable) = 0; diff --git a/src/model/about/iaboutfriend.cpp b/src/model/about/iaboutfriend.cpp new file mode 100644 index 000000000..80a03636a --- /dev/null +++ b/src/model/about/iaboutfriend.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "iaboutfriend.h" + +IAboutFriend::~IAboutFriend() = default; diff --git a/src/model/about/iaboutfriend.h b/src/model/about/iaboutfriend.h index e2fe4efda..82c6271d4 100644 --- a/src/model/about/iaboutfriend.h +++ b/src/model/about/iaboutfriend.h @@ -27,7 +27,13 @@ class IAboutFriend { public: - virtual ~IAboutFriend() = default; + IAboutFriend() = default; + virtual ~IAboutFriend(); + IAboutFriend(const IAboutFriend&) = default; + IAboutFriend& operator=(const IAboutFriend&) = default; + IAboutFriend(IAboutFriend&&) = default; + IAboutFriend& operator=(IAboutFriend&&) = default; + virtual QString getName() const = 0; virtual QString getStatusMessage() const = 0; virtual ToxPk getPublicKey() const = 0; diff --git a/src/model/chatroom/chatroom.cpp b/src/model/chatroom/chatroom.cpp new file mode 100644 index 000000000..07e75d49c --- /dev/null +++ b/src/model/chatroom/chatroom.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "chatroom.h" + +Chatroom::~Chatroom() = default; diff --git a/src/model/chatroom/chatroom.h b/src/model/chatroom/chatroom.h index 2d71f3a62..45c1e3208 100644 --- a/src/model/chatroom/chatroom.h +++ b/src/model/chatroom/chatroom.h @@ -24,5 +24,12 @@ class Chatroom { public: + Chatroom() = default; + virtual ~Chatroom(); + Chatroom(const Chatroom&) = default; + Chatroom& operator=(const Chatroom&) = default; + Chatroom(Chatroom&&) = default; + Chatroom& operator=(Chatroom&&) = default; + virtual Contact* getContact() = 0; }; diff --git a/src/model/dialogs/idialogs.cpp b/src/model/dialogs/idialogs.cpp new file mode 100644 index 000000000..b09a95354 --- /dev/null +++ b/src/model/dialogs/idialogs.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "idialogs.h" + +IDialogs::~IDialogs() = default; diff --git a/src/model/dialogs/idialogs.h b/src/model/dialogs/idialogs.h index 0d5f715a5..8da5dc565 100644 --- a/src/model/dialogs/idialogs.h +++ b/src/model/dialogs/idialogs.h @@ -26,7 +26,13 @@ class ToxPk; class IDialogs { public: - virtual ~IDialogs() = default; + IDialogs() = default; + virtual ~IDialogs(); + IDialogs(const IDialogs&) = default; + IDialogs& operator=(const IDialogs&) = default; + IDialogs(IDialogs&&) = default; + IDialogs& operator=(IDialogs&&) = default; + virtual bool hasContact(const ContactId& contactId) const = 0; virtual bool isContactActive(const ContactId& contactId) const = 0; diff --git a/src/model/dialogs/idialogsmanager.cpp b/src/model/dialogs/idialogsmanager.cpp new file mode 100644 index 000000000..f58d3a429 --- /dev/null +++ b/src/model/dialogs/idialogsmanager.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "idialogsmanager.h" + +IDialogsManager::~IDialogsManager() = default; diff --git a/src/model/dialogs/idialogsmanager.h b/src/model/dialogs/idialogsmanager.h index ddcd78c34..3e3b0a1b7 100644 --- a/src/model/dialogs/idialogsmanager.h +++ b/src/model/dialogs/idialogsmanager.h @@ -27,7 +27,13 @@ class ToxPk; class IDialogsManager { public: - virtual ~IDialogsManager() = default; + IDialogsManager() = default; + virtual ~IDialogsManager(); + IDialogsManager(const IDialogsManager&) = default; + IDialogsManager& operator=(const IDialogsManager&) = default; + IDialogsManager(IDialogsManager&&) = default; + IDialogsManager& operator=(IDialogsManager&&) = default; + virtual IDialogs* getFriendDialogs(const ToxPk& friendPk) const = 0; virtual IDialogs* getGroupDialogs(const GroupId& groupId) const = 0; }; diff --git a/src/model/friendlist/ifriendlistitem.cpp b/src/model/friendlist/ifriendlistitem.cpp new file mode 100644 index 000000000..0bd13431e --- /dev/null +++ b/src/model/friendlist/ifriendlistitem.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "ifriendlistitem.h" + +IFriendListItem::~IFriendListItem() = default; diff --git a/src/model/friendlist/ifriendlistitem.h b/src/model/friendlist/ifriendlistitem.h index e74b746c5..6acff2781 100644 --- a/src/model/friendlist/ifriendlistitem.h +++ b/src/model/friendlist/ifriendlistitem.h @@ -26,8 +26,12 @@ class QWidget; class IFriendListItem { public: - - virtual ~IFriendListItem() = default; + IFriendListItem() = default; + virtual ~IFriendListItem(); + IFriendListItem(const IFriendListItem&) = default; + IFriendListItem& operator=(const IFriendListItem&) = default; + IFriendListItem(IFriendListItem&&) = default; + IFriendListItem& operator=(IFriendListItem&&) = default; virtual bool isFriend() const = 0; virtual bool isGroup() const = 0; diff --git a/src/model/ibootstraplistgenerator.cpp b/src/model/ibootstraplistgenerator.cpp new file mode 100644 index 000000000..744afaffe --- /dev/null +++ b/src/model/ibootstraplistgenerator.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "ibootstraplistgenerator.h" + +IBootstrapListGenerator::~IBootstrapListGenerator() = default; diff --git a/src/model/ibootstraplistgenerator.h b/src/model/ibootstraplistgenerator.h index f6637e237..21750d240 100644 --- a/src/model/ibootstraplistgenerator.h +++ b/src/model/ibootstraplistgenerator.h @@ -25,6 +25,12 @@ class DhtServer; class IBootstrapListGenerator { public: - virtual ~IBootstrapListGenerator() = default; + IBootstrapListGenerator() = default; + virtual ~IBootstrapListGenerator(); + IBootstrapListGenerator(const IBootstrapListGenerator&) = default; + IBootstrapListGenerator& operator=(const IBootstrapListGenerator&) = default; + IBootstrapListGenerator(IBootstrapListGenerator&&) = default; + IBootstrapListGenerator& operator=(IBootstrapListGenerator&&) = default; + virtual QList getBootstrapnodes() = 0; }; diff --git a/src/model/notificationgenerator.cpp b/src/model/notificationgenerator.cpp index 7e0ee49a7..83f8fd9a2 100644 --- a/src/model/notificationgenerator.cpp +++ b/src/model/notificationgenerator.cpp @@ -162,6 +162,8 @@ NotificationGenerator::NotificationGenerator( , profile(profile) {} +NotificationGenerator::~NotificationGenerator() = default; + NotificationData NotificationGenerator::friendMessageNotification(const Friend* f, const QString& message) { friendNotifications[f]++; diff --git a/src/model/notificationgenerator.h b/src/model/notificationgenerator.h index d21b6f38f..3ec982781 100644 --- a/src/model/notificationgenerator.h +++ b/src/model/notificationgenerator.h @@ -39,6 +39,11 @@ public: // currently mockable so we allow profile to be nullptr for unit // testing Profile* profile); + virtual ~NotificationGenerator(); + NotificationGenerator(const NotificationGenerator&) = delete; + NotificationGenerator& operator=(const NotificationGenerator&) = delete; + NotificationGenerator(NotificationGenerator&&) = delete; + NotificationGenerator& operator=(NotificationGenerator&&) = delete; NotificationData friendMessageNotification(const Friend* f, const QString& message); NotificationData groupMessageNotification(const Group* g, const ToxPk& sender, const QString& message); diff --git a/src/model/profile/iprofileinfo.cpp b/src/model/profile/iprofileinfo.cpp new file mode 100644 index 000000000..1848d4812 --- /dev/null +++ b/src/model/profile/iprofileinfo.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "iprofileinfo.h" + +IProfileInfo::~IProfileInfo() = default; diff --git a/src/model/profile/iprofileinfo.h b/src/model/profile/iprofileinfo.h index d532bcd5c..dc13574c9 100644 --- a/src/model/profile/iprofileinfo.h +++ b/src/model/profile/iprofileinfo.h @@ -39,7 +39,13 @@ public: enum class SetAvatarResult { OK, EmptyPath, CanNotOpen, CanNotRead, TooLarge }; - virtual ~IProfileInfo() = default; + + IProfileInfo() = default; + virtual ~IProfileInfo(); + IProfileInfo(const IProfileInfo&) = default; + IProfileInfo& operator=(const IProfileInfo&) = default; + IProfileInfo(IProfileInfo&&) = default; + IProfileInfo& operator=(IProfileInfo&&) = default; virtual bool setPassword(const QString& password) = 0; virtual bool deletePassword() = 0; diff --git a/src/persistence/ifriendsettings.cpp b/src/persistence/ifriendsettings.cpp new file mode 100644 index 000000000..afef21c22 --- /dev/null +++ b/src/persistence/ifriendsettings.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "ifriendsettings.h" + +IFriendSettings::~IFriendSettings() = default; diff --git a/src/persistence/ifriendsettings.h b/src/persistence/ifriendsettings.h index fa7190d71..e14d2372f 100644 --- a/src/persistence/ifriendsettings.h +++ b/src/persistence/ifriendsettings.h @@ -38,7 +38,12 @@ public: }; Q_DECLARE_FLAGS(AutoAcceptCallFlags, AutoAcceptCall) - virtual ~IFriendSettings() = default; + IFriendSettings() = default; + virtual ~IFriendSettings(); + IFriendSettings(const IFriendSettings&) = default; + IFriendSettings& operator=(const IFriendSettings&) = default; + IFriendSettings(IFriendSettings&&) = default; + IFriendSettings& operator=(IFriendSettings&&) = default; virtual QString getContactNote(const ToxPk& pk) const = 0; virtual void setContactNote(const ToxPk& pk, const QString& note) = 0; diff --git a/src/persistence/igroupsettings.cpp b/src/persistence/igroupsettings.cpp new file mode 100644 index 000000000..6e5075d7d --- /dev/null +++ b/src/persistence/igroupsettings.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "igroupsettings.h" + +IGroupSettings::~IGroupSettings() = default; diff --git a/src/persistence/igroupsettings.h b/src/persistence/igroupsettings.h index 158fc484c..46f2064b5 100644 --- a/src/persistence/igroupsettings.h +++ b/src/persistence/igroupsettings.h @@ -24,7 +24,13 @@ class IGroupSettings { public: - virtual ~IGroupSettings() = default; + IGroupSettings() = default; + virtual ~IGroupSettings(); + IGroupSettings(const IGroupSettings&) = default; + IGroupSettings& operator=(const IGroupSettings&) = default; + IGroupSettings(IGroupSettings&&) = default; + IGroupSettings& operator=(IGroupSettings&&) = default; + virtual QStringList getBlackList() const = 0; virtual void setBlackList(const QStringList& blist) = 0; }; diff --git a/src/persistence/inotificationsettings.cpp b/src/persistence/inotificationsettings.cpp new file mode 100644 index 000000000..cb47e5988 --- /dev/null +++ b/src/persistence/inotificationsettings.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "inotificationsettings.h" + +INotificationSettings::~INotificationSettings() = default; diff --git a/src/persistence/inotificationsettings.h b/src/persistence/inotificationsettings.h index da6cb0d22..89ae78228 100644 --- a/src/persistence/inotificationsettings.h +++ b/src/persistence/inotificationsettings.h @@ -24,7 +24,12 @@ class INotificationSettings { public: - virtual ~INotificationSettings() = default; + INotificationSettings() = default; + virtual ~INotificationSettings(); + INotificationSettings(const INotificationSettings&) = default; + INotificationSettings& operator=(const INotificationSettings&) = default; + INotificationSettings(INotificationSettings&&) = default; + INotificationSettings& operator=(INotificationSettings&&) = default; virtual bool getNotify() const = 0; virtual void setNotify(bool newValue) = 0; diff --git a/src/video/ivideosettings.cpp b/src/video/ivideosettings.cpp new file mode 100644 index 000000000..98518dbd0 --- /dev/null +++ b/src/video/ivideosettings.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "ivideosettings.h" + +IVideoSettings::~IVideoSettings() = default; diff --git a/src/video/ivideosettings.h b/src/video/ivideosettings.h index 5c76d7a20..e776f8c41 100644 --- a/src/video/ivideosettings.h +++ b/src/video/ivideosettings.h @@ -26,7 +26,12 @@ class IVideoSettings { public: - virtual ~IVideoSettings() = default; + IVideoSettings() = default; + virtual ~IVideoSettings(); + IVideoSettings(const IVideoSettings&) = default; + IVideoSettings& operator=(const IVideoSettings&) = default; + IVideoSettings(IVideoSettings&&) = default; + IVideoSettings& operator=(IVideoSettings&&) = default; virtual QString getVideoDev() const = 0; virtual void setVideoDev(const QString& deviceSpecifier) = 0; diff --git a/src/widget/imagepreviewwidget.cpp b/src/widget/imagepreviewwidget.cpp index 0a14a0fee..e4f887857 100644 --- a/src/widget/imagepreviewwidget.cpp +++ b/src/widget/imagepreviewwidget.cpp @@ -103,6 +103,8 @@ QString getToolTipDisplayingImage(const QPixmap& image) } // namespace +ImagePreviewButton::~ImagePreviewButton() = default; + void ImagePreviewButton::initialize(const QPixmap& image) { auto desiredSize = qMin(width(), height()); // Assume widget is a square diff --git a/src/widget/imagepreviewwidget.h b/src/widget/imagepreviewwidget.h index 2eb51527b..cc489a3fc 100644 --- a/src/widget/imagepreviewwidget.h +++ b/src/widget/imagepreviewwidget.h @@ -29,6 +29,11 @@ public: ImagePreviewButton(QWidget* parent = nullptr) : QPushButton(parent) {} + ~ImagePreviewButton(); + ImagePreviewButton(const ImagePreviewButton&) = delete; + ImagePreviewButton& operator=(const ImagePreviewButton&) = delete; + ImagePreviewButton(ImagePreviewButton&&) = delete; + ImagePreviewButton& operator=(ImagePreviewButton&&) = delete; void setIconFromFile(const QString& filename); void setIconFromPixmap(const QPixmap& image); diff --git a/test/core/core_test.cpp b/test/core/core_test.cpp index 7e2e2e60c..ee21632e7 100644 --- a/test/core/core_test.cpp +++ b/test/core/core_test.cpp @@ -77,11 +77,13 @@ private: class MockNodeListGenerator : public IBootstrapListGenerator { - QList getBootstrapnodes() { - return BootstrapNodeUpdater::loadDefaultBootstrapNodes(); - } + QList getBootstrapnodes(); }; +QList MockNodeListGenerator::getBootstrapnodes() { + return BootstrapNodeUpdater::loadDefaultBootstrapNodes(); +} + class TestCore : public QObject { Q_OBJECT diff --git a/test/mock/mockcoreidhandler.cpp b/test/mock/mockcoreidhandler.cpp new file mode 100644 index 000000000..7e6a9a18c --- /dev/null +++ b/test/mock/mockcoreidhandler.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "mockcoreidhandler.h" + +MockCoreIdHandler::~MockCoreIdHandler() = default; diff --git a/test/mock/mockcoreidhandler.h b/test/mock/mockcoreidhandler.h index 8aad8117a..477d84a47 100644 --- a/test/mock/mockcoreidhandler.h +++ b/test/mock/mockcoreidhandler.h @@ -26,6 +26,13 @@ class MockCoreIdHandler : public ICoreIdHandler { public: + MockCoreIdHandler() = default; + virtual ~MockCoreIdHandler(); + MockCoreIdHandler(const MockCoreIdHandler&) = default; + MockCoreIdHandler& operator=(const MockCoreIdHandler&) = default; + MockCoreIdHandler(MockCoreIdHandler&&) = default; + MockCoreIdHandler& operator=(MockCoreIdHandler&&) = default; + ToxId getSelfId() const override { std::terminate(); diff --git a/test/mock/mockgroupquery.cpp b/test/mock/mockgroupquery.cpp new file mode 100644 index 000000000..4c6585e99 --- /dev/null +++ b/test/mock/mockgroupquery.cpp @@ -0,0 +1,22 @@ +/* + Copyright © 2021 by The qTox Project Contributors + + This file is part of qTox, a Qt-based graphical interface for Tox. + + qTox is libre software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + qTox is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with qTox. If not, see . +*/ + +#include "mockgroupquery.h" + +MockGroupQuery::~MockGroupQuery() = default; diff --git a/test/mock/mockgroupquery.h b/test/mock/mockgroupquery.h index b039c7cbc..8c00906c8 100644 --- a/test/mock/mockgroupquery.h +++ b/test/mock/mockgroupquery.h @@ -29,6 +29,13 @@ class MockGroupQuery : public ICoreGroupQuery { public: + MockGroupQuery() = default; + virtual ~MockGroupQuery(); + MockGroupQuery(const MockGroupQuery&) = default; + MockGroupQuery& operator=(const MockGroupQuery&) = default; + MockGroupQuery(MockGroupQuery&&) = default; + MockGroupQuery& operator=(MockGroupQuery&&) = default; + GroupId getGroupPersistentId(uint32_t groupNumber) const override { return GroupId(0); diff --git a/test/model/friendmessagedispatcher_test.cpp b/test/model/friendmessagedispatcher_test.cpp index 0b2216f0f..ff34791c0 100644 --- a/test/model/friendmessagedispatcher_test.cpp +++ b/test/model/friendmessagedispatcher_test.cpp @@ -40,17 +40,9 @@ public: , currentReceiptId(currentReceiptId) {} - uint64_t addExtendedMessage(QString message) override - { - this->message = message; - return currentReceiptId++; - } + uint64_t addExtendedMessage(QString message) override; - bool send() override - { - numSentMessages++; - return true; - } + bool send() override; uint64_t& numSentMessages; uint64_t& currentReceiptId; @@ -58,46 +50,65 @@ public: QString message; }; +uint64_t MockCoreExtPacket::addExtendedMessage(QString message) +{ + this->message = message; + return currentReceiptId++; +} + +bool MockCoreExtPacket::send() +{ + numSentMessages++; + return true; +} + class MockCoreExtPacketAllocator : public ICoreExtPacketAllocator { public: - std::unique_ptr getPacket(uint32_t friendId) override - { - return std::unique_ptr(new MockCoreExtPacket(numSentMessages, currentReceiptId)); - } + std::unique_ptr getPacket(uint32_t friendId) override; uint64_t numSentMessages; uint64_t currentReceiptId; }; +std::unique_ptr MockCoreExtPacketAllocator::getPacket(uint32_t friendId) +{ + return std::unique_ptr(new MockCoreExtPacket(numSentMessages, currentReceiptId)); +} + class MockFriendMessageSender : public ICoreFriendMessageSender { public: - bool sendAction(uint32_t friendId, const QString& action, ReceiptNum& receipt) override - { - if (canSend) { - numSentActions++; - receipt = receiptNum; - receiptNum.get() += 1; - } - return canSend; - } + bool sendAction(uint32_t friendId, const QString& action, ReceiptNum& receipt) override; - bool sendMessage(uint32_t friendId, const QString& message, ReceiptNum& receipt) override - { - if (canSend) { - numSentMessages++; - receipt = receiptNum; - receiptNum.get() += 1; - } - return canSend; - } + bool sendMessage(uint32_t friendId, const QString& message, ReceiptNum& receipt) override; bool canSend = true; ReceiptNum receiptNum{0}; size_t numSentActions = 0; size_t numSentMessages = 0; }; + +bool MockFriendMessageSender::sendAction(uint32_t friendId, const QString& action, ReceiptNum& receipt) +{ + if (canSend) { + numSentActions++; + receipt = receiptNum; + receiptNum.get() += 1; + } + return canSend; +} + +bool MockFriendMessageSender::sendMessage(uint32_t friendId, const QString& message, ReceiptNum& receipt) +{ + if (canSend) { + numSentMessages++; + receipt = receiptNum; + receiptNum.get() += 1; + } + return canSend; +} + class TestFriendMessageDispatcher : public QObject { Q_OBJECT diff --git a/test/model/groupmessagedispatcher_test.cpp b/test/model/groupmessagedispatcher_test.cpp index 94c2bd756..584f98bf7 100644 --- a/test/model/groupmessagedispatcher_test.cpp +++ b/test/model/groupmessagedispatcher_test.cpp @@ -36,37 +36,45 @@ class MockGroupMessageSender : public ICoreGroupMessageSender { public: - void sendGroupAction(int groupId, const QString& action) override - { - numSentActions++; - } + void sendGroupAction(int groupId, const QString& action) override; - void sendGroupMessage(int groupId, const QString& message) override - { - numSentMessages++; - } + void sendGroupMessage(int groupId, const QString& message) override; size_t numSentActions = 0; size_t numSentMessages = 0; }; +void MockGroupMessageSender::sendGroupAction(int groupId, const QString& action) +{ + numSentActions++; +} + +void MockGroupMessageSender::sendGroupMessage(int groupId, const QString& message) +{ + numSentMessages++; +} + class MockGroupSettings : public IGroupSettings { public: - QStringList getBlackList() const override - { - return blacklist; - } + QStringList getBlackList() const override; - void setBlackList(const QStringList& blist) override - { - blacklist = blist; - } + void setBlackList(const QStringList& blist) override; private: QStringList blacklist; }; +QStringList MockGroupSettings::getBlackList() const +{ + return blacklist; +} + +void MockGroupSettings::setBlackList(const QStringList& blist) +{ + blacklist = blist; +} + class TestGroupMessageDispatcher : public QObject { Q_OBJECT