2021-02-10 18:52:42 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void error(const QString &msg);
|
|
|
|
void nameEventSent(const QString &);
|
|
|
|
void topicEventSent();
|
|
|
|
void stopLoading();
|
|
|
|
};
|
|
|
|
|
2021-02-10 18:52:42 +03:00
|
|
|
class RoomSettings : public QObject
|
|
|
|
{
|
2021-02-11 21:09:11 +03:00
|
|
|
Q_OBJECT
|
2021-02-10 18:52:42 +03:00
|
|
|
Q_PROPERTY(QString roomName READ roomName CONSTANT)
|
2021-02-11 18:53:33 +03:00
|
|
|
Q_PROPERTY(QString roomId READ roomId CONSTANT)
|
|
|
|
Q_PROPERTY(QString roomVersion READ roomVersion CONSTANT)
|
2021-02-11 21:09:11 +03:00
|
|
|
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY avatarUrlChanged)
|
2021-02-11 18:53:33 +03:00
|
|
|
Q_PROPERTY(int memberCount READ memberCount CONSTANT)
|
2021-02-11 17:24:09 +03:00
|
|
|
Q_PROPERTY(int notifications READ notifications NOTIFY notificationsChanged)
|
|
|
|
Q_PROPERTY(int accessJoinRules READ accessJoinRules NOTIFY accessJoinRulesChanged)
|
2021-02-11 21:09:11 +03:00
|
|
|
Q_PROPERTY(bool isLoading READ isLoading NOTIFY loadingChanged)
|
2021-02-11 17:24:09 +03:00
|
|
|
Q_PROPERTY(bool canChangeJoinRules READ canChangeJoinRules CONSTANT)
|
2021-02-11 21:09:11 +03:00
|
|
|
Q_PROPERTY(bool canChangeNameAndTopic READ canChangeNameAndTopic CONSTANT)
|
|
|
|
Q_PROPERTY(bool canChangeAvatar READ canChangeAvatar CONSTANT)
|
2021-02-11 17:24:09 +03:00
|
|
|
Q_PROPERTY(bool isEncryptionEnabled READ isEncryptionEnabled NOTIFY encryptionChanged)
|
|
|
|
Q_PROPERTY(bool respondsToKeyRequests READ respondsToKeyRequests NOTIFY keyRequestsChanged)
|
2021-02-10 18:52:42 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
RoomSettings(QString roomid, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
QString roomName() const;
|
2021-02-11 18:53:33 +03:00
|
|
|
QString roomId() const;
|
|
|
|
QString roomVersion() const;
|
2021-02-11 21:09:11 +03:00
|
|
|
QString roomAvatarUrl();
|
2021-02-11 18:53:33 +03:00
|
|
|
int memberCount() const;
|
2021-02-11 17:24:09 +03:00
|
|
|
int notifications();
|
|
|
|
int accessJoinRules();
|
|
|
|
bool respondsToKeyRequests();
|
2021-02-11 21:09:11 +03:00
|
|
|
bool isLoading() const;
|
2021-02-11 17:24:09 +03:00
|
|
|
//! Whether the user has enough power level to send m.room.join_rules events.
|
|
|
|
bool canChangeJoinRules() const;
|
2021-02-11 21:09:11 +03:00
|
|
|
//! Whether the user has enough power level to send m.room.name & m.room.topic events.
|
|
|
|
bool canChangeNameAndTopic() const;
|
|
|
|
//! Whether the user has enough power level to send m.room.avatar event.
|
|
|
|
bool canChangeAvatar() const;
|
2021-02-11 17:24:09 +03:00
|
|
|
bool isEncryptionEnabled() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE void changeNotifications(int currentIndex);
|
|
|
|
Q_INVOKABLE void changeAccessRules(int index);
|
|
|
|
Q_INVOKABLE void changeKeyRequestsPreference(bool isOn);
|
|
|
|
Q_INVOKABLE void enableEncryption();
|
2021-02-11 21:09:11 +03:00
|
|
|
Q_INVOKABLE void updateAvatar();
|
2021-02-11 17:24:09 +03:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void notificationsChanged();
|
|
|
|
void accessJoinRulesChanged();
|
|
|
|
void keyRequestsChanged();
|
|
|
|
void encryptionChanged();
|
2021-02-11 21:09:11 +03:00
|
|
|
void avatarUrlChanged();
|
|
|
|
void loadingChanged();
|
|
|
|
void displayError(const QString &errorMessage);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void avatarChanged();
|
|
|
|
void stopLoading();
|
2021-02-10 18:52:42 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
void retrieveRoomInfo();
|
2021-02-11 17:24:09 +03:00
|
|
|
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:
|
|
|
|
QString roomid_;
|
|
|
|
bool usesEncryption_ = false;
|
2021-02-11 21:09:11 +03:00
|
|
|
bool isLoading_ = false;
|
2021-02-10 18:52:42 +03:00
|
|
|
RoomInfo info_;
|
2021-02-11 17:24:09 +03:00
|
|
|
int notifications_ = 0;
|
|
|
|
int accessRules_ = 0;
|
2021-02-10 18:52:42 +03:00
|
|
|
};
|