diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/RoomSettings.cpp | 30 | ||||
-rw-r--r-- | src/ui/RoomSettings.h | 4 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/ui/RoomSettings.cpp b/src/ui/RoomSettings.cpp index fcba8205..2fb93325 100644 --- a/src/ui/RoomSettings.cpp +++ b/src/ui/RoomSettings.cpp @@ -218,8 +218,12 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent) } else { accessRules_ = 1; } - } else { + } else if (info_.join_rule == state::JoinRule::Invite) { accessRules_ = 2; + } else if (info_.join_rule == state::JoinRule::Knock) { + accessRules_ = 3; + } else if (info_.join_rule == state::JoinRule::Restricted) { + accessRules_ = 4; } emit accessJoinRulesChanged(); } @@ -368,6 +372,21 @@ RoomSettings::isEncryptionEnabled() const return usesEncryption_; } +bool +RoomSettings::supportsKnocking() const +{ + return info_.version != "" && info_.version != "1" && info_.version != "2" && + info_.version != "3" && info_.version != "4" && info_.version != "5" && + info_.version != "6"; +} +bool +RoomSettings::supportsRestricted() const +{ + return info_.version != "" && info_.version != "1" && info_.version != "2" && + info_.version != "3" && info_.version != "4" && info_.version != "5" && + info_.version != "6" && info_.version != "7"; +} + void RoomSettings::openEditModal() { @@ -464,6 +483,15 @@ RoomSettings::changeAccessRules(int index) case 1: event.join_rule = state::JoinRule::Public; break; + case 2: + event.join_rule = state::JoinRule::Invite; + break; + case 3: + event.join_rule = state::JoinRule::Knock; + break; + case 4: + event.join_rule = state::JoinRule::Restricted; + break; default: event.join_rule = state::JoinRule::Invite; } diff --git a/src/ui/RoomSettings.h b/src/ui/RoomSettings.h index 1c8b47d6..ab768ffe 100644 --- a/src/ui/RoomSettings.h +++ b/src/ui/RoomSettings.h @@ -78,6 +78,8 @@ class RoomSettings : public QObject Q_PROPERTY(bool canChangeJoinRules READ canChangeJoinRules CONSTANT) Q_PROPERTY(bool canChangeNameAndTopic READ canChangeNameAndTopic CONSTANT) Q_PROPERTY(bool isEncryptionEnabled READ isEncryptionEnabled NOTIFY encryptionChanged) + Q_PROPERTY(bool supportsKnocking READ supportsKnocking CONSTANT) + Q_PROPERTY(bool supportsRestricted READ supportsRestricted CONSTANT) public: RoomSettings(QString roomid, QObject *parent = nullptr); @@ -98,6 +100,8 @@ public: //! 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(); |