1 /******************************************************************************
2  * Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
17  */
18 
19 #include "callanswerevent.h"
20 
21 #include "event.h"
22 #include "logging.h"
23 
24 #include <QtCore/QJsonDocument>
25 
26 /*
27 m.call.answer
28 {
29     "age": 242352,
30     "content": {
31         "answer": {
32             "sdp": "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]",
33             "type": "answer"
34         },
35         "call_id": "12345",
36         "lifetime": 60000,
37         "version": 0
38     },
39     "event_id": "$WLGTSEFSEF:localhost",
40     "origin_server_ts": 1431961217939,
41     "room_id": "!Cuyf34gef24t:localhost",
42     "sender": "@example:localhost",
43     "type": "m.call.answer"
44 }
45 */
46 
47 using namespace Quotient;
48 
CallAnswerEvent(const QJsonObject & obj)49 CallAnswerEvent::CallAnswerEvent(const QJsonObject& obj)
50     : CallEventBase(typeId(), obj)
51 {
52     qCDebug(EVENTS) << "Call Answer event";
53 }
54 
CallAnswerEvent(const QString & callId,const int lifetime,const QString & sdp)55 CallAnswerEvent::CallAnswerEvent(const QString& callId, const int lifetime,
56                                  const QString& sdp)
57     : CallEventBase(
58         typeId(), matrixTypeId(), callId, 0,
59         { { QStringLiteral("lifetime"), lifetime },
60           { QStringLiteral("answer"),
61             QJsonObject { { QStringLiteral("type"), QStringLiteral("answer") },
62                           { QStringLiteral("sdp"), sdp } } } })
63 {}
64 
CallAnswerEvent(const QString & callId,const QString & sdp)65 CallAnswerEvent::CallAnswerEvent(const QString& callId, const QString& sdp)
66     : CallEventBase(
67         typeId(), matrixTypeId(), callId, 0,
68         { { QStringLiteral("answer"),
69             QJsonObject { { QStringLiteral("type"), QStringLiteral("answer") },
70                           { QStringLiteral("sdp"), sdp } } } })
71 {}
72