From 2b7d5134494df35d7540e15f13e2609eb3838d4b Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandre.savard@savoirfairelinux.net> Date: Mon, 2 Mar 2009 18:14:45 -0500 Subject: [PATCH] Robust to cases where several calls are received at the same time --- src/managerimpl.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 70dd45a810..4ad23121b3 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -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); -- GitLab