2021-05-31 13:20:08 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2021 by Savoir-faire Linux
|
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"
|
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)
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
public:
|
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:
|
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);
|
2020-11-20 12:14:24 +01:00
|
|
|
Q_INVOKABLE void maximizeParticipant(const QString& uri);
|
|
|
|
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;
|
|
|
|
Q_INVOKABLE void setHandRaised(const QString& uri, bool state);
|
2020-11-09 20:45:41 +01:00
|
|
|
Q_INVOKABLE bool isCurrentModerator() const;
|
2020-08-03 13:27:42 -04:00
|
|
|
Q_INVOKABLE void holdThisCallToggle();
|
2021-10-19 15:24:19 -04:00
|
|
|
Q_INVOKABLE void muteThisCallToggle(bool mute);
|
2020-08-03 13:27:42 -04:00
|
|
|
Q_INVOKABLE void recordThisCallToggle();
|
2021-10-19 15:24:19 -04:00
|
|
|
Q_INVOKABLE void videoPauseThisCallToggle(bool mute);
|
2020-07-23 17:03:11 -04:00
|
|
|
Q_INVOKABLE bool isRecordingThisCall();
|
2020-07-24 15:15:47 -04:00
|
|
|
Q_INVOKABLE QVariantList getConferencesInfos();
|
2020-11-13 10:49:19 -05:00
|
|
|
Q_INVOKABLE void muteParticipant(const QString& uri, const bool state);
|
2021-01-05 11:26:20 +01:00
|
|
|
Q_INVOKABLE MuteStates getMuteState(const QString& uri) const;
|
2020-12-10 13:23:13 -05:00
|
|
|
Q_INVOKABLE void hangupParticipant(const QString& uri);
|
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);
|
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-25 14:32:34 -04:00
|
|
|
void updateParticipantsInfos(const QVariantList& infos,
|
|
|
|
const QString& accountId,
|
|
|
|
const QString& callId);
|
2020-08-03 13:27:42 -04:00
|
|
|
void previewVisibilityNeedToChange(bool visible);
|
|
|
|
|
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
|
|
|
void showOnHoldLabel(bool isPaused);
|
|
|
|
void updateOverlay(bool isPaused,
|
|
|
|
bool isAudioOnly,
|
|
|
|
bool isAudioMuted,
|
|
|
|
bool isVideoMuted,
|
|
|
|
bool isSIP,
|
2021-05-26 16:35:07 -04:00
|
|
|
bool isConferenceCall,
|
2021-10-15 11:34:17 -04:00
|
|
|
bool isGrid,
|
|
|
|
const QString& previewId);
|
2020-12-17 12:40:08 +01:00
|
|
|
void remoteRecordingChanged(const QStringList& peers, bool state);
|
2021-05-21 14:14:56 -04:00
|
|
|
void eraseRemoteRecording();
|
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 onParticipantsChanged(const QString& confId);
|
|
|
|
void onCallStatusChanged(const QString& callId, int code);
|
|
|
|
void onRemoteRecordingChanged(const QString& callId, const QSet<QString>& peerRec, bool state);
|
2021-05-31 13:20:08 -04:00
|
|
|
void onCallAddedToConference(const QString& callId, const QString& confId);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
private:
|
2021-05-21 14:14:56 -04:00
|
|
|
void updateRecordingPeers(bool eraseLabelOnEmpty = false);
|
2020-08-03 13:27:42 -04:00
|
|
|
bool shouldShowPreview(bool force);
|
2020-09-14 13:04:57 -04:00
|
|
|
void showNotification(const QString& accountId, const QString& convUid);
|
2021-01-05 11:26:20 +01:00
|
|
|
QJsonObject fillParticipantData(QMap<QString, QString> participant);
|
2021-05-31 13:20:08 -04:00
|
|
|
void preventScreenSaver(bool state);
|
|
|
|
void updateCallOverlay(const lrc::api::conversation::Info& convInfo);
|
|
|
|
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-05-31 13:20:08 -04:00
|
|
|
VectorString currentConfSubcalls_;
|
2020-08-03 13:27:42 -04:00
|
|
|
};
|