| 1 | // SPDX-FileCopyrightText: 2017 Kitsune Ral <kitsune-ral@users.sf.net> |
| 2 | // SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "stateevent.h" |
| 7 | #include "single_key_value.h" |
| 8 | |
| 9 | namespace Quotient { |
| 10 | |
| 11 | #define DEFINE_SIMPLE_STATE_EVENT(Name_, TypeId_, ValueType_, GetterName_, \ |
| 12 | JsonKey_) \ |
| 13 | constexpr inline auto Name_##Key = JsonKey_##_ls; \ |
| 14 | class QUOTIENT_API Name_ \ |
| 15 | : public KeylessStateEventBase< \ |
| 16 | Name_, EventContent::SingleKeyValue<ValueType_, Name_##Key>> { \ |
| 17 | public: \ |
| 18 | using value_type = ValueType_; \ |
| 19 | QUO_EVENT(Name_, TypeId_) \ |
| 20 | using KeylessStateEventBase::KeylessStateEventBase; \ |
| 21 | auto GetterName_() const { return content().value; } \ |
| 22 | }; \ |
| 23 | // End of macro |
| 24 | |
| 25 | DEFINE_SIMPLE_STATE_EVENT(RoomNameEvent, "m.room.name" , QString, name, "name" ) |
| 26 | DEFINE_SIMPLE_STATE_EVENT(RoomTopicEvent, "m.room.topic" , QString, topic, |
| 27 | "topic" ) |
| 28 | DEFINE_SIMPLE_STATE_EVENT(RoomPinnedEventsEvent, "m.room.pinned_events" , |
| 29 | QStringList, pinnedEvents, "pinned" ) |
| 30 | using RoomPinnedEvent |
| 31 | [[deprecated("RoomPinnedEventsEvent is the new, correct name" )]] = |
| 32 | RoomPinnedEventsEvent; |
| 33 | |
| 34 | constexpr inline auto RoomAliasesEventKey = "aliases"_ls ; |
| 35 | class QUOTIENT_API RoomAliasesEvent |
| 36 | : public KeyedStateEventBase< |
| 37 | RoomAliasesEvent, |
| 38 | EventContent::SingleKeyValue<QStringList, RoomAliasesEventKey>> |
| 39 | { |
| 40 | public: |
| 41 | QUO_EVENT(RoomAliasesEvent, "m.room.aliases" ) |
| 42 | using KeyedStateEventBase::KeyedStateEventBase; |
| 43 | |
| 44 | Q_DECL_DEPRECATED_X( |
| 45 | "m.room.aliases events are deprecated by the Matrix spec; use" |
| 46 | " RoomCanonicalAliasEvent::altAliases() to get non-authoritative aliases" ) |
| 47 | QString server() const { return stateKey(); } |
| 48 | Q_DECL_DEPRECATED_X( |
| 49 | "m.room.aliases events are deprecated by the Matrix spec; use" |
| 50 | " RoomCanonicalAliasEvent::altAliases() to get non-authoritative aliases" ) |
| 51 | QStringList aliases() const { return content().value; } |
| 52 | }; |
| 53 | } // namespace Quotient |
| 54 | |