Commit fb8639eb authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk
Browse files

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
parent 8dfc664d
......@@ -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>())
......
......@@ -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;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment