Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
69d101b3
Commit
69d101b3
authored
May 02, 2011
by
Alexandre Savard
Browse files
[#5571] Better logic for hangup (for case where call have not been sent yet)
parent
9da81be9
Changes
2
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/managerimpl.cpp
View file @
69d101b3
...
...
@@ -400,68 +400,70 @@ bool ManagerImpl::answerCall (const CallID& call_id)
}
//THREAD=Main
bool
ManagerImpl
::
hangupCall
(
const
CallID
&
call
_i
d
)
bool
ManagerImpl
::
hangupCall
(
const
CallID
&
call
I
d
)
{
bool
returnValue
=
true
;
_info
(
"Manager: Hangup call %s"
,
call_id
.
c_str
());
// First stop audio layer if there is no call anymore
int
nbCalls
=
getCallList
().
size
();
if
(
nbCalls
<=
0
)
{
AudioLayer
*
audiolayer
=
getAudioDriver
();
AccountID
account_id
;
bool
returnValue
=
true
;
if
(
audiolayer
==
NULL
)
{
_error
(
"Manager: Error: Audio layer was not instantiated"
);
return
returnValue
;
}
_debug
(
"Manager: stop audio stream, there is no call remaining"
,
nbCalls
);
audiolayer
->
stopStream
();
}
if
(
_dbus
==
NULL
)
{
_error
(
"Manager: Error: Dbus layer have not been instantiated"
);
return
false
;
}
if
(
!
isValidCall
(
callId
))
{
// We may still want to tell the client to hangup this call...
_dbus
->
getCallManager
()
->
callStateChanged
(
callId
,
"HUNGUP"
);
return
returnValue
;
}
_info
(
"Manager: Hangup call %s"
,
callId
.
c_str
());
// store the current call id
CallID
current
_c
all
_i
d
=
getCurrentCallId
();
CallID
current
C
all
I
d
=
getCurrentCallId
();
stopTone
();
/* Broadcast a signal over DBus */
_debug
(
"Manager: Send DBUS call state change (HUNGUP) for id %s"
,
call_id
.
c_str
());
if
(
_dbus
)
_dbus
->
getCallManager
()
->
callStateChanged
(
call_id
,
"HUNGUP"
);
_debug
(
"Manager: Send DBUS call state change (HUNGUP) for id %s"
,
callId
.
c_str
());
if
(
participToConference
(
call_id
))
{
Conference
*
conf
=
getConferenceFromCallID
(
call_id
);
_dbus
->
getCallManager
()
->
callStateChanged
(
callId
,
"HUNGUP"
);
if
(
participToConference
(
callId
))
{
Conference
*
conf
=
getConferenceFromCallID
(
callId
);
if
(
conf
!=
NULL
)
{
// remove this participant
removeParticipant
(
call_id
);
processRemainingParticipant
(
current_call_id
,
conf
);
removeParticipant
(
callId
);
processRemainingParticipant
(
currentCallId
,
conf
);
}
}
else
{
// we are not participating to a conference, current call switched to ""
if
(
!
isConference
(
current
_c
all
_i
d
))
if
(
!
isConference
(
current
C
all
I
d
))
{
switchCall
(
""
);
}
}
/* Direct
IP
to
IP
call */
if
(
getConfigFromCall
(
call_id
)
==
Call
::
IPtoIP
)
{
returnValue
=
SIPVoIPLink
::
instance
(
AccountNULL
)
->
hangup
(
call
_i
d
);
if
(
getConfigFromCall
(
callId
)
==
Call
::
IPtoIP
)
{
/* Direct
IP
to
IP
call */
returnValue
=
SIPVoIPLink
::
instance
(
AccountNULL
)
->
hangup
(
call
I
d
);
}
/* Classic call, attached to an account */
else
{
account_id
=
getAccountFromCall
(
call_id
);
// // Account may be NULL if call have not been sent yet
// if (account_id == AccountNULL) {
// _error ("Manager: Error: account id is NULL in hangup");
// returnValue = false;
// } else {
returnValue
=
getAccountLink
(
account_id
)
->
hangup
(
call_id
);
removeCallAccount
(
call_id
);
// }
}
int
nbCalls
=
getCallList
().
size
();
AudioLayer
*
audiolayer
=
getAudioDriver
();
// stop streams
if
(
audiolayer
&&
(
nbCalls
<=
0
))
{
_debug
(
"Manager: stop audio stream, ther is only %d call(s) remaining"
,
nbCalls
);
audiolayer
->
stopStream
();
AccountID
accountId
=
getAccountFromCall
(
callId
);
returnValue
=
getAccountLink
(
accountId
)
->
hangup
(
callId
);
removeCallAccount
(
callId
);
}
return
returnValue
;
...
...
@@ -3704,6 +3706,20 @@ bool ManagerImpl::removeCallAccount (const CallID& callID)
return
false
;
}
bool
ManagerImpl
::
isValidCall
(
const
CallID
&
callID
)
{
ost
::
MutexLock
m
(
_callAccountMapMutex
);
CallAccountMap
::
iterator
iter
=
_callAccountMap
.
find
(
callID
);
if
(
iter
!=
_callAccountMap
.
end
())
{
return
true
;
}
else
{
return
false
;
}
}
CallID
ManagerImpl
::
getNewCallID
()
{
std
::
ostringstream
random_id
(
"s"
);
...
...
sflphone-common/src/managerimpl.h
View file @
69d101b3
...
...
@@ -212,6 +212,7 @@ class ManagerImpl
* Functions which occur with a user's action
* Hangup the call
* @param id The call identifier
* @return true on success
*/
bool
hangupCall
(
const
CallID
&
id
);
...
...
@@ -1331,6 +1332,14 @@ class ManagerImpl
*/
bool
removeCallAccount
(
const
CallID
&
callID
);
/**
* Test if call is a valid call, i.e. have been created and stored in
* call-account map
* @param callID the CallID to be tested
* @return true if call is created and present in the call-account map
*/
bool
isValidCall
(
const
CallID
&
callID
);
/**
* Return a pointer to the instance of the mainbuffer
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment