diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 093275b6fbe8c81405e4f187485af82e4b0efe3b..1b2e5e8b43f26438a1e9851f63ce7a806a763fae 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -54,7 +54,7 @@ GtkWidget * entryID; GtkWidget * entryAlias; GtkWidget * protocolComboBox; GtkWidget * entryUsername; -GtkWidget * entryDomainName; +GtkWidget * entryRouteSet; GtkWidget * entryHostname; GtkWidget * entryPassword; GtkWidget * entryMailbox; @@ -240,7 +240,7 @@ static GtkWidget* create_basic_tab (account_t **a) { gchar *curAccountType = "SIP"; gchar *curAlias = ""; gchar *curUsername = ""; - gchar *curDomainName = ""; + gchar *curRouteSet = ""; gchar *curHostname = ""; gchar *curPassword = ""; /* TODO: add curProxy, and add boxes for Proxy support */ @@ -262,7 +262,7 @@ static GtkWidget* create_basic_tab (account_t **a) { curHostname = g_hash_table_lookup(currentAccount->properties, ACCOUNT_HOSTNAME); curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_PASSWORD); curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERNAME); - curDomainName = g_hash_table_lookup(currentAccount->properties, ACCOUNT_DOMAIN); + curRouteSet = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ROUTE); curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX); curUseragent = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERAGENT); } @@ -348,17 +348,20 @@ static GtkWidget* create_basic_tab (account_t **a) { g_signal_connect(G_OBJECT (entryUsername), "changed", G_CALLBACK (update_credential_cb), NULL); g_object_set_data (G_OBJECT (entryUsername), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME)); - // Domain name can be update only for SIP account + // Route set can be update only for SIP account + // TODO: uncomment this code and implement route + /* if(strcmp(curAccountType, "SIP") == 0) { row++; - label = gtk_label_new_with_mnemonic(_("_Domain name (optional)")); + label = gtk_label_new_with_mnemonic(_("_Route (optional)")); gtk_table_attach(GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - entryDomainName = gtk_entry_new(); - gtk_label_set_mnemonic_widget(GTK_LABEL(label), entryDomainName); - gtk_entry_set_text(GTK_ENTRY(entryDomainName), curDomainName); - gtk_table_attach (GTK_TABLE(table), entryDomainName, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + entryRouteSet = gtk_entry_new(); + gtk_label_set_mnemonic_widget(GTK_LABEL(label), entryRouteSet); + gtk_entry_set_text(GTK_ENTRY(entryRouteSet), curRouteSet); + gtk_table_attach (GTK_TABLE(table), entryRouteSet, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); } + */ row++; label = gtk_label_new_with_mnemonic (_("_Password")); @@ -1336,8 +1339,8 @@ void show_account_window (account_t * a) { 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_strdup(ACCOUNT_ROUTE), + g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryRouteSet)))); } g_hash_table_replace(currentAccount->properties, diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index bd7f94327c98b20c71502b4524e6c7e6f133772d..98d73970962bf20a2d97a8e9e352b2aa02258224 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -65,7 +65,7 @@ #define ACCOUNT_DTMF_TYPE "Account.dtmfType" #define ACCOUNT_HOSTNAME "hostname" #define ACCOUNT_USERNAME "username" -#define ACCOUNT_DOMAIN "domainname" +#define ACCOUNT_ROUTE "routeset" #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 5b424a3c06d7e25659f1c5751efd43c1e5fadc59..ce9f45da987db6c10b2719dbb32dfe56945a93a1 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -69,7 +69,7 @@ typedef enum RegistrationState { #define HOSTNAME "hostname" #define USERNAME "username" -#define DOMAINNAME "domainname" +#define ROUTESET "routeset" #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 1ca9d7609a0ee9d4576565d9fc8b2fecdd71d08d..6fca7bd16e70b87fed8f6880535bf3d6e59b14c1 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -3148,8 +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>(ROUTESET, getConfigString( + accountID, ROUTESET))); a.insert(std::pair<std::string, std::string>(PASSWORD, getConfigString( accountID, PASSWORD))); a.insert(std::pair<std::string, std::string>(REALM, getConfigString( @@ -3393,7 +3393,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, map_cpy = details; std::string username; - std::string domain; + std::string routeset; std::string authenticationName; std::string password; std::string realm; @@ -3408,12 +3408,12 @@ 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()); + if ((iter = map_cpy.find(ROUTESET)) != map_cpy.end()) { + routeset = iter->second; + _error("ROUTESET is %s", routeset.c_str()); } else { - _error("DOMAINNAME is empty"); + _error("ROUTESET is empty"); } if ((iter = map_cpy.find(PASSWORD)) != map_cpy.end()) { @@ -3431,7 +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, ROUTESET, routeset); setConfig(accountID, AUTHENTICATION_USERNAME, authenticationName); if (!getMd5CredentialHashing()) { diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 6445a85662a64caf00de52b9252fe2bbe8046bbc..f90faacd7ecba2c1c7e14152f4014d0b8a7b993f 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -26,7 +26,7 @@ SIPAccount::SIPAccount (const AccountID& accountID) : Account (accountID, "sip") - , _domainName("") + , _routeSet("") , _regc (NULL) , _bRegister (false) , _registrationExpire ("") @@ -331,7 +331,7 @@ void SIPAccount::loadConfig() { // Load primary credential setUsername (Manager::instance().getConfigString (_accountID, USERNAME)); - setDomainName(Manager::instance().getConfigString(_accountID, DOMAINNAME)); + setRouteSet(Manager::instance().getConfigString(_accountID, ROUTESET)); setPassword (Manager::instance().getConfigString (_accountID, PASSWORD)); _authenticationUsername = Manager::instance().getConfigString (_accountID, AUTHENTICATION_USERNAME); _realm = Manager::instance().getConfigString (_accountID, REALM); @@ -461,9 +461,6 @@ std::string SIPAccount::getFromUri (void) username = getLoginName(); } - if(!getDomainName().empty()) { - hostname = getDomainName(); - } else { // Get machine hostname if not provided if (_hostname.empty()) { @@ -507,11 +504,8 @@ std::string SIPAccount::getToUri (const std::string& username) // Check if hostname is already specified if (username.find ("@") == std::string::npos) { - // hostname not specified - if(getDomainName().empty()) + // hostname not specified hostname = _hostname; - else - hostname = getDomainName(); } int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE, @@ -532,6 +526,7 @@ std::string SIPAccount::getServerUri (void) std::string scheme; std::string transport; + std::string hostname = _hostname; // UDP does not require the transport specification @@ -544,10 +539,9 @@ std::string SIPAccount::getServerUri (void) } int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE, - "<%s%s%s>", scheme.c_str(), - _hostname.c_str(), + hostname.c_str(), transport.c_str()); return std::string (uri, len); diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h index 8337b33c80a987550b29482693e519b32fd3893b..820d3aee7d3b91b8b7aacf14f0f841cb40afb421 100644 --- a/sflphone-common/src/sip/sipaccount.h +++ b/sflphone-common/src/sip/sipaccount.h @@ -64,14 +64,14 @@ class SIPAccount : public Account virtual ~SIPAccount(); /** - * Set domain to appears in sip messages for this account + * Set route header to appears in sip messages for this account */ - void setDomainName(std::string domain) { _domainName = domain; } + void setRouteSet(std::string route) { _routeSet = route; } /** - * Get domain name to appear in sip messages for this account + * Get route header to appear in sip messages for this account */ - std::string getDomainName(void) { return _domainName; } + std::string getRouteSet(void) { return _routeSet; } /** * Special setVoIPLink which increment SipVoIPLink's number of client. @@ -363,7 +363,7 @@ class SIPAccount : public Account */ std::string getLoginName(void); - std::string _domainName; + std::string _routeSet; // The pjsip client registration information diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index ea98537a7c8afd2731b1d5096dd6bde225ba8771..bf4e21fb2bfcdecaca39a639f8c33d67ab9712e7 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -563,7 +563,6 @@ int SIPVoIPLink::sendRegister (AccountID id) std::string srvUri = account->getServerUri(); std::string address = findLocalAddressFromUri (srvUri, account->getAccountTransport ()); - int port = findLocalPortFromUri (srvUri, account->getAccountTransport ()); std::stringstream ss; @@ -579,20 +578,43 @@ int SIPVoIPLink::sendRegister (AccountID id) contactUri.c_str()); pj_str_t pjFrom; - pj_cstr (&pjFrom, fromUri.c_str()); pj_str_t pjContact; - pj_cstr (&pjContact, contactUri.c_str()); pj_str_t pjSrv; - pj_cstr (&pjSrv, srvUri.c_str()); // Initializes registration + + // Set Route for registration passing throught one or several proxies status = pjsip_regc_init (regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, expire_value); + /* + if(!(account->getDomainName().empty())) { + + _error("Set route with %s", account->getHostname().c_str()); + + pjsip_route_hdr *route_set = pjsip_route_hdr_create(_pool); + pjsip_route_hdr *routing = pjsip_route_hdr_create(_pool); + pjsip_sip_uri *url = pjsip_sip_uri_create(_pool, 0); + routing->name_addr.uri = (pjsip_uri*)url; + pj_strdup2(_pool, &url->host, account->getHostname().c_str()); + + pj_list_push_back(&route_set, pjsip_hdr_clone(_pool, routing)); + + status = pjsip_regc_init (regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, expire_value); + + pjsip_regc_set_route_set(regc, route_set); + } + else { + + status = pjsip_regc_init (regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, expire_value); + } + */ + + if (status != PJ_SUCCESS) { _debug ("UserAgent: Unable to initialize account %d in sendRegister", status); _mutexSIP.leaveMutex(); @@ -613,9 +635,10 @@ int SIPVoIPLink::sendRegister (AccountID id) h = pjsip_generic_string_hdr_create (_pool, &STR_USER_AGENT, &useragent); pj_list_push_back (&hdr_list, (pjsip_hdr*) h); + // pj_list_push_back (&hdr_list, (pjsip_hdr*) routing); pjsip_regc_add_headers (regc, &hdr_list); - + status = pjsip_regc_register (regc, PJ_TRUE, &tdata); if (status != PJ_SUCCESS) {