aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roompowerlevelsevent.h
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /lib/events/roompowerlevelsevent.h
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'lib/events/roompowerlevelsevent.h')
-rw-r--r--lib/events/roompowerlevelsevent.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/lib/events/roompowerlevelsevent.h b/lib/events/roompowerlevelsevent.h
new file mode 100644
index 00000000..f0f7207f
--- /dev/null
+++ b/lib/events/roompowerlevelsevent.h
@@ -0,0 +1,76 @@
+#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<QString, int> events;
+ int eventsDefault;
+ int stateDefault;
+
+ QHash<QString, int> users;
+ int usersDefault;
+
+ Notifications notifications;
+
+protected:
+ void fillJson(QJsonObject* o) const override;
+};
+
+class RoomPowerLevelsEvent : public StateEvent<PowerLevelsEventContent> {
+ Q_GADGET
+public:
+ DEFINE_EVENT_TYPEID("m.room.power_levels", RoomPowerLevelsEvent)
+
+ explicit RoomPowerLevelsEvent(const QJsonObject& obj)
+ : StateEvent(typeId(), obj)
+ {}
+
+ int invite() const { return content().invite; }
+ int kick() const { return content().kick; }
+ int ban() const { return content().ban; }
+
+ int redact() const { return content().redact; }
+
+ QHash<QString, int> events() const { return content().events; }
+ int eventsDefault() const { return content().eventsDefault; }
+ int stateDefault() const { return content().stateDefault; }
+
+ QHash<QString, int> users() const { return content().users; }
+ int usersDefault() const { return content().usersDefault; }
+
+ 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:
+};
+
+template <>
+class EventFactory<RoomPowerLevelsEvent> {
+public:
+ static event_ptr_tt<RoomPowerLevelsEvent> make(const QJsonObject& json,
+ const QString&)
+ {
+ return makeEvent<RoomPowerLevelsEvent>(json);
+ }
+};
+
+REGISTER_EVENT_TYPE(RoomPowerLevelsEvent)
+} // namespace Quotient