Commit e7cfcb99 authored by Tristan Matthews's avatar Tristan Matthews

* #6003, #6004: cleanup of account classes, defaultAccount no longer global

parent 7913e613
......@@ -33,7 +33,7 @@
#include "account.h"
#include "manager.h"
Account::Account (const AccountID& accountID, std::string type) :
Account::Account (const AccountID& accountID, const std::string &type) :
_accountID (accountID)
, _link (NULL)
, _enabled (true)
......
......@@ -156,7 +156,7 @@ class Account : public Serializable
public:
Account (const AccountID& accountID, std::string type);
Account (const AccountID& accountID, const std::string &type);
/**
* Virtual destructor
......@@ -177,7 +177,7 @@ class Account : public Serializable
virtual void setAccountDetails (const std::map<std::string, std::string>& details) = 0;
virtual std::map<std::string, std::string> getAccountDetails() = 0;
virtual std::map<std::string, std::string> getAccountDetails() const = 0;
/**
* Load the settings for this account.
......@@ -188,7 +188,7 @@ class Account : public Serializable
* Get the account ID
* @return constant account id
*/
inline const AccountID& getAccountID() {
const AccountID& getAccountID() const {
return _accountID;
}
......@@ -196,7 +196,7 @@ class Account : public Serializable
* Get the voiplink pointer
* @return VoIPLink* the pointer or 0
*/
inline VoIPLink* getVoIPLink() {
VoIPLink* getVoIPLink() const {
return _link;
}
......@@ -219,7 +219,7 @@ class Account : public Serializable
* @return true if enabled
* false otherwise
*/
bool isEnabled() {
bool isEnabled() const {
return _enabled;
}
......@@ -231,7 +231,7 @@ class Account : public Serializable
* Get the registration state of the specified link
* @return RegistrationState The registration state of underlying VoIPLink
*/
inline RegistrationState getRegistrationState() {
RegistrationState getRegistrationState() const {
return _registrationState;
}
......@@ -259,44 +259,44 @@ class Account : public Serializable
* @param void
* @return std::pair<int, std::string> A Code:Description state
*/
std::pair<int, std::string> getRegistrationStateDetailed (void) {
std::pair<int, std::string> getRegistrationStateDetailed (void) const {
return _registrationStateDetailed;
}
/* They should be treated like macro definitions by the C++ compiler */
inline std::string getUsername (void) {
std::string getUsername (void) const {
return _username;
}
inline void setUsername (std::string username) {
void setUsername (const std::string &username) {
_username = username;
}
inline std::string getHostname (void) {
std::string getHostname (void) const {
return _hostname;
}
inline void setHostname (std::string hostname) {
void setHostname (std::string hostname) {
_hostname = hostname;
}
inline std::string getPassword (void) {
std::string getPassword (void) const {
return _password;
}
inline void setPassword (std::string password) {
void setPassword (const std::string &password) {
_password = password;
}
inline std::string getAlias (void) {
std::string getAlias (void) const {
return _alias;
}
inline void setAlias (std::string alias) {
void setAlias (const std::string &alias) {
_alias = alias;
}
inline std::string getType (void) {
std::string getType (void) const {
return _type;
}
inline void setType (std::string type) {
void setType (const std::string &type) {
_type = type;
}
......@@ -304,7 +304,7 @@ class Account : public Serializable
* Accessor to data structures
* @return CodecOrder& The list that reflects the user's choice
*/
inline CodecOrder& getActiveCodecs (void) {
const CodecOrder& getActiveCodecs (void) const {
return _codecOrder;
}
......@@ -314,35 +314,35 @@ class Account : public Serializable
*/
void setActiveCodecs (const std::vector <std::string>& list);
inline std::string getRingtonePath (void) {
std::string getRingtonePath (void) const {
return _ringtonePath;
}
inline void setRingtonePath (std::string path) {
void setRingtonePath (const std::string &path) {
_ringtonePath = path;
}
inline bool getRingtoneEnabled (void) {
bool getRingtoneEnabled (void) const {
return _ringtoneEnabled;
}
inline void setRingtoneEnabled (bool enabl) {
void setRingtoneEnabled (bool enabl) {
_ringtoneEnabled = enabl;
}
inline std::string getDisplayName (void) {
std::string getDisplayName (void) const {
return _displayName;
}
inline void setDisplayName (std::string name) {
void setDisplayName (const std::string &name) {
_displayName = name;
}
std::string getUseragent (void) {
std::string getUseragent (void) const {
return _useragent;
}
void setUseragent (std::string ua) {
_useragent = ua;
}
std::string getMailBox (void) {
std::string getMailBox (void) const {
return _mailBox;
}
......
......@@ -216,7 +216,7 @@ void IAXAccount::setAccountDetails (const std::map<std::string, std::string>& de
}
std::map<std::string, std::string> IAXAccount::getAccountDetails()
std::map<std::string, std::string> IAXAccount::getAccountDetails() const
{
std::map<std::string, std::string> a;
......
......@@ -50,7 +50,7 @@ class IAXAccount : public Account
void setAccountDetails (const std::map<std::string, std::string>& details);
std::map<std::string, std::string> getAccountDetails();
std::map<std::string, std::string> getAccountDetails() const;
void setVoIPLink ();
......
......@@ -74,9 +74,6 @@
#define MD5_APPEND(pms,buf,len) pj_md5_update(pms, (const pj_uint8_t*)buf, len)
// Default account used to get default parametersa if requested by client (to build ne account)
SIPAccount defaultAccount ("default");
ManagerImpl::ManagerImpl (void) :
_hasTriedToRegister (false), _config(), _currentCallId2(),
_currentCallMutex(), _codecBuilder (NULL), _audiodriver (NULL),
......@@ -3751,18 +3748,20 @@ std::vector<std::string> ManagerImpl::getAccountList ()
std::map<std::string, std::string> ManagerImpl::getAccountDetails (
const AccountID& accountID)
{
// Default account used to get default parameters if requested by client (to build new account)
static const SIPAccount DEFAULT_ACCOUNT("default");
Account * account = _accountMap[accountID];
if (accountID.empty()) {
_debug ("Manager: Returning default account settings");
// return a default map
return defaultAccount.getAccountDetails();
return DEFAULT_ACCOUNT.getAccountDetails();
} else if (account) {
return account->getAccountDetails();
} else {
_debug ("Manager: Get account details on a non-existing accountID %s. Returning default", accountID.c_str());
return defaultAccount.getAccountDetails();
return DEFAULT_ACCOUNT.getAccountDetails();
}
}
......
......@@ -48,7 +48,7 @@ void Credentials::setNewCredential (std::string username, std::string password,
}
CredentialItem *Credentials::getCredential (int index)
const CredentialItem *Credentials::getCredential (int index) const
{
if ( (index >= 0) && (index < credentialCount))
return & (credentialArray[index]);
......@@ -814,7 +814,7 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de
}
}
std::map<std::string, std::string> SIPAccount::getAccountDetails()
std::map<std::string, std::string> SIPAccount::getAccountDetails() const
{
std::map<std::string, std::string> a;
......@@ -1170,12 +1170,12 @@ void SIPAccount::loadConfig()
Account::loadConfig();
}
bool SIPAccount::fullMatch (const std::string& username, const std::string& hostname)
bool SIPAccount::fullMatch (const std::string& username, const std::string& hostname) const
{
return (userMatch (username) && hostnameMatch (hostname));
}
bool SIPAccount::userMatch (const std::string& username)
bool SIPAccount::userMatch (const std::string& username) const
{
if (username.empty()) {
return false;
......@@ -1184,19 +1184,19 @@ bool SIPAccount::userMatch (const std::string& username)
return (username == getUsername());
}
bool SIPAccount::hostnameMatch (const std::string& hostname)
bool SIPAccount::hostnameMatch (const std::string& hostname) const
{
return (hostname == getHostname());
}
std::string SIPAccount::getMachineName (void)
std::string SIPAccount::getMachineName (void) const
{
std::string hostname;
hostname = std::string (pj_gethostname()->ptr, pj_gethostname()->slen);
return hostname;
}
std::string SIPAccount::getLoginName (void)
std::string SIPAccount::getLoginName (void) const
{
std::string username;
......@@ -1212,7 +1212,7 @@ std::string SIPAccount::getLoginName (void)
return username;
}
std::string SIPAccount::getTransportMapKey (void)
std::string SIPAccount::getTransportMapKey (void) const
{
std::stringstream out;
......@@ -1223,7 +1223,7 @@ std::string SIPAccount::getTransportMapKey (void)
}
std::string SIPAccount::getFromUri (void)
std::string SIPAccount::getFromUri (void) const
{
char uri[PJSIP_MAX_URL_SIZE];
......@@ -1265,7 +1265,7 @@ std::string SIPAccount::getFromUri (void)
return std::string (uri, len);
}
std::string SIPAccount::getToUri (const std::string& username)
std::string SIPAccount::getToUri (const std::string& username) const
{
char uri[PJSIP_MAX_URL_SIZE];
......@@ -1305,7 +1305,7 @@ std::string SIPAccount::getToUri (const std::string& username)
return std::string (uri, len);
}
std::string SIPAccount::getServerUri (void)
std::string SIPAccount::getServerUri (void) const
{
char uri[PJSIP_MAX_URL_SIZE];
......@@ -1332,7 +1332,7 @@ std::string SIPAccount::getServerUri (void)
return std::string (uri, len);
}
std::string SIPAccount::getContactHeader (const std::string& address, const std::string& port)
std::string SIPAccount::getContactHeader (const std::string& address, const std::string& port) const
{
char contact[PJSIP_MAX_URL_SIZE];
const char * beginquote, * endquote;
......
This diff is collapsed.
Markdown is supported
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