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
8fc89db3
Commit
8fc89db3
authored
Sep 19, 2011
by
Rafaël Carré
Browse files
Simplify CallManager::placeCallFirstAccount
parent
5cff77e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
daemon/src/dbus/callmanager.cpp
View file @
8fc89db3
...
@@ -40,10 +40,8 @@
...
@@ -40,10 +40,8 @@
#include
"manager.h"
#include
"manager.h"
const
char
*
CallManager
::
SERVER_PATH
=
"/org/sflphone/SFLphone/CallManager"
;
CallManager
::
CallManager
(
DBus
::
Connection
&
connection
)
CallManager
::
CallManager
(
DBus
::
Connection
&
connection
)
:
DBus
::
ObjectAdaptor
(
connection
,
SERVER_PATH
)
:
DBus
::
ObjectAdaptor
(
connection
,
"/org/sflphone/SFLphone/CallManager"
)
{
{
}
}
...
@@ -64,81 +62,39 @@ void
...
@@ -64,81 +62,39 @@ void
CallManager
::
placeCallFirstAccount
(
const
std
::
string
&
callID
,
CallManager
::
placeCallFirstAccount
(
const
std
::
string
&
callID
,
const
std
::
string
&
to
)
const
std
::
string
&
to
)
{
{
if
(
to
==
""
)
{
if
(
to
==
""
)
{
_warn
(
"CallManager: Warning: No number entered, call stopped"
);
_warn
(
"CallManager: Warning: No number entered, call stopped"
);
return
;
return
;
}
}
std
::
vector
<
std
::
string
>
accountOrder
=
Manager
::
instance
().
loadAccountOrder
();
std
::
vector
<
std
::
string
>
accountList
=
Manager
::
instance
().
loadAccountOrder
();
std
::
vector
<
std
::
string
>::
iterator
iter
;
if
(
accountList
.
size
()
==
0
)
accountList
=
Manager
::
instance
().
getAccountList
();
Account
*
account
;
_debug
(
"AccountOrder size: %d"
,
accountOrder
.
size
());
if
(
accountOrder
.
size
()
>
0
)
{
iter
=
accountOrder
.
begin
();
while
(
iter
!=
accountOrder
.
end
())
{
account
=
Manager
::
instance
().
getAccount
(
*
iter
);
if
(
(
*
iter
!=
IP2IP_PROFILE
)
&&
account
->
isEnabled
())
{
Manager
::
instance
().
outgoingCall
(
*
iter
,
callID
,
to
);
return
;
}
iter
++
;
}
}
else
{
_error
(
"AccountOrder is empty"
);
// If accountOrder is empty fallback on accountList (which has no preference order)
std
::
vector
<
std
::
string
>
accountList
=
Manager
::
instance
().
getAccountList
();
iter
=
accountList
.
begin
();
_error
(
"AccountList size: %d"
,
accountList
.
size
());
if
(
accountList
.
size
()
>
0
)
{
while
(
iter
!=
accountList
.
end
())
{
_error
(
"iter"
);
account
=
Manager
::
instance
().
getAccount
(
*
iter
);
if
(
(
*
iter
!=
IP2IP_PROFILE
)
&&
account
->
isEnabled
())
{
_error
(
"makecall"
);
Manager
::
instance
().
outgoingCall
(
*
iter
,
callID
,
to
);
return
;
}
iter
++
;
}
}
}
_warn
(
"CallManager: Warning: No enabled account found, call stopped"
);
std
::
vector
<
std
::
string
>::
const_iterator
iter
;
for
(
iter
=
accountList
.
begin
();
iter
!=
accountList
.
end
();
++
iter
)
{
if
((
*
iter
!=
IP2IP_PROFILE
)
&&
Manager
::
instance
().
getAccount
(
*
iter
)
->
isEnabled
())
{
Manager
::
instance
().
outgoingCall
(
*
iter
,
callID
,
to
);
return
;
}
}
}
}
void
void
CallManager
::
refuse
(
const
std
::
string
&
callID
)
CallManager
::
refuse
(
const
std
::
string
&
callID
)
{
{
_debug
(
"CallManager: Refuse %s"
,
callID
.
c_str
());
Manager
::
instance
().
refuseCall
(
callID
);
Manager
::
instance
().
refuseCall
(
callID
);
}
}
void
void
CallManager
::
accept
(
const
std
::
string
&
callID
)
CallManager
::
accept
(
const
std
::
string
&
callID
)
{
{
_debug
(
"CallManager: Accept received"
);
Manager
::
instance
().
answerCall
(
callID
);
Manager
::
instance
().
answerCall
(
callID
);
}
}
void
void
CallManager
::
hangUp
(
const
std
::
string
&
callID
)
CallManager
::
hangUp
(
const
std
::
string
&
callID
)
{
{
_debug
(
"CallManager: HangUp received %s"
,
callID
.
c_str
());
Manager
::
instance
().
hangupCall
(
callID
);
Manager
::
instance
().
hangupCall
(
callID
);
}
}
...
@@ -146,45 +102,37 @@ CallManager::hangUp (const std::string& callID)
...
@@ -146,45 +102,37 @@ CallManager::hangUp (const std::string& callID)
void
void
CallManager
::
hangUpConference
(
const
std
::
string
&
confID
)
CallManager
::
hangUpConference
(
const
std
::
string
&
confID
)
{
{
_debug
(
"CallManager::hangUpConference received %s"
,
confID
.
c_str
());
Manager
::
instance
().
hangupConference
(
confID
);
Manager
::
instance
().
hangupConference
(
confID
);
}
}
void
void
CallManager
::
hold
(
const
std
::
string
&
callID
)
CallManager
::
hold
(
const
std
::
string
&
callID
)
{
{
_debug
(
"CallManager::hold received %s"
,
callID
.
c_str
());
Manager
::
instance
().
onHoldCall
(
callID
);
Manager
::
instance
().
onHoldCall
(
callID
);
}
}
void
void
CallManager
::
unhold
(
const
std
::
string
&
callID
)
CallManager
::
unhold
(
const
std
::
string
&
callID
)
{
{
_debug
(
"CallManager::unhold received %s"
,
callID
.
c_str
());
Manager
::
instance
().
offHoldCall
(
callID
);
Manager
::
instance
().
offHoldCall
(
callID
);
}
}
void
void
CallManager
::
transfer
(
const
std
::
string
&
callID
,
const
std
::
string
&
to
)
CallManager
::
transfer
(
const
std
::
string
&
callID
,
const
std
::
string
&
to
)
{
{
_debug
(
"CallManager::transfer received"
);
Manager
::
instance
().
transferCall
(
callID
,
to
);
Manager
::
instance
().
transferCall
(
callID
,
to
);
}
}
void
void
CallManager
::
attendedTransfer
(
const
std
::
string
&
transferID
,
const
std
::
string
&
targetID
)
CallManager
::
attendedTransfer
(
const
std
::
string
&
transferID
,
const
std
::
string
&
targetID
)
{
{
_debug
(
"CallManager::attended transfer received"
);
Manager
::
instance
().
attendedTransfer
(
transferID
,
targetID
);
Manager
::
instance
().
attendedTransfer
(
transferID
,
targetID
);
}
}
void
void
CallManager
::
setVolume
(
const
std
::
string
&
device
,
const
double
&
value
)
CallManager
::
setVolume
(
const
std
::
string
&
device
,
const
double
&
value
)
{
{
if
(
device
==
"speaker"
)
{
if
(
device
==
"speaker"
)
{
Manager
::
instance
().
setSpkrVolume
(
(
int
)
(
value
*
100.0
));
Manager
::
instance
().
setSpkrVolume
(
(
int
)
(
value
*
100.0
));
}
else
if
(
device
==
"mic"
)
{
}
else
if
(
device
==
"mic"
)
{
...
@@ -197,12 +145,9 @@ CallManager::setVolume (const std::string& device, const double& value)
...
@@ -197,12 +145,9 @@ CallManager::setVolume (const std::string& device, const double& value)
double
double
CallManager
::
getVolume
(
const
std
::
string
&
device
)
CallManager
::
getVolume
(
const
std
::
string
&
device
)
{
{
if
(
device
==
"speaker"
)
{
if
(
device
==
"speaker"
)
{
_debug
(
"Current speaker = %d"
,
Manager
::
instance
().
getSpkrVolume
());
return
Manager
::
instance
().
getSpkrVolume
()
/
100.0
;
return
Manager
::
instance
().
getSpkrVolume
()
/
100.0
;
}
else
if
(
device
==
"mic"
)
{
}
else
if
(
device
==
"mic"
)
{
_debug
(
"Current mic = %d"
,
Manager
::
instance
().
getMicVolume
());
return
Manager
::
instance
().
getMicVolume
()
/
100.0
;
return
Manager
::
instance
().
getMicVolume
()
/
100.0
;
}
}
...
@@ -212,56 +157,48 @@ CallManager::getVolume (const std::string& device)
...
@@ -212,56 +157,48 @@ CallManager::getVolume (const std::string& device)
void
void
CallManager
::
joinParticipant
(
const
std
::
string
&
sel_callID
,
const
std
::
string
&
drag_callID
)
CallManager
::
joinParticipant
(
const
std
::
string
&
sel_callID
,
const
std
::
string
&
drag_callID
)
{
{
_debug
(
"CallManager: Join participant %s, %s"
,
sel_callID
.
c_str
(),
drag_callID
.
c_str
());
Manager
::
instance
().
joinParticipant
(
sel_callID
,
drag_callID
);
Manager
::
instance
().
joinParticipant
(
sel_callID
,
drag_callID
);
}
}
void
void
CallManager
::
createConfFromParticipantList
(
const
std
::
vector
<
std
::
string
>&
participants
)
CallManager
::
createConfFromParticipantList
(
const
std
::
vector
<
std
::
string
>&
participants
)
{
{
_debug
(
"CallManager: Create conference from participant list"
);
Manager
::
instance
().
createConfFromParticipantList
(
participants
);
Manager
::
instance
().
createConfFromParticipantList
(
participants
);
}
}
void
void
CallManager
::
addParticipant
(
const
std
::
string
&
callID
,
const
std
::
string
&
confID
)
CallManager
::
addParticipant
(
const
std
::
string
&
callID
,
const
std
::
string
&
confID
)
{
{
_debug
(
"CallManager::addParticipant received %s, %s"
,
callID
.
c_str
(),
confID
.
c_str
());
Manager
::
instance
().
addParticipant
(
callID
,
confID
);
Manager
::
instance
().
addParticipant
(
callID
,
confID
);
}
}
void
void
CallManager
::
addMainParticipant
(
const
std
::
string
&
confID
)
CallManager
::
addMainParticipant
(
const
std
::
string
&
confID
)
{
{
_debug
(
"CallManager::addMainParticipant received %s"
,
confID
.
c_str
());
Manager
::
instance
().
addMainParticipant
(
confID
);
Manager
::
instance
().
addMainParticipant
(
confID
);
}
}
void
void
CallManager
::
detachParticipant
(
const
std
::
string
&
callID
)
CallManager
::
detachParticipant
(
const
std
::
string
&
callID
)
{
{
_debug
(
"CallManager::detachParticipant received %s"
,
callID
.
c_str
());
Manager
::
instance
().
detachParticipant
(
callID
,
""
);
Manager
::
instance
().
detachParticipant
(
callID
,
""
);
}
}
void
void
CallManager
::
joinConference
(
const
std
::
string
&
sel_confID
,
const
std
::
string
&
drag_confID
)
CallManager
::
joinConference
(
const
std
::
string
&
sel_confID
,
const
std
::
string
&
drag_confID
)
{
{
_debug
(
"CallManager::joinConference received %s, %s"
,
sel_confID
.
c_str
(),
drag_confID
.
c_str
());
Manager
::
instance
().
joinConference
(
sel_confID
,
drag_confID
);
Manager
::
instance
().
joinConference
(
sel_confID
,
drag_confID
);
}
}
void
void
CallManager
::
holdConference
(
const
std
::
string
&
confID
)
CallManager
::
holdConference
(
const
std
::
string
&
confID
)
{
{
_debug
(
"CallManager::holdConference received %s"
,
confID
.
c_str
());
Manager
::
instance
().
holdConference
(
confID
);
Manager
::
instance
().
holdConference
(
confID
);
}
}
void
void
CallManager
::
unholdConference
(
const
std
::
string
&
confID
)
CallManager
::
unholdConference
(
const
std
::
string
&
confID
)
{
{
_debug
(
"CallManager: Unhold Conference %s"
,
confID
.
c_str
());
Manager
::
instance
().
unHoldConference
(
confID
);
Manager
::
instance
().
unHoldConference
(
confID
);
}
}
...
@@ -280,7 +217,6 @@ CallManager::getConferenceList (void)
...
@@ -280,7 +217,6 @@ CallManager::getConferenceList (void)
std
::
vector
<
std
::
string
>
std
::
vector
<
std
::
string
>
CallManager
::
getParticipantList
(
const
std
::
string
&
confID
)
CallManager
::
getParticipantList
(
const
std
::
string
&
confID
)
{
{
_debug
(
"CallManager: Get Participant list for conference %s"
,
confID
.
c_str
());
return
Manager
::
instance
().
getParticipantList
(
confID
);
return
Manager
::
instance
().
getParticipantList
(
confID
);
}
}
...
@@ -383,7 +319,6 @@ sfl::AudioZrtpSession * CallManager::getAudioZrtpSession (const std::string& cal
...
@@ -383,7 +319,6 @@ sfl::AudioZrtpSession * CallManager::getAudioZrtpSession (const std::string& cal
void
void
CallManager
::
setSASVerified
(
const
std
::
string
&
callID
)
CallManager
::
setSASVerified
(
const
std
::
string
&
callID
)
{
{
try
{
try
{
sfl
::
AudioZrtpSession
*
zSession
;
sfl
::
AudioZrtpSession
*
zSession
;
zSession
=
getAudioZrtpSession
(
callID
);
zSession
=
getAudioZrtpSession
(
callID
);
...
@@ -392,13 +327,11 @@ CallManager::setSASVerified (const std::string& callID)
...
@@ -392,13 +327,11 @@ CallManager::setSASVerified (const std::string& callID)
return
;
return
;
// throw;
// throw;
}
}
}
}
void
void
CallManager
::
resetSASVerified
(
const
std
::
string
&
callID
)
CallManager
::
resetSASVerified
(
const
std
::
string
&
callID
)
{
{
try
{
try
{
sfl
::
AudioZrtpSession
*
zSession
;
sfl
::
AudioZrtpSession
*
zSession
;
zSession
=
getAudioZrtpSession
(
callID
);
zSession
=
getAudioZrtpSession
(
callID
);
...
@@ -407,14 +340,11 @@ CallManager::resetSASVerified (const std::string& callID)
...
@@ -407,14 +340,11 @@ CallManager::resetSASVerified (const std::string& callID)
return
;
return
;
// throw;
// throw;
}
}
}
}
void
void
CallManager
::
setConfirmGoClear
(
const
std
::
string
&
callID
)
CallManager
::
setConfirmGoClear
(
const
std
::
string
&
callID
)
{
{
_debug
(
"CallManager::setConfirmGoClear received for account %s"
,
callID
.
c_str
());
try
{
try
{
sfl
::
AudioZrtpSession
*
zSession
;
sfl
::
AudioZrtpSession
*
zSession
;
zSession
=
getAudioZrtpSession
(
callID
);
zSession
=
getAudioZrtpSession
(
callID
);
...
@@ -423,14 +353,11 @@ CallManager::setConfirmGoClear (const std::string& callID)
...
@@ -423,14 +353,11 @@ CallManager::setConfirmGoClear (const std::string& callID)
return
;
return
;
// throw;
// throw;
}
}
}
}
void
void
CallManager
::
requestGoClear
(
const
std
::
string
&
callID
)
CallManager
::
requestGoClear
(
const
std
::
string
&
callID
)
{
{
_debug
(
"CallManager::requestGoClear received for account %s"
,
callID
.
c_str
());
try
{
try
{
sfl
::
AudioZrtpSession
*
zSession
;
sfl
::
AudioZrtpSession
*
zSession
;
zSession
=
getAudioZrtpSession
(
callID
);
zSession
=
getAudioZrtpSession
(
callID
);
...
@@ -439,15 +366,11 @@ CallManager::requestGoClear (const std::string& callID)
...
@@ -439,15 +366,11 @@ CallManager::requestGoClear (const std::string& callID)
return
;
return
;
/// throw;
/// throw;
}
}
}
}
void
void
CallManager
::
acceptEnrollment
(
const
std
::
string
&
callID
,
const
bool
&
accepted
)
CallManager
::
acceptEnrollment
(
const
std
::
string
&
callID
,
const
bool
&
accepted
)
{
{
_debug
(
"CallManager::acceptEnrollment received for account %s"
,
callID
.
c_str
());
try
{
try
{
sfl
::
AudioZrtpSession
*
zSession
;
sfl
::
AudioZrtpSession
*
zSession
;
zSession
=
getAudioZrtpSession
(
callID
);
zSession
=
getAudioZrtpSession
(
callID
);
...
@@ -456,15 +379,11 @@ CallManager::acceptEnrollment (const std::string& callID, const bool& accepted)
...
@@ -456,15 +379,11 @@ CallManager::acceptEnrollment (const std::string& callID, const bool& accepted)
return
;
return
;
// throw;
// throw;
}
}
}
}
void
void
CallManager
::
setPBXEnrollment
(
const
std
::
string
&
callID
,
const
bool
&
yesNo
)
CallManager
::
setPBXEnrollment
(
const
std
::
string
&
callID
,
const
bool
&
yesNo
)
{
{
_debug
(
"CallManager::setPBXEnrollment received for account %s"
,
callID
.
c_str
());
try
{
try
{
sfl
::
AudioZrtpSession
*
zSession
;
sfl
::
AudioZrtpSession
*
zSession
;
zSession
=
getAudioZrtpSession
(
callID
);
zSession
=
getAudioZrtpSession
(
callID
);
...
@@ -473,7 +392,6 @@ CallManager::setPBXEnrollment (const std::string& callID, const bool& yesNo)
...
@@ -473,7 +392,6 @@ CallManager::setPBXEnrollment (const std::string& callID, const bool& yesNo)
return
;
return
;
// throw;
// throw;
}
}
}
}
void
void
...
...
daemon/src/managerimpl.cpp
View file @
8fc89db3
...
@@ -187,12 +187,12 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
...
@@ -187,12 +187,12 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
const
std
::
string
&
call_id
,
const
std
::
string
&
to
,
const
std
::
string
&
conf_id
)
const
std
::
string
&
call_id
,
const
std
::
string
&
to
,
const
std
::
string
&
conf_id
)
{
{
if
(
call_id
.
empty
())
{
if
(
call_id
.
empty
())
{
_debug
(
"Manager: New outgoing call ab
b
ort, missing callid"
);
_debug
(
"Manager: New outgoing call abort, missing callid"
);
return
false
;
return
false
;
}
}
if
(
account_id
.
empty
())
{
if
(
account_id
.
empty
())
{
_debug
(
"Manager: New outgoing call ab
b
ort, missing account"
);
_debug
(
"Manager: New outgoing call abort, missing account"
);
return
false
;
return
false
;
}
}
...
@@ -2497,35 +2497,25 @@ std::vector<std::string> ManagerImpl::getAccountList () const
...
@@ -2497,35 +2497,25 @@ std::vector<std::string> ManagerImpl::getAccountList () const
else
else
_error
(
"Manager: could not find IP2IP profile in getAccount list"
);
_error
(
"Manager: could not find IP2IP profile in getAccount list"
);
// If no order has been set, load the default one
// If no order has been set, load the default one ie according to the creation date.
// ie according to the creation date.
if
(
account_order
.
empty
())
{
if
(
account_order
.
empty
())
{
_debug
(
"Manager: account order is empty"
);
for
(
AccountMap
::
const_iterator
iter
=
_accountMap
.
begin
();
iter
!=
_accountMap
.
end
();
++
iter
)
{
for
(
AccountMap
::
const_iterator
iter
=
_accountMap
.
begin
();
iter
!=
_accountMap
.
end
();
++
iter
)
{
if
(
iter
->
second
!=
NULL
and
iter
->
first
!=
IP2IP_PROFILE
and
not
iter
->
first
.
empty
())
{
if
(
iter
->
first
==
IP2IP_PROFILE
||
iter
->
first
.
empty
())
_debug
(
"PUSHING BACK %s"
,
iter
->
first
.
c_str
());
continue
;
if
(
iter
->
second
)
v
.
push_back
(
iter
->
second
->
getAccountID
());
v
.
push_back
(
iter
->
second
->
getAccountID
());
}
}
}
else
{
// otherwise, load the custom one
// ie according to the saved order
_debug
(
"Manager: Load account list according to preferences"
);
for
(
vector
<
string
>::
const_iterator
iter
=
account_order
.
begin
();
iter
!=
account_order
.
end
();
++
iter
)
{
// This account has not been loaded, so we ignore it
AccountMap
::
const_iterator
account_iter
=
_accountMap
.
find
(
*
iter
);
if
(
account_iter
!=
_accountMap
.
end
())
{
if
(
account_iter
->
second
and
(
account_iter
->
first
not_eq
IP2IP_PROFILE
)
and
not
account_iter
->
first
.
empty
())
{
// If the account is valid
v
.
push_back
(
account_iter
->
second
->
getAccountID
());
}
}
}
}
return
v
;
}
}
for
(
vector
<
string
>::
const_iterator
iter
=
account_order
.
begin
();
iter
!=
account_order
.
end
();
++
iter
)
{
if
(
*
iter
==
IP2IP_PROFILE
||
*
iter
==
""
)
continue
;
AccountMap
::
const_iterator
account_iter
=
_accountMap
.
find
(
*
iter
);
if
(
account_iter
!=
_accountMap
.
end
()
&&
account_iter
->
second
)
v
.
push_back
(
account_iter
->
second
->
getAccountID
());
}
return
v
;
return
v
;
}
}
...
@@ -2714,11 +2704,7 @@ std::string ManagerImpl::getNewCallID ()
...
@@ -2714,11 +2704,7 @@ std::string ManagerImpl::getNewCallID ()
std
::
vector
<
std
::
string
>
ManagerImpl
::
loadAccountOrder
(
void
)
const
std
::
vector
<
std
::
string
>
ManagerImpl
::
loadAccountOrder
(
void
)
const
{
{
const
std
::
string
account_list
(
preferences
.
getAccountOrder
());
return
unserialize
(
preferences
.
getAccountOrder
());
_debug
(
"Manager: Load account order %s"
,
account_list
.
c_str
());
return
unserialize
(
account_list
);
}
}
void
ManagerImpl
::
loadAccountMap
(
Conf
::
YamlParser
*
parser
)
void
ManagerImpl
::
loadAccountMap
(
Conf
::
YamlParser
*
parser
)
...
...
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