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 <limits>
+#include "Cache.h"
+#include "Cache_p.h"
+
#include <stdexcept>
#include <variant>
-#include <QByteArray>
#include <QCoreApplication>
#include <QCryptographicHash>
+#include <QDir>
#include <QFile>
#include <QHash>
#include <QMap>
@@ -24,9 +26,8 @@
#endif
#include <mtx/responses/common.hpp>
+#include <mtx/responses/messages.hpp>
-#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 <optional>
#include <QDateTime>
-#include <QDir>
-#include <QImage>
#include <QString>
#if __has_include(<lmdbxx/lmdb++.h>)
@@ -22,16 +20,19 @@
#endif
#include <nlohmann/json.hpp>
-#include <mtx/responses/messages.hpp>
#include <mtx/responses/notifications.hpp>
#include <mtx/responses/sync.hpp>
-#include <mtxclient/crypto/client.hpp>
+#include <mtxclient/crypto/types.hpp>
#include <mtxclient/http/client.hpp>
#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> 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> 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> 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> 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 <algorithm>
+#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 <QAbstractListModel>
-#include <QHash>
#include <QString>
#include <string>
#include <vector>
-#include "MatrixClient.h"
#include <mtx/responses/public_rooms.hpp>
-#include <mtxclient/http/errors.hpp>
-
-#include "Logging.h"
-
-namespace mtx::http {
-using RequestErr = const std::optional<mtx::http::ClientError> &;
-}
-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 <QFile>
#include <QMimeDatabase>
+#include <mtx/responses/media.hpp>
+
#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<QString> 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 <QSettings>
#include <QSharedPointer>
-#include "JdenticonProvider.h"
#include <optional>
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<QStringList> 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<mtx::events::msg::KeyVerificationStart> 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 <QObject>
#include <mtx/responses/crypto.hpp>
-#include <nlohmann/json.hpp>
#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<int> 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 <thread>
#include <type_traits>
-#include <QCache>
#include <QClipboard>
#include <QDesktopServices>
#include <QFileDialog>
@@ -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 <QAbstractListModel>
#include <QColor>
#include <QDate>
-#include <QHash>
#include <QSet>
#include <QTimer>
#include <QVariant>
@@ -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<mtx::http::ClientError> &;
@@ -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 <mtx/common.hpp>
#include <mtx/responses/messages.hpp>
+#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 <QString>
#include <QVariantList>
-#include "timeline/TimelineModel.h"
+#include <mtx/events/event_type.hpp>
class HiddenEvents : public QObject
{
|