diff --git a/src/Cache.cpp b/src/Cache.cpp index e8578655..7284ffaa 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -4,13 +4,15 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -#include +#include "Cache.h" +#include "Cache_p.h" + #include #include -#include #include #include +#include #include #include #include @@ -24,9 +26,8 @@ #endif #include +#include -#include "Cache.h" -#include "Cache_p.h" #include "ChatPage.h" #include "EventAccessors.h" #include "Logging.h" diff --git a/src/Cache_p.h b/src/Cache_p.h index 988dc04f..de123a95 100644 --- a/src/Cache_p.h +++ b/src/Cache_p.h @@ -11,8 +11,6 @@ #include #include -#include -#include #include #if __has_include() @@ -22,16 +20,19 @@ #endif #include -#include #include #include -#include +#include #include #include "CacheCryptoStructs.h" #include "CacheStructs.h" #include "Logging.h" +namespace mtx::responses { +struct Messages; +} + class Cache : public QObject { Q_OBJECT diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 967f349d..56be6460 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -47,7 +47,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) : QObject(parent) , isConnected_(true) , userSettings_{userSettings} - , notificationsManager(this) + , notificationsManager(new NotificationsManager(this)) , callManager_(new CallManager(this)) { setObjectName(QStringLiteral("chatPage")); @@ -147,7 +147,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) } }); - connect(¬ificationsManager, + connect(notificationsManager, &NotificationsManager::notificationClicked, this, [this](const QString &roomid, const QString &eventid) { @@ -160,7 +160,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) MainWindow::instance()->requestActivate(); } }); - connect(¬ificationsManager, + connect(notificationsManager, &NotificationsManager::sendNotificationReply, this, [this](const QString &roomid, const QString &eventid, const QString &body) { @@ -396,7 +396,7 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token) connect(cache::client(), &Cache::removeNotification, - ¬ificationsManager, + notificationsManager, &NotificationsManager::removeNotification); } catch (const lmdb::error &e) { @@ -492,7 +492,7 @@ ChatPage::sendNotifications(const mtx::responses::Notifications &res) 96, this, [this, item](QPixmap image) { - notificationsManager.postNotification( + notificationsManager->postNotification( item, image.toImage()); }); } diff --git a/src/ChatPage.h b/src/ChatPage.h index 5228aa8e..af06f02c 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -24,7 +24,6 @@ #include "CacheCryptoStructs.h" #include "CacheStructs.h" -#include "notifications/Manager.h" class TimelineViewManager; class UserSettings; @@ -217,7 +216,7 @@ private: // Global user settings. QSharedPointer userSettings_; - NotificationsManager notificationsManager; + NotificationsManager *notificationsManager; CallManager *callManager_; }; diff --git a/src/RoomDirectoryModel.cpp b/src/RoomDirectoryModel.cpp index 23bca36c..428b0040 100644 --- a/src/RoomDirectoryModel.cpp +++ b/src/RoomDirectoryModel.cpp @@ -4,11 +4,14 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "RoomDirectoryModel.h" -#include "Cache.h" -#include "ChatPage.h" #include +#include "Cache.h" +#include "ChatPage.h" +#include "Logging.h" +#include "MatrixClient.h" + RoomDirectoryModel::RoomDirectoryModel(QObject *parent, const std::string &server) : QAbstractListModel(parent) , server_(server) diff --git a/src/RoomDirectoryModel.h b/src/RoomDirectoryModel.h index 5fcc7b88..b0768997 100644 --- a/src/RoomDirectoryModel.h +++ b/src/RoomDirectoryModel.h @@ -6,23 +6,11 @@ #pragma once #include -#include #include #include #include -#include "MatrixClient.h" #include -#include - -#include "Logging.h" - -namespace mtx::http { -using RequestErr = const std::optional &; -} -namespace mtx::responses { -struct PublicRooms; -} class RoomDirectoryModel : public QAbstractListModel { diff --git a/src/SingleImagePackModel.cpp b/src/SingleImagePackModel.cpp index e0ae7a10..c7f01fad 100644 --- a/src/SingleImagePackModel.cpp +++ b/src/SingleImagePackModel.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include "Cache_p.h" #include "ChatPage.h" #include "Logging.h" diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 025d6681..dc8e87fc 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -17,6 +17,7 @@ #include "Cache.h" #include "Config.h" +#include "JdenticonProvider.h" #include "MainWindow.h" #include "MatrixClient.h" #include "UserSettingsPage.h" @@ -152,6 +153,13 @@ UserSettings::load(std::optional profile) applyTheme(); } + +bool +UserSettings::useIdenticon() const +{ + return useIdenticon_ && JdenticonProvider::isAvailable(); +} + void UserSettings::setMessageHoverHighlight(bool state) { diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h index bcc45cdc..1fb3ddcf 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h @@ -11,7 +11,6 @@ #include #include -#include "JdenticonProvider.h" #include class Toggle; @@ -254,7 +253,7 @@ public: QStringList hiddenPins() const { return hiddenPins_; } QStringList hiddenWidgets() const { return hiddenWidgets_; } QStringList recentReactions() const { return recentReactions_; } - bool useIdenticon() const { return useIdenticon_ && JdenticonProvider::isAvailable(); } + bool useIdenticon() const; bool openImageExternal() const { return openImageExternal_; } bool openVideoExternal() const { return openVideoExternal_; } QList collapsedSpaces() const { return collapsedSpaces_; } diff --git a/src/encryption/DeviceVerificationFlow.cpp b/src/encryption/DeviceVerificationFlow.cpp index fa06fba2..d2dab491 100644 --- a/src/encryption/DeviceVerificationFlow.cpp +++ b/src/encryption/DeviceVerificationFlow.cpp @@ -199,8 +199,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, if (this->sender == false) { this->sendVerificationKey(); } else { - if (this->commitment != mtx::crypto::bin2base64_unpadded(mtx::crypto::sha256( - msg.key + this->canonical_json.dump()))) { + if (this->commitment != mtx::crypto::bin2base64_unpadded( + mtx::crypto::sha256(msg.key + this->canonical_json))) { this->cancelVerification(DeviceVerificationFlow::Error::MismatchedCommitment); return; } @@ -477,7 +477,7 @@ DeviceVerificationFlow::next() } else { switch (state_) { case PromptStartVerification: - if (canonical_json.is_null()) + if (canonical_json.empty()) sendVerificationReady(); else // legacy path without request and ready acceptVerificationRequest(); @@ -569,14 +569,14 @@ DeviceVerificationFlow::handleStartMessage(const mtx::events::msg::KeyVerificati return; } if (!sender) - this->canonical_json = nlohmann::json(msg); + this->canonical_json = nlohmann::json(msg).dump(); else { // resolve glare if (std::tuple(this->toClient.to_string(), this->deviceId.toStdString()) < std::tuple(utils::localUser().toStdString(), http::client()->device_id())) { // treat this as if the user with the smaller mxid or smaller deviceid (if the mxid // was the same) was the sender of "start" - this->canonical_json = nlohmann::json(msg); + this->canonical_json = nlohmann::json(msg).dump(); this->sender = false; } @@ -610,7 +610,7 @@ DeviceVerificationFlow::acceptVerificationRequest() else if (this->method == mtx::events::msg::SASMethods::Decimal) req.short_authentication_string = {mtx::events::msg::SASMethods::Decimal}; req.commitment = mtx::crypto::bin2base64_unpadded( - mtx::crypto::sha256(this->sas->public_key() + this->canonical_json.dump())); + mtx::crypto::sha256(this->sas->public_key() + this->canonical_json)); send(req); setState(WaitingForKeys); @@ -652,12 +652,12 @@ DeviceVerificationFlow::startVerificationRequest() if (this->type == DeviceVerificationFlow::Type::ToDevice) { mtx::requests::ToDeviceMessages body; req.transaction_id = this->transaction_id; - this->canonical_json = nlohmann::json(req); + this->canonical_json = nlohmann::json(req).dump(); } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_) { req.relations.relations.push_back(this->relation); // Set synthesized to surpress the nheko relation extensions req.relations.synthesized = true; - this->canonical_json = nlohmann::json(req); + this->canonical_json = nlohmann::json(req).dump(); } send(req); setState(WaitingForOtherToAccept); diff --git a/src/encryption/DeviceVerificationFlow.h b/src/encryption/DeviceVerificationFlow.h index 1955fab3..7968b739 100644 --- a/src/encryption/DeviceVerificationFlow.h +++ b/src/encryption/DeviceVerificationFlow.h @@ -8,7 +8,6 @@ #include #include -#include #include "CacheCryptoStructs.h" #include "Logging.h" @@ -211,7 +210,7 @@ private: sas_ptr sas; std::string mac_method; std::string commitment; - nlohmann::json canonical_json; + std::string canonical_json; std::vector sasList; UserKeyCache their_keys; diff --git a/src/encryption/SelfVerificationStatus.cpp b/src/encryption/SelfVerificationStatus.cpp index f37b2af4..46e71015 100644 --- a/src/encryption/SelfVerificationStatus.cpp +++ b/src/encryption/SelfVerificationStatus.cpp @@ -11,7 +11,6 @@ #include "Cache_p.h" #include "ChatPage.h" #include "Logging.h" -#include "MainWindow.h" #include "MatrixClient.h" #include "Olm.h" #include "encryption/VerificationManager.h" diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index 32b523db..fe171deb 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -27,7 +27,6 @@ #include "CombinedImagePackModel.h" #include "Config.h" #include "Logging.h" -#include "MainWindow.h" #include "MatrixClient.h" #include "TimelineModel.h" #include "TimelineViewManager.h" diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 53d2fe01..ff722b8b 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -28,9 +27,6 @@ #include "Logging.h" #include "MainWindow.h" #include "MatrixClient.h" -#include "MemberList.h" -#include "MxcImageProvider.h" -#include "ReadReceiptsModel.h" #include "TimelineViewManager.h" #include "Utils.h" #include "encryption/Olm.h" diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 7b5fb907..f569016c 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -23,8 +22,6 @@ #include "MemberList.h" #include "Permissions.h" #include "ReadReceiptsModel.h" -#include "ui/RoomSettings.h" -#include "ui/UserProfile.h" namespace mtx::http { using RequestErr = const std::optional &; @@ -33,6 +30,7 @@ namespace mtx::responses { struct Timeline; struct Messages; struct ClaimKeys; +struct StateEvents; } struct RelatedInfo; @@ -411,7 +409,7 @@ signals: void lastMessageChanged(); void notificationsChanged(); - void newState(mtx::responses::StateEvents events); + void newState(const mtx::responses::StateEvents &events); void newMessageToSend(mtx::events::collections::TimelineEvents event); void addPendingMessageToStore(mtx::events::collections::TimelineEvents event); diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 994042b6..970bf02c 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -13,9 +13,12 @@ #include #include +#include "ReadReceiptsModel.h" #include "timeline/CommunitiesModel.h" #include "timeline/PresenceEmitter.h" #include "timeline/RoomlistModel.h" +#include "ui/RoomSettings.h" +#include "ui/UserProfile.h" class MxcImageProvider; class BlurhashProvider; diff --git a/src/ui/HiddenEvents.cpp b/src/ui/HiddenEvents.cpp index a8da812e..1ebcda3e 100644 --- a/src/ui/HiddenEvents.cpp +++ b/src/ui/HiddenEvents.cpp @@ -7,6 +7,7 @@ #include "Cache_p.h" #include "MainWindow.h" #include "MatrixClient.h" +#include "timeline/TimelineModel.h" void HiddenEvents::load() diff --git a/src/ui/HiddenEvents.h b/src/ui/HiddenEvents.h index 928b14ba..e61cac0a 100644 --- a/src/ui/HiddenEvents.h +++ b/src/ui/HiddenEvents.h @@ -8,7 +8,7 @@ #include #include -#include "timeline/TimelineModel.h" +#include class HiddenEvents : public QObject {