blob: bd7871d792ebe9770157caf7d411537e5728688d [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
2 * Copyright (C) 2020 by Savoir-faire Linux
3 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
Sébastien Blin8940f3c2020-07-23 17:03:11 -04004 * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
Sébastien Blin1f915762020-08-03 13:27:42 -04005 *
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 Blin6607e0e2020-07-24 15:15:47 -040027#include <QVariant>
Sébastien Blin1f915762020-08-03 13:27:42 -040028
29class CallAdapter : public QmlAdapterBase
30{
31 Q_OBJECT
32
33public:
Ming Rui Zhang44dba712020-08-25 14:32:34 -040034 explicit CallAdapter(QObject* parent = nullptr);
Sébastien Blin1f915762020-08-03 13:27:42 -040035 ~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 Zhang44dba712020-08-25 14:32:34 -040044 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 Blin1f915762020-08-03 13:27:42 -040047
Ming Rui Zhang44dba712020-08-25 14:32:34 -040048 Q_INVOKABLE void connectCallModel(const QString& accountId);
49 Q_INVOKABLE void sipInputPanelPlayDTMF(const QString& key);
Sébastien Blin1f915762020-08-03 13:27:42 -040050
51 /*
52 * For Call Overlay
53 */
Sébastien Blin6607e0e2020-07-24 15:15:47 -040054 Q_INVOKABLE void hangupCall(const QString& uri);
55 Q_INVOKABLE void maximizeParticipant(const QString& uri, bool isActive);
56 Q_INVOKABLE void minimizeParticipant();
Sébastien Blin1f915762020-08-03 13:27:42 -040057 Q_INVOKABLE void hangUpThisCall();
Sébastien Blin6607e0e2020-07-24 15:15:47 -040058 Q_INVOKABLE bool isCurrentMaster() const;
ababi76b94aa2020-08-24 17:46:30 +020059 Q_INVOKABLE int getCurrentLayoutType() const;
Sébastien Blin1f915762020-08-03 13:27:42 -040060 Q_INVOKABLE void holdThisCallToggle();
61 Q_INVOKABLE void muteThisCallToggle();
62 Q_INVOKABLE void recordThisCallToggle();
63 Q_INVOKABLE void videoPauseThisCallToggle();
Sébastien Blin8940f3c2020-07-23 17:03:11 -040064 Q_INVOKABLE bool isRecordingThisCall();
Sébastien Blin6607e0e2020-07-24 15:15:47 -040065 Q_INVOKABLE QVariantList getConferencesInfos();
Sébastien Blin1f915762020-08-03 13:27:42 -040066
67signals:
Ming Rui Zhang44dba712020-08-25 14:32:34 -040068 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);
ababi76b94aa2020-08-24 17:46:30 +020075 void callStatusChanged(int index, const QString& accountId, const QString& convUid);
Sébastien Blin1f915762020-08-03 13:27:42 -040076 void updateConversationSmartList();
Ming Rui Zhang44dba712020-08-25 14:32:34 -040077 void updateParticipantsInfos(const QVariantList& infos,
78 const QString& accountId,
79 const QString& callId);
Sébastien Blin1f915762020-08-03 13:27:42 -040080
Ming Rui Zhang44dba712020-08-25 14:32:34 -040081 void incomingCallNeedToSetupMainView(const QString& accountId, const QString& convUid);
Sébastien Blin1f915762020-08-03 13:27:42 -040082 void previewVisibilityNeedToChange(bool visible);
83
84 /*
85 * For Call Overlay
86 */
ababi76b94aa2020-08-24 17:46:30 +020087 void updateTimeText(const QString &time);
Sébastien Blin1f915762020-08-03 13:27:42 -040088 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 Zhang44dba712020-08-25 14:32:34 -040096 const QString& bestName);
Sébastien Blin1f915762020-08-03 13:27:42 -040097
98public slots:
Ming Rui Zhang44dba712020-08-25 14:32:34 -040099 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 Blin5f35e192020-08-06 15:24:57 -0400102 void slotAccountChanged();
Sébastien Blin1f915762020-08-03 13:27:42 -0400103
104private:
Ming Rui Zhang44dba712020-08-25 14:32:34 -0400105 void updateCall(const QString& convUid = {},
106 const QString& accountId = {},
Sébastien Blin1f915762020-08-03 13:27:42 -0400107 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 Blin6607e0e2020-07-24 15:15:47 -0400117 QMetaObject::Connection onParticipantsChangedConnection_;
Sébastien Blin1f915762020-08-03 13:27:42 -0400118 QMetaObject::Connection closeIncomingCallPageConnection_;
119
120 /*
121 * For Call Overlay
122 */
Ming Rui Zhang44dba712020-08-25 14:32:34 -0400123 void updateCallOverlay(const lrc::api::conversation::Info& convInfo);
124 void setTime(const QString& accountId, const QString& convUid);
125 QTimer* oneSecondTimer_;
Sébastien Blin1f915762020-08-03 13:27:42 -0400126};