From af60c28e225fd3748e14da7f96cef1693fce9707 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 20 Jan 2017 09:32:10 +0100 Subject: [PATCH] feat(app): calls in progress --- tests/src/components/call/CallModel.cpp | 54 ++++++++++++++++++++++- tests/src/components/call/CallModel.hpp | 14 ++++-- tests/src/components/core/CoreManager.hpp | 4 +- tests/ui/modules/Linphone/Calls/Calls.qml | 6 +++ 4 files changed, 71 insertions(+), 7 deletions(-) diff --git a/tests/src/components/call/CallModel.cpp b/tests/src/components/call/CallModel.cpp index b701e9c7c..28d8dfc84 100644 --- a/tests/src/components/call/CallModel.cpp +++ b/tests/src/components/call/CallModel.cpp @@ -7,6 +7,36 @@ CallModel::CallModel (shared_ptr linphone_call) { m_linphone_call = linphone_call; + + QObject::connect( + &(*CoreManager::getInstance()->getHandlers()), &CoreHandlers::callStateChanged, + this, [this](const std::shared_ptr &call, linphone::CallState state) { + if (call != m_linphone_call) + return; + + switch (state) { + case linphone::CallStateConnected: + case linphone::CallStateEnd: + case linphone::CallStateError: + case linphone::CallStatePaused: + case linphone::CallStateRefered: + case linphone::CallStateReleased: + case linphone::CallStateStreamsRunning: + m_linphone_call_status = state; + break; + + case linphone::CallStatePausedByRemote: + if (m_linphone_call_status != linphone::CallStatePaused) + m_linphone_call_status = state; + break; + + default: + break; + } + + emit statusChanged(getStatus()); + } + ); } // ----------------------------------------------------------------------------- @@ -19,6 +49,10 @@ void CallModel::terminateCall () { CoreManager::getInstance()->getCore()->terminateCall(m_linphone_call); } +void CallModel::transferCall () { + // TODO +} + // ----------------------------------------------------------------------------- QString CallModel::getSipAddress () const { @@ -26,7 +60,7 @@ QString CallModel::getSipAddress () const { } CallModel::CallStatus CallModel::getStatus () const { - switch (m_linphone_call->getState()) { + switch (m_linphone_call_status) { case linphone::CallStateConnected: case linphone::CallStateStreamsRunning: return CallStatusConnected; @@ -48,8 +82,24 @@ CallModel::CallStatus CallModel::getStatus () const { return m_linphone_call->getDir() == linphone::CallDirIncoming ? CallStatusIncoming : CallStatusOutgoing; } +bool CallModel::getMicroMuted () const { + return m_micro_muted; +} + +void CallModel::setMicroMuted (bool status) { + if (m_micro_muted != status) { + m_micro_muted = status; + + shared_ptr core = CoreManager::getInstance()->getCore(); + if (m_micro_muted == core->micEnabled()) + core->enableMic(!m_micro_muted); + + emit microMutedChanged(m_micro_muted); + } +} + bool CallModel::getPausedByUser () const { - return m_linphone_call->getState() == linphone::CallStatePaused; + return m_linphone_call_status == linphone::CallStatePaused; } void CallModel::setPausedByUser (bool status) { diff --git a/tests/src/components/call/CallModel.hpp b/tests/src/components/call/CallModel.hpp index 3f3f67ce8..58893923c 100644 --- a/tests/src/components/call/CallModel.hpp +++ b/tests/src/components/call/CallModel.hpp @@ -10,16 +10,16 @@ class CallModel : public QObject { Q_OBJECT; Q_PROPERTY(QString sipAddress READ getSipAddress CONSTANT); - Q_PROPERTY(CallStatus status READ getStatus NOTIFY statusChanged); Q_PROPERTY(bool isOutgoing READ isOutgoing CONSTANT); - + Q_PROPERTY(bool microMuted READ getMicroMuted WRITE setMicroMuted NOTIFY microMutedChanged); Q_PROPERTY(bool pausedByUser READ getPausedByUser WRITE setPausedByUser NOTIFY pausedByUserChanged); public: enum CallStatus { CallStatusConnected, CallStatusEnded, + CallStatusIdle, CallStatusIncoming, CallStatusOutgoing, CallStatusPaused @@ -32,23 +32,31 @@ public: Q_INVOKABLE void acceptAudioCall (); Q_INVOKABLE void terminateCall (); + Q_INVOKABLE void transferCall (); signals: void statusChanged (CallStatus status); void pausedByUserChanged (bool status); + void microMutedChanged (bool status); private: QString getSipAddress () const; CallStatus getStatus () const; - bool isOutgoing () const { return m_linphone_call->getDir() == linphone::CallDirOutgoing; } + bool getMicroMuted () const; + void setMicroMuted (bool status); + bool getPausedByUser () const; void setPausedByUser (bool status); + bool m_micro_muted = false; + + linphone::CallState m_linphone_call_status = linphone::CallStateIdle; + std::shared_ptr m_linphone_call; }; diff --git a/tests/src/components/core/CoreManager.hpp b/tests/src/components/core/CoreManager.hpp index ef81957c1..abcba7a81 100644 --- a/tests/src/components/core/CoreManager.hpp +++ b/tests/src/components/core/CoreManager.hpp @@ -29,11 +29,11 @@ public: // Singleton models. // --------------------------------------------------------------------------- - ContactsListModel *getContactsListModel () { + ContactsListModel *getContactsListModel () const { return m_contacts_list_model; } - SipAddressesModel *getSipAddressesModel () { + SipAddressesModel *getSipAddressesModel () const { return m_sip_addresses_model; } diff --git a/tests/ui/modules/Linphone/Calls/Calls.qml b/tests/ui/modules/Linphone/Calls/Calls.qml index 7a2780c03..9e056e528 100644 --- a/tests/ui/modules/Linphone/Calls/Calls.qml +++ b/tests/ui/modules/Linphone/Calls/Calls.qml @@ -9,10 +9,16 @@ import Linphone.Styles 1.0 ListView { id: calls + // --------------------------------------------------------------------------- + property var _mapStatusToParams // --------------------------------------------------------------------------- + signal entrySelected (var entry) + + // --------------------------------------------------------------------------- + function _getSignIcon (call) { if (call) { var string = _mapStatusToParams[call.status].string