From db2b154978516e1905c790696ea9d7afca51bcec Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)> Date: Mon, 4 Jan 2010 12:20:18 -0500 Subject: [PATCH] [#2623] Add local interface field in account configuration file --- sflphone-common/src/account.h | 1 + sflphone-common/src/managerimpl.cpp | 7 +++++++ sflphone-common/src/sip/sipaccount.cpp | 5 ++++- sflphone-common/src/sip/sipaccount.h | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h index c7c0424537..22dc6341b7 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -70,6 +70,7 @@ typedef enum RegistrationState { #define REALM "realm" #define DEFAULT_REALM "*" +#define LOCAL_INTERFACE "Account.localInterface" #define PUBLISHED_SAMEAS_LOCAL "Account.publishedSameAsLocal" #define LOCAL_PORT "Account.localPort" #define LOCAL_ADDRESS "Account.localAddress" diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index a409aa5a6d..29dcc62fd9 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2266,6 +2266,7 @@ ManagerImpl::initConfigFile (bool load_user_value, std::string alternate) _config.addDefaultValue (std::pair<std::string, std::string> (TLS_REQUIRE_CLIENT_CERTIFICATE, TRUE_STR), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_SEC, "2"), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_MSEC, "0"), IP2IP_PROFILE); + _config.addDefaultValue (std::pair<std::string, std::string> (LOCAL_INTERFACE, "default"), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (PUBLISHED_SAMEAS_LOCAL, TRUE_STR), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (LOCAL_PORT, DEFAULT_SIP_PORT), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (PUBLISHED_PORT, DEFAULT_SIP_PORT), IP2IP_PROFILE); @@ -3769,6 +3770,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma std::string hostname; std::string displayName; + std::string localInterface; std::string publishedSameasLocal; std::string localAddress; std::string publishedAddress; @@ -3805,6 +3807,10 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma displayName = iter->second; } + if ( (iter = map_cpy.find (LOCAL_INTERFACE)) != map_cpy.end()) { + localInterface = iter->second; + } + if ( (iter = map_cpy.find (PUBLISHED_SAMEAS_LOCAL)) != map_cpy.end()) { publishedSameasLocal = iter->second; } @@ -3935,6 +3941,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma setConfig (accountID, HOSTNAME, hostname); + setConfig (accountID, LOCAL_INTERFACE, localInterface); setConfig (accountID, PUBLISHED_SAMEAS_LOCAL, publishedSameasLocal); setConfig (accountID, LOCAL_ADDRESS, localAddress); setConfig (accountID, PUBLISHED_ADDRESS, publishedAddress); diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 8c624d036b..60085f54af 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -341,8 +341,11 @@ void SIPAccount::loadConfig() // Load network settings // Local parameters - std::string localPort = Manager::instance().getConfigString (_accountID, LOCAL_PORT); + // Load local interface + setLocalInterface(Manager::instance().getConfigString (_accountID, LOCAL_INTERFACE)); + + std::string localPort = Manager::instance().getConfigString (_accountID, LOCAL_PORT); setLocalPort (atoi (localPort.c_str())); // Do not store or use IP address in config as this address may change diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h index db4dbb17ff..855fbe39e4 100644 --- a/sflphone-common/src/sip/sipaccount.h +++ b/sflphone-common/src/sip/sipaccount.h @@ -201,7 +201,7 @@ class SIPAccount : public Account * that the account is bound to the ANY interafec (0.0.0.0). This method should be * when binding the account to a new sip transport only. */ - inline voidsetLocalInterface(const std::string interface&) {_interface = interface;} + inline void setLocalInterface(const std::string& interface) {_interface = interface;} /** * Get the local interface name on which this account is bound. -- GitLab