aboutsummaryrefslogtreecommitdiff
path: root/lib/events/callcandidatesevent.h
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/callcandidatesevent.h
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/callcandidatesevent.h')
-rw-r--r--lib/events/callcandidatesevent.h31
1 files changed, 10 insertions, 21 deletions
diff --git a/lib/events/callcandidatesevent.h b/lib/events/callcandidatesevent.h
index 8e66499d..4618832c 100644
--- a/lib/events/callcandidatesevent.h
+++ b/lib/events/callcandidatesevent.h
@@ -19,39 +19,28 @@
#pragma once
#include "roomevent.h"
-#include <QtCore/QJsonArray>
namespace QMatrixClient
{
- class CallCandidatesEvent: public RoomEvent
+ class CallCandidatesEvent: public CallEventBase
{
public:
DEFINE_EVENT_TYPEID("m.call.candidates", CallCandidatesEvent)
- explicit CallCandidatesEvent(const QJsonObject& obj);
+ explicit CallCandidatesEvent(const QJsonObject& obj)
+ : CallEventBase(typeId(), obj)
+ { }
explicit CallCandidatesEvent(const QString& callId,
- const QJsonArray& candidates);
+ const QJsonArray& candidates)
+ : CallEventBase(typeId(), matrixTypeId(), callId, 0,
+ {{ QStringLiteral("candidates"), candidates }})
+ { }
- bool isStateEvent() const override { return true; }
-
- const QJsonArray& candidates() const { return _candidates; }
- const QString& callId() const { return _callId; }
- const int version() const { return _version; }
-
- QJsonObject toJson() const
+ QJsonArray candidates() const
{
- QJsonObject obj;
- obj.insert("call_id", _callId);
- obj.insert("version", _version);
- obj.insert("candidates", _candidates);
- return obj;
+ return content<QJsonArray>("candidates"_ls);
}
-
- private:
- QJsonArray _candidates;
- QString _callId;
- int _version;
};
REGISTER_EVENT_TYPE(CallCandidatesEvent)