Commit 40cdb895 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3170] Rename "domain name" for "route set"

parent e88b5633
...@@ -54,7 +54,7 @@ GtkWidget * entryID; ...@@ -54,7 +54,7 @@ GtkWidget * entryID;
GtkWidget * entryAlias; GtkWidget * entryAlias;
GtkWidget * protocolComboBox; GtkWidget * protocolComboBox;
GtkWidget * entryUsername; GtkWidget * entryUsername;
GtkWidget * entryDomainName; GtkWidget * entryRouteSet;
GtkWidget * entryHostname; GtkWidget * entryHostname;
GtkWidget * entryPassword; GtkWidget * entryPassword;
GtkWidget * entryMailbox; GtkWidget * entryMailbox;
...@@ -240,7 +240,7 @@ static GtkWidget* create_basic_tab (account_t **a) { ...@@ -240,7 +240,7 @@ static GtkWidget* create_basic_tab (account_t **a) {
gchar *curAccountType = "SIP"; gchar *curAccountType = "SIP";
gchar *curAlias = ""; gchar *curAlias = "";
gchar *curUsername = ""; gchar *curUsername = "";
gchar *curDomainName = ""; gchar *curRouteSet = "";
gchar *curHostname = ""; gchar *curHostname = "";
gchar *curPassword = ""; gchar *curPassword = "";
/* TODO: add curProxy, and add boxes for Proxy support */ /* TODO: add curProxy, and add boxes for Proxy support */
...@@ -262,7 +262,7 @@ static GtkWidget* create_basic_tab (account_t **a) { ...@@ -262,7 +262,7 @@ static GtkWidget* create_basic_tab (account_t **a) {
curHostname = g_hash_table_lookup(currentAccount->properties, ACCOUNT_HOSTNAME); curHostname = g_hash_table_lookup(currentAccount->properties, ACCOUNT_HOSTNAME);
curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_PASSWORD); curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_PASSWORD);
curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERNAME); 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); curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX);
curUseragent = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERAGENT); curUseragent = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERAGENT);
} }
...@@ -348,17 +348,20 @@ static GtkWidget* create_basic_tab (account_t **a) { ...@@ -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_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)); 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) { if(strcmp(curAccountType, "SIP") == 0) {
row++; 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_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); gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
entryDomainName = gtk_entry_new(); entryRouteSet = gtk_entry_new();
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entryDomainName); gtk_label_set_mnemonic_widget(GTK_LABEL(label), entryRouteSet);
gtk_entry_set_text(GTK_ENTRY(entryDomainName), curDomainName); gtk_entry_set_text(GTK_ENTRY(entryRouteSet), curRouteSet);
gtk_table_attach (GTK_TABLE(table), entryDomainName, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE(table), entryRouteSet, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
} }
*/
row++; row++;
label = gtk_label_new_with_mnemonic (_("_Password")); label = gtk_label_new_with_mnemonic (_("_Password"));
...@@ -1336,8 +1339,8 @@ void show_account_window (account_t * a) { ...@@ -1336,8 +1339,8 @@ void show_account_window (account_t * a) {
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryUsername)))); g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryUsername))));
if(strcmp(proto, "SIP") == 0) { if(strcmp(proto, "SIP") == 0) {
g_hash_table_replace(currentAccount->properties, g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_DOMAIN), g_strdup(ACCOUNT_ROUTE),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryDomainName)))); g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryRouteSet))));
} }
g_hash_table_replace(currentAccount->properties, g_hash_table_replace(currentAccount->properties,
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#define ACCOUNT_DTMF_TYPE "Account.dtmfType" #define ACCOUNT_DTMF_TYPE "Account.dtmfType"
#define ACCOUNT_HOSTNAME "hostname" #define ACCOUNT_HOSTNAME "hostname"
#define ACCOUNT_USERNAME "username" #define ACCOUNT_USERNAME "username"
#define ACCOUNT_DOMAIN "domainname" #define ACCOUNT_ROUTE "routeset"
#define ACCOUNT_PASSWORD "password" #define ACCOUNT_PASSWORD "password"
#define ACCOUNT_AUTHENTICATION_USERNAME "authenticationUsername" #define ACCOUNT_AUTHENTICATION_USERNAME "authenticationUsername"
#define ACCOUNT_REALM "realm" #define ACCOUNT_REALM "realm"
......
...@@ -69,7 +69,7 @@ typedef enum RegistrationState { ...@@ -69,7 +69,7 @@ typedef enum RegistrationState {
#define HOSTNAME "hostname" #define HOSTNAME "hostname"
#define USERNAME "username" #define USERNAME "username"
#define DOMAINNAME "domainname" #define ROUTESET "routeset"
#define AUTHENTICATION_USERNAME "authenticationUsername" #define AUTHENTICATION_USERNAME "authenticationUsername"
#define PASSWORD "password" #define PASSWORD "password"
#define REALM "realm" #define REALM "realm"
......
...@@ -3148,8 +3148,8 @@ std::map<std::string, std::string> ManagerImpl::getAccountDetails ( ...@@ -3148,8 +3148,8 @@ std::map<std::string, std::string> ManagerImpl::getAccountDetails (
accountID, HOSTNAME))); accountID, HOSTNAME)));
a.insert(std::pair<std::string, std::string>(USERNAME, getConfigString( a.insert(std::pair<std::string, std::string>(USERNAME, getConfigString(
accountID, USERNAME))); accountID, USERNAME)));
a.insert(std::pair<std::string, std::string>(DOMAINNAME, getConfigString( a.insert(std::pair<std::string, std::string>(ROUTESET, getConfigString(
accountID, DOMAINNAME))); accountID, ROUTESET)));
a.insert(std::pair<std::string, std::string>(PASSWORD, getConfigString( a.insert(std::pair<std::string, std::string>(PASSWORD, getConfigString(
accountID, PASSWORD))); accountID, PASSWORD)));
a.insert(std::pair<std::string, std::string>(REALM, getConfigString( a.insert(std::pair<std::string, std::string>(REALM, getConfigString(
...@@ -3393,7 +3393,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, ...@@ -3393,7 +3393,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
map_cpy = details; map_cpy = details;
std::string username; std::string username;
std::string domain; std::string routeset;
std::string authenticationName; std::string authenticationName;
std::string password; std::string password;
std::string realm; std::string realm;
...@@ -3408,12 +3408,12 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, ...@@ -3408,12 +3408,12 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
username = iter->second; username = iter->second;
} }
if ((iter = map_cpy.find(DOMAINNAME)) != map_cpy.end()) { if ((iter = map_cpy.find(ROUTESET)) != map_cpy.end()) {
domain = iter->second; routeset = iter->second;
_error("DOMAINNAME is %s", domain.c_str()); _error("ROUTESET is %s", routeset.c_str());
} }
else { else {
_error("DOMAINNAME is empty"); _error("ROUTESET is empty");
} }
if ((iter = map_cpy.find(PASSWORD)) != map_cpy.end()) { if ((iter = map_cpy.find(PASSWORD)) != map_cpy.end()) {
...@@ -3431,7 +3431,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, ...@@ -3431,7 +3431,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
setConfig(accountID, REALM, realm); setConfig(accountID, REALM, realm);
setConfig(accountID, USERAGENT, ua_name); setConfig(accountID, USERAGENT, ua_name);
setConfig(accountID, USERNAME, username); setConfig(accountID, USERNAME, username);
setConfig(accountID, DOMAINNAME, domain); setConfig(accountID, ROUTESET, routeset);
setConfig(accountID, AUTHENTICATION_USERNAME, authenticationName); setConfig(accountID, AUTHENTICATION_USERNAME, authenticationName);
if (!getMd5CredentialHashing()) { if (!getMd5CredentialHashing()) {
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
SIPAccount::SIPAccount (const AccountID& accountID) SIPAccount::SIPAccount (const AccountID& accountID)
: Account (accountID, "sip") : Account (accountID, "sip")
, _domainName("") , _routeSet("")
, _regc (NULL) , _regc (NULL)
, _bRegister (false) , _bRegister (false)
, _registrationExpire ("") , _registrationExpire ("")
...@@ -331,7 +331,7 @@ void SIPAccount::loadConfig() ...@@ -331,7 +331,7 @@ void SIPAccount::loadConfig()
{ {
// Load primary credential // Load primary credential
setUsername (Manager::instance().getConfigString (_accountID, USERNAME)); setUsername (Manager::instance().getConfigString (_accountID, USERNAME));
setDomainName(Manager::instance().getConfigString(_accountID, DOMAINNAME)); setRouteSet(Manager::instance().getConfigString(_accountID, ROUTESET));
setPassword (Manager::instance().getConfigString (_accountID, PASSWORD)); setPassword (Manager::instance().getConfigString (_accountID, PASSWORD));
_authenticationUsername = Manager::instance().getConfigString (_accountID, AUTHENTICATION_USERNAME); _authenticationUsername = Manager::instance().getConfigString (_accountID, AUTHENTICATION_USERNAME);
_realm = Manager::instance().getConfigString (_accountID, REALM); _realm = Manager::instance().getConfigString (_accountID, REALM);
...@@ -461,9 +461,6 @@ std::string SIPAccount::getFromUri (void) ...@@ -461,9 +461,6 @@ std::string SIPAccount::getFromUri (void)
username = getLoginName(); username = getLoginName();
} }
if(!getDomainName().empty()) {
hostname = getDomainName();
}
else { else {
// Get machine hostname if not provided // Get machine hostname if not provided
if (_hostname.empty()) { if (_hostname.empty()) {
...@@ -507,11 +504,8 @@ std::string SIPAccount::getToUri (const std::string& username) ...@@ -507,11 +504,8 @@ std::string SIPAccount::getToUri (const std::string& username)
// Check if hostname is already specified // Check if hostname is already specified
if (username.find ("@") == std::string::npos) { if (username.find ("@") == std::string::npos) {
// hostname not specified // hostname not specified
if(getDomainName().empty())
hostname = _hostname; hostname = _hostname;
else
hostname = getDomainName();
} }
int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE, int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE,
...@@ -532,6 +526,7 @@ std::string SIPAccount::getServerUri (void) ...@@ -532,6 +526,7 @@ std::string SIPAccount::getServerUri (void)
std::string scheme; std::string scheme;
std::string transport; std::string transport;
std::string hostname = _hostname;
// UDP does not require the transport specification // UDP does not require the transport specification
...@@ -544,10 +539,9 @@ std::string SIPAccount::getServerUri (void) ...@@ -544,10 +539,9 @@ std::string SIPAccount::getServerUri (void)
} }
int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE, int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE,
"<%s%s%s>", "<%s%s%s>",
scheme.c_str(), scheme.c_str(),
_hostname.c_str(), hostname.c_str(),
transport.c_str()); transport.c_str());
return std::string (uri, len); return std::string (uri, len);
......
...@@ -64,14 +64,14 @@ class SIPAccount : public Account ...@@ -64,14 +64,14 @@ class SIPAccount : public Account
virtual ~SIPAccount(); 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. * Special setVoIPLink which increment SipVoIPLink's number of client.
...@@ -363,7 +363,7 @@ class SIPAccount : public Account ...@@ -363,7 +363,7 @@ class SIPAccount : public Account
*/ */
std::string getLoginName(void); std::string getLoginName(void);
std::string _domainName; std::string _routeSet;
// The pjsip client registration information // The pjsip client registration information
......
...@@ -563,7 +563,6 @@ int SIPVoIPLink::sendRegister (AccountID id) ...@@ -563,7 +563,6 @@ int SIPVoIPLink::sendRegister (AccountID id)
std::string srvUri = account->getServerUri(); std::string srvUri = account->getServerUri();
std::string address = findLocalAddressFromUri (srvUri, account->getAccountTransport ()); std::string address = findLocalAddressFromUri (srvUri, account->getAccountTransport ());
int port = findLocalPortFromUri (srvUri, account->getAccountTransport ()); int port = findLocalPortFromUri (srvUri, account->getAccountTransport ());
std::stringstream ss; std::stringstream ss;
...@@ -579,20 +578,43 @@ int SIPVoIPLink::sendRegister (AccountID id) ...@@ -579,20 +578,43 @@ int SIPVoIPLink::sendRegister (AccountID id)
contactUri.c_str()); contactUri.c_str());
pj_str_t pjFrom; pj_str_t pjFrom;
pj_cstr (&pjFrom, fromUri.c_str()); pj_cstr (&pjFrom, fromUri.c_str());
pj_str_t pjContact; pj_str_t pjContact;
pj_cstr (&pjContact, contactUri.c_str()); pj_cstr (&pjContact, contactUri.c_str());
pj_str_t pjSrv; pj_str_t pjSrv;
pj_cstr (&pjSrv, srvUri.c_str()); pj_cstr (&pjSrv, srvUri.c_str());
// Initializes registration // Initializes registration
// Set Route for registration passing throught one or several proxies
status = pjsip_regc_init (regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, expire_value); 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) { if (status != PJ_SUCCESS) {
_debug ("UserAgent: Unable to initialize account %d in sendRegister", status); _debug ("UserAgent: Unable to initialize account %d in sendRegister", status);
_mutexSIP.leaveMutex(); _mutexSIP.leaveMutex();
...@@ -613,9 +635,10 @@ int SIPVoIPLink::sendRegister (AccountID id) ...@@ -613,9 +635,10 @@ int SIPVoIPLink::sendRegister (AccountID id)
h = pjsip_generic_string_hdr_create (_pool, &STR_USER_AGENT, &useragent); 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*) h);
// pj_list_push_back (&hdr_list, (pjsip_hdr*) routing);
pjsip_regc_add_headers (regc, &hdr_list); pjsip_regc_add_headers (regc, &hdr_list);
status = pjsip_regc_register (regc, PJ_TRUE, &tdata); status = pjsip_regc_register (regc, PJ_TRUE, &tdata);
if (status != PJ_SUCCESS) { if (status != PJ_SUCCESS) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment