libQuotient
A Qt library for building matrix clients
simplestateevents.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2017 Kitsune Ral <kitsune-ral@users.sf.net>
2 // SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 
5 #pragma once
6 
7 #include "stateevent.h"
9 
10 namespace Quotient {
11 
12 #define DEFINE_SIMPLE_STATE_EVENT(Name_, TypeId_, ValueType_, GetterName_, JsonKey_)
13  constexpr inline auto Name_##Key = JsonKey_##_L1;
14  class QUOTIENT_API Name_ : public ::Quotient::KeylessStateEventBase<
15  Name_, EventContent::SingleKeyValue<ValueType_, Name_##Key>> {
16  public:
17  using value_type = ValueType_;
18  QUO_EVENT(Name_, TypeId_)
19  using KeylessStateEventBase::KeylessStateEventBase;
20  auto GetterName_() const { return content().value; }
21  };
22  // End of macro
23 
24 DEFINE_SIMPLE_STATE_EVENT(RoomNameEvent, "m.room.name", QString, name, "name")
25 DEFINE_SIMPLE_STATE_EVENT(RoomTopicEvent, "m.room.topic", QString, topic,
26  "topic")
27 DEFINE_SIMPLE_STATE_EVENT(RoomPinnedEventsEvent, "m.room.pinned_events",
28  QStringList, pinnedEvents, "pinned")
29 
30 class QUOTIENT_API RoomServerAclEvent : public StateEvent {
31 public:
32  QUO_EVENT(RoomServerAclEvent, "m.room.server_acl")
33 
34  using StateEvent::StateEvent;
35 
36  QUO_CONTENT_GETTER(QStringList, allow)
37  QUO_CONTENT_GETTER(bool, allowIpLiterals)
38  QUO_CONTENT_GETTER(QStringList, deny)
39 };
40 } // namespace Quotient