From fb617034d4f13359dd01393e8a01de4980cbf0c6 Mon Sep 17 00:00:00 2001 From: Tristan Matthews <tristan.matthews@savoirfairelinux.com> Date: Wed, 20 Feb 2013 14:33:53 -0500 Subject: [PATCH] * #19940: account: get rid of "type" field The type field was erroneously either "IAX" or "iax2" for IAX accounts, and modifiable. A SIPAccount should always be a SIPAccount, and likewise for IAXAccounts. --- daemon/src/account.cpp | 3 +-- daemon/src/account.h | 8 +------- daemon/src/iax/iaxaccount.cpp | 10 +++++----- daemon/src/iax/iaxaccount.h | 1 + daemon/src/sip/sipaccount.cpp | 9 ++++----- daemon/src/sip/sipaccount.h | 1 + 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/daemon/src/account.cpp b/daemon/src/account.cpp index 80479a3245..c6b107ed4b 100644 --- a/daemon/src/account.cpp +++ b/daemon/src/account.cpp @@ -67,14 +67,13 @@ using std::string; using std::vector; -Account::Account(const string &accountID, const string &type) : +Account::Account(const string &accountID) : accountID_(accountID) , username_() , hostname_() , alias_() , enabled_(true) , autoAnswerEnabled_(false) - , type_(type) , registrationState_(UNREGISTERED) , audioCodecList_() , videoCodecList_() diff --git a/daemon/src/account.h b/daemon/src/account.h index 4f636a7729..71bf9c0bf7 100644 --- a/daemon/src/account.h +++ b/daemon/src/account.h @@ -57,7 +57,7 @@ class Account : public Serializable { public: - Account(const std::string& accountID, const std::string &type); + Account(const std::string& accountID); /** * Virtual destructor @@ -252,12 +252,6 @@ class Account : public Serializable { /* If true, automatically answer calls to this account */ bool autoAnswerEnabled_; - /* - * The account type - * IAX2 or SIP - */ - std::string type_; - /* * The general, protocol neutral registration * state of the account diff --git a/daemon/src/iax/iaxaccount.cpp b/daemon/src/iax/iaxaccount.cpp index e27d4f7504..6010d3b4ee 100644 --- a/daemon/src/iax/iaxaccount.cpp +++ b/daemon/src/iax/iaxaccount.cpp @@ -43,8 +43,10 @@ #include "config/yamlnode.h" #include "config/yamlemitter.h" +const char * const IAXAccount::ACCOUNT_TYPE = "IAX"; + IAXAccount::IAXAccount(const std::string& accountID) - : Account(accountID, "iax2"), password_(), link_(accountID) + : Account(accountID), password_(), link_(accountID) {} void IAXAccount::serialize(Conf::YamlEmitter &emitter) @@ -57,7 +59,7 @@ void IAXAccount::serialize(Conf::YamlEmitter &emitter) Conf::ScalarNode alias(alias_); Conf::ScalarNode hostname(hostname_); Conf::ScalarNode enable(enabled_); - Conf::ScalarNode type(type_); + Conf::ScalarNode type(ACCOUNT_TYPE); Conf::ScalarNode mailbox(mailBox_); Conf::ScalarNode codecs(audioCodecStr_); @@ -85,7 +87,6 @@ void IAXAccount::serialize(Conf::YamlEmitter &emitter) void IAXAccount::unserialize(const Conf::YamlNode &map) { map.getValue(ALIAS_KEY, &alias_); - map.getValue(TYPE_KEY, &type_); map.getValue(USERNAME_KEY, &username_); map.getValue(PASSWORD_KEY, &password_); map.getValue(HOSTNAME_KEY, &hostname_); @@ -102,7 +103,6 @@ void IAXAccount::setAccountDetails(std::map<std::string, std::string> details) { // Account setting common to SIP and IAX alias_ = details[CONFIG_ACCOUNT_ALIAS]; - type_ = details[CONFIG_ACCOUNT_TYPE]; username_ = details[CONFIG_ACCOUNT_USERNAME]; hostname_ = details[CONFIG_ACCOUNT_HOSTNAME]; password_ = details[CONFIG_ACCOUNT_PASSWORD]; @@ -119,7 +119,7 @@ std::map<std::string, std::string> IAXAccount::getAccountDetails() const a[CONFIG_ACCOUNT_ID] = accountID_; a[CONFIG_ACCOUNT_ALIAS] = alias_; a[CONFIG_ACCOUNT_ENABLE] = enabled_ ? "true" : "false"; - a[CONFIG_ACCOUNT_TYPE] = type_; + a[CONFIG_ACCOUNT_TYPE] = ACCOUNT_TYPE; a[CONFIG_ACCOUNT_HOSTNAME] = hostname_; a[CONFIG_ACCOUNT_USERNAME] = username_; a[CONFIG_ACCOUNT_PASSWORD] = password_; diff --git a/daemon/src/iax/iaxaccount.h b/daemon/src/iax/iaxaccount.h index aa0a8f1534..d5fbb71108 100644 --- a/daemon/src/iax/iaxaccount.h +++ b/daemon/src/iax/iaxaccount.h @@ -67,6 +67,7 @@ class IAXAccount : public Account { std::string password_; IAXVoIPLink link_; virtual VoIPLink* getVoIPLink(); + static const char * const ACCOUNT_TYPE; }; #endif diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index 195b7c11bf..0101dc1885 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -54,6 +54,7 @@ const char * const SIPAccount::IP2IP_PROFILE = "IP2IP"; const char * const SIPAccount::OVERRTP_STR = "overrtp"; const char * const SIPAccount::SIPINFO_STR = "sipinfo"; +const char * const SIPAccount::ACCOUNT_TYPE = "SIP"; namespace { const int MIN_REGISTRATION_TIME = 60; @@ -63,7 +64,7 @@ namespace { } SIPAccount::SIPAccount(const std::string& accountID) - : Account(accountID, "SIP") + : Account(accountID) , transport_(NULL) , credentials_() , regc_(NULL) @@ -139,7 +140,7 @@ void SIPAccount::serialize(Conf::YamlEmitter &emitter) ScalarNode hostname(Account::hostname_); ScalarNode enable(enabled_); ScalarNode autoAnswer(autoAnswerEnabled_); - ScalarNode type(Account::type_); + ScalarNode type(ACCOUNT_TYPE); std::stringstream registrationExpireStr; registrationExpireStr << registrationExpire_; ScalarNode expire(registrationExpireStr.str()); @@ -310,7 +311,6 @@ void SIPAccount::unserialize(const Conf::YamlNode &mapNode) using std::string; mapNode.getValue(ALIAS_KEY, &alias_); - mapNode.getValue(TYPE_KEY, &type_); mapNode.getValue(USERNAME_KEY, &username_); if (not isIP2IP()) mapNode.getValue(HOSTNAME_KEY, &hostname_); mapNode.getValue(ACCOUNT_ENABLE_KEY, &enabled_); @@ -469,7 +469,6 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details) { // Account setting common to SIP and IAX alias_ = details[CONFIG_ACCOUNT_ALIAS]; - type_ = details[CONFIG_ACCOUNT_TYPE]; username_ = details[CONFIG_ACCOUNT_USERNAME]; hostname_ = details[CONFIG_ACCOUNT_HOSTNAME]; enabled_ = details[CONFIG_ACCOUNT_ENABLE] == TRUE_STR; @@ -548,7 +547,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const a[CONFIG_ACCOUNT_ENABLE] = enabled_ ? TRUE_STR : FALSE_STR; a[CONFIG_ACCOUNT_AUTOANSWER]= autoAnswerEnabled_ ? TRUE_STR : FALSE_STR; - a[CONFIG_ACCOUNT_TYPE] = type_; + a[CONFIG_ACCOUNT_TYPE] = ACCOUNT_TYPE; a[CONFIG_ACCOUNT_HOSTNAME] = hostname_; a[CONFIG_ACCOUNT_USERNAME] = username_; diff --git a/daemon/src/sip/sipaccount.h b/daemon/src/sip/sipaccount.h index a8160c219f..e837b048e4 100644 --- a/daemon/src/sip/sipaccount.h +++ b/daemon/src/sip/sipaccount.h @@ -104,6 +104,7 @@ class SIPAccount : public Account { static const char * const IP2IP_PROFILE; static const char * const OVERRTP_STR; static const char * const SIPINFO_STR; + static const char * const ACCOUNT_TYPE; /** * Constructor -- GitLab