Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
jami-daemon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
146
Issues
146
List
Boards
Labels
Service Desk
Milestones
Iterations
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
savoirfairelinux
jami-daemon
Commits
d23e280b
Commit
d23e280b
authored
Jul 08, 2010
by
Alexandre Savard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[#3649] Finalize preference parsing and serialization
parent
49a2f72e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
676 additions
and
63 deletions
+676
-63
sflphone-common/sequenceParser.yml
sflphone-common/sequenceParser.yml
+47
-47
sflphone-common/src/config/yamlemitter.cpp
sflphone-common/src/config/yamlemitter.cpp
+92
-1
sflphone-common/src/config/yamlemitter.h
sflphone-common/src/config/yamlemitter.h
+5
-1
sflphone-common/src/config/yamlnode.cpp
sflphone-common/src/config/yamlnode.cpp
+10
-2
sflphone-common/src/config/yamlparser.cpp
sflphone-common/src/config/yamlparser.cpp
+9
-5
sflphone-common/src/config/yamlparser.h
sflphone-common/src/config/yamlparser.h
+3
-3
sflphone-common/src/managerimpl.cpp
sflphone-common/src/managerimpl.cpp
+6
-0
sflphone-common/src/managerimpl.h
sflphone-common/src/managerimpl.h
+6
-0
sflphone-common/src/preferences.cpp
sflphone-common/src/preferences.cpp
+298
-3
sflphone-common/src/preferences.h
sflphone-common/src/preferences.h
+200
-1
No files found.
sflphone-common/sequenceParser.yml
View file @
d23e280b
---
accounts
:
-
id
:
IP2IP
alias
:
...
...
@@ -135,30 +136,30 @@ accounts:
verifyServer
:
false
addressbook
:
photo
:
fals
e
enabled
:
true
list
:
1243608768.30329.0@emilou-desktop/1243456917.15690.23@emilou-desktop/
max
_results
:
25
business
:
true
home
:
false
mobile
:
false
photo
:
tru
e
enabled
:
true
list
:
1243608768.30329.0@emilou-desktop/1243456917.15690.23@emilou-desktop/
max
Results
:
25
business
:
true
home
:
false
mobile
:
false
audio
:
alsa
:
cardin
:
0
cardout
:
0
cardout
:
0
framesize
:
20
plugin
:
default
smplrate
:
44100
cardin
:
0
cardout
:
0
cardout
:
0
framesize
:
20
plugin
:
default
smplrate
:
44100
pulse
:
devicePlayback
:
deviceRecord
:
deviceRingtone
:
recordpath
:
/home/msavard/Bureau
ringchoice
:
/usr/share/sflphone/ringtones/konga.ul
volumemic
:
100
volumespkr
:
100
recordpath
:
/home/msavard/Bureau
ringchoice
:
/usr/share/sflphone/ringtones/konga.ul
volumemic
:
100
volumespkr
:
100
hooks
:
iax2Enabled
:
false
...
...
@@ -169,34 +170,33 @@ hooks:
urlSipField
:
X-sflphone-url
preferences
:
order
:
1234/2345
/
audioApi
:
0
dialpadDisplay
:
0
historyEnabled
:
1
historyLimit
:
30
historyMaxCalls
:
20
notifyAll
:
true
notifyMails
:
false
zoneToneChoice
:
North America
registrationExpire
:
180
ringtoneEnabled
:
true
portNum
:
5060
searchBarDisplay
:
true
startHidden
:
0
volumeDisplay
:
0
windowHeight
:
332
windowPopup
:
0
windowPosition
:
0
windowWidth
:
240
zeroConfenable
:
false
md5Hash
:
false
order
:
Account:1278432440/Account:1278432417
/
audioApi
:
0
dialpadDisplay
:
0
historyEnabled
:
1
historyLimit
:
30
historyMaxCalls
:
20
notifyAll
:
true
notifyMails
:
false
zoneToneChoice
:
North America
registrationExpire
:
180
ringtoneEnabled
:
true
portNum
:
5060
searchBarDisplay
:
true
startHidden
:
0
volumeDisplay
:
0
windowHeight
:
332
windowPopup
:
0
windowPosition
:
0
windowWidth
:
240
zeroConfenable
:
false
md5Hash
:
false
voiplink
:
playDtmf
:
true
playTones
:
true
pulseLength
:
250
sendDTMFas
:
0
stunenable
:
0
stunserver
:
stun.sflphone.org
symmetric
:
true
zidFile
:
sfl.zid
\ No newline at end of file
voipPreferences
:
playDtmf
:
true
playTones
:
true
pulseLength
:
250
sendDtmfAs
:
0
symmetric
:
true
zidFile
:
sfl.zid
...
\ No newline at end of file
sflphone-common/src/config/yamlemitter.cpp
View file @
d23e280b
...
...
@@ -173,7 +173,98 @@ void YamlEmitter::serializeVoipPreference(MappingNode *map)
int
preferenceid
,
preferencemapping
;
_debug
(
"YamlEmitter: Serialize preference"
);
_debug
(
"YamlEmitter: Serialize voip preference"
);
if
(
map
->
getType
()
!=
MAPPING
)
throw
YamlEmitterException
(
"Node type is not a mapping while writing preferences"
);
if
((
preferenceid
=
yaml_document_add_scalar
(
&
document
,
NULL
,
(
yaml_char_t
*
)
preferencestr
.
c_str
(),
-
1
,
YAML_PLAIN_SCALAR_STYLE
))
==
0
)
throw
YamlEmitterException
(
"Could not add scalar to document"
);
if
((
preferencemapping
=
yaml_document_add_mapping
(
&
document
,
NULL
,
YAML_BLOCK_MAPPING_STYLE
))
==
0
)
throw
YamlEmitterException
(
"Could not add mapping to document"
);
if
(
!
yaml_document_append_mapping_pair
(
&
document
,
topLevelMapping
,
preferenceid
,
preferencemapping
))
throw
YamlEmitterException
(
"Could not add mapping pair to top leve mapping"
);
Mapping
*
internalmap
=
map
->
getMapping
();
Mapping
::
iterator
iter
=
internalmap
->
begin
();
while
(
iter
!=
internalmap
->
end
())
{
addMappingItem
(
preferencemapping
,
iter
->
first
,
iter
->
second
);
iter
++
;
}
}
void
YamlEmitter
::
serializeAddressbookPreference
(
MappingNode
*
map
)
{
std
::
string
preferencestr
(
"addressbook"
);
int
preferenceid
,
preferencemapping
;
_debug
(
"YamlEmitter: Serialize addressbook preferences"
);
if
(
map
->
getType
()
!=
MAPPING
)
throw
YamlEmitterException
(
"Node type is not a mapping while writing preferences"
);
if
((
preferenceid
=
yaml_document_add_scalar
(
&
document
,
NULL
,
(
yaml_char_t
*
)
preferencestr
.
c_str
(),
-
1
,
YAML_PLAIN_SCALAR_STYLE
))
==
0
)
throw
YamlEmitterException
(
"Could not add scalar to document"
);
if
((
preferencemapping
=
yaml_document_add_mapping
(
&
document
,
NULL
,
YAML_BLOCK_MAPPING_STYLE
))
==
0
)
throw
YamlEmitterException
(
"Could not add mapping to document"
);
if
(
!
yaml_document_append_mapping_pair
(
&
document
,
topLevelMapping
,
preferenceid
,
preferencemapping
))
throw
YamlEmitterException
(
"Could not add mapping pair to top leve mapping"
);
Mapping
*
internalmap
=
map
->
getMapping
();
Mapping
::
iterator
iter
=
internalmap
->
begin
();
while
(
iter
!=
internalmap
->
end
())
{
addMappingItem
(
preferencemapping
,
iter
->
first
,
iter
->
second
);
iter
++
;
}
}
void
YamlEmitter
::
serializeHooksPreference
(
MappingNode
*
map
)
{
std
::
string
preferencestr
(
"hooks"
);
int
preferenceid
,
preferencemapping
;
_debug
(
"YamlEmitter: Serialize hooks preferences"
);
if
(
map
->
getType
()
!=
MAPPING
)
throw
YamlEmitterException
(
"Node type is not a mapping while writing preferences"
);
if
((
preferenceid
=
yaml_document_add_scalar
(
&
document
,
NULL
,
(
yaml_char_t
*
)
preferencestr
.
c_str
(),
-
1
,
YAML_PLAIN_SCALAR_STYLE
))
==
0
)
throw
YamlEmitterException
(
"Could not add scalar to document"
);
if
((
preferencemapping
=
yaml_document_add_mapping
(
&
document
,
NULL
,
YAML_BLOCK_MAPPING_STYLE
))
==
0
)
throw
YamlEmitterException
(
"Could not add mapping to document"
);
if
(
!
yaml_document_append_mapping_pair
(
&
document
,
topLevelMapping
,
preferenceid
,
preferencemapping
))
throw
YamlEmitterException
(
"Could not add mapping pair to top leve mapping"
);
Mapping
*
internalmap
=
map
->
getMapping
();
Mapping
::
iterator
iter
=
internalmap
->
begin
();
while
(
iter
!=
internalmap
->
end
())
{
addMappingItem
(
preferencemapping
,
iter
->
first
,
iter
->
second
);
iter
++
;
}
}
void
YamlEmitter
::
serializeAudioPreference
(
MappingNode
*
map
)
{
std
::
string
preferencestr
(
"audio"
);
int
preferenceid
,
preferencemapping
;
_debug
(
"YamlEmitter: Serialize hooks preferences"
);
if
(
map
->
getType
()
!=
MAPPING
)
throw
YamlEmitterException
(
"Node type is not a mapping while writing preferences"
);
...
...
sflphone-common/src/config/yamlemitter.h
View file @
d23e280b
...
...
@@ -81,7 +81,11 @@ class YamlEmitter {
void
serializeVoipPreference
(
MappingNode
*
map
);
void
writeAddressbook
();
void
serializeAddressbookPreference
(
MappingNode
*
map
);
void
serializeHooksPreference
(
MappingNode
*
map
);
void
serializeAudioPreference
(
MappingNode
*
map
);
void
writeAudio
();
...
...
sflphone-common/src/config/yamlnode.cpp
View file @
d23e280b
...
...
@@ -29,6 +29,7 @@
*/
#include "yamlnode.h"
#include "src/global.h"
namespace
Conf
{
...
...
@@ -65,7 +66,7 @@ void MappingNode::setKeyValue(Key key, YamlNode *value)
void
MappingNode
::
removeKeyValue
(
Key
key
)
{
Mapping
::
iterator
it
=
map
.
find
(
key
);
Mapping
::
iterator
it
=
map
.
find
(
key
);
map
.
erase
(
it
);
}
...
...
@@ -73,7 +74,14 @@ void MappingNode::removeKeyValue(Key key)
YamlNode
*
MappingNode
::
getValue
(
Key
key
)
{
Mapping
::
iterator
it
=
map
.
find
(
key
);
return
it
->
second
;
if
(
it
!=
map
.
end
())
{
return
it
->
second
;
}
else
{
_debug
(
"Could not fine %s"
,
key
.
c_str
());
return
NULL
;
}
}
...
...
sflphone-common/src/config/yamlparser.cpp
View file @
d23e280b
...
...
@@ -250,7 +250,7 @@ void YamlParser::processDocument()
void
YamlParser
::
processScalar
(
YamlNode
*
topNode
)
{
//
_debug("YamlParser: process scalar");
_debug
(
"YamlParser: process scalar"
);
if
(
!
topNode
)
throw
YamlParserException
(
"No container for scalar"
);
...
...
@@ -279,7 +279,7 @@ void YamlParser::processScalar(YamlNode *topNode)
void
YamlParser
::
processSequence
(
YamlNode
*
topNode
)
{
//
_debug("YamlParser: process sequence");
_debug
(
"YamlParser: process sequence"
);
if
(
!
topNode
)
throw
YamlParserException
(
"No container for sequence"
);
...
...
@@ -328,7 +328,7 @@ void YamlParser::processSequence(YamlNode *topNode)
void
YamlParser
::
processMapping
(
YamlNode
*
topNode
)
{
// _debug("YamlParser: process mapping
");
_debug
(
"YamlParser: process mapping -----------------------------------------
"
);
if
(
!
topNode
)
throw
YamlParserException
(
"No container for mapping"
);
...
...
@@ -436,24 +436,28 @@ void YamlParser::mainNativeDataMapping(MappingNode *map) {
_debug
(
"Iterating: %s"
,
iter
->
first
.
c_str
());
if
(
accounts
.
compare
(
iter
->
first
)
==
0
)
{
_debug
(
"Adding voip account sequence"
);
accountSequence
=
(
SequenceNode
*
)(
iter
->
second
);
}
else
if
(
addressbook
.
compare
(
iter
->
first
)
==
0
)
{
_debug
(
"Adding voip addressbook sequence"
);
addressbookSequence
=
(
SequenceNode
*
)(
iter
->
second
);
}
else
if
(
audio
.
compare
(
iter
->
first
)
==
0
)
{
_debug
(
"Adding voip audio sequence"
);
audioSequence
=
(
SequenceNode
*
)(
iter
->
second
);
}
else
if
(
hooks
.
compare
(
iter
->
first
)
==
0
)
{
_debug
(
"Adding voip hooks sequence"
);
hooksSequence
=
(
SequenceNode
*
)(
iter
->
second
);
}
else
if
(
preferences
.
compare
(
iter
->
first
)
==
0
)
{
_debug
(
"Adding voip preference sequence"
);
preferenceSequence
=
(
SequenceNode
*
)(
iter
->
second
);
}
else
if
(
voiplink
.
compare
(
iter
->
first
)
==
0
)
{
_debug
(
"Adding voip
preference
sequence"
);
_debug
(
"Adding voip
voip
sequence"
);
voiplinkSequence
=
(
SequenceNode
*
)(
iter
->
second
);
_debug
(
"Added"
);
}
else
throw
YamlParserException
(
"Unknow map key in configuration"
);
...
...
sflphone-common/src/config/yamlparser.h
View file @
d23e280b
...
...
@@ -82,11 +82,11 @@ class YamlParser {
SequenceNode
*
getPreferenceSequence
(
void
)
{
return
preferenceSequence
;
}
SequenceNode
*
getAddressbookSequence
(
void
)
{
return
preference
Sequence
;
}
SequenceNode
*
getAddressbookSequence
(
void
)
{
return
addressbook
Sequence
;
}
SequenceNode
*
getAudioSequence
(
void
)
{
return
preference
Sequence
;
}
SequenceNode
*
getAudioSequence
(
void
)
{
return
audio
Sequence
;
}
SequenceNode
*
getHook
sSequence
(
void
)
{
return
preference
Sequence
;
}
SequenceNode
*
getHook
Sequence
(
void
)
{
return
hooks
Sequence
;
}
SequenceNode
*
getVoipPreferenceSequence
(
void
)
{
return
voiplinkSequence
;
}
...
...
sflphone-common/src/managerimpl.cpp
View file @
d23e280b
...
...
@@ -1426,6 +1426,9 @@ bool ManagerImpl::saveConfig (void) {
preferences
.
serialize
(
emitter
);
voipPreferences
.
serialize
(
emitter
);
addressbookPreference
.
serialize
(
emitter
);
hookPreference
.
serialize
(
emitter
);
audioPreference
.
serialize
(
emitter
);
emitter
->
serializeData
();
...
...
@@ -4140,6 +4143,9 @@ short ManagerImpl::buildConfiguration() {
// build preferences
preferences
.
unserialize
((
Conf
::
MappingNode
*
)(
parser
->
getPreferenceSequence
()));
voipPreferences
.
unserialize
((
Conf
::
MappingNode
*
)(
parser
->
getVoipPreferenceSequence
()));
addressbookPreference
.
unserialize
((
Conf
::
MappingNode
*
)(
parser
->
getAddressbookSequence
()));
hookPreference
.
unserialize
((
Conf
::
MappingNode
*
)(
parser
->
getHookSequence
()));
audioPreference
.
unserialize
((
Conf
::
MappingNode
*
)(
parser
->
getAudioSequence
()));
Conf
::
SequenceNode
*
seq
=
parser
->
getAccountSequence
();
...
...
sflphone-common/src/managerimpl.h
View file @
d23e280b
...
...
@@ -118,6 +118,12 @@ class ManagerImpl {
VoipPreference
voipPreferences
;
AddressbookPreference
addressbookPreference
;
HookPreference
hookPreference
;
AudioPreference
audioPreference
;
short
buildConfiguration
();
/**
...
...
sflphone-common/src/preferences.cpp
View file @
d23e280b
...
...
@@ -30,6 +30,7 @@
#include "preferences.h"
#include <sstream>
#include "global.h"
Preferences
::
Preferences
()
:
_accountOrder
(
""
)
,
_audioApi
(
0
)
...
...
@@ -53,6 +54,8 @@ Preferences::~Preferences() {}
void
Preferences
::
serialize
(
Conf
::
YamlEmitter
*
emiter
)
{
_debug
(
"Preference: Serialize configuration"
);
Conf
::
MappingNode
preferencemap
(
NULL
);
Conf
::
ScalarNode
order
(
_accountOrder
);
...
...
@@ -92,6 +95,8 @@ void Preferences::serialize(Conf::YamlEmitter *emiter)
void
Preferences
::
unserialize
(
Conf
::
MappingNode
*
map
)
{
_debug
(
"Preference: Unserialize configuration"
);
Conf
::
ScalarNode
*
val
;
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
orderKey
));
...
...
@@ -113,12 +118,302 @@ void Preferences::unserialize(Conf::MappingNode *map)
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
portNumKey
));
if
(
val
)
{
_portNum
=
atoi
(
val
->
getValue
().
data
());
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
searchBarDisplayKey
));
if
(
val
)
{
_searchBarDisplay
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
if
(
val
&&
!
val
->
getValue
().
empty
()
)
{
_searchBarDisplay
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
zeroConfenableKey
));
if
(
val
)
{
_zeroConfenable
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
if
(
val
&&
!
val
->
getValue
().
empty
()
)
{
_zeroConfenable
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
md5HashKey
));
if
(
val
)
{
_md5Hash
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
if
(
val
&&
!
val
->
getValue
().
empty
())
{
_md5Hash
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
}
VoipPreference
::
VoipPreference
()
:
_playDtmf
(
true
)
,
_playTones
(
true
)
,
_pulseLength
(
250
)
,
_sendDtmfAs
(
0
)
,
_symmetricRtp
(
true
)
,
_zidFile
(
"zidFile"
)
{
}
VoipPreference
::~
VoipPreference
()
{}
void
VoipPreference
::
serialize
(
Conf
::
YamlEmitter
*
emitter
)
{
Conf
::
MappingNode
preferencemap
(
NULL
);
Conf
::
ScalarNode
playDtmf
(
_playDtmf
?
"true"
:
"false"
);
Conf
::
ScalarNode
playTones
(
_playTones
?
"true"
:
"false"
);
std
::
stringstream
pulselengthstr
;
pulselengthstr
<<
_pulseLength
;
Conf
::
ScalarNode
pulseLength
(
pulselengthstr
.
str
());
std
::
stringstream
senddtmfstr
;
senddtmfstr
<<
_sendDtmfAs
;
Conf
::
ScalarNode
sendDtmfAs
(
senddtmfstr
.
str
());
Conf
::
ScalarNode
symmetricRtp
(
_symmetricRtp
?
"true"
:
"false"
);
Conf
::
ScalarNode
zidFile
(
_zidFile
.
c_str
());
preferencemap
.
setKeyValue
(
playDtmfKey
,
&
playDtmf
);
preferencemap
.
setKeyValue
(
playTonesKey
,
&
playTones
);
preferencemap
.
setKeyValue
(
pulseLengthKey
,
&
pulseLength
);
preferencemap
.
setKeyValue
(
sendDtmfAsKey
,
&
sendDtmfAs
);
preferencemap
.
setKeyValue
(
symmetricRtpKey
,
&
symmetricRtp
);
preferencemap
.
setKeyValue
(
zidFileKey
,
&
zidFile
);
emitter
->
serializeVoipPreference
(
&
preferencemap
);
}
void
VoipPreference
::
unserialize
(
Conf
::
MappingNode
*
map
)
{
_debug
(
"VoipPreference: Unserialize configuration"
);
Conf
::
ScalarNode
*
val
=
NULL
;
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
playDtmfKey
));
if
(
val
&&
!
val
->
getValue
().
empty
())
{
_playDtmf
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
playTonesKey
));
if
(
val
&&
!
val
->
getValue
().
empty
())
{
_playTones
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
pulseLengthKey
));
if
(
val
)
{
_pulseLength
=
atoi
(
val
->
getValue
().
data
());
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
sendDtmfAsKey
));
if
(
val
)
{
_sendDtmfAs
=
atoi
(
val
->
getValue
().
data
());
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
symmetricRtpKey
));
if
(
val
&&
!
val
->
getValue
().
empty
())
{
_symmetricRtp
=
(
val
->
getValue
().
compare
(
"true"
)
==
0
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
zidFileKey
));
if
(
val
)
{
_zidFile
=
val
->
getValue
().
c_str
();
val
=
NULL
;
}
}
AddressbookPreference
::
AddressbookPreference
()
:
_photo
(
true
)
,
_enabled
(
true
)
,
_list
(
""
)
,
_maxResults
(
25
)
,
_business
(
true
)
,
_home
(
true
)
,
_mobile
(
true
)
{
}
AddressbookPreference
::~
AddressbookPreference
()
{}
void
AddressbookPreference
::
serialize
(
Conf
::
YamlEmitter
*
emitter
)
{
_debug
(
"Addressbook: Serialize configuration"
);
Conf
::
MappingNode
preferencemap
(
NULL
);
Conf
::
ScalarNode
photo
(
_photo
?
"true"
:
"false"
);
Conf
::
ScalarNode
enabled
(
_enabled
?
"true"
:
"false"
);
Conf
::
ScalarNode
list
(
_list
);
std
::
stringstream
maxresultstr
;
maxresultstr
<<
_maxResults
;
Conf
::
ScalarNode
maxResults
(
maxresultstr
.
str
());
Conf
::
ScalarNode
business
(
_business
?
"true"
:
"false"
);
Conf
::
ScalarNode
home
(
_home
?
"true"
:
"false"
);
Conf
::
ScalarNode
mobile
(
_mobile
?
"true"
:
"false"
);
preferencemap
.
setKeyValue
(
photoKey
,
&
photo
);
preferencemap
.
setKeyValue
(
enabledKey
,
&
enabled
);
preferencemap
.
setKeyValue
(
listKey
,
&
list
);
preferencemap
.
setKeyValue
(
maxResultsKey
,
&
maxResults
);
preferencemap
.
setKeyValue
(
businessKey
,
&
business
);
preferencemap
.
setKeyValue
(
homeKey
,
&
home
);
preferencemap
.
setKeyValue
(
mobileKey
,
&
mobile
);
emitter
->
serializeAddressbookPreference
(
&
preferencemap
);
}
void
AddressbookPreference
::
unserialize
(
Conf
::
MappingNode
*
map
)
{
_debug
(
"Addressbook: Unserialize configuration"
);
Conf
::
ScalarNode
*
val
=
NULL
;
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
photoKey
));
if
(
val
&&
!
(
val
->
getValue
().
empty
()))
{
_photo
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
enabledKey
));
if
(
val
&&
!
val
->
getValue
().
empty
())
{
_enabled
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
listKey
));
if
(
val
)
{
_list
=
val
->
getValue
();
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
maxResultsKey
));
if
(
val
)
{
_maxResults
=
atoi
(
val
->
getValue
().
data
());
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
businessKey
));
if
(
val
&&
!
val
->
getValue
().
empty
())
{
_business
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
homeKey
));
if
(
val
&&
!
val
->
getValue
().
empty
())
{
_home
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
mobileKey
));
if
(
val
&&
!
val
->
getValue
().
empty
())
{
_mobile
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
}
HookPreference
::
HookPreference
()
:
_iax2Enabled
(
false
)
,
_numberAddPrefix
(
false
)
,
_numberEnabled
(
false
)
,
_sipEnabled
(
false
)
,
_urlCommand
(
"x-www-browser"
)
,
_urlSipField
(
"X-sflphone-url"
)
{
}
HookPreference
::~
HookPreference
()
{}
void
HookPreference
::
serialize
(
Conf
::
YamlEmitter
*
emitter
)
{
_debug
(
"Hook: Serialize configuration"
);
Conf
::
MappingNode
preferencemap
(
NULL
);
Conf
::
ScalarNode
iax2Enabled
(
_iax2Enabled
?
"true"
:
"false"
);
Conf
::
ScalarNode
numberAddPrefix
(
_numberAddPrefix
?
"true"
:
"false"
);
Conf
::
ScalarNode
numberEnabled
(
_numberEnabled
?
"true"
:
"false"
);
Conf
::
ScalarNode
sipEnabled
(
_sipEnabled
?
"true"
:
"false"
);
Conf
::
ScalarNode
urlCommand
(
_urlCommand
);
Conf
::
ScalarNode
urlSipField
(
_urlSipField
);
preferencemap
.
setKeyValue
(
iax2EnabledKey
,
&
iax2Enabled
);
preferencemap
.
setKeyValue
(
numberAddPrefixKey
,
&
numberAddPrefix
);
preferencemap
.
setKeyValue
(
numberEnabledKey
,
&
numberEnabled
);
preferencemap
.
setKeyValue
(
sipEnabledKey
,
&
sipEnabled
);
preferencemap
.
setKeyValue
(
urlCommandKey
,
&
urlCommand
);
preferencemap
.
setKeyValue
(
urlSipFieldKey
,
&
urlSipField
);
emitter
->
serializeHooksPreference
(
&
preferencemap
);
}
void
HookPreference
::
unserialize
(
Conf
::
MappingNode
*
map
)
{
Conf
::
ScalarNode
*
val
=
NULL
;
_debug
(
"Hook: Unserialize preference"
);
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
iax2EnabledKey
));
if
(
val
)
{
_iax2Enabled
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
numberAddPrefixKey
));
if
(
val
)
{
_numberAddPrefix
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
numberEnabledKey
));
if
(
val
)
{
_numberEnabled
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
sipEnabledKey
));
if
(
val
)
{
_sipEnabled
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
urlCommandKey
));
if
(
val
)
{
_urlCommand
=
val
->
getValue
();
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
urlSipFieldKey
));
if
(
val
)
{
_urlSipField
=
val
->
getValue
();
val
=
NULL
;
}
}
AudioPreference
::
AudioPreference
()
:
_cardin
(
0
)
,
_cardout
(
0
)
,
_cardring
(
0
)
,
_framesize
(
20
)
,
_plugin
(
"default"
)
,
_smplrate
(
44100
)
,
_devicePlayback
(
""
)
,
_deviceRecord
(
""
)
,
_deviceRingtone
(
""
)
,
_recordpath
(
""
)
,
_ringchoice
(
"/usr/share/sflphone/ringtones/konga.ul"
)
,
_volumemic
(
100
)
,
_volumespkr
(
100
)
{
}
AudioPreference
::~
AudioPreference
()
{}