diff --git a/linphone-desktop/src/components/call/CallModel.cpp b/linphone-desktop/src/components/call/CallModel.cpp index 830ae0489..51a04a550 100644 --- a/linphone-desktop/src/components/call/CallModel.cpp +++ b/linphone-desktop/src/components/call/CallModel.cpp @@ -59,54 +59,7 @@ CallModel::CallModel (shared_ptr call) { QObject::connect( CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::callStateChanged, - this, [this](const shared_ptr &call, linphone::CallState state) { - if (call != mCall) - return; - - switch (state) { - case linphone::CallStateError: - setReason(call->getReason()); - case linphone::CallStateEnd: - stopAutoAnswerTimer(); - mPausedByRemote = false; - break; - - case linphone::CallStateConnected: - case linphone::CallStateRefered: - case linphone::CallStateReleased: - case linphone::CallStateStreamsRunning: - mPausedByRemote = false; - break; - - case linphone::CallStatePausedByRemote: - mPausedByRemote = true; - break; - - case linphone::CallStatePausing: - mPausedByUser = true; - break; - - case linphone::CallStateResuming: - mPausedByUser = false; - break; - - case linphone::CallStateUpdatedByRemote: - if ( - !mCall->getCurrentParams()->videoEnabled() && - mCall->getRemoteParams()->videoEnabled() - ) { - mCall->deferUpdate(); - emit videoRequested(); - } - - break; - - default: - break; - } - - emit statusChanged(getStatus()); - } + this, &CallModel::handleCallStateChanged ); } @@ -235,6 +188,57 @@ void CallModel::stopRecording () { // ----------------------------------------------------------------------------- +void CallModel::handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state) { + if (call != mCall) + return; + + switch (state) { + case linphone::CallStateError: + setReason(call->getReason()); + case linphone::CallStateEnd: + stopAutoAnswerTimer(); + mPausedByRemote = false; + break; + + case linphone::CallStateConnected: + case linphone::CallStateRefered: + case linphone::CallStateReleased: + case linphone::CallStateStreamsRunning: + mPausedByRemote = false; + break; + + case linphone::CallStatePausedByRemote: + mPausedByRemote = true; + break; + + case linphone::CallStatePausing: + mPausedByUser = true; + break; + + case linphone::CallStateResuming: + mPausedByUser = false; + break; + + case linphone::CallStateUpdatedByRemote: + if ( + !mCall->getCurrentParams()->videoEnabled() && + mCall->getRemoteParams()->videoEnabled() + ) { + mCall->deferUpdate(); + emit videoRequested(); + } + + break; + + default: + break; + } + + emit statusChanged(getStatus()); +} + +// ----------------------------------------------------------------------------- + void CallModel::stopAutoAnswerTimer () const { QTimer *timer = findChild(AUTO_ANSWER_OBJECT_NAME, Qt::FindDirectChildrenOnly); if (timer) { @@ -333,6 +337,9 @@ inline float computeVu (float volume) { return (volume - VU_MIN) / (VU_MAX - VU_MIN); } +#undef VU_MIN +#undef VU_MAX + float CallModel::getMicroVu () const { return computeVu(mCall->getRecordVolume()); } diff --git a/linphone-desktop/src/components/call/CallModel.hpp b/linphone-desktop/src/components/call/CallModel.hpp index 2a92ca436..b6a6103ac 100644 --- a/linphone-desktop/src/components/call/CallModel.hpp +++ b/linphone-desktop/src/components/call/CallModel.hpp @@ -98,6 +98,8 @@ signals: void statsUpdated (); private: + void handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state); + void stopAutoAnswerTimer () const; QString getSipAddress () const; diff --git a/linphone-desktop/src/components/calls/CallsListModel.cpp b/linphone-desktop/src/components/calls/CallsListModel.cpp index 9b1efbd36..dbecc0dc2 100644 --- a/linphone-desktop/src/components/calls/CallsListModel.cpp +++ b/linphone-desktop/src/components/calls/CallsListModel.cpp @@ -53,28 +53,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) { mCoreHandlers = CoreManager::getInstance()->getHandlers(); QObject::connect( mCoreHandlers.get(), &CoreHandlers::callStateChanged, - this, [this](const shared_ptr &call, linphone::CallState state) { - switch (state) { - case linphone::CallStateIncomingReceived: - case linphone::CallStateOutgoingInit: - addCall(call); - break; - - case linphone::CallStateEnd: - case linphone::CallStateError: - removeCall(call); - break; - - case linphone::CallStateStreamsRunning: { - int index = static_cast(distance(mList.begin(), findCallModel(mList, call))); - emit callRunning(index, &call->getData("call-model")); - } - break; - - default: - break; - } - } + this, &CallsListModel::handleCallStateChanged ); } @@ -148,6 +127,29 @@ void CallsListModel::terminateAllCalls () const { // ----------------------------------------------------------------------------- +void CallsListModel::handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state) { + switch (state) { + case linphone::CallStateIncomingReceived: + case linphone::CallStateOutgoingInit: + addCall(call); + break; + + case linphone::CallStateEnd: + case linphone::CallStateError: + removeCall(call); + break; + + case linphone::CallStateStreamsRunning: { + int index = static_cast(distance(mList.begin(), findCallModel(mList, call))); + emit callRunning(index, &call->getData("call-model")); + } + break; + + default: + break; + } +} + bool CallsListModel::removeRow (int row, const QModelIndex &parent) { return removeRows(row, 1, parent); } diff --git a/linphone-desktop/src/components/calls/CallsListModel.hpp b/linphone-desktop/src/components/calls/CallsListModel.hpp index bf80e4050..7df045579 100644 --- a/linphone-desktop/src/components/calls/CallsListModel.hpp +++ b/linphone-desktop/src/components/calls/CallsListModel.hpp @@ -59,6 +59,8 @@ private: bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; + void handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state); + void addCall (const std::shared_ptr &call); void removeCall (const std::shared_ptr &call);