File indexing completed on 2024-05-12 05:02:13
0001 /* 0002 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "videoconference.h" 0008 #include "ruqola_debug.h" 0009 0010 #include <QJsonObject> 0011 0012 VideoConference::VideoConference() = default; 0013 0014 VideoConference::~VideoConference() = default; 0015 0016 bool VideoConference::operator==(const VideoConference &other) const 0017 { 0018 return mAction == other.action() && mCallId == other.callId() && mRoomId == other.roomId() && mUserId == other.userId(); 0019 } 0020 0021 void VideoConference::parseVideoConference(const QJsonObject &content) 0022 { 0023 mAction = convertActionToEnum(content[QLatin1String("action")].toString()); 0024 const QJsonObject videoConfParams = content[QLatin1String("params")].toObject(); 0025 mCallId = videoConfParams[QLatin1String("callId")].toString(); 0026 mRoomId = videoConfParams[QLatin1String("rid")].toString(); 0027 mUserId = videoConfParams[QLatin1String("uid")].toString(); 0028 // {"action":"call","params":{"callId":"63983180a7f9e1466a4eedc6","rid":"YbwG4T2uB3wZSZSKBxkNpoB3T98EEPCj2K","uid":"YbwG4T2uB3wZSZSKB"}} 0029 } 0030 0031 VideoConference::Action VideoConference::convertActionToEnum(const QString &str) 0032 { 0033 Action action = Unknown; 0034 if (str == QLatin1String("call")) { 0035 action = IncomingCall; 0036 } else if (str == QLatin1String("canceled")) { 0037 action = Canceled; 0038 } else if (str == QLatin1String("confirmed")) { 0039 action = Confirmed; 0040 } else if (str == QLatin1String("accepted")) { 0041 action = Accepted; 0042 } else if (str == QLatin1String("rejected")) { 0043 action = Rejected; 0044 } else { 0045 qCWarning(RUQOLA_LOG) << "Action not implemented! " << str; 0046 } 0047 return action; 0048 } 0049 0050 VideoConference::Action VideoConference::action() const 0051 { 0052 return mAction; 0053 } 0054 0055 void VideoConference::setAction(Action newAction) 0056 { 0057 mAction = newAction; 0058 } 0059 0060 QString VideoConference::callId() const 0061 { 0062 return mCallId; 0063 } 0064 0065 void VideoConference::setCallId(const QString &newCallId) 0066 { 0067 mCallId = newCallId; 0068 } 0069 0070 QString VideoConference::roomId() const 0071 { 0072 return mRoomId; 0073 } 0074 0075 void VideoConference::setRoomId(const QString &newRoomId) 0076 { 0077 mRoomId = newRoomId; 0078 } 0079 0080 QString VideoConference::userId() const 0081 { 0082 return mUserId; 0083 } 0084 0085 void VideoConference::setUserId(const QString &newUserId) 0086 { 0087 mUserId = newUserId; 0088 } 0089 0090 bool VideoConference::isValid() const 0091 { 0092 return !mCallId.isEmpty() && !mRoomId.isEmpty() && !mUserId.isEmpty() && mAction != Unknown; 0093 } 0094 0095 QDebug operator<<(QDebug d, const VideoConference &t) 0096 { 0097 d << "mCallId " << t.callId(); 0098 d << "mRoomId " << t.roomId(); 0099 d << "mUserId " << t.userId(); 0100 d << "mAction " << t.action(); 0101 return d; 0102 } 0103 0104 #include "moc_videoconference.cpp"