aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roomevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-10-04 14:41:48 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-10-04 14:49:04 +0900
commit50cc85d3dea93735fe352831421eea2fcf9c24c5 (patch)
tree7aa91a3da084058a8fdd87ca9f72ed313eac79ec /lib/events/roomevent.cpp
parent5f2b4caa9b9cd63e1652d6550ceebecdb52df424 (diff)
downloadlibquotient-50cc85d3dea93735fe352831421eea2fcf9c24c5.tar.gz
libquotient-50cc85d3dea93735fe352831421eea2fcf9c24c5.zip
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).
Diffstat (limited to 'lib/events/roomevent.cpp')
-rw-r--r--lib/events/roomevent.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/events/roomevent.cpp b/lib/events/roomevent.cpp
index e9d74cf6..80d121de 100644
--- a/lib/events/roomevent.cpp
+++ b/lib/events/roomevent.cpp
@@ -101,3 +101,25 @@ void RoomEvent::addId(const QString& newId)
qCDebug(EVENTS) << "Event txnId -> id:" << transactionId() << "->" << id();
Q_ASSERT(id() == newId);
}
+
+QJsonObject makeCallContentJson(const QString& callId, int version,
+ QJsonObject content)
+{
+ content.insert(QStringLiteral("call_id"), callId);
+ content.insert(QStringLiteral("version"), version);
+ return content;
+}
+
+CallEventBase::CallEventBase(Type type, event_mtype_t matrixType,
+ const QString& callId, int version,
+ const QJsonObject& contentJson)
+ : RoomEvent(type, matrixType,
+ makeCallContentJson(callId, version, contentJson))
+{ }
+
+CallEventBase::CallEventBase(Event::Type type, const QJsonObject& json)
+ : RoomEvent(type, json)
+{
+ if (callId().isEmpty())
+ qCWarning(EVENTS) << id() << "is a call event with an empty call id";
+}