Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 by Savoir-faire Linux |
| 3 | * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 4 | * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include "lrcinstance.h" |
| 23 | #include "qmladapterbase.h" |
| 24 | |
| 25 | #include <QObject> |
| 26 | #include <QString> |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame] | 27 | #include <QVariant> |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 28 | |
| 29 | class CallAdapter : public QmlAdapterBase |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | |
| 33 | public: |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 34 | explicit CallAdapter(QObject* parent = nullptr); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 35 | ~CallAdapter(); |
| 36 | |
| 37 | /* |
| 38 | * This is needed to be public since it has to be recognized by qml. |
| 39 | */ |
| 40 | Q_INVOKABLE void initQmlObject() override; |
| 41 | |
| 42 | Q_INVOKABLE void placeAudioOnlyCall(); |
| 43 | Q_INVOKABLE void placeCall(); |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 44 | Q_INVOKABLE void hangUpACall(const QString& accountId, const QString& convUid); |
| 45 | Q_INVOKABLE void refuseACall(const QString& accountId, const QString& convUid); |
| 46 | Q_INVOKABLE void acceptACall(const QString& accountId, const QString& convUid); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 47 | |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 48 | Q_INVOKABLE void connectCallModel(const QString& accountId); |
| 49 | Q_INVOKABLE void sipInputPanelPlayDTMF(const QString& key); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 50 | |
| 51 | /* |
| 52 | * For Call Overlay |
| 53 | */ |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame] | 54 | Q_INVOKABLE void hangupCall(const QString& uri); |
| 55 | Q_INVOKABLE void maximizeParticipant(const QString& uri, bool isActive); |
| 56 | Q_INVOKABLE void minimizeParticipant(); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 57 | Q_INVOKABLE void hangUpThisCall(); |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame] | 58 | Q_INVOKABLE bool isCurrentMaster() const; |
ababi | 76b94aa | 2020-08-24 17:46:30 +0200 | [diff] [blame] | 59 | Q_INVOKABLE int getCurrentLayoutType() const; |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 60 | Q_INVOKABLE void holdThisCallToggle(); |
| 61 | Q_INVOKABLE void muteThisCallToggle(); |
| 62 | Q_INVOKABLE void recordThisCallToggle(); |
| 63 | Q_INVOKABLE void videoPauseThisCallToggle(); |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 64 | Q_INVOKABLE bool isRecordingThisCall(); |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame] | 65 | Q_INVOKABLE QVariantList getConferencesInfos(); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 66 | |
| 67 | signals: |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 68 | void showOutgoingCallPage(const QString& accountId, const QString& convUid); |
| 69 | void showIncomingCallPage(const QString& accountId, const QString& convUid); |
| 70 | void showAudioCallPage(const QString& accountId, const QString& convUid); |
| 71 | void showVideoCallPage(const QString& accountId, const QString& convUid, const QString& callId); |
| 72 | void showCallStack(const QString& accountId, const QString& convUid, bool forceReset = false); |
| 73 | void closeCallStack(const QString& accountId, const QString& convUid); |
| 74 | void closePotentialIncomingCallPageWindow(const QString& accountId, const QString& convUid); |
ababi | 76b94aa | 2020-08-24 17:46:30 +0200 | [diff] [blame] | 75 | void callStatusChanged(int index, const QString& accountId, const QString& convUid); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 76 | void updateConversationSmartList(); |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 77 | void updateParticipantsInfos(const QVariantList& infos, |
| 78 | const QString& accountId, |
| 79 | const QString& callId); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 80 | |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 81 | void incomingCallNeedToSetupMainView(const QString& accountId, const QString& convUid); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 82 | void previewVisibilityNeedToChange(bool visible); |
| 83 | |
| 84 | /* |
| 85 | * For Call Overlay |
| 86 | */ |
ababi | 76b94aa | 2020-08-24 17:46:30 +0200 | [diff] [blame] | 87 | void updateTimeText(const QString &time); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 88 | void showOnHoldLabel(bool isPaused); |
| 89 | void updateOverlay(bool isPaused, |
| 90 | bool isAudioOnly, |
| 91 | bool isAudioMuted, |
| 92 | bool isVideoMuted, |
| 93 | bool isRecording, |
| 94 | bool isSIP, |
| 95 | bool isConferenceCall, |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 96 | const QString& bestName); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 97 | |
| 98 | public slots: |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 99 | void slotShowIncomingCallView(const QString& accountId, |
| 100 | const lrc::api::conversation::Info& convInfo); |
| 101 | void slotShowCallView(const QString& accountId, const lrc::api::conversation::Info& convInfo); |
Sébastien Blin | 5f35e19 | 2020-08-06 15:24:57 -0400 | [diff] [blame] | 102 | void slotAccountChanged(); |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 103 | |
| 104 | private: |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 105 | void updateCall(const QString& convUid = {}, |
| 106 | const QString& accountId = {}, |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 107 | bool forceCallOnly = false); |
| 108 | bool shouldShowPreview(bool force); |
| 109 | |
| 110 | /* |
| 111 | * Current conf/call info. |
| 112 | */ |
| 113 | QString accountId_; |
| 114 | QString convUid_; |
| 115 | |
| 116 | QMetaObject::Connection callStatusChangedConnection_; |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame] | 117 | QMetaObject::Connection onParticipantsChangedConnection_; |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 118 | QMetaObject::Connection closeIncomingCallPageConnection_; |
| 119 | |
| 120 | /* |
| 121 | * For Call Overlay |
| 122 | */ |
Ming Rui Zhang | 44dba71 | 2020-08-25 14:32:34 -0400 | [diff] [blame] | 123 | void updateCallOverlay(const lrc::api::conversation::Info& convInfo); |
| 124 | void setTime(const QString& accountId, const QString& convUid); |
| 125 | QTimer* oneSecondTimer_; |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 126 | }; |