Commit ee09fc14 authored by yanmorin's avatar yanmorin

parent 2c74a005
......@@ -32,5 +32,3 @@ Account::~Account()
{
delete _link; _link = 0;
}
......@@ -20,10 +20,14 @@
#define ACCOUNT_H
#include <string>
#include "config/config.h"
class VoIPLink;
typedef std::string AccountID;
#define AccountNULL ""
#define CONFIG_ACCOUNT_TYPE "Account.type"
#define CONFIG_ACCOUNT_ENABLE "Account.enable"
/**
@author Yan Morin
......@@ -37,6 +41,11 @@ public:
~Account();
/**
* Load the default properties for the account
*/
virtual void initConfig(Conf::ConfigTree& config) = 0;
/**
* Register the account
* @return false is an error occurs
......@@ -69,10 +78,6 @@ private:
*/
virtual bool createVoIPLink() = 0;
/**
* Account ID are assign in constructor and shall not changed
*/
AccountID _accountID;
/**
* Voice over IP Link contains a listener thread and calls
*/
......@@ -95,6 +100,13 @@ private:
* Modified by unregister/register
*/
bool _registered;
protected:
/**
* Account ID are assign in constructor and shall not changed
*/
AccountID _accountID;
};
#endif
......@@ -59,4 +59,16 @@ AIXAccount::terminate()
return false;
}
void
AIXAccount::initConfig(Conf::ConfigTree& config)
{
std::string section(_accountID);
std::string type_str("string");
std::string type_int("int");
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_TYPE, "AIX", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_ENABLE, "1", type_int));
config.addConfigTreeItem(section, Conf::ConfigTreeItem("AIX.Proxy", "", type_str));
}
......@@ -33,6 +33,7 @@ public:
~AIXAccount();
/* virtual Account function implementation */
void initConfig(Conf::ConfigTree& config);
bool registerAccount();
bool unregisterAccount();
bool init();
......
......@@ -89,6 +89,16 @@ ManagerImpl::ManagerImpl (void)
_hasTriedToRegister = false;
// initialize random generator for call id
srand (time(NULL));
#ifdef TEST
testAccountMap();
loadAccountMap();
testCallAccountMap();
unloadAccountMap();
#endif
// should be call before initConfigFile
loadAccountMap();
}
// never call if we use only the singleton...
......@@ -106,12 +116,6 @@ ManagerImpl::~ManagerImpl (void)
void
ManagerImpl::init()
{
#ifdef TEST
testAccountMap();
loadAccountMap();
testCallAccountMap();
unloadAccountMap();
#endif
initVolume();
if (_exist == 0) {
......@@ -157,7 +161,6 @@ ManagerImpl::init()
// Set a sip voip link by default
_voIPLinkVector.push_back(new SipVoIPLink());
loadAccountMap();
// initRegisterVoIP was here, but we doing it after the gui loaded...
// the stun detection is long, so it's a better idea to do it after getEvents
initZeroconf();
......@@ -1270,6 +1273,8 @@ ManagerImpl::initConfigFile (void)
fill_config_str(VOICEMAIL_NUM, DFT_VOICEMAIL);
fill_config_int(CONFIG_ZEROCONF, CONFIG_ZEROCONF_DEFAULT_STR);
initConfigAccount();
_exist = createSettingsPath();
_setupLoaded = (_exist == 2 ) ? false : true;
}
......@@ -1839,22 +1844,15 @@ ManagerImpl::getNewCallID()
return random_id;
}
AccountMap _accountMap;
short
ManagerImpl::loadAccountMap()
{
short nbAccount = 0;
AccountID accID = "acc0";
_accountMap[accID] = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, accID);
_accountMap[ACCOUNT_SIP0] = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, ACCOUNT_SIP0);
nbAccount++;
accID = "acc1";
_accountMap[accID] = AccountCreator::createAccount(AccountCreator::AIX_ACCOUNT, accID);
_accountMap[ACCOUNT_AIX0] = AccountCreator::createAccount(AccountCreator::AIX_ACCOUNT, ACCOUNT_AIX0);
nbAccount++;
return nbAccount;
......@@ -1891,6 +1889,17 @@ ManagerImpl::getAccount(AccountID accountID)
return iter->second;
}
void
ManagerImpl::initConfigAccount() {
AccountMap::iterator iter = _accountMap.begin();
while ( iter != _accountMap.end() ) {
if (iter!=0 && iter->second!=0) {
iter->second->initConfig(_config);
}
iter++;
}
}
#ifdef TEST
/**
* Test accountMap
......
......@@ -486,6 +486,12 @@ private:
*/
Account* getAccount(AccountID accountID);
/**
* load default account variable for each protocol
*/
void initConfigAccount();
#ifdef TEST
bool testCallAccountMap();
bool testAccountMap();
......
......@@ -17,6 +17,16 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "sipaccount.h"
#define SIP_FULL_NAME "SIP.fullName"
#define SIP_USER_PART "SIP.userPart"
#define SIP_AUTH_USER_NAME "SIP.username"
#define SIP_PASSWORD "SIP.password"
#define SIP_HOST_PART "SIP.hostPart"
#define SIP_PROXY "SIP.proxy"
#define SIP_AUTO_REGISTER "SIP.autoregister"
#define SIP_STUN_SERVER "STUN.STUNserver"
#define SIP_USE_STUN "STUN.useStun"
SIPAccount::SIPAccount(const AccountID& accountID)
: Account(accountID)
......@@ -59,3 +69,21 @@ SIPAccount::terminate()
return false;
}
void
SIPAccount::initConfig(Conf::ConfigTree& config)
{
std::string section(_accountID);
std::string type_str("string");
std::string type_int("int");
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_TYPE, "SIP", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_ENABLE,"1", type_int));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_FULL_NAME, "", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_USER_PART, "", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_AUTH_USER_NAME, "", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_PROXY, "", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_AUTO_REGISTER, "1", type_int));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_STUN_SERVER, "stun.fwdnet.net:3478", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_USE_STUN, "0", type_int));
}
......@@ -33,6 +33,7 @@ public:
~SIPAccount();
/* virtual Account function implementation */
void initConfig(Conf::ConfigTree& config);
bool registerAccount();
bool unregisterAccount();
bool init();
......
......@@ -37,6 +37,10 @@
#define NETWORK "Network"
#define PREFERENCES "Preferences"
#define ACCOUNT_SIP0 "SIP0"
#define ACCOUNT_AIX0 "AIX0"
// Fields to fill
#define VOIP_LINK_ID "VoIPLink.index"
#define SYMMETRIC "VoIPLink.symmetric"
......
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