Commit 4ef84dc8 authored by Pierre-Luc Beaudoin's avatar Pierre-Luc Beaudoin

Better event communication between server and clients. There can be only one current call.

parent 4fc061f3
......@@ -41,7 +41,6 @@ CallManager::refuse( const ::DBus::String& callID )
{
_debug("CallManager::refuse received\n");
Manager::instance().refuseCall(callID);
callStateChanged(callID, "HUNGUP");
}
void
......@@ -49,7 +48,6 @@ CallManager::accept( const ::DBus::String& callID )
{
_debug("CallManager::accept received\n");
Manager::instance().answerCall(callID);
callStateChanged(callID, "CURRENT");
}
void
......@@ -57,7 +55,6 @@ CallManager::hangUp( const ::DBus::String& callID )
{
_debug("CallManager::hangUp received\n");
Manager::instance().hangupCall(callID);
callStateChanged(callID, "HUNGUP");
}
......@@ -66,7 +63,6 @@ CallManager::hold( const ::DBus::String& callID )
{
_debug("CallManager::hold received\n");
Manager::instance().onHoldCall(callID);
callStateChanged(callID, "HOLD");
}
......@@ -75,7 +71,6 @@ CallManager::unhold( const ::DBus::String& callID )
{
_debug("CallManager::unhold received\n");
Manager::instance().offHoldCall(callID);
callStateChanged(callID, "UNHOLD");
}
void
......@@ -83,7 +78,6 @@ CallManager::transfert( const ::DBus::String& callID, const ::DBus::String& to )
{
_debug("CallManager::transfert received\n");
Manager::instance().transferCall(callID, to);
callStateChanged(callID, "HUNGUP");
}
void
......
......@@ -215,7 +215,10 @@ bool
ManagerImpl::answerCall(const CallID& id)
{
stopTone(false);
if (hasCurrentCall())
{
onHoldCall(getCurrentCallId());
}
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
_debug("Answering Call: Call doesn't exists\n");
......@@ -224,12 +227,15 @@ ManagerImpl::answerCall(const CallID& id)
if (!getAccountLink(accountid)->answer(id)) {
// error when receiving...
removeCallAccount(id);
return false;
}
//Place current call on hold if it isn't
// if it was waiting, it's waiting no more
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "CURRENT");
removeWaitingCall(id);
switchCall(id);
return true;
......@@ -250,7 +256,7 @@ bool
ManagerImpl::hangupCall(const CallID& id)
{
stopTone(true);
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HUNGUP");
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
_debug("! Manager Hangup Call: Call doesn't exists\n");
......@@ -260,7 +266,8 @@ ManagerImpl::hangupCall(const CallID& id)
bool returnValue = getAccountLink(accountid)->hangup(id);
removeCallAccount(id);
switchCall("");
return returnValue;
}
......@@ -296,7 +303,9 @@ ManagerImpl::onHoldCall(const CallID& id)
}
bool returnValue = getAccountLink(accountid)->onhold(id);
removeWaitingCall(id);
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HOLD");
switchCall("");
return returnValue;
......@@ -312,9 +321,16 @@ ManagerImpl::offHoldCall(const CallID& id)
_debug("5 Manager OffHold Call: Call doesn't exists\n");
return false;
}
//Place current call on hold if it isn't
if (hasCurrentCall())
{
onHoldCall(getCurrentCallId());
}
bool returnValue = getAccountLink(accountid)->offhold(id);
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "UNHOLD");
switchCall(id);
if (returnValue) {
try {
getAudioDriver()->startStream();
......@@ -338,6 +354,7 @@ ManagerImpl::transferCall(const CallID& id, const std::string& to)
bool returnValue = getAccountLink(accountid)->transfer(id, to);
removeWaitingCall(id);
removeCallAccount(id);
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HUNGUP");
switchCall("");
return returnValue;
......@@ -374,6 +391,7 @@ ManagerImpl::refuseCall (const CallID& id)
if (returnValue) {
removeWaitingCall(id);
removeCallAccount(id);
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HUNGUP");
switchCall("");
}
return returnValue;
......@@ -538,8 +556,6 @@ ManagerImpl::playDtmf(char code)
return returnValue;
}
// Multi-thread
bool
ManagerImpl::incomingCallWaiting() {
......@@ -647,26 +663,28 @@ ManagerImpl::peerHungupCall(const CallID& id)
_debug("peerHungupCall: Call doesn't exists\n");
return;
}
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HUNGUP");
if (isCurrentCall(id)) {
stopTone(true);
switchCall("");
}
removeWaitingCall(id);
removeCallAccount(id);
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HUNGUP");
}
//THREAD=VoIP
void
ManagerImpl::callBusy(const CallID& id) {
_debug("Call busy\n");
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "BUSY");
if (isCurrentCall(id) ) {
playATone(Tone::TONE_BUSY);
switchCall("");
}
removeCallAccount(id);
removeWaitingCall(id);
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "BUSY");
}
//THREAD=VoIP
......@@ -674,13 +692,13 @@ void
ManagerImpl::callFailure(const CallID& id)
{
_debug("Call failed\n");
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "FAILURE");
if (isCurrentCall(id) ) {
playATone(Tone::TONE_BUSY);
switchCall("");
}
removeCallAccount(id);
removeWaitingCall(id);
if (_dbus) _dbus->getCallManager()->callStateChanged(id, "FAILURE");
}
......
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