Commit 1f0d62c1 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6699: accounts: cleanup/refactoring

parent 29b600a7
......@@ -125,7 +125,6 @@ std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails (void)
ip2ipAccountDetails, ip2ipAccountDetails.end()));
return ip2ipAccountDetails;
}
void ConfigurationManager::setIp2IpDetails (const std::map<std::string,
......@@ -191,7 +190,6 @@ void ConfigurationManager::setIp2IpDetails (const std::map<std::string,
std::map<std::string, std::string> ConfigurationManager::getTlsSettings()
{
std::map<std::string, std::string> tlsSettings;
SIPAccount *sipaccount = (SIPAccount *) Manager::instance().getAccount (IP2IP_PROFILE);
......@@ -715,7 +713,6 @@ std::vector<std::string> ConfigurationManager::getAllIpInterfaceByName (void)
std::map<std::string, std::string> ConfigurationManager::getShortcuts()
{
return Manager::instance().shortcutPreferences.getShortcuts();
}
......
......@@ -31,6 +31,7 @@
*/
#include "sipaccount.h"
#include "sipvoiplink.h"
#include "manager.h"
#include "config.h"
#include <pwd.h>
......@@ -485,50 +486,50 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const
// Add sip specific details
a[ROUTESET] = getServiceRoute();
a[CONFIG_ACCOUNT_RESOLVE_ONCE] = isResolveOnce() ? "true" : "false";
a[CONFIG_ACCOUNT_RESOLVE_ONCE] = resolveOnce_ ? "true" : "false";
a[USERAGENT] = userAgent_;
a[CONFIG_ACCOUNT_REGISTRATION_EXPIRE] = getRegistrationExpire();
a[LOCAL_INTERFACE] = getLocalInterface();
a[PUBLISHED_SAMEAS_LOCAL] = getPublishedSameasLocal() ? "true" : "false";
a[PUBLISHED_ADDRESS] = getPublishedAddress();
a[CONFIG_ACCOUNT_REGISTRATION_EXPIRE] = registrationExpire_;
a[LOCAL_INTERFACE] = interface_;
a[PUBLISHED_SAMEAS_LOCAL] = publishedSameasLocal_ ? "true" : "false";
a[PUBLISHED_ADDRESS] = publishedIpAddress_;
std::stringstream localport;
localport << getLocalPort();
localport << localPort_;
a[LOCAL_PORT] = localport.str();
std::stringstream publishedport;
publishedport << getPublishedPort();
publishedport << publishedPort_;
a[PUBLISHED_PORT] = publishedport.str();
a[STUN_ENABLE] = isStunEnabled() ? "true" : "false";
a[STUN_SERVER] = getStunServer();
a[ACCOUNT_DTMF_TYPE] = (getDtmfType() == OVERRTP) ? "overrtp" : "sipinfo";
a[STUN_ENABLE] = stunEnabled_ ? "true" : "false";
a[STUN_SERVER] = stunServer_;
a[ACCOUNT_DTMF_TYPE] = (dtmfType_ == OVERRTP) ? "overrtp" : "sipinfo";
a[SRTP_KEY_EXCHANGE] = getSrtpKeyExchange();
a[SRTP_ENABLE] = getSrtpEnable() ? "true" : "false";
a[SRTP_RTP_FALLBACK] = getSrtpFallback() ? "true" : "false";
a[SRTP_KEY_EXCHANGE] = srtpKeyExchange_;
a[SRTP_ENABLE] = srtpEnabled_ ? "true" : "false";
a[SRTP_RTP_FALLBACK] = srtpFallback_ ? "true" : "false";
a[ZRTP_DISPLAY_SAS] = getZrtpDisplaySas() ? "true" : "false";
a[ZRTP_DISPLAY_SAS_ONCE] = getZrtpDiaplaySasOnce() ? "true" : "false";
a[ZRTP_HELLO_HASH] = getZrtpHelloHash() ? "true" : "false";
a[ZRTP_NOT_SUPP_WARNING] = getZrtpNotSuppWarning() ? "true" : "false";
a[ZRTP_DISPLAY_SAS] = zrtpDisplaySas_ ? "true" : "false";
a[ZRTP_DISPLAY_SAS_ONCE] = zrtpDisplaySasOnce_ ? "true" : "false";
a[ZRTP_HELLO_HASH] = zrtpHelloHash_ ? "true" : "false";
a[ZRTP_NOT_SUPP_WARNING] = zrtpNotSuppWarning_ ? "true" : "false";
// TLS listener is unique and parameters are modified through IP2IP_PROFILE
std::stringstream tlslistenerport;
tlslistenerport << getTlsListenerPort();
tlslistenerport << tlsListenerPort_;
a[TLS_LISTENER_PORT] = tlslistenerport.str();
a[TLS_ENABLE] = getTlsEnable();
a[TLS_CA_LIST_FILE] = getTlsCaListFile();
a[TLS_CERTIFICATE_FILE] = getTlsCertificateFile();
a[TLS_PRIVATE_KEY_FILE] = getTlsPrivateKeyFile();
a[TLS_PASSWORD] = getTlsPassword();
a[TLS_METHOD] = getTlsMethod();
a[TLS_CIPHERS] = getTlsCiphers();
a[TLS_SERVER_NAME] = getTlsServerName();
a[TLS_VERIFY_SERVER] = getTlsVerifyServer() ? "true" : "false";
a[TLS_VERIFY_CLIENT] = getTlsVerifyClient() ? "true" : "false";
a[TLS_REQUIRE_CLIENT_CERTIFICATE] = getTlsRequireClientCertificate() ? "true" : "false";
a[TLS_NEGOTIATION_TIMEOUT_SEC] = getTlsNegotiationTimeoutSec();
a[TLS_NEGOTIATION_TIMEOUT_MSEC] = getTlsNegotiationTimeoutMsec();
a[TLS_ENABLE] = tlsEnable_;
a[TLS_CA_LIST_FILE] = tlsCaListFile_;
a[TLS_CERTIFICATE_FILE] = tlsCertificateFile_;
a[TLS_PRIVATE_KEY_FILE] = tlsPrivateKeyFile_;
a[TLS_PASSWORD] = tlsPassword_;
a[TLS_METHOD] = tlsMethod_;
a[TLS_CIPHERS] = tlsCiphers_;
a[TLS_SERVER_NAME] = tlsServerName_;
a[TLS_VERIFY_SERVER] = tlsVerifyServer_ ? "true" : "false";
a[TLS_VERIFY_CLIENT] = tlsVerifyClient_ ? "true" : "false";
a[TLS_REQUIRE_CLIENT_CERTIFICATE] = tlsRequireClientCertificate_ ? "true" : "false";
a[TLS_NEGOTIATION_TIMEOUT_SEC] = tlsNegotiationTimeoutSec_;
a[TLS_NEGOTIATION_TIMEOUT_MSEC] = tlsNegotiationTimeoutMsec_;
return a;
}
......@@ -549,7 +550,7 @@ int SIPAccount::registerVoIPLink()
// Init TLS settings if the user wants to use TLS
if (tlsEnable_ == "true") {
_debug ("SIPAccount: TLS is enabled for account %s", getAccountID().c_str());
_debug ("SIPAccount: TLS is enabled for account %s", accountID_.c_str());
transportType_ = PJSIP_TRANSPORT_TLS;
initTlsConfiguration();
}
......@@ -671,9 +672,8 @@ void SIPAccount::loadConfig()
if (tlsEnable_ == "true") {
initTlsConfiguration();
transportType_ = PJSIP_TRANSPORT_TLS;
} else {
} else
transportType_ = PJSIP_TRANSPORT_UDP;
}
}
bool SIPAccount::fullMatch (const std::string& username, const std::string& hostname) const
......
......@@ -37,73 +37,72 @@
#include <sstream>
#include "account.h"
#include "sipvoiplink.h"
#include "pjsip/sip_transport_tls.h"
#include "pjsip/sip_types.h"
#include "config/serializable.h"
#include <exception>
#include "pjsip-ua/sip_regc.h"
#include <vector>
#include <map>
namespace Conf {
class YamlEmitter;
class MappingNode;
}
enum DtmfType { OVERRTP, SIPINFO};
#define OVERRTPSTR "overrtp"
#define SIPINFOSTR "sipinfo"
// SIP specific configuration keys
const std::string expireKey ("expire");
const std::string interfaceKey ("interface");
const std::string portKey ("port");
const std::string publishAddrKey ("publishAddr");
const std::string publishPortKey ("publishPort");
const std::string sameasLocalKey ("sameasLocal");
const std::string resolveOnceKey ("resolveOnce");
const std::string dtmfTypeKey ("dtmfType");
const std::string serviceRouteKey ("serviceRoute");
static const char *const expireKey = "expire";
static const char *const interfaceKey = "interface";
static const char *const portKey = "port";
static const char *const publishAddrKey = "publishAddr";
static const char *const publishPortKey = "publishPort";
static const char *const sameasLocalKey = "sameasLocal";
static const char *const resolveOnceKey = "resolveOnce";
static const char *const dtmfTypeKey = "dtmfType";
static const char *const serviceRouteKey = "serviceRoute";
// TODO: write an object to store credential which implement serializable
const std::string srtpKey ("srtp");
const std::string srtpEnableKey ("enable");
const std::string keyExchangeKey ("keyExchange");
const std::string rtpFallbackKey ("rtpFallback");
static const char *const srtpKey = "srtp";
static const char *const srtpEnableKey = "enable";
static const char *const keyExchangeKey = "keyExchange";
static const char *const rtpFallbackKey = "rtpFallback";
// TODO: wirte an object to store zrtp params wich implement serializable
const std::string zrtpKey ("zrtp");
const std::string displaySasKey ("displaySas");
const std::string displaySasOnceKey ("displaySasOnce");
const std::string helloHashEnabledKey ("helloHashEnabled");
const std::string notSuppWarningKey ("notSuppWarning");
static const char *const zrtpKey = "zrtp";
static const char *const displaySasKey = "displaySas";
static const char *const displaySasOnceKey = "displaySasOnce";
static const char *const helloHashEnabledKey = "helloHashEnabled";
static const char *const notSuppWarningKey = "notSuppWarning";
// TODO: write an object to store tls params which implement serializable
const std::string tlsKey ("tls");
const std::string tlsPortKey ("tlsPort");
const std::string certificateKey ("certificate");
const std::string calistKey ("calist");
const std::string ciphersKey ("ciphers");
const std::string tlsEnableKey ("enable");
const std::string methodKey ("method");
const std::string timeoutKey ("timeout");
const std::string tlsPasswordKey ("password");
const std::string privateKeyKey ("privateKey");
const std::string requireCertifKey ("requireCertif");
const std::string serverKey ("server");
const std::string verifyClientKey ("verifyClient");
const std::string verifyServerKey ("verifyServer");
const std::string stunEnabledKey ("stunEnabled");
const std::string stunServerKey ("stunServer");
const std::string credKey ("credential");
static const char *const tlsKey = "tls";
static const char *const tlsPortKey = "tlsPort";
static const char *const certificateKey = "certificate";
static const char *const calistKey = "calist";
static const char *const ciphersKey = "ciphers";
static const char *const tlsEnableKey = "enable";
static const char *const methodKey = "method";
static const char *const timeoutKey = "timeout";
static const char *const tlsPasswordKey = "password";
static const char *const privateKeyKey = "privateKey";
static const char *const requireCertifKey = "requireCertif";
static const char *const serverKey = "server";
static const char *const verifyClientKey = "verifyClient";
static const char *const verifyServerKey = "verifyServer";
static const char *const stunEnabledKey = "stunEnabled";
static const char *const stunServerKey = "stunServer";
static const char *const credKey = "credential";
class SIPVoIPLink;
/**
* @file sipaccount.h
* @brief A SIP Account specify SIP specific functions and object (SIPCall/SIPVoIPLink)
* @brief A SIP Account specify SIP specific functions and object = SIPCall/SIPVoIPLink)
*/
class SIPAccount : public Account
......@@ -115,12 +114,6 @@ class SIPAccount : public Account
*/
SIPAccount (const std::string& accountID);
/* Copy Constructor */
SIPAccount (const SIPAccount& rh);
/* Assignment Operator */
SIPAccount& operator= (const SIPAccount& rh);
/**
* Virtual destructor
*/
......@@ -136,24 +129,9 @@ class SIPAccount : public Account
virtual std::map<std::string, std::string> getAccountDetails() const;
/**
* Set route header to appears in sip messages for this account
*/
void setRouteSet (const std::string &route) {
routeSet_ = route;
}
/**
* Get route header to appear in sip messages for this account
*/
std::string getRouteSet (void) const {
return routeSet_;
}
/**
* Special setVoIPLink which increment SipVoIPLink's number of client.
*/
// void setVoIPLink(VoIPLink *link);
void setVoIPLink();
/**
......@@ -559,6 +537,7 @@ class SIPAccount : public Account
std::string getTlsPassword (void) const {
return tlsPassword_;
}
void setTlsPassword (const std::string &pass) {
tlsPassword_ = pass;
}
......
......@@ -1184,7 +1184,6 @@ SIPVoIPLink::carryingDTMFdigits (const std::string& id, char code)
return true;
}
bool
SIPVoIPLink::dtmfSipInfo (SIPCall *call, char code)
{
......
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