From a6e83f1ee88aefbbf30cc19db7f3baf9ac1effd6 Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)> Date: Mon, 12 Apr 2010 16:42:21 -0400 Subject: [PATCH] [#3170] Add domainname in configuration for sip account --- .../src/config/accountconfigdialog.c | 11 +++++++++-- sflphone-client-gnome/src/sflphone_const.h | 4 ++-- sflphone-common/src/account.h | 1 + sflphone-common/src/managerimpl.cpp | 12 ++++++++++++ sflphone-common/src/sip/sipaccount.cpp | 6 ++++-- sflphone-common/src/sip/sipaccount.h | 12 ++++++++++++ 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 295ba4aa79..5fd5ea1b91 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -1334,6 +1334,12 @@ void show_account_window (account_t * a) { g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_USERNAME), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryUsername)))); + if(strcmp(proto, "SIP") == 0) { + g_hash_table_replace(currentAccount->properties, + g_strdup(ACCOUNT_DOMAIN), + g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryDomainName)))); + } + g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_PASSWORD), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryPassword)))); @@ -1350,8 +1356,9 @@ void show_account_window (account_t * a) { if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_USERAGENT), - g_strdup(gtk_entry_get_text (GTK_ENTRY(entryUseragent)))); + g_hash_table_replace(currentAccount->properties, + g_strdup(ACCOUNT_USERAGENT), + g_strdup(gtk_entry_get_text (GTK_ENTRY(entryUseragent)))); g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED), g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox)) ? "true":"false")); diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index 0f081fbad5..bd7f94327c 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -62,10 +62,10 @@ #define ACCOUNT_REGISTRATION_EXPIRE "Account.expire" #define ACCOUNT_SIP_STUN_SERVER "STUN.server" #define ACCOUNT_SIP_STUN_ENABLED "STUN.enable" -#define ACCOUNT_DTMF_TYPE "Account.dtmfType" +#define ACCOUNT_DTMF_TYPE "Account.dtmfType" #define ACCOUNT_HOSTNAME "hostname" #define ACCOUNT_USERNAME "username" -#define ACCOUNT_DOMAIN "domainame" +#define ACCOUNT_DOMAIN "domainname" #define ACCOUNT_PASSWORD "password" #define ACCOUNT_AUTHENTICATION_USERNAME "authenticationUsername" #define ACCOUNT_REALM "realm" diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h index 3272010a2e..5b424a3c06 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -69,6 +69,7 @@ typedef enum RegistrationState { #define HOSTNAME "hostname" #define USERNAME "username" +#define DOMAINNAME "domainname" #define AUTHENTICATION_USERNAME "authenticationUsername" #define PASSWORD "password" #define REALM "realm" diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 89441cf5e0..1ca9d7609a 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -3148,6 +3148,8 @@ std::map<std::string, std::string> ManagerImpl::getAccountDetails ( accountID, HOSTNAME))); a.insert(std::pair<std::string, std::string>(USERNAME, getConfigString( accountID, USERNAME))); + a.insert(std::pair<std::string, std::string>(DOMAINNAME, getConfigString( + accountID, DOMAINNAME))); a.insert(std::pair<std::string, std::string>(PASSWORD, getConfigString( accountID, PASSWORD))); a.insert(std::pair<std::string, std::string>(REALM, getConfigString( @@ -3391,6 +3393,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, map_cpy = details; std::string username; + std::string domain; std::string authenticationName; std::string password; std::string realm; @@ -3405,6 +3408,14 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, username = iter->second; } + if ((iter = map_cpy.find(DOMAINNAME)) != map_cpy.end()) { + domain = iter->second; + _error("DOMAINNAME is %s", domain.c_str()); + } + else { + _error("DOMAINNAME is empty"); + } + if ((iter = map_cpy.find(PASSWORD)) != map_cpy.end()) { password = iter->second; } @@ -3420,6 +3431,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, setConfig(accountID, REALM, realm); setConfig(accountID, USERAGENT, ua_name); setConfig(accountID, USERNAME, username); + setConfig(accountID, DOMAINNAME, domain); setConfig(accountID, AUTHENTICATION_USERNAME, authenticationName); if (!getMd5CredentialHashing()) { diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index e50ac19058..4dfa02783f 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -26,6 +26,7 @@ SIPAccount::SIPAccount (const AccountID& accountID) : Account (accountID, "sip") + , _domainName("") , _regc (NULL) , _bRegister (false) , _registrationExpire ("") @@ -33,7 +34,7 @@ SIPAccount::SIPAccount (const AccountID& accountID) , _publishedIpAddress ("") , _localPort (atoi (DEFAULT_SIP_PORT)) , _publishedPort (atoi (DEFAULT_SIP_PORT)) - , _tlsListenerPort (atoi (DEFAULT_SIP_TLS_PORT)) + , _tlsListenerPort (atoi (DEFAULT_SIP_TLS_PORT)) , _transportType (PJSIP_TRANSPORT_UNSPECIFIED) , _transport (NULL) , _resolveOnce (false) @@ -42,7 +43,7 @@ SIPAccount::SIPAccount (const AccountID& accountID) , _realm (DEFAULT_REALM) , _authenticationUsername ("") , _tlsSetting (NULL) - , _dtmfType(OVERRTP) + , _dtmfType(OVERRTP) , _displayName ("") { @@ -330,6 +331,7 @@ void SIPAccount::loadConfig() { // Load primary credential setUsername (Manager::instance().getConfigString (_accountID, USERNAME)); + setDomainName(Manager::instance().getConfigString(_accountID, DOMAINNAME)); setPassword (Manager::instance().getConfigString (_accountID, PASSWORD)); _authenticationUsername = Manager::instance().getConfigString (_accountID, AUTHENTICATION_USERNAME); _realm = Manager::instance().getConfigString (_accountID, REALM); diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h index 57fd602c62..8337b33c80 100644 --- a/sflphone-common/src/sip/sipaccount.h +++ b/sflphone-common/src/sip/sipaccount.h @@ -63,6 +63,16 @@ class SIPAccount : public Account */ virtual ~SIPAccount(); + /** + * Set domain to appears in sip messages for this account + */ + void setDomainName(std::string domain) { _domainName = domain; } + + /** + * Get domain name to appear in sip messages for this account + */ + std::string getDomainName(void) { return _domainName; } + /** * Special setVoIPLink which increment SipVoIPLink's number of client. */ @@ -352,6 +362,8 @@ class SIPAccount : public Account * @return std::string The login name under which SFLPhone is running. */ std::string getLoginName(void); + + std::string _domainName; // The pjsip client registration information -- GitLab