aboutsummaryrefslogtreecommitdiff
path: root/lib/events
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events')
-rw-r--r--lib/events/callanswerevent.cpp76
-rw-r--r--lib/events/callanswerevent.h68
-rw-r--r--lib/events/callcandidatesevent.cpp69
-rw-r--r--lib/events/callcandidatesevent.h59
-rw-r--r--lib/events/callhangupevent.cpp59
-rw-r--r--lib/events/callhangupevent.h54
-rw-r--r--lib/events/callinviteevent.cpp68
-rw-r--r--lib/events/callinviteevent.h65
8 files changed, 518 insertions, 0 deletions
diff --git a/lib/events/callanswerevent.cpp b/lib/events/callanswerevent.cpp
new file mode 100644
index 00000000..c28ad305
--- /dev/null
+++ b/lib/events/callanswerevent.cpp
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "callanswerevent.h"
+
+#include "event.h"
+
+#include "logging.h"
+
+#include <QtCore/QJsonDocument>
+
+/*
+m.call.answer
+{
+ "age": 242352,
+ "content": {
+ "answer": {
+ "sdp": "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]",
+ "type": "answer"
+ },
+ "call_id": "12345",
+ "lifetime": 60000,
+ "version": 0
+ },
+ "event_id": "$WLGTSEFSEF:localhost",
+ "origin_server_ts": 1431961217939,
+ "room_id": "!Cuyf34gef24t:localhost",
+ "sender": "@example:localhost",
+ "type": "m.call.answer"
+}
+*/
+
+using namespace QMatrixClient;
+
+CallAnswerEvent::CallAnswerEvent(const QJsonObject& obj)
+ : RoomEvent(typeId(), obj)
+ , _lifetime(contentJson()["lifetime"].toInt())
+ , _sdp(contentJson()["answer"].toObject()["sdp"].toString())
+ , _callId(contentJson()["call_id"].toString())
+ , _version(contentJson()["version"].toInt())
+{
+ qCDebug(EVENTS) << "Call Answer event";
+}
+
+CallAnswerEvent::CallAnswerEvent(const QString& callId, const int lifetime,
+ const QString& sdp)
+ : RoomEvent(typeId(), NULL)
+{
+ _version = 0;
+ _callId = callId;
+ _lifetime = lifetime;
+ _sdp = sdp;
+}
+
+CallAnswerEvent::CallAnswerEvent(const QString& callId, const QString& sdp)
+ : RoomEvent(typeId(), NULL)
+{
+ _version = 0;
+ _callId = callId;
+ _sdp = sdp;
+}
diff --git a/lib/events/callanswerevent.h b/lib/events/callanswerevent.h
new file mode 100644
index 00000000..b5b47899
--- /dev/null
+++ b/lib/events/callanswerevent.h
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include "roomevent.h"
+
+namespace QMatrixClient
+{
+ class CallAnswerEvent: public RoomEvent
+ {
+ public:
+ DEFINE_EVENT_TYPEID("m.call.answer", CallAnswerEvent)
+
+ explicit CallAnswerEvent(const QJsonObject& obj);
+
+ explicit CallAnswerEvent(const QString& callId, const int lifetime,
+ const QString& sdp);
+ explicit CallAnswerEvent(const QString& callId, 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 answer;
+ answer.insert("sdp", _sdp);
+ answer.insert("type", QStringLiteral("answer"));
+
+ QJsonObject obj;
+ obj.insert("call_id", _callId);
+ obj.insert("version", _version);
+ if (_lifetime != NULL)
+ obj.insert("lifetime", _lifetime);
+ obj.insert("answer", answer);
+ return obj;
+ }
+
+ private:
+ int _lifetime;
+ QJsonObject _answer;
+ QString _sdp;
+ QString _callId;
+ int _version;
+ };
+
+ REGISTER_EVENT_TYPE(CallAnswerEvent)
+ DEFINE_EVENTTYPE_ALIAS(CallAnswer, CallAnswerEvent)
+} // namespace QMatrixClient
diff --git a/lib/events/callcandidatesevent.cpp b/lib/events/callcandidatesevent.cpp
new file mode 100644
index 00000000..40d9ce05
--- /dev/null
+++ b/lib/events/callcandidatesevent.cpp
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "callcandidatesevent.h"
+
+#include "event.h"
+
+#include "logging.h"
+
+#include <QtCore/QJsonDocument>
+
+/*
+m.call.candidates
+{
+ "age": 242352,
+ "content": {
+ "call_id": "12345",
+ "candidates": [
+ {
+ "candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0",
+ "sdpMLineIndex": 0,
+ "sdpMid": "audio"
+ }
+ ],
+ "version": 0
+ },
+ "event_id": "$WLGTSEFSEF:localhost",
+ "origin_server_ts": 1431961217939,
+ "room_id": "!Cuyf34gef24t:localhost",
+ "sender": "@example:localhost",
+ "type": "m.call.candidates"
+}
+*/
+
+using namespace QMatrixClient;
+
+
+CallCandidatesEvent::CallCandidatesEvent(const QJsonObject& obj)
+ : RoomEvent(typeId(), obj)
+ , _candidates(contentJson()["candidates"].toArray())
+ , _callId(contentJson()["call_id"].toString())
+ , _version(contentJson()["version"].toInt())
+{
+ qCDebug(EVENTS) << "Call Candidates event";
+}
+
+CallCandidatesEvent::CallCandidatesEvent(const QString& callId,
+ const QJsonArray& candidates)
+ : RoomEvent(typeId(), NULL)
+{
+ _version = 0;
+ _callId = callId;
+ _candidates = candidates;
+}
diff --git a/lib/events/callcandidatesevent.h b/lib/events/callcandidatesevent.h
new file mode 100644
index 00000000..8e66499d
--- /dev/null
+++ b/lib/events/callcandidatesevent.h
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include "roomevent.h"
+#include <QtCore/QJsonArray>
+
+namespace QMatrixClient
+{
+ class CallCandidatesEvent: public RoomEvent
+ {
+ public:
+ DEFINE_EVENT_TYPEID("m.call.candidates", CallCandidatesEvent)
+
+ explicit CallCandidatesEvent(const QJsonObject& obj);
+
+ explicit CallCandidatesEvent(const QString& callId,
+ const QJsonArray& 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
+ {
+ QJsonObject obj;
+ obj.insert("call_id", _callId);
+ obj.insert("version", _version);
+ obj.insert("candidates", _candidates);
+ return obj;
+ }
+
+ private:
+ QJsonArray _candidates;
+ QString _callId;
+ int _version;
+ };
+
+ REGISTER_EVENT_TYPE(CallCandidatesEvent)
+ DEFINE_EVENTTYPE_ALIAS(CallCandidates, CallCandidatesEvent)
+}
diff --git a/lib/events/callhangupevent.cpp b/lib/events/callhangupevent.cpp
new file mode 100644
index 00000000..27f41a5f
--- /dev/null
+++ b/lib/events/callhangupevent.cpp
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "callhangupevent.h"
+
+#include "event.h"
+
+#include "logging.h"
+
+#include <QtCore/QJsonDocument>
+
+/*
+m.call.hangup
+{
+ "age": 242352,
+ "content": {
+ "call_id": "12345",
+ "version": 0
+ },
+ "event_id": "$WLGTSEFSEF:localhost",
+ "origin_server_ts": 1431961217939,
+ "room_id": "!Cuyf34gef24t:localhost",
+ "sender": "@example:localhost",
+ "type": "m.call.hangup"
+}
+*/
+
+using namespace QMatrixClient;
+
+
+CallHangupEvent::CallHangupEvent(const QJsonObject& obj)
+ : RoomEvent(typeId(), obj)
+ , _callId(contentJson()["call_id"].toString())
+ , _version(contentJson()["version"].toInt())
+{
+ qCDebug(EVENTS) << "Call Hangup event";
+}
+
+CallHangupEvent::CallHangupEvent(const QString& callId)
+ : RoomEvent(typeId(), NULL)
+{
+ _version = 0;
+ _callId = callId;
+}
diff --git a/lib/events/callhangupevent.h b/lib/events/callhangupevent.h
new file mode 100644
index 00000000..57e565a6
--- /dev/null
+++ b/lib/events/callhangupevent.h
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include "roomevent.h"
+
+namespace QMatrixClient
+{
+ class CallHangupEvent: public RoomEvent
+ {
+ public:
+ DEFINE_EVENT_TYPEID("m.call.hangup", CallHangupEvent)
+
+ explicit CallHangupEvent(const QJsonObject& obj);
+
+ explicit CallHangupEvent(const QString& callId);
+
+ bool isStateEvent() const override { return true; }
+
+ const QString& callId() const { return _callId; }
+ const int version() const { return _version; }
+
+ QJsonObject toJson() const
+ {
+ QJsonObject obj;
+ obj.insert("call_id", _callId);
+ obj.insert("version", _version);
+ return obj;
+ }
+
+ private:
+ QString _callId;
+ int _version;
+ };
+
+ REGISTER_EVENT_TYPE(CallHangupEvent)
+ DEFINE_EVENTTYPE_ALIAS(CallHangup, CallHangupEvent)
+}
diff --git a/lib/events/callinviteevent.cpp b/lib/events/callinviteevent.cpp
new file mode 100644
index 00000000..71c49d66
--- /dev/null
+++ b/lib/events/callinviteevent.cpp
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "callinviteevent.h"
+
+#include "event.h"
+
+#include "logging.h"
+
+#include <QtCore/QJsonDocument>
+
+/*
+m.call.invite
+{
+ "age": 242352,
+ "content": {
+ "call_id": "12345",
+ "lifetime": 60000,
+ "offer": {
+ "sdp": "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]",
+ "type": "offer"
+ },
+ "version": 0
+ },
+ "event_id": "$WLGTSEFSEF:localhost",
+ "origin_server_ts": 1431961217939,
+ "room_id": "!Cuyf34gef24t:localhost",
+ "sender": "@example:localhost",
+ "type": "m.call.invite"
+}
+*/
+
+using namespace QMatrixClient;
+
+CallInviteEvent::CallInviteEvent(const QJsonObject& obj)
+ : RoomEvent(typeId(), obj)
+ , _lifetime(contentJson()["lifetime"].toInt())
+ , _sdp(contentJson()["offer"].toObject()["sdp"].toString())
+ , _callId(contentJson()["call_id"].toString())
+ , _version(contentJson()["version"].toInt())
+{
+ qCDebug(EVENTS) << "Call Invite event";
+}
+
+CallInviteEvent::CallInviteEvent(const QString& callId, const int lifetime,
+ const QString& sdp)
+ : RoomEvent(typeId(), NULL)
+{
+ _version = 0;
+ _callId = callId;
+ _lifetime = lifetime;
+ _sdp = sdp;
+}
diff --git a/lib/events/callinviteevent.h b/lib/events/callinviteevent.h
new file mode 100644
index 00000000..029b2e3d
--- /dev/null
+++ b/lib/events/callinviteevent.h
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include "roomevent.h"
+
+namespace QMatrixClient
+{
+ class CallInviteEvent: public RoomEvent
+ {
+ public:
+ DEFINE_EVENT_TYPEID("m.call.invite", CallInviteEvent)
+
+ explicit CallInviteEvent(const QJsonObject& obj);
+
+ 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;
+ };
+
+ REGISTER_EVENT_TYPE(CallInviteEvent)
+ DEFINE_EVENTTYPE_ALIAS(CallInvite, CallInviteEvent)
+}