Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
savoirfairelinux
jami-daemon
Commits
ba58d452
Commit
ba58d452
authored
Jul 09, 2010
by
Alexandre Savard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[#3649] Migrate hook configuration to new config
parent
7601339d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
24 deletions
+53
-24
sflphone-common/src/managerimpl.cpp
sflphone-common/src/managerimpl.cpp
+47
-18
sflphone-common/src/preferences.cpp
sflphone-common/src/preferences.cpp
+3
-3
sflphone-common/src/preferences.h
sflphone-common/src/preferences.h
+3
-3
No files found.
sflphone-common/src/managerimpl.cpp
View file @
ba58d452
...
...
@@ -3736,6 +3736,8 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
sipaccount
->
setLocalPort
(
atoi
(
localPort
.
data
()));
sipaccount
->
setPublishedPort
(
atoi
(
publishedPort
.
data
()));
// sipaccount->setStunServerName
// sipaccount->setStunServer();
// sipaccount->setStunEnable();
sipaccount
->
setResolveOnce
((
resolveOnce
.
compare
(
"true"
)
==
0
)
?
true
:
false
);
sipaccount
->
setRegistrationExpire
(
registrationExpire
);
...
...
@@ -3746,8 +3748,8 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
// setConfig(accountID, PUBLISHED_ADDRESS, publishedAddress);
// setConfig(accountID, LOCAL_PORT, localPort);
// setConfig(accountID, PUBLISHED_PORT, publishedPort);
setConfig
(
accountID
,
STUN_ENABLE
,
stunEnable
);
setConfig
(
accountID
,
STUN_SERVER
,
stunServer
);
//
setConfig(accountID, STUN_ENABLE, stunEnable);
//
setConfig(accountID, STUN_SERVER, stunServer);
// setConfig(accountID, ACCOUNT_DTMF_TYPE, dtmfType);
// setConfig(accountID, CONFIG_ACCOUNT_RESOLVE_ONCE, resolveOnce);
// setConfig(accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE, registrationExpire);
...
...
@@ -3759,7 +3761,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
setConfig
(
accountID
,
REALM
,
realm
);
// setConfig(accountID, USERAGENT, ua_name);
setConfig
(
accountID
,
AUTHENTICATION_USERNAME
,
authenticationName
);
//
setConfig(accountID, AUTHENTICATION_USERNAME, authenticationName);
sipaccount
->
setUseragent
(
ua_name
);
...
...
@@ -3849,23 +3851,25 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
// setConfig(accountID, TLS_NEGOTIATION_TIMEOUT_MSEC,tlsNegotiationTimeoutMsec);
if
(
!
getMd5CredentialHashing
())
{
setConfig
(
accountID
,
PASSWORD
,
password
);
// setConfig(accountID, PASSWORD, password);
sipaccount
->
setPassword
(
password
);
}
else
{
// Make sure not to re-hash the password field if
// it is already saved as a MD5 Hash.
// TODO: This test is weak. Fix this.
if
((
password
.
compare
(
getConfigString
(
accountID
,
PASSWORD
))
!=
0
))
{
// if ((password.compare(getConfig(accountID, PASSWORD)) != 0)) {
if
((
password
.
compare
(
sipaccount
->
getPassword
())
!=
0
))
{
_debug
(
"Password sent and password from config are different. Re-hashing"
);
std
::
string
hash
;
if
(
authenticationName
.
empty
())
{
hash
=
computeMd5HashFromCredential
(
username
,
password
,
realm
);
}
else
{
hash
=
computeMd5HashFromCredential
(
authenticationName
,
password
,
realm
);
hash
=
computeMd5HashFromCredential
(
authenticationName
,
password
,
realm
);
}
setConfig
(
accountID
,
PASSWORD
,
hash
);
// setConfig(accountID, PASSWORD, hash);
sipaccount
->
setPassword
(
hash
);
}
}
...
...
@@ -3877,8 +3881,6 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
acc
=
getAccount
(
accountID
);
if
(
acc
!=
NULL
)
{
// acc->loadConfig();
if
(
acc
->
isEnabled
())
{
...
...
@@ -3938,7 +3940,8 @@ std::string ManagerImpl::addAccount (
newAccountID
+=
"/"
;
// Prepend the new account
account_list
.
insert
(
0
,
newAccountID
);
setConfig
(
PREFERENCES
,
CONFIG_ACCOUNTS_ORDER
,
account_list
);
// setConfig(PREFERENCES, CONFIG_ACCOUNTS_ORDER, account_list);
preferences
.
setAccountOrder
(
account_list
);
}
saveConfig
();
...
...
@@ -3950,11 +3953,17 @@ std::string ManagerImpl::addAccount (
}
void
ManagerImpl
::
deleteAllCredential
(
const
AccountID
&
accountID
)
{
int
numberOfCredential
=
getConfigInt
(
accountID
,
CONFIG_CREDENTIAL_NUMBER
);
int
i
;
Account
*
account
=
getAccount
(
accountID
);
if
(
account
->
getType
()
!=
"SIP"
)
return
;
SIPAccount
*
sipaccount
=
(
SIPAccount
*
)
account
;
int
numberOfCredential
=
getConfigInt
(
accountID
,
CONFIG_CREDENTIAL_NUMBER
);
for
(
i
=
0
;
i
<
numberOfCredential
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numberOfCredential
;
i
++
)
{
std
::
string
credentialIndex
;
std
::
stringstream
streamOut
;
streamOut
<<
i
;
...
...
@@ -3966,7 +3975,8 @@ void ManagerImpl::deleteAllCredential (const AccountID& accountID) {
}
if
(
accountID
.
empty
()
==
false
)
{
setConfig
(
accountID
,
CONFIG_CREDENTIAL_NUMBER
,
0
);
// setConfig(accountID, CONFIG_CREDENTIAL_NUMBER, 0);
}
}
...
...
@@ -4456,6 +4466,15 @@ std::map<std::string, std::string> ManagerImpl::getHookSettings () {
std
::
map
<
std
::
string
,
std
::
string
>
settings
;
settings
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"URLHOOK_IAX2_ENABLED"
,
hookPreference
.
getIax2Enabled
()
?
"true"
:
"false"
));
settings
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"PHONE_NUMBER_HOOK_ADD_PREFIX"
,
hookPreference
.
getNumberAddPrefix
()));
settings
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"PHONE_NUMBER_HOOK_ENABLED"
,
hookPreference
.
getNumberEnabled
()
?
"true"
:
"false"
));
settings
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"URLHOOK_SIP_ENABLED"
,
hookPreference
.
getSipEnabled
()
?
"true"
:
"false"
));
settings
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"URLHOOK_COMMAND"
,
hookPreference
.
getUrlCommand
()));
settings
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"URLHOOK_SIP_FIELD"
,
hookPreference
.
getUrlSipField
()));
/*
settings.insert(std::pair<std::string, std::string>("URLHOOK_SIP_FIELD",
getConfigString(HOOKS, URLHOOK_SIP_FIELD)));
settings.insert(std::pair<std::string, std::string>("URLHOOK_COMMAND",
...
...
@@ -4471,12 +4490,21 @@ std::map<std::string, std::string> ManagerImpl::getHookSettings () {
"PHONE_NUMBER_HOOK_ADD_PREFIX", getConfigString(HOOKS,
PHONE_NUMBER_HOOK_ADD_PREFIX)));
*/
return
settings
;
}
void
ManagerImpl
::
setHookSettings
(
const
std
::
map
<
std
::
string
,
std
::
string
>&
settings
)
{
void
ManagerImpl
::
setHookSettings
(
const
std
::
map
<
std
::
string
,
std
::
string
>&
settings
)
{
hookPreference
.
setIax2Enabled
((
settings
.
find
(
"URLHOOK_IAX2_ENABLED"
)
->
second
==
"true"
)
?
true
:
false
);
hookPreference
.
setNumberAddPrefix
(
settings
.
find
(
"PHONE_NUMBER_HOOK_ADD_PREFIX"
)
->
second
);
hookPreference
.
setNumberEnabled
((
settings
.
find
(
"PHONE_NUMBER_HOOK_ENABLED"
)
->
second
==
"true"
)
?
true
:
false
);
hookPreference
.
setSipEnabled
((
settings
.
find
(
"URLHOOK_SIP_ENABLED"
)
->
second
==
"true"
)
?
true
:
false
);
hookPreference
.
setUrlCommand
(
settings
.
find
(
"URLHOOK_COMMAND"
)
->
second
);
hookPreference
.
setUrlSipField
(
settings
.
find
(
"URLHOOK_SIP_FIELD"
)
->
second
);
/*
setConfig(HOOKS, URLHOOK_SIP_FIELD,
(*settings.find("URLHOOK_SIP_FIELD")).second);
setConfig(HOOKS, URLHOOK_COMMAND,
...
...
@@ -4489,6 +4517,7 @@ void ManagerImpl::setHookSettings (
"PHONE_NUMBER_HOOK_ENABLED")).second);
setConfig(HOOKS, PHONE_NUMBER_HOOK_ADD_PREFIX, (*settings.find(
"PHONE_NUMBER_HOOK_ADD_PREFIX")).second);
*/
// Write it to the configuration file
saveConfig
();
...
...
sflphone-common/src/preferences.cpp
View file @
ba58d452
...
...
@@ -254,7 +254,7 @@ void AddressbookPreference::unserialize(Conf::MappingNode *map)
HookPreference
::
HookPreference
()
:
_iax2Enabled
(
false
)
,
_numberAddPrefix
(
false
)
,
_numberAddPrefix
(
""
)
,
_numberEnabled
(
false
)
,
_sipEnabled
(
false
)
,
_urlCommand
(
"x-www-browser"
)
...
...
@@ -272,7 +272,7 @@ void HookPreference::serialize(Conf::YamlEmitter *emitter)
Conf
::
MappingNode
preferencemap
(
NULL
);
Conf
::
ScalarNode
iax2Enabled
(
_iax2Enabled
?
"true"
:
"false"
);
Conf
::
ScalarNode
numberAddPrefix
(
_numberAddPrefix
?
"true"
:
"false"
);
Conf
::
ScalarNode
numberAddPrefix
(
_numberAddPrefix
);
Conf
::
ScalarNode
numberEnabled
(
_numberEnabled
?
"true"
:
"false"
);
Conf
::
ScalarNode
sipEnabled
(
_sipEnabled
?
"true"
:
"false"
);
Conf
::
ScalarNode
urlCommand
(
_urlCommand
);
...
...
@@ -297,7 +297,7 @@ void HookPreference::unserialize(Conf::MappingNode *map)
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
;
}
if
(
val
)
{
_numberAddPrefix
=
val
->
getValue
();
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
numberEnabledKey
));
if
(
val
)
{
_numberEnabled
=
(
val
->
getValue
()
==
"true"
)
?
true
:
false
;
val
=
NULL
;
}
val
=
(
Conf
::
ScalarNode
*
)(
map
->
getValue
(
sipEnabledKey
));
...
...
sflphone-common/src/preferences.h
View file @
ba58d452
...
...
@@ -261,8 +261,8 @@ class HookPreference : public Serializable {
bool
getIax2Enabled
(
void
)
{
return
_iax2Enabled
;
}
void
setIax2Enabled
(
bool
i
)
{
_iax2Enabled
=
i
;
}
bool
getNumberAddPrefix
(
void
)
{
return
_numberAddPrefix
;
}
void
setNumberAddPrefix
(
bool
n
)
{
_numberAddPrefix
=
n
;
}
std
::
string
getNumberAddPrefix
(
void
)
{
return
_numberAddPrefix
;
}
void
setNumberAddPrefix
(
std
::
string
n
)
{
_numberAddPrefix
=
n
;
}
bool
getNumberEnabled
(
void
)
{
return
_numberEnabled
;
}
void
setNumberEnabled
(
bool
n
)
{
_numberEnabled
=
n
;
}
...
...
@@ -279,7 +279,7 @@ class HookPreference : public Serializable {
private:
bool
_iax2Enabled
;
// : false
bool
_numberAddPrefix
;
//: false
std
::
string
_numberAddPrefix
;
//: false
bool
_numberEnabled
;
//: false
bool
_sipEnabled
;
//: false
std
::
string
_urlCommand
;
//: x-www-browser
...
...
Write
Preview
Markdown
is supported
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