From 1e644587b314306e364b48bbfd544caa827788fc Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Tue, 23 Apr 2024 11:31:30 +0200 Subject: [PATCH] Replace Quotient::Connection with NeoChatConnection where possible --- src/controller.cpp | 1 - src/controller.h | 2 +- src/login.cpp | 7 +++---- src/login.h | 2 +- src/matriximageprovider.cpp | 2 -- src/matriximageprovider.h | 4 ++-- src/models/accountemoticonmodel.cpp | 6 ++++-- src/models/accountemoticonmodel.h | 10 +++++----- src/models/actionsmodel.cpp | 3 ++- src/models/customemojimodel.h | 2 +- src/models/customemojimodel_p.h | 5 +++-- src/models/devicesmodel.cpp | 7 ++++--- src/models/devicesmodel.h | 14 +++++--------- src/models/messageeventmodel.cpp | 1 - src/models/notificationsmodel.cpp | 1 - src/models/publicroomlistmodel.cpp | 11 +++++------ src/models/publicroomlistmodel.h | 13 +++++-------- src/models/pushrulemodel.cpp | 4 ++-- src/models/pushrulemodel.h | 2 +- src/models/roomlistmodel.cpp | 4 ++-- src/models/roomlistmodel.h | 11 ++++++----- src/models/roomtreemodel.cpp | 1 - src/models/searchmodel.cpp | 1 - src/models/serverlistmodel.cpp | 2 -- src/models/serverlistmodel.h | 2 +- src/models/sortfilterroomlistmodel.cpp | 2 ++ src/models/spacechildrenmodel.cpp | 3 +-- src/models/spacetreeitem.h | 4 +++- src/models/userdirectorylistmodel.cpp | 11 ++++++----- src/models/userdirectorylistmodel.h | 13 +++++-------- src/models/userlistmodel.cpp | 1 - src/registration.cpp | 2 +- src/registration.h | 7 +++---- src/roommanager.cpp | 8 ++++---- src/roommanager.h | 4 ++-- src/spacehierarchycache.h | 2 +- src/utils.cpp | 2 ++ src/utils.h | 1 - 38 files changed, 83 insertions(+), 95 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 6fa9d83a1..0682b145f 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/src/controller.h b/src/controller.h index 6cd3e3109..4e427ace7 100644 --- a/src/controller.h +++ b/src/controller.h @@ -117,7 +117,7 @@ private: Quotient::AccountRegistry m_accountRegistry; QStringList m_accountsLoading; - QMap> m_connectionsLoading; + QMap> m_connectionsLoading; QString m_endpoint; private Q_SLOTS: diff --git a/src/login.cpp b/src/login.cpp index cfe37d3d2..8855ea1b7 100644 --- a/src/login.cpp +++ b/src/login.cpp @@ -4,7 +4,6 @@ #include "login.h" #include -#include #include #include "controller.h" @@ -54,7 +53,7 @@ void LoginHelper::init() m_connection = new NeoChatConnection(); } m_connection->resolveServer(m_matrixId); - connectSingleShot(m_connection, &Connection::loginFlowsChanged, this, [this]() { + connectSingleShot(m_connection.get(), &Connection::loginFlowsChanged, this, [this]() { setHomeserverReachable(true); m_testing = false; Q_EMIT testingChanged(); @@ -100,7 +99,7 @@ void LoginHelper::init() Q_EMIT Controller::instance().errorOccured(i18n("Network Error"), std::move(error)); }); - connectSingleShot(m_connection, &Connection::syncDone, this, [this]() { + connectSingleShot(m_connection.get(), &Connection::syncDone, this, [this]() { Q_EMIT loaded(); }); } @@ -182,7 +181,7 @@ QUrl LoginHelper::ssoUrl() const void LoginHelper::loginWithSso() { m_connection->resolveServer(m_matrixId); - connectSingleShot(m_connection, &Connection::loginFlowsChanged, this, [this]() { + connectSingleShot(m_connection.get(), &Connection::loginFlowsChanged, this, [this]() { SsoSession *session = m_connection->prepareForSso(m_deviceName); m_ssoUrl = session->ssoUrl(); Q_EMIT ssoUrlChanged(); diff --git a/src/login.h b/src/login.h index fd8f3fee6..917df9e5d 100644 --- a/src/login.h +++ b/src/login.h @@ -146,7 +146,7 @@ private: QString m_deviceName; bool m_supportsSso = false; bool m_supportsPassword = false; - NeoChatConnection *m_connection = nullptr; + QPointer m_connection; QUrl m_ssoUrl; bool m_testing = false; bool m_isLoggingIn = false; diff --git a/src/matriximageprovider.cpp b/src/matriximageprovider.cpp index 7c180d2dc..eb82a2c32 100644 --- a/src/matriximageprovider.cpp +++ b/src/matriximageprovider.cpp @@ -14,8 +14,6 @@ #include "neochatconnection.h" -#include - using namespace Quotient; ThumbnailResponse::ThumbnailResponse(QString id, QSize size, NeoChatConnection *connection) diff --git a/src/matriximageprovider.h b/src/matriximageprovider.h index 393ba928d..2730d0e82 100644 --- a/src/matriximageprovider.h +++ b/src/matriximageprovider.h @@ -35,7 +35,7 @@ private: QSize requestedSize; const QString localFile; Quotient::MediaThumbnailJob *job = nullptr; - NeoChatConnection *m_connection; + QPointer m_connection; QImage image; QString errorStr; @@ -75,6 +75,6 @@ public: QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override; private: - NeoChatConnection *m_connection = nullptr; + QPointer m_connection; MatrixImageProvider() = default; }; diff --git a/src/models/accountemoticonmodel.cpp b/src/models/accountemoticonmodel.cpp index 44a39261a..2de63577d 100644 --- a/src/models/accountemoticonmodel.cpp +++ b/src/models/accountemoticonmodel.cpp @@ -10,6 +10,8 @@ #include #include +#include "neochatconnection.h" + using namespace Quotient; AccountEmoticonModel::AccountEmoticonModel(QObject *parent) @@ -77,12 +79,12 @@ QHash AccountEmoticonModel::roleNames() const }; } -Connection *AccountEmoticonModel::connection() const +NeoChatConnection *AccountEmoticonModel::connection() const { return m_connection; } -void AccountEmoticonModel::setConnection(Connection *connection) +void AccountEmoticonModel::setConnection(NeoChatConnection *connection) { if (m_connection) { disconnect(m_connection, nullptr, this, nullptr); diff --git a/src/models/accountemoticonmodel.h b/src/models/accountemoticonmodel.h index f0cf7c7fb..100a9a189 100644 --- a/src/models/accountemoticonmodel.h +++ b/src/models/accountemoticonmodel.h @@ -12,7 +12,7 @@ #include #include -#include +class NeoChatConnection; /** * @class AccountEmoticonModel @@ -29,7 +29,7 @@ class AccountEmoticonModel : public QAbstractListModel /** * @brief The connection to get emoticons from. */ - Q_PROPERTY(Quotient::Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged) + Q_PROPERTY(NeoChatConnection *connection READ connection WRITE setConnection NOTIFY connectionChanged) public: enum Roles { @@ -63,8 +63,8 @@ public: */ [[nodiscard]] QHash roleNames() const override; - [[nodiscard]] Quotient::Connection *connection() const; - void setConnection(Quotient::Connection *connection); + [[nodiscard]] NeoChatConnection *connection() const; + void setConnection(NeoChatConnection *connection); /** * @brief Deletes the emoticon at the given index. @@ -96,7 +96,7 @@ Q_SIGNALS: private: std::optional m_images; - QPointer m_connection; + QPointer m_connection; QCoro::Task doSetEmoticonImage(int index, QUrl source); QCoro::Task doAddEmoticon(QUrl source, QString shortcode, QString description, QString type); diff --git a/src/models/actionsmodel.cpp b/src/models/actionsmodel.cpp index e59106e80..e0d66df72 100644 --- a/src/models/actionsmodel.cpp +++ b/src/models/actionsmodel.cpp @@ -4,6 +4,7 @@ #include "actionsmodel.h" #include "chatbarcache.h" +#include "neochatconnection.h" #include "neochatroom.h" #include "roommanager.h" #include @@ -260,7 +261,7 @@ QList actions{ return QString(); } Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("Knocking room .", "Knocking room %1.", text)); - auto connection = room->connection(); + auto connection = dynamic_cast(room->connection()); const auto knownServer = roomName.mid(roomName.indexOf(":"_ls) + 1); if (parts.length() >= 2) { RoomManager::instance().knockRoom(connection, roomName, parts[1], QStringList{knownServer}); diff --git a/src/models/customemojimodel.h b/src/models/customemojimodel.h index 51907c0c7..09fff27dd 100644 --- a/src/models/customemojimodel.h +++ b/src/models/customemojimodel.h @@ -110,7 +110,7 @@ Q_SIGNALS: private: explicit CustomEmojiModel(QObject *parent = nullptr); QList m_emojis; - NeoChatConnection *m_connection = nullptr; + QPointer m_connection; void fetchEmojis(); }; diff --git a/src/models/customemojimodel_p.h b/src/models/customemojimodel_p.h index 05b02513b..08bb32713 100644 --- a/src/models/customemojimodel_p.h +++ b/src/models/customemojimodel_p.h @@ -5,7 +5,8 @@ #include "customemojimodel.h" #include -#include + +class NeoChatConnection; struct CustomEmoji { QString name; // with :semicolons: @@ -14,6 +15,6 @@ struct CustomEmoji { }; struct CustomEmojiModel::Private { - Quotient::Connection *conn = nullptr; + QPointer connection; QList emojies; }; diff --git a/src/models/devicesmodel.cpp b/src/models/devicesmodel.cpp index 01b4cb3f2..33c3c9112 100644 --- a/src/models/devicesmodel.cpp +++ b/src/models/devicesmodel.cpp @@ -11,9 +11,10 @@ #include #include -#include #include +#include "neochatconnection.h" + using namespace Quotient; DevicesModel::DevicesModel(QObject *parent) @@ -152,12 +153,12 @@ void DevicesModel::setName(const QString &deviceId, const QString &name) }); } -Connection *DevicesModel::connection() const +NeoChatConnection *DevicesModel::connection() const { return m_connection; } -void DevicesModel::setConnection(Connection *connection) +void DevicesModel::setConnection(NeoChatConnection *connection) { if (m_connection) { disconnect(m_connection, nullptr, this, nullptr); diff --git a/src/models/devicesmodel.h b/src/models/devicesmodel.h index a405ec6a3..1d9682aee 100644 --- a/src/models/devicesmodel.h +++ b/src/models/devicesmodel.h @@ -9,10 +9,7 @@ #include -namespace Quotient -{ -class Connection; -} +class NeoChatConnection; /** * @class DevicesModel @@ -31,7 +28,7 @@ class DevicesModel : public QAbstractListModel /** * @brief The current connection that the model is getting its devices from. */ - Q_PROPERTY(Quotient::Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged REQUIRED) + Q_PROPERTY(NeoChatConnection *connection READ connection WRITE setConnection NOTIFY connectionChanged REQUIRED) public: /** @@ -88,9 +85,8 @@ public: explicit DevicesModel(QObject *parent = nullptr); - - [[nodiscard]] Quotient::Connection *connection() const; - void setConnection(Quotient::Connection *connection); + [[nodiscard]] NeoChatConnection *connection() const; + void setConnection(NeoChatConnection *connection); Q_SIGNALS: void connectionChanged(); @@ -99,5 +95,5 @@ Q_SIGNALS: private: void fetchDevices(); QList m_devices; - QPointer m_connection; + QPointer m_connection; }; diff --git a/src/models/messageeventmodel.cpp b/src/models/messageeventmodel.cpp index 452b3134d..e23eb4cc3 100644 --- a/src/models/messageeventmodel.cpp +++ b/src/models/messageeventmodel.cpp @@ -7,7 +7,6 @@ #include "neochatconfig.h" -#include #include #include #include diff --git a/src/models/notificationsmodel.cpp b/src/models/notificationsmodel.cpp index 13f3e6069..9cd573d3c 100644 --- a/src/models/notificationsmodel.cpp +++ b/src/models/notificationsmodel.cpp @@ -3,7 +3,6 @@ #include "notificationsmodel.h" -#include #include #include diff --git a/src/models/publicroomlistmodel.cpp b/src/models/publicroomlistmodel.cpp index 2cf585b2c..cab664705 100644 --- a/src/models/publicroomlistmodel.cpp +++ b/src/models/publicroomlistmodel.cpp @@ -3,8 +3,7 @@ #include "publicroomlistmodel.h" -#include - +#include "neochatconnection.h" #include "publicroomlist_logging.h" using namespace Quotient; @@ -14,14 +13,14 @@ PublicRoomListModel::PublicRoomListModel(QObject *parent) { } -Quotient::Connection *PublicRoomListModel::connection() const +NeoChatConnection *PublicRoomListModel::connection() const { return m_connection; } -void PublicRoomListModel::setConnection(Connection *conn) +void PublicRoomListModel::setConnection(NeoChatConnection *connection) { - if (m_connection == conn) { + if (m_connection == connection) { return; } @@ -38,7 +37,7 @@ void PublicRoomListModel::setConnection(Connection *conn) endResetModel(); - m_connection = conn; + m_connection = connection; if (job) { job->abandon(); diff --git a/src/models/publicroomlistmodel.h b/src/models/publicroomlistmodel.h index 7d077adeb..6f60b81cc 100644 --- a/src/models/publicroomlistmodel.h +++ b/src/models/publicroomlistmodel.h @@ -9,10 +9,7 @@ #include -namespace Quotient -{ -class Connection; -} +class NeoChatConnection; /** * @class PublicRoomListModel @@ -33,7 +30,7 @@ class PublicRoomListModel : public QAbstractListModel /** * @brief The current connection that the model is getting its rooms from. */ - Q_PROPERTY(Quotient::Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged) + Q_PROPERTY(NeoChatConnection *connection READ connection WRITE setConnection NOTIFY connectionChanged) /** * @brief The server to get the public room list from. @@ -95,8 +92,8 @@ public: */ [[nodiscard]] QHash roleNames() const override; - [[nodiscard]] Quotient::Connection *connection() const; - void setConnection(Quotient::Connection *conn); + [[nodiscard]] NeoChatConnection *connection() const; + void setConnection(NeoChatConnection *connection); [[nodiscard]] QString server() const; void setServer(const QString &value); @@ -117,7 +114,7 @@ public: Q_INVOKABLE void search(int limit = 50); private: - QPointer m_connection = nullptr; + QPointer m_connection = nullptr; QString m_server; QString m_searchText; bool m_showOnlySpaces = false; diff --git a/src/models/pushrulemodel.cpp b/src/models/pushrulemodel.cpp index d1e68dcad..53ae52e20 100644 --- a/src/models/pushrulemodel.cpp +++ b/src/models/pushrulemodel.cpp @@ -5,13 +5,13 @@ #include -#include #include #include #include #include #include "neochatconfig.h" +#include "neochatconnection.h" #include @@ -454,7 +454,7 @@ void PushRuleModel::setConnection(NeoChatConnection *connection) Q_EMIT connectionChanged(); if (m_connection) { - connect(m_connection, &Quotient::Connection::accountDataChanged, this, &PushRuleModel::updateNotificationRules); + connect(m_connection, &NeoChatConnection::accountDataChanged, this, &PushRuleModel::updateNotificationRules); updateNotificationRules(QStringLiteral("m.push_rules")); } } diff --git a/src/models/pushrulemodel.h b/src/models/pushrulemodel.h index 4521eb9eb..96f9da112 100644 --- a/src/models/pushrulemodel.h +++ b/src/models/pushrulemodel.h @@ -126,7 +126,7 @@ private Q_SLOTS: private: PushRuleAction::Action m_defaultKeywordAction; QList m_rules; - NeoChatConnection *m_connection; + QPointer m_connection; void setRules(QList rules, PushRuleKind::Kind kind); diff --git a/src/models/roomlistmodel.cpp b/src/models/roomlistmodel.cpp index f41628f39..5654395fa 100644 --- a/src/models/roomlistmodel.cpp +++ b/src/models/roomlistmodel.cpp @@ -25,12 +25,12 @@ RoomListModel::RoomListModel(QObject *parent) RoomListModel::~RoomListModel() = default; -Quotient::Connection *RoomListModel::connection() const +NeoChatConnection *RoomListModel::connection() const { return m_connection; } -void RoomListModel::setConnection(Connection *connection) +void RoomListModel::setConnection(NeoChatConnection *connection) { if (connection == m_connection) { return; diff --git a/src/models/roomlistmodel.h b/src/models/roomlistmodel.h index d28c7fb15..b2c7f268d 100644 --- a/src/models/roomlistmodel.h +++ b/src/models/roomlistmodel.h @@ -12,10 +12,11 @@ class NeoChatRoom; namespace Quotient { -class Connection; class Room; } +class NeoChatConnection; + /** * @class RoomListModel * @@ -29,7 +30,7 @@ class RoomListModel : public QAbstractListModel /** * @brief The current connection that the model is getting its rooms from. */ - Q_PROPERTY(Quotient::Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged) + Q_PROPERTY(NeoChatConnection *connection READ connection WRITE setConnection NOTIFY connectionChanged) public: /** @@ -60,8 +61,8 @@ public: explicit RoomListModel(QObject *parent = nullptr); ~RoomListModel() override; - [[nodiscard]] Quotient::Connection *connection() const; - void setConnection(Quotient::Connection *connection); + [[nodiscard]] NeoChatConnection *connection() const; + void setConnection(NeoChatConnection *connection); /** * @brief Get the given role value at the given index. @@ -109,7 +110,7 @@ private Q_SLOTS: void refresh(NeoChatRoom *room, const QList &roles = {}); private: - Quotient::Connection *m_connection = nullptr; + QPointer m_connection; QList m_rooms; QString m_activeSpaceId; diff --git a/src/models/roomtreemodel.cpp b/src/models/roomtreemodel.cpp index 709ebff11..a04882965 100644 --- a/src/models/roomtreemodel.cpp +++ b/src/models/roomtreemodel.cpp @@ -3,7 +3,6 @@ #include "roomtreemodel.h" -#include #include #include "eventhandler.h" diff --git a/src/models/searchmodel.cpp b/src/models/searchmodel.cpp index 50a685b2d..40e387ad6 100644 --- a/src/models/searchmodel.cpp +++ b/src/models/searchmodel.cpp @@ -10,7 +10,6 @@ #include -#include #include #include diff --git a/src/models/serverlistmodel.cpp b/src/models/serverlistmodel.cpp index a0e8e97c1..602eca8e1 100644 --- a/src/models/serverlistmodel.cpp +++ b/src/models/serverlistmodel.cpp @@ -3,8 +3,6 @@ #include "serverlistmodel.h" -#include - #include #include diff --git a/src/models/serverlistmodel.h b/src/models/serverlistmodel.h index 4a18be5b4..1fb2e5963 100644 --- a/src/models/serverlistmodel.h +++ b/src/models/serverlistmodel.h @@ -110,7 +110,7 @@ Q_SIGNALS: private: QList m_servers; QPointer m_checkServerJob = nullptr; - NeoChatConnection *m_connection = nullptr; + QPointer m_connection; void initialize(); }; diff --git a/src/models/sortfilterroomlistmodel.cpp b/src/models/sortfilterroomlistmodel.cpp index 4dcffa19f..b6a05be39 100644 --- a/src/models/sortfilterroomlistmodel.cpp +++ b/src/models/sortfilterroomlistmodel.cpp @@ -5,6 +5,8 @@ #include "roomlistmodel.h" +#include "neochatconnection.h" + SortFilterRoomListModel::SortFilterRoomListModel(RoomListModel *sourceModel, QObject *parent) : QSortFilterProxyModel(parent) { diff --git a/src/models/spacechildrenmodel.cpp b/src/models/spacechildrenmodel.cpp index 3730ce8a2..d5e5df5cb 100644 --- a/src/models/spacechildrenmodel.cpp +++ b/src/models/spacechildrenmodel.cpp @@ -3,7 +3,6 @@ #include "spacechildrenmodel.h" -#include #include #include @@ -47,7 +46,7 @@ void SpaceChildrenModel::setSpace(NeoChatRoom *space) } auto connection = m_space->connection(); - connect(connection, &Quotient::Connection::loadedRoomState, this, [this](Quotient::Room *room) { + connect(connection, &NeoChatConnection::loadedRoomState, this, [this](Quotient::Room *room) { if (m_pendingChildren.contains(room->name())) { m_pendingChildren.removeAll(room->name()); refreshModel(); diff --git a/src/models/spacetreeitem.h b/src/models/spacetreeitem.h index 1075cb3a5..7af977641 100644 --- a/src/models/spacetreeitem.h +++ b/src/models/spacetreeitem.h @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 James Graham // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +#include + #include #include @@ -149,7 +151,7 @@ public: bool isSuggested() const; private: - NeoChatConnection *m_connection; + QPointer m_connection; std::vector> m_children; SpaceTreeItem *m_parentItem; diff --git a/src/models/userdirectorylistmodel.cpp b/src/models/userdirectorylistmodel.cpp index 6bbf78405..6b7faac49 100644 --- a/src/models/userdirectorylistmodel.cpp +++ b/src/models/userdirectorylistmodel.cpp @@ -3,9 +3,10 @@ #include "userdirectorylistmodel.h" -#include #include +#include "neochatconnection.h" + using namespace Quotient; UserDirectoryListModel::UserDirectoryListModel(QObject *parent) @@ -13,14 +14,14 @@ UserDirectoryListModel::UserDirectoryListModel(QObject *parent) { } -Quotient::Connection *UserDirectoryListModel::connection() const +NeoChatConnection *UserDirectoryListModel::connection() const { return m_connection; } -void UserDirectoryListModel::setConnection(Connection *conn) +void UserDirectoryListModel::setConnection(NeoChatConnection *connection) { - if (m_connection == conn) { + if (m_connection == connection) { return; } @@ -35,7 +36,7 @@ void UserDirectoryListModel::setConnection(Connection *conn) endResetModel(); - m_connection = conn; + m_connection = connection; Q_EMIT connectionChanged(); if (m_job) { diff --git a/src/models/userdirectorylistmodel.h b/src/models/userdirectorylistmodel.h index 76b1872d6..1c2c230c3 100644 --- a/src/models/userdirectorylistmodel.h +++ b/src/models/userdirectorylistmodel.h @@ -9,10 +9,7 @@ #include -namespace Quotient -{ -class Connection; -} +class NeoChatConnection; /** * @class UserDirectoryListModel @@ -32,7 +29,7 @@ class UserDirectoryListModel : public QAbstractListModel /** * @brief The current connection that the model is getting users from. */ - Q_PROPERTY(Quotient::Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged) + Q_PROPERTY(NeoChatConnection *connection READ connection WRITE setConnection NOTIFY connectionChanged) /** * @brief The text to search the public room list for. @@ -57,8 +54,8 @@ public: explicit UserDirectoryListModel(QObject *parent = nullptr); - [[nodiscard]] Quotient::Connection *connection() const; - void setConnection(Quotient::Connection *conn); + [[nodiscard]] NeoChatConnection *connection() const; + void setConnection(NeoChatConnection *connection); [[nodiscard]] QString searchText() const; void setSearchText(const QString &searchText); @@ -99,7 +96,7 @@ Q_SIGNALS: void searchingChanged(); private: - Quotient::Connection *m_connection = nullptr; + QPointer m_connection; QString m_searchText; bool attempted = false; diff --git a/src/models/userlistmodel.cpp b/src/models/userlistmodel.cpp index 40a5ff8ad..0d0903d35 100644 --- a/src/models/userlistmodel.cpp +++ b/src/models/userlistmodel.cpp @@ -5,7 +5,6 @@ #include -#include #include #include "neochatroom.h" diff --git a/src/registration.cpp b/src/registration.cpp index 38dadd9f0..9907eb345 100644 --- a/src/registration.cpp +++ b/src/registration.cpp @@ -170,7 +170,7 @@ void Registration::testHomeserver() delete m_connection; } - m_connection = new Connection(this); + m_connection = new NeoChatConnection(this); m_connection->resolveServer("@user:%1"_ls.arg(m_homeserver)); connectSingleShot(m_connection.data(), &Connection::loginFlowsChanged, this, [this]() { if (m_testServerJob) { diff --git a/src/registration.h b/src/registration.h index fa5e994f8..aea7bbd44 100644 --- a/src/registration.h +++ b/src/registration.h @@ -13,17 +13,16 @@ #include -#include - #include #include namespace Quotient { -class Connection; class CheckUsernameAvailabilityJob; } +class NeoChatConnection; + class NeoChatRegisterJob : public Quotient::BaseJob { public: @@ -159,7 +158,7 @@ private: QPointer m_usernameJob; QPointer m_testServerJob; QList> m_flows; - QPointer m_connection; + QPointer m_connection; void testHomeserver(); void testUsername(); diff --git a/src/roommanager.cpp b/src/roommanager.cpp index df4653f54..62b384d8b 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -150,7 +150,7 @@ void RoomManager::resolveResource(const QString &idOrUri, const QString &action) Q_ASSERT(result == Quotient::UriResolved); if (uri.type() == Uri::RoomAlias || uri.type() == Uri::RoomId) { - connectSingleShot(m_connection, &Connection::newRoom, this, [this, uri](Room *room) { + connectSingleShot(m_connection.get(), &NeoChatConnection::newRoom, this, [this, uri](Room *room) { resolveResource(room->id()); }); } @@ -303,7 +303,7 @@ void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAli auto job = account->joinRoom(roomAliasOrId, viaServers); connectSingleShot(job, &Quotient::BaseJob::finished, this, [this, account](Quotient::BaseJob *finish) { if (finish->status() == Quotient::BaseJob::Success) { - connectSingleShot(account, &Quotient::Connection::newRoom, this, [this](Quotient::Room *room) { + connectSingleShot(account, &NeoChatConnection::newRoom, this, [this](Quotient::Room *room) { resolveResource(room->id()); }); } else { @@ -312,7 +312,7 @@ void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAli }); } -void RoomManager::knockRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers) +void RoomManager::knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers) { auto *const job = account->callApi(roomAliasOrId, viaServers, reason); // Upon completion, ensure a room object is created in case it hasn't come @@ -321,7 +321,7 @@ void RoomManager::knockRoom(Quotient::Connection *account, const QString &roomAl // to overtake clients that may add their own slots to finished(). connectSingleShot(job, &BaseJob::finished, this, [this, job, account] { if (job->status() == Quotient::BaseJob::Success) { - connectSingleShot(account, &Quotient::Connection::newRoom, this, [this](Quotient::Room *room) { + connectSingleShot(account, &NeoChatConnection::newRoom, this, [this](Quotient::Room *room) { Q_EMIT currentRoom()->showMessage(NeoChatRoom::Info, i18n("You requested to join '%1'", room->name())); }); } else { diff --git a/src/roommanager.h b/src/roommanager.h index 1a91373e6..7c4e9264f 100644 --- a/src/roommanager.h +++ b/src/roommanager.h @@ -192,7 +192,7 @@ public: * See https://spec.matrix.org/latest/client-server-api/#knocking-on-rooms for * knocking on rooms. */ - void knockRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers); + void knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers); /** * @brief Show a media item maximized. @@ -358,7 +358,7 @@ private: TimelineModel *m_timelineModel; MessageFilterModel *m_messageFilterModel; MediaMessageFilterModel *m_mediaMessageFilterModel; - NeoChatConnection *m_connection; + QPointer m_connection; void setCurrentRoom(const QString &roomId); diff --git a/src/spacehierarchycache.h b/src/spacehierarchycache.h index 929cd9c72..9dc3b323f 100644 --- a/src/spacehierarchycache.h +++ b/src/spacehierarchycache.h @@ -116,5 +116,5 @@ private: QHash> m_nextBatchTokens; void populateSpaceHierarchy(const QString &spaceId); void addBatch(const QString &spaceId, Quotient::GetSpaceHierarchyJob *job); - NeoChatConnection *m_connection; + QPointer m_connection; }; diff --git a/src/utils.cpp b/src/utils.cpp index e09d87d79..b07922230 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -3,6 +3,8 @@ #include "utils.h" +#include + #include using namespace Quotient; diff --git a/src/utils.h b/src/utils.h index 786c6a136..1fc0e3e78 100644 --- a/src/utils.h +++ b/src/utils.h @@ -9,7 +9,6 @@ #include #include -#include #include class QmlUtils : public QObject