Make a few headers forward declarations

This commit is contained in:
Nicolas Werner 2024-03-16 03:55:57 +01:00
parent 06927cd3c2
commit aef9617d1e
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
39 changed files with 198 additions and 118 deletions

View file

@ -444,6 +444,7 @@ set(SRC_FILES
src/BlurhashProvider.h src/BlurhashProvider.h
src/Cache.cpp src/Cache.cpp
src/Cache.h src/Cache.h
src/CacheCryptoStructs.cpp
src/CacheCryptoStructs.h src/CacheCryptoStructs.h
src/CacheStructs.h src/CacheStructs.h
src/Cache_p.h src/Cache_p.h
@ -603,7 +604,7 @@ if(USE_BUNDLED_MTXCLIENT)
FetchContent_Declare( FetchContent_Declare(
MatrixClient MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
GIT_TAG 188ecb899744e55842c1debaa4597cdc5184be8a GIT_TAG 4fb7d678aeea197d16b52bfb1dc35b506673bb52
) )
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")

View file

@ -223,7 +223,7 @@ modules:
buildsystem: cmake-ninja buildsystem: cmake-ninja
name: mtxclient name: mtxclient
sources: sources:
- commit: 188ecb899744e55842c1debaa4597cdc5184be8a - commit: 4fb7d678aeea197d16b52bfb1dc35b506673bb52
#tag: v0.9.2 #tag: v0.9.2
type: git type: git
url: https://github.com/Nheko-Reborn/mtxclient.git url: https://github.com/Nheko-Reborn/mtxclient.git

View file

@ -6296,3 +6296,5 @@ NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::policy_rule::ServerRu
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::space::Child) NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::space::Child)
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::space::Parent) NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::state::space::Parent)
NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::msc2545::ImagePack) NHEKO_CACHE_GET_STATE_EVENT_DEFINITION(mtx::events::msc2545::ImagePack)
#include "moc_Cache_p.cpp"

View file

@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "CacheCryptoStructs.h"
#include <mtx/events/encrypted.hpp>
MegolmSessionIndex::MegolmSessionIndex(std::string room_id_, const mtx::events::msg::Encrypted &e)
: room_id(std::move(room_id_))
, session_id(e.session_id)
{
}
#include "moc_CacheCryptoStructs.cpp"

View file

