From fb8639eb74df8de272ef8e7b0d3b0b80f13cfa3b Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Wed, 14 Aug 2019 14:34:04 -0400 Subject: [PATCH] callmodel: fix getCallFromURI/getActiveCalls to return active calls - change these functions to return calls in states that indicate that the call is truly current and active Change-Id: Iad8cc5d8a22ddff94fd52e7cb589896482debe86 --- src/lrc.cpp | 23 ++++++++++++++++++++++- src/newcallmodel.cpp | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/lrc.cpp b/src/lrc.cpp index f612b7f8..91acd433 100644 --- a/src/lrc.cpp +++ b/src/lrc.cpp @@ -24,6 +24,8 @@ #include "../../daemon/MSVC/unistd.h" #endif // !_MSC_VER +#include "call_const.h" + // Models and database #include "api/avmodel.h" #include "api/behaviorcontroller.h" @@ -41,6 +43,9 @@ namespace lrc using namespace api; +// To judge whether the call is finished or not depending on callState +bool isFinished(const QString& callState); + class LrcPimpl { @@ -137,11 +142,27 @@ Lrc::activeCalls() std::vector<std::string> result; result.reserve(callLists.size()); for (const auto &call : callLists) { - result.emplace_back(call.toStdString()); + MapStringString callDetails = CallManager::instance().getCallDetails(call); + if(!isFinished(callDetails[QString(DRing::Call::Details::CALL_STATE)])) + result.emplace_back(call.toStdString()); } return result; } +bool +isFinished(const QString& callState) +{ + if (callState == QLatin1String(DRing::Call::StateEvent::HUNGUP) || + callState == QLatin1String(DRing::Call::StateEvent::BUSY) || + callState == QLatin1String(DRing::Call::StateEvent::PEER_BUSY) || + callState == QLatin1String(DRing::Call::StateEvent::FAILURE) || + callState == QLatin1String(DRing::Call::StateEvent::INACTIVE) || + callState == QLatin1String(DRing::Call::StateEvent::OVER)) { + return true; + } + return false; +} + LrcPimpl::LrcPimpl(Lrc& linked, MigrationCb& willMigrateCb, MigrationCb& didMigrateCb) : linked(linked) , behaviorController(std::make_unique<BehaviorController>()) diff --git a/src/newcallmodel.cpp b/src/newcallmodel.cpp index a1fbc963..4d8e74d1 100644 --- a/src/newcallmodel.cpp +++ b/src/newcallmodel.cpp @@ -185,7 +185,7 @@ NewCallModel::getCallFromURI(const std::string& uri, bool notOver) const auto url = (owner.profileInfo.type != profile::Type::SIP && uri.find("ring:") == std::string::npos) ? "ring:" + uri : uri; for (const auto& call: pimpl_->calls) { if (call.second->peerUri == url) { - if (!notOver || call.second->status != call::Status::ENDED) + if (!notOver || !call::isTerminating(call.second->status)) return *call.second; } } -- GitLab