diff --git a/sflphone-gtk/src/accountwindow.c b/sflphone-gtk/src/accountwindow.c index 4308d94c2c8190b64e38d373fee87be988271fdd..660eca97a81c15c4f2f06cab57debea0a589a123 100644 --- a/sflphone-gtk/src/accountwindow.c +++ b/sflphone-gtk/src/accountwindow.c @@ -65,6 +65,7 @@ change_protocol (account_t * currentAccount) else if (strcmp(proto, "IAX") == 0) { gtk_widget_set_sensitive( GTK_WIDGET(stunEnable), FALSE); gtk_widget_set_sensitive( GTK_WIDGET(stunServer), FALSE); + gtk_widget_set_sensitive( GTK_WIDGET(entryPort), FALSE); } else { // Should not get here. diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 0738d4c14ee81d25c819a072cb312fbc3ce9ed1e..7102d2a27360241e3564c36a1364ded94a291378 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -26,7 +26,7 @@ #include <cstdlib> #include <iostream> #include <fstream> - +#include <sstream> #include <sys/types.h> // mkdir(2) #include <sys/stat.h> // mkdir(2) @@ -50,6 +50,7 @@ #include "user_cfg.h" +#define DEFAULT_SIP_PORT 5060 #ifdef USE_ZEROCONF #include "zeroconf/DNSService.h" @@ -2231,6 +2232,8 @@ ManagerImpl::loadAccountMap() TokenList sections = _config.getSections(); std::string accountType; Account* tmpAccount; + std::string port; + unsigned int iPort; TokenList::iterator iter = sections.begin(); while(iter != sections.end()) { @@ -2246,6 +2249,7 @@ ManagerImpl::loadAccountMap() // Initialize the SIP Manager _userAgent = new UserAgent(); _userAgentInitlized = true; + _userAgent->setRegPort(DEFAULT_SIP_PORT); } tmpAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, *iter); @@ -2257,7 +2261,12 @@ ManagerImpl::loadAccountMap() _userAgent->setStunServer(Manager::instance().getConfigString(tmpAccount->getAccountID(), SIP_STUN_SERVER).data()); } - + // Set registration port for all accounts, The last non-5060 port will be recorded in _userAgent. + port = Manager::instance().getConfigString(tmpAccount->getAccountID(), SIP_PORT); + std::istringstream is(port); + is >> iPort; + if (iPort != DEFAULT_SIP_PORT) + _userAgent->setRegPort(iPort); } else if (accountType == "IAX") { tmpAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, *iter); diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 6334e686e1e6292107f9eb5ebdb33f4937639e0f..942f8bb698f80e2cccb50b4429f05923088bc294 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -23,7 +23,7 @@ #include "sipvoiplink.h" #include "eventthread.h" #include "sipcall.h" -#include <sstream> // for ostringstream +#include <sstream> // for istringstream #include "sipaccount.h" #include "useragent.h" #include "audio/audiortp.h" diff --git a/src/useragent.cpp b/src/useragent.cpp index f13a120f326ba4ac7ce0e4a6bb55b776a274e7ff..dcc3cec4f1548032b650879a0837e6d798279044 100644 --- a/src/useragent.cpp +++ b/src/useragent.cpp @@ -104,7 +104,7 @@ pj_status_t UserAgent::sipInit() { return false; } int errPjsip = 0; - int port = DEFAULT_SIP_PORT; + int port = _regPort; //_debug("stun host is %s\n", _stunHost.ptr); if (_useStun && !Manager::instance().behindNat(_stunServer, port)) { diff --git a/src/useragent.h b/src/useragent.h index f5cf104f819944e157edd682a01a9924669a816a..783e86eca5093899119814f88fb68391d0d033a0 100644 --- a/src/useragent.h +++ b/src/useragent.h @@ -65,6 +65,9 @@ private: /** Local Extern Port is the port seen by peers for SIP listener */ unsigned int _localExternPort; unsigned int _localPort; + + /** For registration use only */ + unsigned int _regPort; pj_thread_t *_thread; @@ -89,8 +92,13 @@ public: /** Set whether it will use stun server */ void setStunServer(const char *server); + + /** Set the port number user designated */ + void setRegPort(unsigned int port) { _regPort = port; } + + unsigned int getRegPort() { return _regPort; } - pj_str_t getStunServer() {return _stunHost;} + pj_str_t getStunServer() { return _stunHost; } bool addAccount(AccountID id, pjsip_regc **regc, const std::string& server, const std::string& user, const std::string& passwd , const int& timeout, const unsigned int& port);