Commit 8291487d authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk
Browse files

newcallmodel: add setCurrentCall logic

Change-Id: I1377de37deef1814b38f639eda9973ccc266e662
parent ea4f1625
......@@ -1529,10 +1529,6 @@ ConversationModelPimpl::slotCallStatusChanged(const std::string& callId, int cod
}
return;
}
auto& conversation = *i;
auto uid = conversation.uid;
linked.selectConversation(uid);
}
void
......
......@@ -28,6 +28,7 @@
#include "api/conversationmodel.h"
#include "api/contact.h"
#include "api/contactmodel.h"
#include "api/lrc.h"
#include "api/newaccountmodel.h"
#include "authority/storagehelper.h"
#include "dbus/callmanager.h"
......@@ -137,6 +138,13 @@ public:
* Retrieve active conferences from the daemon and init the model
*/
void initConferencesFromDaemon();
/**
* Set a call as the current call (hold other calls)
*/
void setCurrentCall(const std::string& callId);
bool manageCurrentCall_ {true};
bool dontHoldConferences_ {false};
public Q_SLOTS:
/**
* Listen from CallbacksHandler when a call is incoming
......@@ -311,9 +319,10 @@ NewCallModel::togglePause(const std::string& callId) const
auto& call = pimpl_->calls[callId];
if (call->status == call::Status::PAUSED) {
if (call->type == call::Type::DIALOG)
if (call->type == call::Type::DIALOG) {
CallManager::instance().unhold(callId.c_str());
else {
pimpl_->setCurrentCall(callId);
} else {
CallManager::instance().unholdConference(callId.c_str());
}
} else if (call->status == call::Status::IN_PROGRESS) {
......@@ -560,6 +569,29 @@ NewCallModelPimpl::initConferencesFromDaemon()
}
}
void
NewCallModelPimpl::setCurrentCall(const std::string& callId)
{
if (!manageCurrentCall_) return;
std::vector<std::string> filterCalls;
if (dontHoldConferences_) {
// Do not hold calls in a conference
QStringList conferences = CallManager::instance().getConferenceList();
for (const auto& confId : conferences) {
QStringList callList = CallManager::instance().getParticipantList(confId);
foreach(const auto& callId, callList) {
filterCalls.emplace_back(callId.toStdString());
}
}
}
for (const auto& cid : Lrc::activeCalls()) {
auto filtered = std::find(filterCalls.begin(), filterCalls.end(), cid) != filterCalls.end();
if (cid != callId && !filtered) {
CallManager::instance().hold(cid.c_str());
}
}
}
void
NewCallModel::sendSipMessage(const std::string& callId, const std::string& body) const
{
......@@ -645,6 +677,7 @@ NewCallModelPimpl::slotCallStateChanged(const std::string& callId, const std::st
if (previousStatus == call::Status::INCOMING_RINGING
|| previousStatus == call::Status::OUTGOING_RINGING) {
call->startTime = std::chrono::steady_clock::now();
setCurrentCall(callId);
emit linked.callStarted(callId);
sendProfile(callId);
}
......
Markdown is supported
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