Commit 13dadfa2 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

* #6905 : SIP refactor

parent f498e9ed
...@@ -576,22 +576,15 @@ void ManagerImpl::transferSucceded () ...@@ -576,22 +576,15 @@ void ManagerImpl::transferSucceded ()
bool ManagerImpl::attendedTransfer(const std::string& transferID, const std::string& targetID) bool ManagerImpl::attendedTransfer(const std::string& transferID, const std::string& targetID)
{ {
bool returnValue;; if (getConfigFromCall(transferID) == Call::IPtoIP)
return SIPVoIPLink::instance()->attendedTransfer(transferID, targetID);
// Direct IP to IP call // Classic call, attached to an account
if (getConfigFromCall (transferID) == Call::IPtoIP) std::string accountid = getAccountFromCall(transferID);
returnValue = SIPVoIPLink::instance ()-> attendedTransfer(transferID, targetID); if (accountid.empty())
else { // Classic call, attached to an account return false;
std::string accountid = getAccountFromCall (transferID);
if (accountid.empty())
return false;
returnValue = getAccountLink (accountid)->attendedTransfer (transferID, targetID);
}
getMainBuffer()->stateInfo();
return returnValue; return getAccountLink(accountid)->attendedTransfer(transferID, targetID);
} }
//THREAD=Main : Call:Incoming //THREAD=Main : Call:Incoming
...@@ -2682,7 +2675,7 @@ bool ManagerImpl::associateCallToAccount (const std::string& callID, ...@@ -2682,7 +2675,7 @@ bool ManagerImpl::associateCallToAccount (const std::string& callID,
return false; return false;
} }
std::string ManagerImpl::getAccountFromCall (const std::string& callID) std::string ManagerImpl::getAccountFromCall(const std::string& callID)
{ {
ost::MutexLock m (_callAccountMapMutex); ost::MutexLock m (_callAccountMapMutex);
CallAccountMap::iterator iter = _callAccountMap.find (callID); CallAccountMap::iterator iter = _callAccountMap.find (callID);
......
...@@ -43,7 +43,7 @@ SIPAccount::SIPAccount (const std::string& accountID) ...@@ -43,7 +43,7 @@ SIPAccount::SIPAccount (const std::string& accountID)
, transport (NULL) , transport (NULL)
, regc_ (NULL) , regc_ (NULL)
, bRegister_ (false) , bRegister_ (false)
, registrationExpire_ ("") , registrationExpire_ (600)
, interface_ ("default") , interface_ ("default")
, publishedSameasLocal_ (true) , publishedSameasLocal_ (true)
, publishedIpAddress_ ("") , publishedIpAddress_ ("")
...@@ -102,7 +102,9 @@ void SIPAccount::serialize (Conf::YamlEmitter *emitter) ...@@ -102,7 +102,9 @@ void SIPAccount::serialize (Conf::YamlEmitter *emitter)
Conf::ScalarNode hostname (Account::hostname_); Conf::ScalarNode hostname (Account::hostname_);
Conf::ScalarNode enable (enabled_); Conf::ScalarNode enable (enabled_);
Conf::ScalarNode type (Account::type_); Conf::ScalarNode type (Account::type_);
Conf::ScalarNode expire (registrationExpire_); std::stringstream expirevalstr;
expirevalstr << registrationExpire_;
Conf::ScalarNode expire (expirevalstr);
Conf::ScalarNode interface (interface_); Conf::ScalarNode interface (interface_);
std::stringstream portstr; std::stringstream portstr;
portstr << localPort_; portstr << localPort_;
...@@ -381,7 +383,7 @@ void SIPAccount::setAccountDetails (std::map<std::string, std::string> details) ...@@ -381,7 +383,7 @@ void SIPAccount::setAccountDetails (std::map<std::string, std::string> details)
stunEnabled_ = details[STUN_ENABLE] == "true"; stunEnabled_ = details[STUN_ENABLE] == "true";
dtmfType_ = details[ACCOUNT_DTMF_TYPE] == "overrtp" ? OVERRTP : SIPINFO; dtmfType_ = details[ACCOUNT_DTMF_TYPE] == "overrtp" ? OVERRTP : SIPINFO;
registrationExpire_ = details[CONFIG_ACCOUNT_REGISTRATION_EXPIRE]; registrationExpire_ = atoi(details[CONFIG_ACCOUNT_REGISTRATION_EXPIRE].c_str());
userAgent_ = details[USERAGENT]; userAgent_ = details[USERAGENT];
...@@ -464,7 +466,9 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const ...@@ -464,7 +466,9 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const
a[ROUTESET] = serviceRoute_; a[ROUTESET] = serviceRoute_;
a[USERAGENT] = userAgent_; a[USERAGENT] = userAgent_;
a[CONFIG_ACCOUNT_REGISTRATION_EXPIRE] = registrationExpire_; std::stringstream expireval;
expireval << registrationExpire_;
a[CONFIG_ACCOUNT_REGISTRATION_EXPIRE] = expireval.str();
a[LOCAL_INTERFACE] = interface_; a[LOCAL_INTERFACE] = interface_;
a[PUBLISHED_SAMEAS_LOCAL] = publishedSameasLocal_ ? "true" : "false"; a[PUBLISHED_SAMEAS_LOCAL] = publishedSameasLocal_ ? "true" : "false";
a[PUBLISHED_ADDRESS] = publishedIpAddress_; a[PUBLISHED_ADDRESS] = publishedIpAddress_;
...@@ -619,8 +623,8 @@ void SIPAccount::initStunConfiguration (void) ...@@ -619,8 +623,8 @@ void SIPAccount::initStunConfiguration (void)
void SIPAccount::loadConfig() void SIPAccount::loadConfig()
{ {
if (registrationExpire_.empty()) if (registrationExpire_ == 0)
registrationExpire_ = "600"; /** Default expire value for registration */ registrationExpire_ = 600; /** Default expire value for registration */
if (tlsEnable_ == "true") { if (tlsEnable_ == "true") {
initTlsConfiguration(); initTlsConfiguration();
......
...@@ -165,19 +165,21 @@ class SIPAccount : public Account ...@@ -165,19 +165,21 @@ class SIPAccount : public Account
* interval that indicates how long the client would like the * interval that indicates how long the client would like the
* registration to be valid. * registration to be valid.
* *
* @return A string describing the expiration value. * @return the expiration value.
*/ */
const std::string& getRegistrationExpire (void) const { unsigned getRegistrationExpire (void) const {
return registrationExpire_; if (registrationExpire_ == 0)
return PJSIP_REGC_EXPIRATION_NOT_SPECIFIED;
return registrationExpire_;
} }
/** /**
* Setting the Expiration Interval of Contact Addresses. * Doubles the Expiration Interval of Contact Addresses.
*
* @param A string describing the expiration value.
*/ */
void setRegistrationExpire (const std::string &expr) { void doubleRegistrationExpire (void) {
registrationExpire_ = expr; registrationExpire_ *= 2;
if (registrationExpire_ < 0)
registrationExpire_ = 0;
} }
bool fullMatch (const std::string& username, const std::string& hostname) const; bool fullMatch (const std::string& username, const std::string& hostname) const;
...@@ -444,7 +446,7 @@ class SIPAccount : public Account ...@@ -444,7 +446,7 @@ class SIPAccount : public Account
bool bRegister_; bool bRegister_;
// Network settings // Network settings
std::string registrationExpire_; int registrationExpire_;
// interface name on which this account is bound // interface name on which this account is bound
std::string interface_; std::string interface_;
......
This diff is collapsed.
...@@ -144,6 +144,8 @@ class SIPVoIPLink : public VoIPLink ...@@ -144,6 +144,8 @@ class SIPVoIPLink : public VoIPLink
*/ */
virtual void offhold (const std::string& id); virtual void offhold (const std::string& id);
bool transferCommon(SIPCall *call, pj_str_t *dst);
/** /**
* Transfer the call * Transfer the call
* @param id The call identifier * @param id The call identifier
......
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