From 50cc85d3dea93735fe352831421eea2fcf9c24c5 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 4 Oct 2018 14:41:48 +0900 Subject: Modernise and fix code dealing with call events Call events no more store deserialised values; instead they deserialise values on the fly, same as all other events. They are no more treated as state events (The Spec doesn't define them as state events in the first place). A common base class, CallEventBase, is introduced that defines data pieces common to all call events (call id and version). --- lib/events/event.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/events/event.h') diff --git a/lib/events/event.h b/lib/events/event.h index 9ba4b85a..cd23a818 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -18,11 +18,9 @@ #pragma once -#include "util.h" +#include "converters.h" #include "logging.h" -#include - #ifndef DISABLE_EVENTTYPE #define USE_EVENTTYPE 1 #endif @@ -247,7 +245,20 @@ namespace QMatrixClient const QJsonObject contentJson() const; const QJsonObject unsignedJson() const; + template + T content(const QString& key) const + { + return fromJson(contentJson()[key]); + } + + template + T content(const QLatin1String& key) const + { + return fromJson(contentJson()[key]); + } + virtual bool isStateEvent() const { return false; } + virtual bool isCallEvent() const { return false; } protected: QJsonObject& editJson() { return _json; } -- cgit v1.2.3