aboutsummaryrefslogtreecommitdiff
path: root/lib/events/keyverificationevent.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-08-12 16:46:01 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-04 18:42:11 +0200
commit17cd3beaefa5501a902e08c7644e8cd97c9091a0 (patch)
treeca98dd3a927bb45f6ff5f4749b5e04f83e4ed321 /lib/events/keyverificationevent.h
parenta18f505fe7ca66556d66538a7c9b9ff31d2c1b29 (diff)
downloadlibquotient-17cd3beaefa5501a902e08c7644e8cd97c9091a0.tar.gz
libquotient-17cd3beaefa5501a902e08c7644e8cd97c9091a0.zip
Streamline event types
This commit introduces a few things to further reduce the boilerplate across event type definitions: - Event type is no more separately stored in Event and therefore no more passed to base event constructors. Until the previous commit, it was used by is() to quickly match the event type; with the new event metatype class, the same is achieved even quicker by comparing metatype pointers. - EventTemplate is a generalisation of StateEvent for all event types providing common constructor signatures and content() for (most) leaf event types. StateEvent therefore has become a partial specialisation of EventTemplate for types derived from StateEventBase; as the known client code base does not use it directly, a compatibility alias is not provided. Also, DEFINE_SIMPLE_EVENT now expands into a class deriving from EventTemplate. - On top of StateEvent->EventTemplate specialisation, KeyedStateEventBase and KeylessStateEventBase types are introduced with appropriate constructor signatures (with or without state_key, respectively) to allow `using` of them from derived event types. To facilitate writing of constraints, concepts for keyed and keyless state event types are also introduced; RoomStateView, e.g., makes use of those to provide appropriate method signatures. - typeId(), unknownEventTypeId(), UnknownEventTypeId are no more provided - they weren't used throughout the known code base (Quaternion, NeoChat), and the concept of "unknown event types" is hereby eliminated entirely. - RoomKeyEvent no more accepts senderId as a parameter; it has never been a good practice as the sender is assigned by Connection anyway.
Diffstat (limited to 'lib/events/keyverificationevent.h')
-rw-r--r--lib/events/keyverificationevent.h32
1 files changed, 8 insertions, 24 deletions
diff --git a/lib/events/keyverificationevent.h b/lib/events/keyverificationevent.h
index 5b5a518f..0ffd8b2c 100644
--- a/lib/events/keyverificationevent.h
+++ b/lib/events/keyverificationevent.h
@@ -15,9 +15,7 @@ class QUOTIENT_API KeyVerificationRequestEvent : public Event {
public:
QUO_EVENT(KeyVerificationRequestEvent, "m.key.verification.request")
- explicit KeyVerificationRequestEvent(const QJsonObject& obj)
- : Event(TypeId, obj)
- {}
+ using Event::Event;
KeyVerificationRequestEvent(const QString& transactionId,
const QString& fromDevice,
const QStringList& methods,
@@ -50,9 +48,7 @@ class QUOTIENT_API KeyVerificationReadyEvent : public Event {
public:
QUO_EVENT(KeyVerificationReadyEvent, "m.key.verification.ready")
- explicit KeyVerificationReadyEvent(const QJsonObject& obj)
- : Event(TypeId, obj)
- {}
+ using Event::Event;
KeyVerificationReadyEvent(const QString& transactionId,
const QString& fromDevice,
const QStringList& methods)
@@ -77,9 +73,7 @@ class QUOTIENT_API KeyVerificationStartEvent : public Event {
public:
QUO_EVENT(KeyVerificationStartEvent, "m.key.verification.start")
- explicit KeyVerificationStartEvent(const QJsonObject& obj)
- : Event(TypeId, obj)
- {}
+ using Event::Event;
KeyVerificationStartEvent(const QString& transactionId,
const QString& fromDevice)
: KeyVerificationStartEvent(
@@ -150,9 +144,7 @@ class QUOTIENT_API KeyVerificationAcceptEvent : public Event {
public:
QUO_EVENT(KeyVerificationAcceptEvent, "m.key.verification.accept")
- explicit KeyVerificationAcceptEvent(const QJsonObject& obj)
- : Event(TypeId, obj)
- {}
+ using Event::Event;
KeyVerificationAcceptEvent(const QString& transactionId,
const QString& commitment)
: KeyVerificationAcceptEvent(basicJson(
@@ -200,9 +192,7 @@ class QUOTIENT_API KeyVerificationCancelEvent : public Event {
public:
QUO_EVENT(KeyVerificationCancelEvent, "m.key.verification.cancel")
- explicit KeyVerificationCancelEvent(const QJsonObject& obj)
- : Event(TypeId, obj)
- {}
+ using Event::Event;
KeyVerificationCancelEvent(const QString& transactionId,
const QString& reason)
: KeyVerificationCancelEvent(
@@ -230,9 +220,7 @@ class QUOTIENT_API KeyVerificationKeyEvent : public Event {
public:
QUO_EVENT(KeyVerificationKeyEvent, "m.key.verification.key")
- explicit KeyVerificationKeyEvent(const QJsonObject& obj)
- : Event(TypeId, obj)
- {}
+ using Event::Event;
KeyVerificationKeyEvent(const QString& transactionId, const QString& key)
: KeyVerificationKeyEvent(
basicJson(TypeId, { { "transaction_id"_ls, transactionId },
@@ -251,9 +239,7 @@ class QUOTIENT_API KeyVerificationMacEvent : public Event {
public:
QUO_EVENT(KeyVerificationMacEvent, "m.key.verification.mac")
- explicit KeyVerificationMacEvent(const QJsonObject& obj)
- : Event(TypeId, obj)
- {}
+ using Event::Event;
KeyVerificationMacEvent(const QString& transactionId, const QString& keys,
const QJsonObject& mac)
: KeyVerificationMacEvent(
@@ -278,9 +264,7 @@ class QUOTIENT_API KeyVerificationDoneEvent : public Event {
public:
QUO_EVENT(KeyVerificationDoneEvent, "m.key.verification.done")
- explicit KeyVerificationDoneEvent(const QJsonObject& obj)
- : Event(TypeId, obj)
- {}
+ using Event::Event;
explicit KeyVerificationDoneEvent(const QString& transactionId)
: KeyVerificationDoneEvent(
basicJson(TypeId, { { "transaction_id"_ls, transactionId } }))