Skip to content
Snippets Groups Projects
Commit fb617034 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #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.
parent f5cbf0fe
Branches
Tags
No related merge requests found
......@@ -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_()
......
......@@ -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
......
......@@ -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_;
......
......@@ -67,6 +67,7 @@ class IAXAccount : public Account {
std::string password_;
IAXVoIPLink link_;
virtual VoIPLink* getVoIPLink();
static const char * const ACCOUNT_TYPE;
};
#endif
......@@ -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_;
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment