diff --git a/sflphone-client-gnome/src/config/accountwindow.c b/sflphone-client-gnome/src/config/accountwindow.c index 5954b53770c1bf444239ee74e1a5e392ff702908..30a2c27761dd29d94535458f4c15eb2bf699d261 100644 --- a/sflphone-client-gnome/src/config/accountwindow.c +++ b/sflphone-client-gnome/src/config/accountwindow.c @@ -136,6 +136,7 @@ static GtkWidget * create_basic_tab(account_t **a) { curAccountID = currentAccount->accountID; curAccountType = g_hash_table_lookup(currentAccount->properties, ACCOUNT_TYPE); + DEBUG("CuraccountType %s", curAccountType); curAccountEnabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ENABLED); curAlias = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ALIAS); curHostname = g_hash_table_lookup(currentAccount->properties, ACCOUNT_HOSTNAME); @@ -143,12 +144,6 @@ static GtkWidget * create_basic_tab(account_t **a) curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERNAME); curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX); } - else - { - currentAccount = g_new0(account_t, 1); - currentAccount->properties = g_hash_table_new(NULL, g_str_equal); - curAccountID = "new"; - } gnome_main_section_new (_("Account Parameters"), &frame); gtk_widget_show(frame); @@ -821,7 +816,14 @@ show_account_window (account_t * a) account_t *currentAccount; currentAccount = a; - + + if (currentAccount == NULL) { + currentAccount = g_new0(account_t, 1); + currentAccount->properties = dbus_account_details(NULL); + currentAccount->accountID = "new"; + DEBUG("Account is NULL. Will fetch default values\n"); + } + dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Account settings"), GTK_WINDOW(get_main_window()), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 6e780db05f2fbda7a2b4b4a7de2e4b1dc84969fd..240419f640405b84e80c2b64bddc93c333922297 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2541,9 +2541,8 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou std::map<std::string, std::string> a; Account * account = _accountMap[accountID]; - if(!account){ - _debug("Cannot getAccountDetails on a non-existing accountID. Returning.\n"); - return a; + if(account == NULL) { + _debug("Cannot getAccountDetails on a non-existing accountID. Defaults will be used.\n"); } a.insert(std::pair<std::string, std::string> (CONFIG_ACCOUNT_ALIAS, getConfigString(accountID, CONFIG_ACCOUNT_ALIAS))); @@ -2564,7 +2563,11 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou a.insert(std::pair<std::string, std::string> (DISPLAY_NAME, getConfigString(accountID, DISPLAY_NAME))); RegistrationState state; - state = account->getRegistrationState(); + if (account != NULL) { + state = account->getRegistrationState(); + } else { + state = Unregistered; + } a.insert(std::pair<std::string, std::string> ("Status", mapStateNumberToString (state))); a.insert(std::pair<std::string, std::string> (SRTP_KEY_EXCHANGE, getConfigString(accountID, SRTP_KEY_EXCHANGE))); a.insert(std::pair<std::string, std::string> (SRTP_ENABLE, getConfigString(accountID, SRTP_ENABLE))); diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index ed04e13e39d78f5db73948fd5056a94d96da2a8a..9afb0531f39179d226f7e92cdc36ae2c1c40106c 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -244,13 +244,10 @@ void SIPAccount::loadConfig() // Load network settings std::string localPort = Manager::instance().getConfigString(_accountID, LOCAL_PORT); - std::string publishedPort = Manager::instance().getConfigString(_accountID, PUBLISHED_PORT); - std::stringstream ss; - ss << localPort; - ss >> _localPort; - ss << publishedPort; - ss >> _publishedPort; - + std::string publishedPort = Manager::instance().getConfigString(_accountID, PUBLISHED_PORT); + + _localPort = atoi(localPort.c_str()); + _publishedPort = atoi(publishedPort.c_str()); _localIpAddress = Manager::instance().getConfigString(_accountID, LOCAL_ADDRESS); _publishedIpAddress = Manager::instance().getConfigString(_accountID, PUBLISHED_ADDRESS); _transportType = PJSIP_TRANSPORT_UDP; diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 40f2354eea5ba42ad8f97395815bd48534c705d2..755585d251f2820372d87ee9fa212f5bb775a805 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -489,8 +489,7 @@ int SIPVoIPLink::sendRegister (AccountID id) std::string portStr; ss << port; ss >> portStr; - // DON'T FORGET TO REMOVE THIS 5061 VALUE ! - contactUri = account->getContactHeader(address, "5061"); + contactUri = account->getContactHeader(address, portStr); _debug("sendRegister: fromUri: %s serverUri: %s contactUri: %s\n", fromUri.c_str(), @@ -2020,19 +2019,30 @@ pj_status_t SIPVoIPLink::createTlsTransport(AccountID id) /** * Init local address. - * IP interface address is not specified, - * so socket will be bound to PJ_INADDR_ANY. + * If IP interface address is not specified, + * socket will be bound to PJ_INADDR_ANY. * If user specified port is an empty string * or if it is equal to 0, then the port will * be chosen automatically by the OS. */ pj_sockaddr_in_init(&local_addr, 0, 0); - //pj_uint16_t localTlsPort = account->getLocalPort(); - pj_uint16_t localTlsPort = 5061; + pj_uint16_t localTlsPort = account->getLocalPort(); if (localTlsPort != 0) { local_addr.sin_port = pj_htons(localTlsPort); } + std::string localAddress = account->getLocalAddress(); + if (!localAddress.empty()) { + pj_str_t pjAddress; + pj_cstr(&pjAddress, (account->getLocalAddress()).c_str()); + + pj_status_t success; + success = pj_sockaddr_in_set_str_addr(&local_addr, &pjAddress); + if (success != PJ_SUCCESS) { + _debug("Failed to set local address in %d\n", __LINE__); + } + } + /* Init published name */ pj_bzero(&a_name, sizeof(pjsip_host_port)); pj_cstr(&a_name.host, (account->getPublishedAddress()).c_str()); @@ -2041,6 +2051,11 @@ pj_status_t SIPVoIPLink::createTlsTransport(AccountID id) /* Get TLS settings. Expected to be filled */ pjsip_tls_setting * tls_setting = account->getTlsSetting(); + _debug("TLS transport to be initialized with published address %.*s," + " published port %d, local address %s, local port %d\n", + (int)a_name.host.slen, a_name.host.ptr, + (int)a_name.port, localAddress.c_str(), (int)localTlsPort); + status = pjsip_tls_transport_start(_endpt, tls_setting, &local_addr, &a_name, 1, &tls); if (status != PJ_SUCCESS) {