2021-05-31 13:20:08 -04:00
|
|
|
/*
|
2022-01-06 11:24:13 -05:00
|
|
|
* Copyright (C) 2020-2022 Savoir-faire Linux Inc.
|
2020-08-03 13:27:42 -04:00
|
|
|
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
|
2020-07-23 17:03:11 -04:00
|
|
|
* Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
|
2021-05-31 13:20:08 -04:00
|
|
|
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
|
2020-08-03 13:27:42 -04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "lrcinstance.h"
|
|
|
|
#include "qmladapterbase.h"
|
2021-01-28 16:09:55 +01:00
|
|
|
#include "screensaver.h"
|
2021-05-14 16:53:57 -04:00
|
|
|
#include "calloverlaymodel.h"
|
2021-12-15 14:07:43 -05:00
|
|
|
#include "callparticipantsmodel.h"
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2020-07-24 15:15:47 -04:00
|
|
|
#include <QVariant>
|
2020-08-31 13:17:44 +02:00
|
|
|
#include <QSystemTrayIcon>
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-03-30 15:15:36 -04:00
|
|
|
class SystemTray;
|
|
|
|
|
2020-09-03 09:24:49 -04:00
|
|
|
class CallAdapter final : public QmlAdapterBase
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-04-09 13:41:08 -04:00
|
|
|
QML_PROPERTY(bool, hasCall)
|
2022-10-25 11:25:14 -04:00
|
|
|
QML_RO_PROPERTY(QVariantList, callInformation)
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
public:
|
2022-10-25 11:25:14 -04:00
|
|
|
QTimer* timer;
|
2021-01-05 11:26:20 +01:00
|
|
|
enum MuteStates { UNMUTED, LOCAL_MUTED, MODERATOR_MUTED, BOTH_MUTED };
|
|
|
|
Q_ENUM(MuteStates)
|
|
|
|
|
2021-03-30 15:15:36 -04:00
|
|
|
explicit CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject* parent = nullptr);
|
2020-09-03 09:24:49 -04:00
|
|
|
~CallAdapter() = default;
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 09:24:49 -04:00
|
|
|
protected:
|
|
|
|
void safeInit() override {};
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 09:24:49 -04:00
|
|
|
public:
|
2022-10-25 11:25:14 -04:00
|
|
|
Q_INVOKABLE void startTimerInformation();
|
|
|
|
Q_INVOKABLE void stopTimerInformation();
|
2020-08-03 13:27:42 -04:00
|
|
|
Q_INVOKABLE void placeAudioOnlyCall();
|
|
|
|
Q_INVOKABLE void placeCall();
|
2020-08-25 14:32:34 -04:00
|
|
|
Q_INVOKABLE void hangUpACall(const QString& accountId, const QString& convUid);
|
2021-05-12 23:01:38 -04:00
|
|
|
Q_INVOKABLE void setCallMedia(const QString& accountId, const QString& convUid, bool video);
|
2020-08-25 14:32:34 -04:00
|
|
|
Q_INVOKABLE void acceptACall(const QString& accountId, const QString& convUid);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-25 14:32:34 -04:00
|
|
|
Q_INVOKABLE void connectCallModel(const QString& accountId);
|
|
|
|
Q_INVOKABLE void sipInputPanelPlayDTMF(const QString& key);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// For Call Overlay
|
2021-05-17 11:06:11 -04:00
|
|
|
Q_INVOKABLE void hangUpCall(const QString& callId);
|
2022-07-12 10:57:20 -04:00
|
|
|
Q_INVOKABLE void setActiveStream(const QString& uri,
|
|
|
|
const QString& deviceId,
|
|
|
|
const QString& streamId);
|
2020-11-20 12:14:24 +01:00
|
|
|
Q_INVOKABLE void minimizeParticipant(const QString& uri);
|
2021-05-26 16:35:07 -04:00
|
|
|
Q_INVOKABLE void showGridConferenceLayout();
|
2020-08-03 13:27:42 -04:00
|
|
|
Q_INVOKABLE void hangUpThisCall();
|
2020-09-28 16:38:15 -04:00
|
|
|
Q_INVOKABLE bool isCurrentHost() const;
|
2020-11-20 12:14:24 +01:00
|
|
|
Q_INVOKABLE bool participantIsHost(const QString& uri) const;
|
|
|
|
Q_INVOKABLE void setModerator(const QString& uri, const bool state);
|
2020-11-09 20:45:41 +01:00
|
|
|
Q_INVOKABLE bool isModerator(const QString& uri = {}) const;
|
2021-10-26 11:42:35 -04:00
|
|
|
Q_INVOKABLE bool isHandRaised(const QString& uri = {}) const;
|
2022-06-09 11:24:29 -04:00
|
|
|
Q_INVOKABLE void raiseHand(const QString& uri, const QString& deviceId, bool state);
|
2020-08-03 13:27:42 -04:00
|
|
|
Q_INVOKABLE void holdThisCallToggle();
|
|
|
|
Q_INVOKABLE void recordThisCallToggle();
|
2022-06-09 11:20:24 -04:00
|
|
|
Q_INVOKABLE void muteAudioToggle();
|
|
|
|
Q_INVOKABLE void muteCameraToggle();
|
2020-07-23 17:03:11 -04:00
|
|
|
Q_INVOKABLE bool isRecordingThisCall();
|
2021-12-15 14:07:43 -05:00
|
|
|
Q_INVOKABLE QVariantList getConferencesInfos() const;
|
2022-07-12 10:57:20 -04:00
|
|
|
Q_INVOKABLE void muteParticipant(const QString& accountUri,
|
|
|
|
const QString& deviceId,
|
|
|
|
const QString& sinkId,
|
|
|
|
const bool state);
|
2021-01-05 11:26:20 +01:00
|
|
|
Q_INVOKABLE MuteStates getMuteState(const QString& uri) const;
|
2022-06-09 11:24:29 -04:00
|
|
|
Q_INVOKABLE void hangupParticipant(const QString& uri, const QString& deviceId);
|
2020-11-06 10:52:21 -05:00
|
|
|
Q_INVOKABLE void updateCall(const QString& convUid = {},
|
|
|
|
const QString& accountId = {},
|
|
|
|
bool forceCallOnly = false);
|
2021-05-13 17:53:37 -04:00
|
|
|
Q_INVOKABLE QString getCallDurationTime(const QString& accountId, const QString& convUid);
|
2022-10-25 11:25:14 -04:00
|
|
|
Q_INVOKABLE void updateAdvancedInformation();
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-03-29 16:51:53 -04:00
|
|
|
Q_SIGNALS:
|
2020-08-24 17:46:30 +02:00
|
|
|
void callStatusChanged(int index, const QString& accountId, const QString& convUid);
|
2021-05-28 10:28:04 -04:00
|
|
|
void callInfosChanged(const QVariant& infos, const QString& accountId, const QString& convUid);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// For Call Overlay
|
2020-09-10 17:40:51 -04:00
|
|
|
void updateTimeText(const QString& time);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-03-29 16:51:53 -04:00
|
|
|
public Q_SLOTS:
|
2020-12-15 11:55:38 -05:00
|
|
|
void onShowIncomingCallView(const QString& accountId, const QString& convUid);
|
|
|
|
void onShowCallView(const QString& accountId, const QString& convUid);
|
|
|
|
void onAccountChanged();
|
2021-04-01 18:58:05 -04:00
|
|
|
void onCallStatusChanged(const QString& accountId, const QString& callId);
|
2021-05-28 10:28:04 -04:00
|
|
|
void onCallInfosChanged(const QString& accountId, const QString& callId);
|
2021-05-14 16:53:57 -04:00
|
|
|
void onCallStatusChanged(const QString& callId, int code);
|
2021-05-31 13:20:08 -04:00
|
|
|
void onCallAddedToConference(const QString& callId, const QString& confId);
|
2021-12-15 14:07:43 -05:00
|
|
|
void onParticipantAdded(const QString& callId, int index);
|
|
|
|
void onParticipantRemoved(const QString& callId, int index);
|
|
|
|
void onParticipantUpdated(const QString& callId, int index);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
private:
|
2020-09-14 13:04:57 -04:00
|
|
|
void showNotification(const QString& accountId, const QString& convUid);
|
2021-12-15 14:07:43 -05:00
|
|
|
void fillParticipantData(QJsonObject& participant) const;
|
2021-05-31 13:20:08 -04:00
|
|
|
void preventScreenSaver(bool state);
|
|
|
|
void saveConferenceSubcalls();
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
QString accountId_;
|
|
|
|
|
2021-01-28 16:09:55 +01:00
|
|
|
ScreenSaver screenSaver;
|
2021-03-30 15:15:36 -04:00
|
|
|
SystemTray* systemTray_;
|
2021-05-14 16:53:57 -04:00
|
|
|
QScopedPointer<CallOverlayModel> overlayModel_;
|
2021-12-15 14:07:43 -05:00
|
|
|
QScopedPointer<CallParticipantsModel> participantsModel_;
|
2021-05-31 13:20:08 -04:00
|
|
|
VectorString currentConfSubcalls_;
|
2020-08-03 13:27:42 -04:00
|
|
|
};
|