2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2021-03-05 02:35:15 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-02-10 18:52:42 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
2022-01-13 01:26:50 +03:00
|
|
|
#include <QSet>
|
2021-02-10 18:52:42 +03:00
|
|
|
#include <QString>
|
|
|
|
|
2022-01-13 01:26:50 +03:00
|
|
|
#include <mtx/events/event_type.hpp>
|
2021-02-11 17:24:09 +03:00
|
|
|
#include <mtx/events/guest_access.hpp>
|
|
|
|
|
2021-02-10 18:52:42 +03:00
|
|
|
#include "CacheStructs.h"
|
|
|
|
|
2021-02-11 21:09:11 +03:00
|
|
|
/// Convenience class which connects events emmited from threads
|
|
|
|
/// outside of main with the UI code.
|
|
|
|
class ThreadProxy : public QObject
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_OBJECT
|
2021-02-11 21:09:11 +03:00
|
|
|
|
|
|
|
signals:
|
2021-09-18 01:22:33 +03:00
|
|
|
void error(const QString &msg);
|
|
|
|
void nameEventSent(const QString &);
|
|
|
|
void topicEventSent(const QString &);
|
|
|
|
void stopLoading();
|
2021-02-11 21:09:11 +03:00
|
|
|
};
|
|
|
|
|
2021-02-10 18:52:42 +03:00
|
|
|
class RoomSettings : public QObject
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QString roomId READ roomId CONSTANT)
|
|
|
|
Q_PROPERTY(QString roomVersion READ roomVersion CONSTANT)
|
|
|
|
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
|
|
|
|
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged)
|
2022-03-30 07:45:31 +03:00
|
|
|
Q_PROPERTY(QString plainRoomName READ plainRoomName NOTIFY roomNameChanged)
|
|
|
|
Q_PROPERTY(QString plainRoomTopic READ plainRoomTopic NOTIFY roomTopicChanged)
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY avatarUrlChanged)
|
|
|
|
Q_PROPERTY(int memberCount READ memberCount CONSTANT)
|
|
|
|
Q_PROPERTY(int notifications READ notifications NOTIFY notificationsChanged)
|
|
|
|
Q_PROPERTY(int accessJoinRules READ accessJoinRules NOTIFY accessJoinRulesChanged)
|
|
|
|
Q_PROPERTY(bool isLoading READ isLoading NOTIFY loadingChanged)
|
|
|
|
Q_PROPERTY(bool canChangeAvatar READ canChangeAvatar CONSTANT)
|
|
|
|
Q_PROPERTY(bool canChangeJoinRules READ canChangeJoinRules CONSTANT)
|
2022-03-30 07:45:31 +03:00
|
|
|
Q_PROPERTY(bool canChangeName READ canChangeName CONSTANT)
|
|
|
|
Q_PROPERTY(bool canChangeTopic READ canChangeTopic CONSTANT)
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_PROPERTY(bool isEncryptionEnabled READ isEncryptionEnabled NOTIFY encryptionChanged)
|
|
|
|
Q_PROPERTY(bool supportsKnocking READ supportsKnocking CONSTANT)
|
|
|
|
Q_PROPERTY(bool supportsRestricted READ supportsRestricted CONSTANT)
|
2021-02-10 18:52:42 +03:00
|
|
|
|
|
|
|
public:
|
2021-09-18 01:22:33 +03:00
|
|
|
RoomSettings(QString roomid, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
QString roomId() const;
|
|
|
|
QString roomName() const;
|
|
|
|
QString roomTopic() const;
|
2022-03-30 07:45:31 +03:00
|
|
|
QString plainRoomName() const;
|
|
|
|
QString plainRoomTopic() const;
|
2021-09-18 01:22:33 +03:00
|
|
|
QString roomVersion() const;
|
|
|
|
QString roomAvatarUrl();
|
|
|
|
int memberCount() const;
|
|
|
|
int notifications();
|
|
|
|
int accessJoinRules();
|
|
|
|
bool isLoading() const;
|
|
|
|
//! Whether the user has enough power level to send m.room.join_rules events.
|
|
|
|
bool canChangeJoinRules() const;
|
2022-03-30 07:45:31 +03:00
|
|
|
//! Whether the user has enough power level to send m.room.name.
|
|
|
|
bool canChangeName() const;
|
|
|
|
//! Whether the user has enough power level to send m.room.topic events.
|
|
|
|
bool canChangeTopic() const;
|
2021-09-18 01:22:33 +03:00
|
|
|
//! Whether the user has enough power level to send m.room.avatar event.
|
|
|
|
bool canChangeAvatar() const;
|
|
|
|
bool isEncryptionEnabled() const;
|
|
|
|
bool supportsKnocking() const;
|
|
|
|
bool supportsRestricted() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE void enableEncryption();
|
|
|
|
Q_INVOKABLE void updateAvatar();
|
|
|
|
Q_INVOKABLE void changeAccessRules(int index);
|
|
|
|
Q_INVOKABLE void changeNotifications(int currentIndex);
|
2022-03-30 07:45:31 +03:00
|
|
|
Q_INVOKABLE void changeTopic(QString topic);
|
|
|
|
Q_INVOKABLE void changeName(QString name);
|
2021-02-11 17:24:09 +03:00
|
|
|
|
|
|
|
signals:
|
2021-09-18 01:22:33 +03:00
|
|
|
void loadingChanged();
|
|
|
|
void roomNameChanged();
|
|
|
|
void roomTopicChanged();
|
|
|
|
void avatarUrlChanged();
|
|
|
|
void encryptionChanged();
|
|
|
|
void notificationsChanged();
|
|
|
|
void accessJoinRulesChanged();
|
|
|
|
void displayError(const QString &errorMessage);
|
2021-02-11 21:09:11 +03:00
|
|
|
|
|
|
|
public slots:
|
2021-09-18 01:22:33 +03:00
|
|
|
void stopLoading();
|
|
|
|
void avatarChanged();
|
2021-02-10 18:52:42 +03:00
|
|
|
|
|
|
|
private:
|
2021-09-18 01:22:33 +03:00
|
|
|
void retrieveRoomInfo();
|
|
|
|
void updateAccessRules(const std::string &room_id,
|
|
|
|
const mtx::events::state::JoinRules &,
|
|
|
|
const mtx::events::state::GuestAccess &);
|
2021-02-10 18:52:42 +03:00
|
|
|
|
|
|
|
private:
|
2021-09-18 01:22:33 +03:00
|
|
|
QString roomid_;
|
|
|
|
bool usesEncryption_ = false;
|
|
|
|
bool isLoading_ = false;
|
|
|
|
RoomInfo info_;
|
|
|
|
int notifications_ = 0;
|
|
|
|
int accessRules_ = 0;
|
2021-07-21 14:37:57 +03:00
|
|
|
};
|