From 52fdd715d605f201331a88ffb1d9caafcf86beb1 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Sun, 29 Dec 2019 21:43:35 +0800 Subject: Add missing file --- lib/events/roompowerlevelsevent.h | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lib/events/roompowerlevelsevent.h (limited to 'lib/events/roompowerlevelsevent.h') diff --git a/lib/events/roompowerlevelsevent.h b/lib/events/roompowerlevelsevent.h new file mode 100644 index 00000000..3a940380 --- /dev/null +++ b/lib/events/roompowerlevelsevent.h @@ -0,0 +1,75 @@ +#pragma once + +#include "eventcontent.h" +#include "stateevent.h" + +namespace Quotient { +class PowerLevelsEventContent : public EventContent::Base { +public: + struct Notifications { + int room; + }; + + explicit PowerLevelsEventContent(const QJsonObject& json); + + int invite; + int kick; + int ban; + + int redact; + + QHash events; + int eventsDefault; + int stateDefault; + + QHash users; + int usersDefault; + + Notifications notifications; + +protected: + void fillJson(QJsonObject* o) const override; +}; + +class RoomPowerLevelsEvent : public StateEvent { + Q_GADGET +public: + DEFINE_EVENT_TYPEID("m.room.power_levels", RoomPowerLevelsEvent) + + explicit RoomPowerLevelsEvent(const QJsonObject& obj) + : StateEvent(typeId(), obj) + {} + + int invite() { return content().invite; } + int kick() { return content().kick; } + int ban() { return content().ban; } + + int redact() { return content().redact; } + + QHash events() { return content().events; } + int eventsDefault() { return content().eventsDefault; } + int stateDefault() { return content().stateDefault; } + + QHash users() { return content().users; } + int usersDefault() { return content().usersDefault; } + + int roomNotification() { return content().notifications.room; } + + int powerLevelForEvent(const QString& eventId); + int powerLevelForUser(const QString& userId); + +private: +}; + +template <> +class EventFactory { +public: + static event_ptr_tt make(const QJsonObject& json, + const QString&) + { + return makeEvent(json); + } +}; + +REGISTER_EVENT_TYPE(RoomPowerLevelsEvent) +} // namespace Quotient -- cgit v1.2.3 From 2a54e66226863bdea4b0828675f38b75e4c7776f Mon Sep 17 00:00:00 2001 From: Black Hat Date: Wed, 1 Jan 2020 14:04:47 +0800 Subject: Mark methods as const. --- lib/events/roompowerlevelsevent.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/events/roompowerlevelsevent.h') diff --git a/lib/events/roompowerlevelsevent.h b/lib/events/roompowerlevelsevent.h index 3a940380..b3405c56 100644 --- a/lib/events/roompowerlevelsevent.h +++ b/lib/events/roompowerlevelsevent.h @@ -40,23 +40,23 @@ public: : StateEvent(typeId(), obj) {} - int invite() { return content().invite; } - int kick() { return content().kick; } - int ban() { return content().ban; } + int invite() const { return content().invite; } + int kick() const { return content().kick; } + int ban() const { return content().ban; } - int redact() { return content().redact; } + int redact() const { return content().redact; } - QHash events() { return content().events; } - int eventsDefault() { return content().eventsDefault; } - int stateDefault() { return content().stateDefault; } + QHash events() const { return content().events; } + int eventsDefault() const { return content().eventsDefault; } + int stateDefault() const { return content().stateDefault; } - QHash users() { return content().users; } - int usersDefault() { return content().usersDefault; } + QHash users() const { return content().users; } + int usersDefault() const { return content().usersDefault; } - int roomNotification() { return content().notifications.room; } + int roomNotification() const { return content().notifications.room; } - int powerLevelForEvent(const QString& eventId); - int powerLevelForUser(const QString& userId); + int powerLevelForEvent(const QString& eventId) const; + int powerLevelForUser(const QString& userId) const; private: }; -- cgit v1.2.3 From d4034fb12b189156e135dcf0fb94960a1d8e9be9 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Wed, 1 Jan 2020 14:45:42 +0800 Subject: Add powerLevelForState() --- lib/events/roompowerlevelsevent.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/events/roompowerlevelsevent.h') diff --git a/lib/events/roompowerlevelsevent.h b/lib/events/roompowerlevelsevent.h index b3405c56..f0f7207f 100644 --- a/lib/events/roompowerlevelsevent.h +++ b/lib/events/roompowerlevelsevent.h @@ -56,6 +56,7 @@ public: int roomNotification() const { return content().notifications.room; } int powerLevelForEvent(const QString& eventId) const; + int powerLevelForState(const QString& eventId) const; int powerLevelForUser(const QString& userId) const; private: -- cgit v1.2.3