@ -11,10 +11,13 @@
#include <mutex> #include <mutex>
#include <set> #include <set>
#include <mtx/events/encrypted.hpp>
#include <mtx/responses/crypto.hpp> #include <mtx/responses/crypto.hpp>
#include <mtxclient/crypto/objects.hpp> #include <mtxclient/crypto/objects.hpp>
namespace mtx::events::msg {
struct Encrypted;
}
namespace crypto { namespace crypto {
Q_NAMESPACE Q_NAMESPACE
QML_NAMED_ELEMENT(Crypto) QML_NAMED_ELEMENT(Crypto)
@ -96,11 +99,7 @@ from_json(const nlohmann::json &obj, DevicePublicKeys &msg);
struct MegolmSessionIndex struct MegolmSessionIndex
{ {
MegolmSessionIndex() = default; MegolmSessionIndex() = default;
MegolmSessionIndex(std::string room_id_, const mtx::events::msg::Encrypted &e) MegolmSessionIndex(std::string room_id_, const mtx::events::msg::Encrypted &e);
: room_id(std::move(room_id_))
, session_id(e.session_id)
{
}
//! The room in which this session exists. //! The room in which this session exists.
std::string room_id; std::string room_id;

View file

@ -19,13 +19,14 @@
#include <mtx/responses/notifications.hpp> #include <mtx/responses/notifications.hpp>
#include <mtx/responses/sync.hpp> #include <mtx/responses/sync.hpp>
#include <mtxclient/crypto/types.hpp> #include <mtxclient/crypto/types.hpp>
#include <mtxclient/http/client.hpp> #include <mtxclient/http/errors.hpp>
#include "CacheCryptoStructs.h" #include "CacheCryptoStructs.h"
#include "CacheStructs.h" #include "CacheStructs.h"
namespace mtx::responses { namespace mtx::responses {
struct Messages; struct Messages;
struct StateEvents;
} }
class Cache final : public QObject class Cache final : public QObject
@ -51,8 +52,9 @@ public:
lmdb::dbi &db, lmdb::dbi &db,
const std::vector<std::string> &user_ids, const std::vector<std::string> &user_ids,
const std::string &sync_token); const std::string &sync_token);
void query_keys(const std::string &user_id, void query_keys(
std::function<void(const UserKeyCache &, mtx::http::RequestErr)> cb); const std::string &user_id,
std::function<void(const UserKeyCache &, const std::optional<mtx::http::ClientError> &)> cb);
// device & user verification cache // device & user verification cache
std::optional<UserKeyCache> userKeys(const std::string &user_id); std::optional<UserKeyCache> userKeys(const std::string &user_id);

View file

@ -31,6 +31,8 @@
#include "notifications/Manager.h" #include "notifications/Manager.h"
#include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h"
#include "timeline/TimelineViewManager.h" #include "timeline/TimelineViewManager.h"
ChatPage *ChatPage::instance_ = nullptr; ChatPage *ChatPage::instance_ = nullptr;

View file

@ -17,32 +17,6 @@ struct TimelineEvents;
struct StateEvents; struct StateEvents;
} }
namespace nheko {
struct nonesuch
{
~nonesuch() = delete;
nonesuch(nonesuch const &) = delete;
void operator=(nonesuch const &) = delete;
};
namespace detail {
template<class Default, class AlwaysVoid, template<class...> class Op, class... Args>
struct detector
{
using value_t = std::false_type;
using type = Default;
};
template<class Default, template<class...> class Op, class... Args>
struct detector<Default, std::void_t<Op<Args...>>, Op, Args...>
{
using value_t = std::true_type;
using type = Op<Args...>;
};
} // namespace detail
}
namespace mtx::accessors { namespace mtx::accessors {
const std::string & const std::string &
event_id(const mtx::events::collections::TimelineEvents &event); event_id(const mtx::events::collections::TimelineEvents &event);

View file

@ -7,6 +7,7 @@
#include "Logging.h" #include "Logging.h"
#include "MatrixClient.h" #include "MatrixClient.h"
#include "mtx/responses/profile.hpp" #include "mtx/responses/profile.hpp"
#include "timeline/TimelineModel.h"
InviteesModel::InviteesModel(TimelineModel *room, QObject *parent) InviteesModel::InviteesModel(TimelineModel *room, QObject *parent)
: QAbstractListModel{parent} : QAbstractListModel{parent}

View file

@ -8,7 +8,7 @@
#include <QQmlEngine> #include <QQmlEngine>
#include <QVector> #include <QVector>
#include "timeline/TimelineModel.h" class TimelineModel;
class Invitee final : public QObject class Invitee final : public QObject
{ {

View file

@ -9,8 +9,6 @@
#include <QQuickImageResponse> #include <QQuickImageResponse>
#include <QThreadPool> #include <QThreadPool>
#include <mtx/common.hpp>
class JdenticonRunnable final class JdenticonRunnable final
: public QObject : public QObject
, public QRunnable , public QRunnable

View file

@ -24,6 +24,8 @@
#include "Utils.h" #include "Utils.h"
#include "dock/Dock.h" #include "dock/Dock.h"
#include "encryption/DeviceVerificationFlow.h" #include "encryption/DeviceVerificationFlow.h"
#include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h"
#include "timeline/TimelineViewManager.h" #include "timeline/TimelineViewManager.h"
#include "ui/Theme.h" #include "ui/Theme.h"
#include "voip/CallManager.h" #include "voip/CallManager.h"

View file

@ -8,6 +8,8 @@
#include "Cache_p.h" #include "Cache_p.h"
#include "ChatPage.h" #include "ChatPage.h"
#include "Logging.h" #include "Logging.h"
#include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h"
#include "timeline/TimelineViewManager.h" #include "timeline/TimelineViewManager.h"
MemberListBackend::MemberListBackend(const QString &room_id, QObject *parent) MemberListBackend::MemberListBackend(const QString &room_id, QObject *parent)

View file

@ -6,6 +6,7 @@
#include <optional> #include <optional>
#include <mtx/common.hpp>
#include <mtxclient/crypto/client.hpp> #include <mtxclient/crypto/client.hpp>
#include <QByteArray> #include <QByteArray>
@ -87,7 +88,7 @@ MxcImageProvider::requestImageResponse(const QString &id, const QSize &requested
} }
void void
MxcImageProvider::addEncryptionInfo(mtx::crypto::EncryptedFile info) MxcImageProvider::addEncryptionInfo(const mtx::crypto::EncryptedFile &info)
{ {
infos.insert(QString::fromStdString(info.url), info); infos.insert(QString::fromStdString(info.url), info);
} }

View file

@ -11,7 +11,9 @@
#include <functional> #include <functional>
#include <mtx/common.hpp> namespace mtx::crypto {
struct EncryptedFile;
}
class MxcImageRunnable final : public QObject class MxcImageRunnable final : public QObject
{ {
@ -81,7 +83,7 @@ public slots:
QQuickImageResponse * QQuickImageResponse *
requestImageResponse(const QString &id, const QSize &requestedSize) override; requestImageResponse(const QString &id, const QSize &requestedSize) override;
static void addEncryptionInfo(mtx::crypto::EncryptedFile info); static void addEncryptionInfo(const mtx::crypto::EncryptedFile &info);
static void download(const QString &id, static void download(const QString &id,
const QSize &requestedSize, const QSize &requestedSize,
std::function<void(QString, QSize, QImage, QString)> then, std::function<void(QString, QSize, QImage, QString)> then,

View file

@ -8,9 +8,6 @@
#include <QQmlEngine> #include <QQmlEngine>
#include <QString> #include <QString>
#include <mtx/user_interactive.hpp>
#include <mtxclient/http/client.hpp>
class RegisterPage : public QObject class RegisterPage : public QObject
{ {
Q_OBJECT Q_OBJECT

View file

@ -6,6 +6,8 @@
#include <algorithm> #include <algorithm>
#include <mtx/requests.hpp>
#include "Cache.h" #include "Cache.h"
#include "ChatPage.h" #include "ChatPage.h"
#include "Logging.h" #include "Logging.h"

View file

@ -47,5 +47,7 @@ private:
QAction *viewAction_; QAction *viewAction_;
QAction *quitAction_; QAction *quitAction_;
#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
MsgCountComposedIcon *icon_; MsgCountComposedIcon *icon_;
#endif
}; };

View file

@ -12,6 +12,7 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "MxcImageProvider.h" #include "MxcImageProvider.h"
#include "timeline/RoomlistModel.h" #include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h"
#include <QDBusConnection> #include <QDBusConnection>

View file

@ -15,6 +15,7 @@
#include "Cache_p.h" #include "Cache_p.h"
#include "ChatPage.h" #include "ChatPage.h"
#include "Logging.h" #include "Logging.h"
#include "MatrixClient.h"
#include "Utils.h" #include "Utils.h"
#include "timeline/TimelineModel.h" #include "timeline/TimelineModel.h"

View file

@ -5,13 +5,11 @@
#pragma once #pragma once
#include <QObject> #include <QObject>
#include <QQmlEngine>
#include <mtx/responses/crypto.hpp>
#include <mtxclient/crypto/client.hpp> #include <mtxclient/crypto/client.hpp>
#include "CacheCryptoStructs.h" #include "CacheCryptoStructs.h"
#include "Logging.h"
#include "MatrixClient.h"
class QTimer; class QTimer;
class TimelineModel; class TimelineModel;
@ -152,8 +150,6 @@ public:
bool isSelfVerification() const; bool isSelfVerification() const;
bool isMultiDeviceVerification() const { return deviceIds.size() > 1; } bool isMultiDeviceVerification() const { return deviceIds.size() > 1; }
void callback_fn(const UserKeyCache &res, mtx::http::RequestErr err, std::string user_id);
public slots: public slots:
//! unverifies a device //! unverifies a device
void unverify(); void unverify();

View file

@ -9,6 +9,9 @@
#include "Cache.h" #include "Cache.h"
#include "ChatPage.h" #include "ChatPage.h"
#include "DeviceVerificationFlow.h" #include "DeviceVerificationFlow.h"
#include "Logging.h"
#include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h"
#include "timeline/TimelineViewManager.h" #include "timeline/TimelineViewManager.h"
VerificationManager::VerificationManager(TimelineViewManager *o) VerificationManager::VerificationManager(TimelineViewManager *o)

View file

@ -12,7 +12,7 @@
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QVariant> #include <QtCore/QVariant>
#include "TimelineModel.h" class TimelineModel;
class EventDelegateChooserAttachedType : public QObject class EventDelegateChooserAttachedType : public QObject
{ {

View file

@ -36,6 +36,7 @@
#include "TimelineViewManager.h" #include "TimelineViewManager.h"
#include "UserSettingsPage.h" #include "UserSettingsPage.h"
#include "Utils.h" #include "Utils.h"
#include "ui/UserProfile.h"
#include "blurhash.hpp" #include "blurhash.hpp"

View file

@ -945,6 +945,34 @@ FilteredRoomlistModel::FilteredRoomlistModel(RoomlistModel *model, QObject *pare
sort(0); sort(0);
} }
FilteredRoomlistModel *
FilteredRoomlistModel::create(QQmlEngine *qmlEngine, QJSEngine *)
{
// The instance has to exist before it is used. We cannot replace it.
Q_ASSERT(instance_);
// The engine has to have the same thread affinity as the singleton.
Q_ASSERT(qmlEngine->thread() == instance_->thread());
// There can only be one engine accessing the singleton.
static QJSEngine *s_engine = nullptr;
if (s_engine)
Q_ASSERT(qmlEngine == s_engine);
else
s_engine = qmlEngine;
QJSEngine::setObjectOwnership(instance_, QJSEngine::CppOwnership);
return instance_;
}
TimelineModel *
FilteredRoomlistModel::getRoomById(const QString &id) const
{
auto r = roomlistmodel->getRoomById(id).data();
QQmlEngine::setObjectOwnership(r, QQmlEngine::CppOwnership);
return r;
}
void void
FilteredRoomlistModel::updateHiddenTagsAndSpaces() FilteredRoomlistModel::updateHiddenTagsAndSpaces()
{ {

View file

@ -15,12 +15,11 @@
#include <mtx/responses/sync.hpp> #include <mtx/responses/sync.hpp>
#include "TimelineModel.h"
#ifdef NHEKO_DBUS_SYS #ifdef NHEKO_DBUS_SYS
#include "dbus/NhekoDBusBackend.h" #include "dbus/NhekoDBusBackend.h"
#endif #endif
class TimelineModel;
class TimelineViewManager; class TimelineViewManager;
class RoomPreview class RoomPreview
@ -178,24 +177,7 @@ class FilteredRoomlistModel final : public QSortFilterProxyModel
public: public:
FilteredRoomlistModel(RoomlistModel *model, QObject *parent = nullptr); FilteredRoomlistModel(RoomlistModel *model, QObject *parent = nullptr);
static FilteredRoomlistModel *create(QQmlEngine *qmlEngine, QJSEngine *) static FilteredRoomlistModel *create(QQmlEngine *qmlEngine, QJSEngine *);
{
// The instance has to exist before it is used. We cannot replace it.
Q_ASSERT(instance_);
// The engine has to have the same thread affinity as the singleton.
Q_ASSERT(qmlEngine->thread() == instance_->thread());
// There can only be one engine accessing the singleton.
static QJSEngine *s_engine = nullptr;
if (s_engine)
Q_ASSERT(qmlEngine == s_engine);
else
s_engine = qmlEngine;
QJSEngine::setObjectOwnership(instance_, QJSEngine::CppOwnership);
return instance_;
}
static FilteredRoomlistModel *instance() { return instance_; } static FilteredRoomlistModel *instance() { return instance_; }
@ -218,12 +200,7 @@ public slots:
RoomPreview currentRoomPreview() const { return roomlistmodel->currentRoomPreview(); } RoomPreview currentRoomPreview() const { return roomlistmodel->currentRoomPreview(); }
void setCurrentRoom(QString roomid) { roomlistmodel->setCurrentRoom(std::move(roomid)); } void setCurrentRoom(QString roomid) { roomlistmodel->setCurrentRoom(std::move(roomid)); }
void resetCurrentRoom() { roomlistmodel->resetCurrentRoom(); } void resetCurrentRoom() { roomlistmodel->resetCurrentRoom(); }
TimelineModel *getRoomById(const QString &id) const TimelineModel *getRoomById(const QString &id) const;
{
auto r = roomlistmodel->getRoomById(id).data();
QQmlEngine::setObjectOwnership(r, QQmlEngine::CppOwnership);
return r;
}
RoomPreview getRoomPreviewById(QString roomid) const RoomPreview getRoomPreviewById(QString roomid) const
{ {
return roomlistmodel->getRoomPreviewById(roomid); return roomlistmodel->getRoomPreviewById(roomid);

View file

@ -8,6 +8,7 @@
#include <QEvent> #include <QEvent>
#include "Logging.h" #include "Logging.h"
#include "TimelineModel.h"
/// Searching currently can be done incrementally. For that we define a specific role to filter on /// Searching currently can be done incrementally. For that we define a specific role to filter on
/// and then process that role in chunk. This is the `FilterRole`. Of course we need to then also /// and then process that role in chunk. This is the `FilterRole`. Of course we need to then also

View file

@ -10,7 +10,7 @@
#include <mtx/events/power_levels.hpp> #include <mtx/events/power_levels.hpp>
#include "TimelineModel.h" class TimelineModel;
class TimelineFilter : public QSortFilterProxyModel class TimelineFilter : public QSortFilterProxyModel
{ {

View file

@ -29,9 +29,12 @@
#include "Logging.h" #include "Logging.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "MatrixClient.h" #include "MatrixClient.h"
#include "ReadReceiptsModel.h"
#include "RoomlistModel.h"
#include "TimelineViewManager.h" #include "TimelineViewManager.h"
#include "Utils.h" #include "Utils.h"
#include "encryption/Olm.h" #include "encryption/Olm.h"
#include "ui/UserProfile.h"
namespace std { namespace std {
inline uint // clazy:exclude=qhash-namespace inline uint // clazy:exclude=qhash-namespace
@ -1703,7 +1706,8 @@ TimelineModel::checkAfterFetch()
template<typename T> template<typename T>
void void
TimelineModel::sendEncryptedMessage(mtx::events::RoomEvent<T> msg, mtx::events::EventType eventType) TimelineModel::sendEncryptedMessage(const mtx::events::RoomEvent<T> &msg,
mtx::events::EventType eventType)
{ {
const auto room_id = room_id_.toStdString(); const auto room_id = room_id_.toStdString();

View file

@ -20,7 +20,6 @@
#include "InputBar.h" #include "InputBar.h"
#include "Permissions.h" #include "Permissions.h"
#include "Reaction.h" #include "Reaction.h"
#include "ReadReceiptsModel.h"
#include "ui/RoomSummary.h" #include "ui/RoomSummary.h"
namespace mtx::http { namespace mtx::http {
@ -33,6 +32,7 @@ struct ClaimKeys;
struct StateEvents; struct StateEvents;
} }
struct RelatedInfo; struct RelatedInfo;
class ReadReceiptsProxy;
namespace qml_mtx_events { namespace qml_mtx_events {
Q_NAMESPACE Q_NAMESPACE
@ -516,7 +516,8 @@ signals:
private: private:
template<typename T> template<typename T>
void sendEncryptedMessage(mtx::events::RoomEvent<T> msg, mtx::events::EventType eventType); void
sendEncryptedMessage(const mtx::events::RoomEvent<T> &msg, mtx::events::EventType eventType);
void readEvent(const std::string &id); void readEvent(const std::string &id);
void setPaginationInProgress(const bool paginationInProgress); void setPaginationInProgress(const bool paginationInProgress);

View file

@ -8,6 +8,8 @@
#include <QClipboard> #include <QClipboard>
#include <QFileDialog> #include <QFileDialog>
#include <QMimeData> #include <QMimeData>
#include <QQuickItem>
#include <QQuickTextDocument>
#include <QStandardPaths> #include <QStandardPaths>
#include <QString> #include <QString>
@ -24,17 +26,48 @@
#include "Logging.h" #include "Logging.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "MatrixClient.h" #include "MatrixClient.h"
#include "MemberList.h"
#include "RoomsModel.h" #include "RoomsModel.h"
#include "TimelineModel.h"
#include "UserSettingsPage.h" #include "UserSettingsPage.h"
#include "UsersModel.h" #include "UsersModel.h"
#include "Utils.h" #include "Utils.h"
#include "encryption/VerificationManager.h" #include "encryption/VerificationManager.h"
#include "timeline/CommunitiesModel.h"
#include "timeline/PresenceEmitter.h"
#include "timeline/RoomlistModel.h"
#include "ui/RoomSettings.h"
#include "ui/UserProfile.h"
#include "voip/CallManager.h" #include "voip/CallManager.h"
#include "voip/WebRTCSession.h" #include "voip/WebRTCSession.h"
namespace { namespace {
struct nonesuch
{
~nonesuch() = delete;
nonesuch(nonesuch const &) = delete;
void operator=(nonesuch const &) = delete;
};
namespace detail {
template<class Default, class AlwaysVoid, template<class...> class Op, class... Args>
struct detector
{
using value_t = std::false_type;
using type = Default;
};
template<class Default, template<class...> class Op, class... Args>
struct detector<Default, std::void_t<Op<Args...>>, Op, Args...>
{
using value_t = std::true_type;
using type = Op<Args...>;
};
} // namespace detail
template<template<class...> class Op, class... Args> template<template<class...> class Op, class... Args>
using is_detected = typename nheko::detail::detector<nheko::nonesuch, void, Op, Args...>::value_t; using is_detected = typename detail::detector<nonesuch, void, Op, Args...>::value_t;
template<class Content> template<class Content>
using file_t = decltype(Content::file); using file_t = decltype(Content::file);
@ -88,7 +121,7 @@ TimelineViewManager::updateColorPalette()
QColor QColor
TimelineViewManager::userColor(QString id, QColor background) TimelineViewManager::userColor(QString id, QColor background)
{ {
QPair<QString, quint64> idx{id, background.rgba64()}; std::pair<QString, quint64> idx{id, background.rgba64()};
if (!userColors.contains(idx)) if (!userColors.contains(idx))
userColors.insert(idx, QColor(utils::generateContrastingHexColor(id, background))); userColors.insert(idx, QColor(utils::generateContrastingHexColor(id, background)));
return userColors.value(idx); return userColors.value(idx);
@ -148,6 +181,32 @@ TimelineViewManager::TimelineViewManager(CallManager *, ChatPage *parent)
}); });
} }
TimelineViewManager *
TimelineViewManager::create(QQmlEngine *qmlEngine, QJSEngine *)
{
// The instance has to exist before it is used. We cannot replace it.
Q_ASSERT(instance_);
// The engine has to have the same thread affinity as the singleton.
Q_ASSERT(qmlEngine->thread() == instance_->thread());
// There can only be one engine accessing the singleton.
static QJSEngine *s_engine = nullptr;
if (s_engine)
Q_ASSERT(qmlEngine == s_engine);
else
s_engine = qmlEngine;
QJSEngine::setObjectOwnership(instance_, QJSEngine::CppOwnership);
return instance_;
}
void
TimelineViewManager::clearAll()
{
rooms_->clear();
}
void void
TimelineViewManager::openRoomMembers(TimelineModel *room) TimelineViewManager::openRoomMembers(TimelineModel *room)
{ {

View file

@ -5,19 +5,12 @@
#pragma once #pragma once
#include <QHash> #include <QHash>
#include <QQuickItem> #include <QQmlEngine>
#include <QQuickTextDocument>
#include <mtx/common.hpp> #include <unordered_map>
#include <mtx/responses/messages.hpp>
#include "InviteesModel.h" class QQuickItem;
#include "MemberList.h" class QQuickTextDocument;
#include "timeline/CommunitiesModel.h"
#include "timeline/PresenceEmitter.h"
#include "timeline/RoomlistModel.h"
#include "ui/RoomSettings.h"
#include "ui/UserProfile.h"
class UserSettings; class UserSettings;
class ChatPage; class ChatPage;
@ -25,9 +18,32 @@ class ImagePackListModel;
class TimelineModel; class TimelineModel;
class CallManager; class CallManager;
class VerificationManager; class VerificationManager;
class InviteesModel;
class MemberList;
class CommunitiesModel;
class RoomlistModel;
class PresenceEmitter;
class UserProfile;
class RoomSettings;
class FilteredRoomlistModel;
class QAbstractItemModel;
namespace mtx::responses { namespace mtx::responses {
struct Sync; struct Sync;
struct AccountData;
}
namespace mtx::events::voip {
struct CallInvite;
struct CallCandidates;
struct CallAnswer;
struct CallHangUp;
struct CallSelectAnswer;
struct CallReject;
struct CallNegotiate;
}
namespace mtx::events::collections {
struct TimelineEvents;
} }
class TimelineViewManager final : public QObject class TimelineViewManager final : public QObject
@ -45,24 +61,7 @@ class TimelineViewManager final : public QObject
public: public:
TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr); TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr);
static TimelineViewManager *create(QQmlEngine *qmlEngine, QJSEngine *) static TimelineViewManager *create(QQmlEngine *qmlEngine, QJSEngine *);
{
// The instance has to exist before it is used. We cannot replace it.
Q_ASSERT(instance_);
// The engine has to have the same thread affinity as the singleton.
Q_ASSERT(qmlEngine->thread() == instance_->thread());
// There can only be one engine accessing the singleton.
static QJSEngine *s_engine = nullptr;
if (s_engine)
Q_ASSERT(qmlEngine == s_engine);
else
s_engine = qmlEngine;
QJSEngine::setObjectOwnership(instance_, QJSEngine::CppOwnership);
return instance_;
}
static TimelineViewManager *instance() { return TimelineViewManager::instance_; } static TimelineViewManager *instance() { return TimelineViewManager::instance_; }
@ -72,7 +71,7 @@ public:
VerificationManager *verificationManager() { return verificationManager_; } VerificationManager *verificationManager() { return verificationManager_; }
void clearAll() { rooms_->clear(); } void clearAll();
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; } Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
bool isConnected() const { return isConnected_; } bool isConnected() const { return isConnected_; }
@ -158,7 +157,7 @@ private:
VerificationManager *verificationManager_ = nullptr; VerificationManager *verificationManager_ = nullptr;
PresenceEmitter *presenceEmitter = nullptr; PresenceEmitter *presenceEmitter = nullptr;
QHash<QPair<QString, quint64>, QColor> userColors; QHash<std::pair<QString, quint64>, QColor> userColors;
inline static TimelineViewManager *instance_ = nullptr; inline static TimelineViewManager *instance_ = nullptr;

View file

@ -9,7 +9,7 @@
#include <QObject> #include <QObject>
#include <QQuickItem> #include <QQuickItem>
#include "timeline/TimelineModel.h" class TimelineModel;
// This is an AnimatedImage, that can draw encrypted images // This is an AnimatedImage, that can draw encrypted images
class MxcAnimatedImage : public QQuickItem class MxcAnimatedImage : public QQuickItem

View file

@ -17,6 +17,7 @@
#include "EventAccessors.h" #include "EventAccessors.h"
#include "Logging.h" #include "Logging.h"
#include "MatrixClient.h" #include "MatrixClient.h"
#include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h" #include "timeline/TimelineModel.h"
#include "timeline/TimelineViewManager.h" #include "timeline/TimelineViewManager.h"

View file

@ -8,6 +8,7 @@
#include "ChatPage.h" #include "ChatPage.h"
#include "timeline/InputBar.h" #include "timeline/InputBar.h"
#include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h" #include "timeline/TimelineModel.h"
#include "timeline/TimelineViewManager.h" #include "timeline/TimelineViewManager.h"

View file

@ -11,12 +11,13 @@
#include <QUrl> #include <QUrl>
#include <QWindow> #include <QWindow>
#include <mtx/requests.hpp>
#include "Cache_p.h" #include "Cache_p.h"
#include "ChatPage.h" #include "ChatPage.h"
#include "Logging.h" #include "Logging.h"
#include "UserSettingsPage.h" #include "UserSettingsPage.h"
#include "Utils.h" #include "Utils.h"
#include "voip/WebRTCSession.h"
#if XCB_AVAILABLE #if XCB_AVAILABLE
#include <xcb/xproto.h> #include <xcb/xproto.h>

View file

@ -9,6 +9,7 @@
#include <QInputDialog> #include <QInputDialog>
#include <QTimer> #include <QTimer>
#include <mtx/requests.hpp>
#include <mtx/responses/common.hpp> #include <mtx/responses/common.hpp>
#include "Logging.h" #include "Logging.h"

View file

@ -16,6 +16,7 @@
#include "UserProfile.h" #include "UserProfile.h"
#include "Utils.h" #include "Utils.h"
#include "encryption/VerificationManager.h" #include "encryption/VerificationManager.h"
#include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h" #include "timeline/TimelineModel.h"
#include "timeline/TimelineViewManager.h" #include "timeline/TimelineViewManager.h"
#include "ui/UIA.h" #include "ui/UIA.h"

View file

@ -13,7 +13,9 @@
#include <mtx/responses/common.hpp> #include <mtx/responses/common.hpp>
#include "CacheCryptoStructs.h" #include "CacheCryptoStructs.h"
#include "timeline/TimelineModel.h" #include "CacheStructs.h"
class TimelineModel;
namespace verification { namespace verification {
Q_NAMESPACE Q_NAMESPACE