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
4ac4098d
Commit
4ac4098d
authored
Feb 29, 2012
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
refactor accountmap initialization
parent
58775832
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/managerimpl.cpp
+44
-46
44 additions, 46 deletions
daemon/src/managerimpl.cpp
daemon/src/managerimpl.h
+6
-2
6 additions, 2 deletions
daemon/src/managerimpl.h
with
50 additions
and
48 deletions
daemon/src/managerimpl.cpp
+
44
−
46
View file @
4ac4098d
...
...
@@ -62,6 +62,7 @@
#include
<ctime>
#include
<cstdlib>
#include
<iostream>
#include
<algorithm>
#include
<iterator>
#include
<fstream>
#include
<sstream>
...
...
@@ -92,22 +93,18 @@ void ManagerImpl::init(std::string config_file)
path_
=
config_file
.
empty
()
?
createConfigFile
()
:
config_file
;
DEBUG
(
"Manager: configuration file path: %s"
,
path_
.
c_str
());
Conf
::
YamlParser
*
parser
=
NULL
;
try
{
parser
=
new
Conf
::
YamlParser
(
path_
.
c_str
());
parser
->
serializeEvents
();
parser
->
composeEvents
();
parser
->
constructNativeData
();
Conf
::
YamlParser
parser
(
path_
.
c_str
());
parser
.
serializeEvents
();
parser
.
composeEvents
();
parser
.
constructNativeData
();
loadAccountMap
(
parser
);
}
catch
(
const
Conf
::
YamlParserException
&
e
)
{
ERROR
(
"Manager: %s"
,
e
.
what
());
fflush
(
stderr
);
delete
parser
;
parser
=
NULL
;
loadDefaultAccountMap
();
}
loadAccountMap
(
parser
);
delete
parser
;
initAudioDriver
();
{
...
...
@@ -2568,26 +2565,35 @@ std::vector<std::string> ManagerImpl::loadAccountOrder() const
return
unserialize
(
preferences
.
getAccountOrder
());
}
void
ManagerImpl
::
loadAccountMap
(
Conf
::
YamlParser
*
parser
)
void
ManagerImpl
::
load
Default
AccountMap
()
{
// build a default IP2IP account with default parameters
Account
*
ip2ip
=
new
SIPAccount
(
IP2IP_PROFILE
);
accountMap_
[
IP2IP_PROFILE
]
=
ip2ip
;
// If configuration file parsed, load saved preferences
if
(
parser
)
{
Conf
::
Sequence
*
seq
=
parser
->
getAccountSequence
()
->
getSequence
();
for
(
Conf
::
Sequence
::
const_iterator
iter
=
seq
->
begin
();
iter
!=
seq
->
end
();
++
iter
)
{
Conf
::
MappingNode
*
map
=
(
Conf
::
MappingNode
*
)(
*
iter
);
std
::
string
accountid
;
map
->
getValue
(
"id"
,
&
accountid
);
accountMap_
[
IP2IP_PROFILE
]
=
new
SIPAccount
(
IP2IP_PROFILE
);
SIPVoIPLink
::
instance
()
->
createDefaultSipUdpTransport
();
accountMap_
[
IP2IP_PROFILE
]
->
registerVoIPLink
();
}
if
(
accountid
==
"IP2IP"
)
{
ip2ip
->
unserialize
(
map
);
break
;
namespace
{
bool
hasIP2IPAccountID
(
Conf
::
YamlNode
*
node
)
{
std
::
string
id
;
dynamic_cast
<
Conf
::
MappingNode
*>
(
node
)
->
getValue
(
"id"
,
&
id
);
return
id
==
"IP2IP"
;
}
}
void
ManagerImpl
::
loadAccountMap
(
Conf
::
YamlParser
&
parser
)
{
using
namespace
Conf
;
// build a default IP2IP account with default parameters
accountMap_
[
IP2IP_PROFILE
]
=
new
SIPAccount
(
IP2IP_PROFILE
);
// load saved preferences for IP2IP account from configuration file
Sequence
*
seq
=
parser
.
getAccountSequence
()
->
getSequence
();
Sequence
::
const_iterator
ip2ip
=
std
::
find_if
(
seq
->
begin
(),
seq
->
end
(),
hasIP2IPAccountID
);
if
(
ip2ip
!=
seq
->
end
())
{
MappingNode
*
node
=
dynamic_cast
<
MappingNode
*>
(
*
ip2ip
);
accountMap_
[
IP2IP_PROFILE
]
->
unserialize
(
node
);
}
// Initialize default UDP transport according to
...
...
@@ -2596,39 +2602,32 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser *parser)
// Force IP2IP settings to be loaded to be loaded
// No registration in the sense of the REGISTER method is performed.
ip2ip
->
registerVoIPLink
();
if
(
!
parser
)
return
;
accountMap_
[
IP2IP_PROFILE
]
->
registerVoIPLink
();
// build preferences
preferences
.
unserialize
(
parser
->
getPreferenceNode
());
voipPreferences
.
unserialize
(
parser
->
getVoipPreferenceNode
());
addressbookPreference
.
unserialize
(
parser
->
getAddressbookNode
());
hookPreference
.
unserialize
(
parser
->
getHookNode
());
audioPreference
.
unserialize
(
parser
->
getAudioNode
());
shortcutPreferences
.
unserialize
(
parser
->
getShortcutNode
());
Conf
::
Sequence
*
seq
=
parser
->
getAccountSequence
()
->
getSequence
();
preferences
.
unserialize
(
parser
.
getPreferenceNode
());
voipPreferences
.
unserialize
(
parser
.
getVoipPreferenceNode
());
addressbookPreference
.
unserialize
(
parser
.
getAddressbookNode
());
hookPreference
.
unserialize
(
parser
.
getHookNode
());
audioPreference
.
unserialize
(
parser
.
getAudioNode
());
shortcutPreferences
.
unserialize
(
parser
.
getShortcutNode
());
// Each element in sequence is a new account to create
for
(
Conf
::
Sequence
::
const_iterator
iter
=
seq
->
begin
();
iter
!=
seq
->
end
();
++
iter
)
{
Conf
::
MappingNode
*
map
=
(
Conf
::
MappingNode
*
)(
*
iter
);
for
(
Sequence
::
const_iterator
iter
=
seq
->
begin
();
iter
!=
seq
->
end
();
++
iter
)
{
MappingNode
*
node
=
dynamic_cast
<
MappingNode
*>
(
*
iter
);
std
::
string
accountType
;
map
->
getValue
(
"type"
,
&
accountType
);
node
->
getValue
(
"type"
,
&
accountType
);
std
::
string
accountid
;
map
->
getValue
(
"id"
,
&
accountid
);
node
->
getValue
(
"id"
,
&
accountid
);
std
::
string
accountAlias
;
map
->
getValue
(
"alias"
,
&
accountAlias
);
node
->
getValue
(
"alias"
,
&
accountAlias
);
if
(
accountid
.
empty
()
or
accountAlias
.
empty
()
or
accountid
==
IP2IP_PROFILE
)
continue
;
Account
*
a
;
#if HAVE_IAX
if
(
accountType
==
"IAX"
)
a
=
new
IAXAccount
(
accountid
);
...
...
@@ -2637,8 +2636,7 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser *parser)
a
=
new
SIPAccount
(
accountid
);
accountMap_
[
accountid
]
=
a
;
a
->
unserialize
(
map
);
a
->
unserialize
(
node
);
}
}
...
...
...
...
This diff is collapsed.
Click to expand it.
daemon/src/managerimpl.h
+
6
−
2
View file @
4ac4098d
...
...
@@ -996,9 +996,13 @@ class ManagerImpl {
AccountMap
accountMap_
;
/**
* Load the account from configuration
* Load the account
map
from configuration
*/
void
loadAccountMap
(
Conf
::
YamlParser
*
parser
);
void
loadAccountMap
(
Conf
::
YamlParser
&
parser
);
/**
* Load default account map (no configuration)
*/
void
loadDefaultAccountMap
();
/**
* Unload the account (delete them)
...
...
...
...
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
sign in
to comment