Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
51f7409e
Commit
51f7409e
authored
13 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #6655: more cleanup
parent
9e304321
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
daemon/src/managerimpl.cpp
+52
-93
52 additions, 93 deletions
daemon/src/managerimpl.cpp
with
52 additions
and
93 deletions
daemon/src/managerimpl.cpp
+
52
−
93
View file @
51f7409e
...
...
@@ -2581,7 +2581,6 @@ int ManagerImpl::isRingtoneEnabled (const std::string& id)
void
ManagerImpl
::
ringtoneEnabled
(
const
std
::
string
&
id
)
{
Account
*
account
=
getAccount
(
id
);
if
(
!
account
)
{
...
...
@@ -2659,7 +2658,6 @@ void ManagerImpl::setIsAlwaysRecording(bool isAlwaysRec)
return
audioPreference
.
setIsAlwaysRecording
(
isAlwaysRec
);
}
void
ManagerImpl
::
setRecordingCall
(
const
std
::
string
&
id
)
{
Recordable
*
rec
=
NULL
;
...
...
@@ -2958,10 +2956,6 @@ bool ManagerImpl::initAudioDriver (void)
*/
void
ManagerImpl
::
selectAudioDriver
(
void
)
{
int
layerType
,
numCardIn
,
numCardOut
,
numCardRing
,
sampleRate
,
frameSize
;
std
::
string
alsaPlugin
;
AlsaLayer
*
alsalayer
;
audioLayerMutexLock
();
if
(
_audiodriver
==
NULL
)
{
...
...
@@ -2970,22 +2964,19 @@ void ManagerImpl::selectAudioDriver (void)
return
;
}
layerType
=
_audiodriver
->
getLayerType
();
_debug
(
"Manager: Audio layer type: %d"
,
layerType
);
/* Retrieve the global devices info from the user config */
alsaPlugin
=
audioPreference
.
getPlugin
();
numCardIn
=
audioPreference
.
getCardin
();
numCardOut
=
audioPreference
.
getCardout
();
numCardRing
=
audioPreference
.
getCardring
();
std
::
string
alsaPlugin
(
audioPreference
.
getPlugin
()
)
;
int
numCardIn
=
audioPreference
.
getCardin
();
int
numCardOut
=
audioPreference
.
getCardout
();
int
numCardRing
=
audioPreference
.
getCardring
();
sampleRate
=
getMainBuffer
()
->
getInternalSamplingRate
();
frameSize
=
audioPreference
.
getFramesize
();
int
sampleRate
=
getMainBuffer
()
->
getInternalSamplingRate
();
int
frameSize
=
audioPreference
.
getFramesize
();
/* Only for the ALSA layer, we check the sound card information */
if
(
layerType
==
ALSA
)
{
alsalayer
=
dynamic_cast
<
AlsaLayer
*>
(
_audiodriver
);
AlsaLayer
*
alsalayer
=
dynamic_cast
<
AlsaLayer
*>
(
_audiodriver
);
if
(
alsalayer
)
{
if
(
!
alsalayer
->
soundCardIndexExist
(
numCardIn
,
SFL_PCM_CAPTURE
))
{
_debug
(
" Card with index %d doesn't exist or cannot capture. Switch to 0."
,
numCardIn
);
...
...
@@ -3022,9 +3013,6 @@ void ManagerImpl::selectAudioDriver (void)
void
ManagerImpl
::
switchAudioManager
(
void
)
{
int
type
,
samplerate
,
framesize
,
numCardIn
,
numCardOut
,
numCardRing
;
std
::
string
alsaPlugin
;
_debug
(
"Manager: Switching audio manager "
);
audioLayerMutexLock
();
...
...
@@ -3036,18 +3024,18 @@ void ManagerImpl::switchAudioManager (void)
bool
wasStarted
=
_audiodriver
->
isStarted
();
type
=
_audiodriver
->
getLayerType
();
int
type
=
_audiodriver
->
getLayerType
();
samplerate
=
_mainBuffer
.
getInternalSamplingRate
();
framesize
=
audioPreference
.
getFramesize
();
int
samplerate
=
_mainBuffer
.
getInternalSamplingRate
();
int
framesize
=
audioPreference
.
getFramesize
();
_debug
(
"Manager: samplerate: %d, framesize %d"
,
samplerate
,
framesize
);
alsaPlugin
=
audioPreference
.
getPlugin
();
std
::
string
alsaPlugin
(
audioPreference
.
getPlugin
()
)
;
numCardIn
=
audioPreference
.
getCardin
();
numCardOut
=
audioPreference
.
getCardout
();
numCardRing
=
audioPreference
.
getCardring
();
int
numCardIn
=
audioPreference
.
getCardin
();
int
numCardOut
=
audioPreference
.
getCardout
();
int
numCardRing
=
audioPreference
.
getCardring
();
_debug
(
"Manager: Deleting current layer... "
);
...
...
@@ -3055,7 +3043,6 @@ void ManagerImpl::switchAudioManager (void)
_audiodriver
=
NULL
;
switch
(
type
)
{
case
ALSA
:
_debug
(
"Manager: Creating Pulseaudio layer..."
);
_audiodriver
=
new
PulseLayer
(
this
);
...
...
@@ -3091,10 +3078,6 @@ void ManagerImpl::switchAudioManager (void)
void
ManagerImpl
::
audioSamplingRateChanged
(
int
samplerate
)
{
int
type
,
currentSamplerate
,
framesize
,
numCardIn
,
numCardOut
,
numCardRing
;
std
::
string
alsaPlugin
;
bool
wasActive
;
audioLayerMutexLock
();
if
(
!
_audiodriver
)
{
...
...
@@ -3105,7 +3088,7 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
// Only modify internal sampling rate if new sampling rate is higher
currentSamplerate
=
_mainBuffer
.
getInternalSamplingRate
();
int
currentSamplerate
=
_mainBuffer
.
getInternalSamplingRate
();
if
(
currentSamplerate
>=
samplerate
)
{
_debug
(
"Manager: No need to update audio layer sampling rate"
);
audioLayerMutexUnlock
();
...
...
@@ -3114,20 +3097,20 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
else
_debug
(
"Manager: Audio sampling rate changed"
);
type
=
_audiodriver
->
getLayerType
();
framesize
=
audioPreference
.
getFramesize
();
int
type
=
_audiodriver
->
getLayerType
();
int
framesize
=
audioPreference
.
getFramesize
();
_debug
(
"Manager: New samplerate: %d, New framesize %d"
,
samplerate
,
framesize
);
alsaPlugin
=
audioPreference
.
getPlugin
();
std
::
string
alsaPlugin
(
audioPreference
.
getPlugin
()
)
;
numCardIn
=
audioPreference
.
getCardin
();
numCardOut
=
audioPreference
.
getCardout
();
numCardRing
=
audioPreference
.
getCardring
();
int
numCardIn
=
audioPreference
.
getCardin
();
int
numCardOut
=
audioPreference
.
getCardout
();
int
numCardRing
=
audioPreference
.
getCardring
();
_debug
(
"Manager: Deleting current layer..."
);
wasActive
=
_audiodriver
->
isStarted
();
bool
wasActive
=
_audiodriver
->
isStarted
();
delete
_audiodriver
;
_audiodriver
=
0
;
...
...
@@ -3157,9 +3140,8 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
_audiodriver
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
samplerate
,
framesize
,
SFL_PCM_BOTH
,
alsaPlugin
);
if
(
_audiodriver
->
getErrorMessage
()
!=
-
1
)
{
if
(
_audiodriver
->
getErrorMessage
()
!=
-
1
)
notifyErrClient
(
_audiodriver
->
getErrorMessage
());
}
_debug
(
"Manager: Current device: %d "
,
type
);
...
...
@@ -3273,7 +3255,6 @@ std::string ManagerImpl::getConfigString (const std::string& section,
bool
ManagerImpl
::
setConfig
(
const
std
::
string
&
section
,
const
std
::
string
&
name
,
const
std
::
string
&
value
)
{
return
_config
.
setConfigTreeItem
(
section
,
name
,
value
);
}
...
...
@@ -3611,8 +3592,6 @@ short ManagerImpl::loadAccountMap()
{
_debug
(
"Manager: Load account map"
);
int
nbAccount
=
0
;
if
(
!
_setupLoaded
)
{
_error
(
"Manager: Error: Configuration file not loaded yet, could not load config"
);
return
0
;
...
...
@@ -3630,6 +3609,7 @@ short ManagerImpl::loadAccountMap()
// Each element in sequence is a new account to create
Conf
::
Sequence
::
iterator
iterSeq
;
int
nbAccount
=
0
;
for
(
iterSeq
=
seq
->
getSequence
()
->
begin
();
iterSeq
!=
seq
->
getSequence
()
->
end
();
++
iterSeq
)
{
// Pointer to the account and account preferences map
...
...
@@ -3649,16 +3629,14 @@ short ManagerImpl::loadAccountMap()
map
->
getValue
(
"alias"
,
&
accountAlias
);
// do not insert in account map if id or alias is empty
if
(
accountid
.
empty
()
||
accountAlias
.
empty
())
{
if
(
accountid
.
empty
()
or
accountAlias
.
empty
())
continue
;
}
// Create a default account for specific type
if
(
accountType
==
"SIP"
&&
accountid
!=
"IP2IP"
)
{
if
(
accountType
==
"SIP"
&&
accountid
!=
"IP2IP"
)
tmpAccount
=
AccountCreator
::
createAccount
(
AccountCreator
::
SIP_ACCOUNT
,
accountid
);
}
else
if
(
accountType
==
"IAX"
&&
accountid
!=
"IP2IP"
)
{
else
if
(
accountType
==
"IAX"
and
accountid
!=
"IP2IP"
)
tmpAccount
=
AccountCreator
::
createAccount
(
AccountCreator
::
IAX_ACCOUNT
,
accountid
);
}
// Fill account with configuration preferences
if
(
tmpAccount
!=
NULL
)
{
...
...
@@ -3720,37 +3698,31 @@ std::string ManagerImpl::getAccountIdFromNameAndServer (
for
(
AccountMap
::
const_iterator
iter
=
_accountMap
.
begin
();
iter
!=
_accountMap
.
end
();
++
iter
)
{
SIPAccount
*
account
=
dynamic_cast
<
SIPAccount
*>
(
iter
->
second
);
if
(
account
!=
NULL
)
{
if
(
account
->
fullMatch
(
userName
,
server
))
{
if
(
account
and
account
->
fullMatch
(
userName
,
server
))
{
_debug
(
"Manager: Matching account id in request is a fullmatch %s@%s"
,
userName
.
c_str
(),
server
.
c_str
());
return
iter
->
first
;
}
}
}
// We failed! Then only match the hostname
for
(
AccountMap
::
const_iterator
iter
=
_accountMap
.
begin
();
iter
!=
_accountMap
.
end
();
++
iter
)
{
SIPAccount
*
account
=
dynamic_cast
<
SIPAccount
*>
(
iter
->
second
);
if
(
account
!=
NULL
)
{
if
(
account
->
hostnameMatch
(
server
))
{
if
(
account
and
account
->
hostnameMatch
(
server
))
{
_debug
(
"Manager: Matching account id in request with hostname %s"
,
server
.
c_str
());
return
iter
->
first
;
}
}
}
// We failed! Then only match the username
for
(
AccountMap
::
const_iterator
iter
=
_accountMap
.
begin
();
iter
!=
_accountMap
.
end
();
++
iter
)
{
SIPAccount
*
account
=
dynamic_cast
<
SIPAccount
*>
(
iter
->
second
);
if
(
account
!=
NULL
)
{
if
(
account
->
userMatch
(
userName
))
{
if
(
account
and
account
->
userMatch
(
userName
))
{
_debug
(
"Manager: Matching account id in request with username %s"
,
userName
.
c_str
());
return
iter
->
first
;
}
}
}
_debug
(
"Manager: Username %s or server %s doesn't match any account, using IP2IP"
,
userName
.
c_str
(),
server
.
c_str
());
...
...
@@ -3821,7 +3793,6 @@ std::map<std::string, std::string> ManagerImpl::getHookSettings () const
void
ManagerImpl
::
setHookSettings
(
const
std
::
map
<
std
::
string
,
std
::
string
>&
settings
)
{
hookPreference
.
setIax2Enabled
(
settings
.
find
(
"URLHOOK_IAX2_ENABLED"
)
->
second
==
"true"
);
hookPreference
.
setNumberAddPrefix
(
settings
.
find
(
"PHONE_NUMBER_HOOK_ADD_PREFIX"
)
->
second
);
hookPreference
.
setNumberEnabled
(
settings
.
find
(
"PHONE_NUMBER_HOOK_ENABLED"
)
->
second
==
"true"
);
...
...
@@ -3840,7 +3811,7 @@ void ManagerImpl::checkCallConfiguration (const std::string& id,
{
Call
::
CallConfiguration
config
;
if
(
to
.
find
(
SIP_SCHEME
)
==
0
||
to
.
find
(
SIPS_SCHEME
)
==
0
)
{
if
(
to
.
find
(
SIP_SCHEME
)
==
0
or
to
.
find
(
SIPS_SCHEME
)
==
0
)
{
_debug
(
"Manager: Sip scheme detected (sip: or sips:), sending IP2IP Call"
);
config
=
Call
::
IPtoIP
;
}
else
...
...
@@ -3854,7 +3825,6 @@ void ManagerImpl::checkCallConfiguration (const std::string& id,
bool
ManagerImpl
::
associateConfigToCall
(
const
std
::
string
&
callID
,
Call
::
CallConfiguration
config
)
{
if
(
getConfigFromCall
(
callID
)
==
CallConfigNULL
)
{
// nothing with the same ID
_callConfigMap
[
callID
]
=
config
;
_debug
(
"Manager: Associate call %s with config %d"
,
callID
.
c_str
(),
config
);
...
...
@@ -3865,51 +3835,40 @@ bool ManagerImpl::associateConfigToCall (const std::string& callID,
Call
::
CallConfiguration
ManagerImpl
::
getConfigFromCall
(
const
std
::
string
&
callID
)
const
{
CallConfigMap
::
const_iterator
iter
=
_callConfigMap
.
find
(
callID
);
if
(
iter
==
_callConfigMap
.
end
())
{
if
(
iter
==
_callConfigMap
.
end
())
return
(
Call
::
CallConfiguration
)
CallConfigNULL
;
}
else
else
return
iter
->
second
;
}
bool
ManagerImpl
::
removeCallConfig
(
const
std
::
string
&
callID
)
{
if
(
_callConfigMap
.
erase
(
callID
))
{
return
true
;
}
return
false
;
return
_callConfigMap
.
erase
(
callID
);
}
std
::
map
<
std
::
string
,
std
::
string
>
ManagerImpl
::
getCallDetails
(
const
std
::
string
&
callID
)
{
std
::
map
<
std
::
string
,
std
::
string
>
call_details
;
std
::
string
accountid
;
Account
*
account
;
VoIPLink
*
link
;
Call
*
call
=
NULL
;
std
::
stringstream
type
;
// We need here to retrieve the call information attached to the call ID
// To achieve that, we need to get the voip link attached to the call
// But to achieve that, we need to get the account the call was made with
// So first we fetch the account
accountid
=
getAccountFromCall
(
callID
);
const
std
::
string
accountid
(
getAccountFromCall
(
callID
)
)
;
// Then the VoIP link this account is linked with (IAX2 or SIP)
if
(
(
account
=
getAccount
(
accountid
))
!=
NULL
)
{
link
=
account
->
getVoIPLink
();
Call
*
call
=
NULL
;
if
(
Account
*
account
=
getAccount
(
accountid
))
{
VoIPLink
*
link
=
account
->
getVoIPLink
();
if
(
link
)
call
=
link
->
getCall
(
callID
);
}
std
::
map
<
std
::
string
,
std
::
string
>
call_details
;
if
(
call
)
{
std
::
ostringstream
type
;
type
<<
call
->
getCallType
();
call_details
[
"ACCOUNTID"
]
=
accountid
;
call_details
[
"PEER_NUMBER"
]
=
call
->
getPeerNumber
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment