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