Commit 716ce26d authored by Sébastien Blin's avatar Sébastien Blin Committed by Kateryna Kostiuk
Browse files

newcallmodel: add method to add a contact to a current call

Change-Id: Id63ddfd6ace0d68e641020d1c90ecd53678428da
parent 8291487d
...@@ -186,6 +186,15 @@ public: ...@@ -186,6 +186,15 @@ public:
*/ */
void joinCalls(const std::string& callIdA, const std::string& callIdB) const; void joinCalls(const std::string& callIdA, const std::string& callIdB) const;
/**
* Call a participant and add it to a call
* @param uri URI of the participant
* @param callId Call receiving the participant
* @param audioOnly If the call is audio only
* @return id for a new call
*/
std::string callAndAddParticipant(const std::string uri, const std::string& callId, bool audioOnly);
/** /**
* Not implemented yet * Not implemented yet
*/ */
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
// std // std
#include <chrono> #include <chrono>
#include <random> #include <random>
#include <map>
// Lrc // Lrc
#include "callbackshandler.h" #include "callbackshandler.h"
...@@ -145,6 +146,7 @@ public: ...@@ -145,6 +146,7 @@ public:
bool manageCurrentCall_ {true}; bool manageCurrentCall_ {true};
bool dontHoldConferences_ {false}; bool dontHoldConferences_ {false};
std::map<std::string, std::string> pendingConferences_;
public Q_SLOTS: public Q_SLOTS:
/** /**
* Listen from CallbacksHandler when a call is incoming * Listen from CallbacksHandler when a call is incoming
...@@ -450,6 +452,14 @@ NewCallModel::joinCalls(const std::string& callIdA, const std::string& callIdB) ...@@ -450,6 +452,14 @@ NewCallModel::joinCalls(const std::string& callIdA, const std::string& callIdB)
} }
} }
std::string
NewCallModel::callAndAddParticipant(const std::string uri, const std::string& callId, bool audioOnly)
{
auto newCallId = createCall(uri, audioOnly);
pimpl_->pendingConferences_.insert({newCallId, callId});
return newCallId;
}
void void
NewCallModel::removeParticipant(const std::string& callId, const std::string& participant) const NewCallModel::removeParticipant(const std::string& callId, const std::string& participant) const
{ {
...@@ -573,6 +583,10 @@ void ...@@ -573,6 +583,10 @@ void
NewCallModelPimpl::setCurrentCall(const std::string& callId) NewCallModelPimpl::setCurrentCall(const std::string& callId)
{ {
if (!manageCurrentCall_) return; if (!manageCurrentCall_) return;
auto it = pendingConferences_.find(callId);
// Set current call only if not adding this call
// to a current conference
if (it != pendingConferences_.end()) return;
std::vector<std::string> filterCalls; std::vector<std::string> filterCalls;
if (dontHoldConferences_) { if (dontHoldConferences_) {
// Do not hold calls in a conference // Do not hold calls in a conference
...@@ -671,16 +685,28 @@ NewCallModelPimpl::slotCallStateChanged(const std::string& callId, const std::st ...@@ -671,16 +685,28 @@ NewCallModelPimpl::slotCallStateChanged(const std::string& callId, const std::st
// NOTE: signal emission order matters, always emit CallStatusChanged before CallEnded // NOTE: signal emission order matters, always emit CallStatusChanged before CallEnded
emit linked.callStatusChanged(callId, code); emit linked.callStatusChanged(callId, code);
if (call->status == call::Status::ENDED) { if (call->status == call::Status::OUTGOING_RINGING) {
setCurrentCall(callId);
} else if (call->status == call::Status::ENDED) {
emit linked.callEnded(callId); emit linked.callEnded(callId);
} else if (call->status == call::Status::IN_PROGRESS) { } else if (call->status == call::Status::IN_PROGRESS) {
if (previousStatus == call::Status::INCOMING_RINGING if (previousStatus == call::Status::INCOMING_RINGING
|| previousStatus == call::Status::OUTGOING_RINGING) { || previousStatus == call::Status::OUTGOING_RINGING) {
if (previousStatus == call::Status::INCOMING_RINGING)
setCurrentCall(callId);
call->startTime = std::chrono::steady_clock::now(); call->startTime = std::chrono::steady_clock::now();
setCurrentCall(callId); setCurrentCall(callId);
emit linked.callStarted(callId); emit linked.callStarted(callId);
sendProfile(callId); sendProfile(callId);
} }
// Add to calls if in pendingConferences_
auto it = pendingConferences_.find(callId);
if (it != pendingConferences_.end()) {
linked.joinCalls(it->second, it->first);
pendingConferences_.erase(it);
}
} }
} }
......
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