Commit 2b7d5134 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

Robust to cases where several calls are received at the same time

parent a207be45
......@@ -227,6 +227,14 @@ ManagerImpl::outgoingCall(const std::string& accountid, const CallID& id, const
bool
ManagerImpl::answerCall(const CallID& id)
{
bool isActive = false;
AccountID currentaccountid = getAccountFromCall( id );
Call* currentcall = getAccountLink(currentaccountid)->getCall(getCurrentCallId());
_debug("ManagerImpl::answerCall :: current call->getState %i \n",currentcall->getState());
if (currentcall->getState() == 1)
isActive = true;
stopTone(false);
_debug("Try to answer call: %s\n", id.data());
......@@ -236,10 +244,27 @@ ManagerImpl::answerCall(const CallID& id)
return false;
}
if (id != getCurrentCallId()) {
/*
_debug("_nbIncomingWaitingCall =======>>>>>>>> %i \n",_nbIncomingWaitingCall);
CallIDSet::iterator iter = _waitingCall.begin();
while (iter != _waitingCall.end()) {
CallID ident = *iter;
AccountID acc = getAccountFromCall( ident );
Call* call = getAccountLink(acc)->getCall(ident);
_debug("ManagerImpl::answerCall :: incoming call ident: %s \n",ident.c_str());
_debug("ManagerImpl::answerCall :: incoming call state: %i \n",call->getState());
++iter;
}
*/
// if (id != getCurrentCallId()) {
if (isActive) {
_debug("* Manager Info: there is currently a call, try to hold it\n");
onHoldCall(getCurrentCallId());
}
if (!getAccountLink(accountid)->answer(id)) {
// error when receiving...
......@@ -323,7 +348,7 @@ ManagerImpl::onHoldCall(const CallID& id)
stopTone(true);
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
_debug("5 Manager On Hold Call: Account ID %s or callid %s desn't exists\n", accountid.c_str(), id.c_str());
_debug("5 Manager On Hold Call: Account ID %s or callid %s doesn't exists\n", accountid.c_str(), id.c_str());
return false;
}
......@@ -604,13 +629,21 @@ ManagerImpl::incomingCall(Call* call, const AccountID& accountId)
associateCallToAccount(call->getCallId(), accountId);
_debug("ManagerImpl::incomingCall :: hasCurrentCall() %i \n",hasCurrentCall());
if ( !hasCurrentCall() ) {
call->setConnectionState(Call::Ringing);
ringtone();
switchCall(call->getCallId());
} else {
}
/*
else {
addWaitingCall(call->getCallId());
}
*/
addWaitingCall(call->getCallId());
from = call->getPeerName();
number = call->getPeerNumber();
......@@ -624,6 +657,15 @@ ManagerImpl::incomingCall(Call* call, const AccountID& accountId)
from.append(number);
from.append(">");
}
/*
CallIDSet::iterator iter = _waitingCall.begin();
while (iter != _waitingCall.end()) {
CallID ident = *iter;
_debug("ManagerImpl::incomingCall :: CALL iteration: %s \n",ident.c_str());
++iter;
}
*/
/* Broadcast a signal over DBus */
_dbus->getCallManager()->incomingCall(accountId, call->getCallId(), from);
......
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