diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 4dfa02783f5f89784f82140ac13be5b4ab923711..6445a85662a64caf00de52b9252fe2bbe8046bbc 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -461,9 +461,14 @@ std::string SIPAccount::getFromUri (void) username = getLoginName(); } - // Get machine hostname if not provided - if (_hostname.empty()) { - hostname = getMachineName(); + if(!getDomainName().empty()) { + hostname = getDomainName(); + } + else { + // Get machine hostname if not provided + if (_hostname.empty()) { + hostname = getMachineName(); + } } int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE, @@ -483,7 +488,7 @@ std::string SIPAccount::getToUri (const std::string& username) std::string scheme; std::string transport; - std::string hostname = _hostname; + std::string hostname = ""; // UDP does not require the transport specification @@ -501,8 +506,12 @@ std::string SIPAccount::getToUri (const std::string& username) } // Check if hostname is already specified - if (username.find ("@") != std::string::npos) { - hostname = ""; + if (username.find ("@") == std::string::npos) { + // hostname not specified + if(getDomainName().empty()) + hostname = _hostname; + else + hostname = getDomainName(); } int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE, diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 75e4bf9e7edc05d2cd8ff750a7a9e3e8d2b9401d..ea98537a7c8afd2731b1d5096dd6bde225ba8771 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -559,28 +559,19 @@ int SIPVoIPLink::sendRegister (AccountID id) } // Creates URI - std::string fromUri; - std::string contactUri; - std::string srvUri; - std::string address; - - fromUri = account->getFromUri(); - - srvUri = account->getServerUri(); + std::string fromUri = account->getFromUri(); + std::string srvUri = account->getServerUri(); - address = findLocalAddressFromUri (srvUri, account->getAccountTransport ()); + std::string address = findLocalAddressFromUri (srvUri, account->getAccountTransport ()); int port = findLocalPortFromUri (srvUri, account->getAccountTransport ()); std::stringstream ss; - std::string portStr; - ss << port; - ss >> portStr; - contactUri = account->getContactHeader (address, portStr); + std::string contactUri = account->getContactHeader (address, portStr); _debug ("sendRegister: fromUri: %s serverUri: %s contactUri: %s", fromUri.c_str(),