aboutsummaryrefslogtreecommitdiff
path: root/lib/events/callinviteevent.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/callinviteevent.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/callinviteevent.h')
-rw-r--r--lib/events/callinviteevent.h41
1 files changed, 10 insertions, 31 deletions
diff --git a/lib/events/callinviteevent.h b/lib/events/callinviteevent.h
index 029b2e3d..d5315309 100644
--- a/lib/events/callinviteevent.h
+++ b/lib/events/callinviteevent.h
@@ -22,42 +22,21 @@
namespace QMatrixClient
{
- class CallInviteEvent: public RoomEvent
+ class CallInviteEvent: public CallEventBase
{
public:
- DEFINE_EVENT_TYPEID("m.call.invite", CallInviteEvent)
+ DEFINE_EVENT_TYPEID("m.call.invite", CallInviteEvent)
- explicit CallInviteEvent(const QJsonObject& obj);
+ explicit CallInviteEvent(const QJsonObject& obj);
- explicit CallInviteEvent(const QString& callId, const int lifetime,
- const QString& sdp);
+ explicit CallInviteEvent(const QString& callId, const int lifetime,
+ const QString& sdp);
- bool isStateEvent() const override { return true; }
-
- const int lifetime() const { return _lifetime; }
- const QString& sdp() const { return _sdp; }
- const QString& callId() const { return _callId; }
- const int version() const { return _version; }
-
- QJsonObject toJson() const
- {
- QJsonObject offer;
- offer.insert("sdp", _sdp);
- offer.insert("type", QStringLiteral("offer"));
-
- QJsonObject obj;
- obj.insert("call_id", _callId);
- obj.insert("version", _version);
- obj.insert("lifetime", _lifetime);
- obj.insert("offer", offer);
- return obj;
- }
-
- private:
- int _lifetime;
- QString _sdp;
- QString _callId;
- int _version;
+ int lifetime() const { return content<int>("lifetime"_ls); } // FIXME: Omittable<>?
+ QString sdp() const {
+ return contentJson()["offer"_ls].toObject()
+ .value("sdp"_ls).toString();
+ }
};
REGISTER_EVENT_TYPE(CallInviteEvent)