diff options
author | Black Hat <bhat@encom.eu.org> | 2019-12-29 21:43:35 +0800 |
---|---|---|
committer | Black Hat <bhat@encom.eu.org> | 2019-12-29 21:43:35 +0800 |
commit | 52fdd715d605f201331a88ffb1d9caafcf86beb1 (patch) | |
tree | 885dac03ffd0ae60189fa7620b84e89e3e03222b /lib/events | |
parent | 7d55e22ee3465e75e5ac7750bb1d205eb555761d (diff) | |
download | libquotient-52fdd715d605f201331a88ffb1d9caafcf86beb1.tar.gz libquotient-52fdd715d605f201331a88ffb1d9caafcf86beb1.zip |
Add missing file
Diffstat (limited to 'lib/events')
-rw-r--r-- | lib/events/roompowerlevelsevent.h | 75 |
1 files changed, 75 insertions, 0 deletions
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<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() { return content().invite; } + int kick() { return content().kick; } + int ban() { return content().ban; } + + int redact() { return content().redact; } + + QHash<QString, int> events() { return content().events; } + int eventsDefault() { return content().eventsDefault; } + int stateDefault() { return content().stateDefault; } + + QHash<QString, int> 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<RoomPowerLevelsEvent> { +public: + static event_ptr_tt<RoomPowerLevelsEvent> make(const QJsonObject& json, + const QString&) + { + return makeEvent<RoomPowerLevelsEvent>(json); + } +}; + +REGISTER_EVENT_TYPE(RoomPowerLevelsEvent) +} // namespace Quotient |