// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // Public rooms of the homeserver, for the Browse page. Same query as NeoChat's // Explore page, over the session MatrixManager owns. #pragma once #include #include #include namespace Quotient { class BaseJob; } namespace koutnet { class MatrixManager; class MatrixDirectory : public QObject { Q_OBJECT Q_PROPERTY(QVariantList rooms READ rooms NOTIFY roomsChanged) Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) Q_PROPERTY(bool available READ available NOTIFY availableChanged) Q_PROPERTY(QString error READ error NOTIFY errorChanged) public: explicit MatrixDirectory(MatrixManager *manager, QObject *parent = nullptr); QVariantList rooms() const { return m_rooms; } bool loading() const { return m_loading; } bool available() const; QString error() const { return m_error; } // empty term lists the directory, a term searches name, topic and alias. Q_INVOKABLE void search(const QString &term); // the window's id for a room, keeps the mx: prefix out of QML. Q_INVOKABLE QString chatIdForRoom(const QString &roomId) const; Q_SIGNALS: void roomsChanged(); void loadingChanged(); void availableChanged(); void errorChanged(); private: void setLoading(bool loading); void setError(const QString &error); void finish(const QVariantList &rooms); void fail(const Quotient::BaseJob *job); MatrixManager *m_manager = nullptr; QPointer m_job; QVariantList m_rooms; bool m_loading = false; QString m_error; // newer search wins if two are in flight. int m_generation = 0; }; } // namespace koutnet