diff --git a/src/lrc.cpp b/src/lrc.cpp index f612b7f826aeaf6a7954fe679dfef3bc595a2c94..91acd433715df2e0763ea8ffc1749ac137631a96 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 a1fbc963d679a640271aaccf1800ab125eb9f0fd..4d8e74d108b40daeb93fb45e30299697ea3a70dd 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; } }