diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp index a8d406b717fe02a2a05919c7e4e86728f89a64ef..b6a88323440856cf0227fd7aaf61850f2d8bfb4f 100644 --- a/src/conversationmodel.cpp +++ b/src/conversationmodel.cpp @@ -1529,10 +1529,6 @@ ConversationModelPimpl::slotCallStatusChanged(const std::string& callId, int cod } return; } - - auto& conversation = *i; - auto uid = conversation.uid; - linked.selectConversation(uid); } void diff --git a/src/newcallmodel.cpp b/src/newcallmodel.cpp index 1d3b5712da1cb0717b228cef7762b67306e7c0ba..1aa165c6f16dea6d8c8eeaf54697769f1720788a 100644 --- a/src/newcallmodel.cpp +++ b/src/newcallmodel.cpp @@ -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); }