Commit b3db6f08 authored by Alexandre Bourget's avatar Alexandre Bourget
Browse files

Get and save correctly IAX accounts (via DBUS, in ManagerImpl)

parent 41e9f585
......@@ -31,6 +31,23 @@ typedef std::string AccountID;
#define CONFIG_ACCOUNT_AUTO_REGISTER "Account.autoregister"
#define CONFIG_ACCOUNT_ALIAS "Account.alias"
#define IAX_FULL_NAME "IAX.fullName"
#define IAX_HOST "IAX.host"
#define IAX_USER "IAX.user"
#define IAX_PASS "IAX.pass"
#define SIP_FULL_NAME "SIP.fullName"
#define SIP_USER_PART "SIP.userPart"
#define SIP_AUTH_NAME "SIP.username"
#define SIP_PASSWORD "SIP.password"
#define SIP_HOST_PART "SIP.hostPart"
#define SIP_PROXY "SIP.proxy"
#define SIP_STUN_SERVER "STUN.STUNserver"
#define SIP_USE_STUN "STUN.useStun"
/**
* Class account is an interface to protocol account (SIPAccount, IAXAccount)
* It can be enable on loading or activate after.
......
......@@ -21,11 +21,6 @@
#include "iaxvoiplink.h"
#include "manager.h"
#define IAX_FULL_NAME "IAX.fullName"
#define IAX_HOST "IAX.host"
#define IAX_USER "IAX.user"
#define IAX_PASS "IAX.pass"
IAXAccount::IAXAccount(const AccountID& accountID)
: Account(accountID)
{
......
......@@ -33,7 +33,7 @@
#include <cc++/file.h>
#include "manager.h"
#include "sipaccount.h"
#include "account.h"
#include "audio/audiolayer.h"
#include "audio/audiocodec.h"
#include "audio/tonelist.h"
......@@ -1502,19 +1502,19 @@ ManagerImpl::getDirListing(const std::string& sequenceId, const std::string& pat
std::vector< std::string >
ManagerImpl::getAccountList()
{
std::vector< std::string > v;
std::vector< std::string > v;
AccountMap::iterator iter = _accountMap.begin();
while ( iter != _accountMap.end() ) {
if ( iter->second != 0 ) {
_debug("Account List: %s\n", iter->first.data());
v.push_back(iter->first.data());
AccountMap::iterator iter = _accountMap.begin();
while ( iter != _accountMap.end() ) {
if ( iter->second != 0 ) {
_debug("Account List: %s\n", iter->first.data());
v.push_back(iter->first.data());
}
iter++;
}
_debug("Size: %d\n", v.size());
return v;
iter++;
}
_debug("Size: %d\n", v.size());
return v;
}
......@@ -1522,89 +1522,157 @@ ManagerImpl::getAccountList()
std::map< std::string, std::string >
ManagerImpl::getAccountDetails(const AccountID& accountID)
{
std::map<std::string, std::string> a;
std::map<std::string, std::string> a;
std::string accountType;
accountType = getConfigString(accountID, CONFIG_ACCOUNT_TYPE);
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_ALIAS,
getConfigString(accountID, CONFIG_ACCOUNT_ALIAS)
)
);
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_AUTO_REGISTER,
getConfigString(accountID, CONFIG_ACCOUNT_AUTO_REGISTER)== "1" ? "TRUE": "FALSE"
)
);
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_ENABLE,
getConfigString(accountID, CONFIG_ACCOUNT_ENABLE) == "1" ? "TRUE": "FALSE"
)
);
a.insert(
std::pair<std::string, std::string>(
"Status",
_accountMap[accountID]->getState() ? "REGISTERED": "UNREGISTERED"
)
);
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_TYPE, accountType
)
);
if (accountType == "SIP") {
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_ALIAS,
getConfigString(accountID, CONFIG_ACCOUNT_ALIAS)
SIP_FULL_NAME,
getConfigString(accountID, SIP_FULL_NAME)
)
);
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_AUTO_REGISTER,
getConfigString(accountID, CONFIG_ACCOUNT_AUTO_REGISTER)== "1" ? "TRUE": "FALSE"
SIP_USER_PART,
getConfigString(accountID, SIP_USER_PART)
)
);
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_ENABLE,
getConfigString(accountID, CONFIG_ACCOUNT_ENABLE) == "1" ? "TRUE": "FALSE"
SIP_AUTH_NAME,
getConfigString(accountID, SIP_AUTH_NAME)
)
);
a.insert(
std::pair<std::string, std::string>(
"Status",
_accountMap[accountID]->getState() ? "REGISTERED": "UNREGISTERED"
SIP_PASSWORD,
getConfigString(accountID, SIP_PASSWORD)
)
);
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_TYPE,
getConfigString(accountID, CONFIG_ACCOUNT_TYPE)
SIP_HOST_PART,
getConfigString(accountID, SIP_HOST_PART)
)
);
a.insert(
std::pair<std::string, std::string>(
SIP_FULL_NAME,
getConfigString(accountID, SIP_FULL_NAME)
SIP_PROXY,
getConfigString(accountID, SIP_PROXY)
)
);
a.insert(
std::pair<std::string, std::string>(
SIP_USER_PART,
getConfigString(accountID, SIP_USER_PART)
SIP_STUN_SERVER,
getConfigString(accountID, SIP_STUN_SERVER)
)
);
a.insert(
std::pair<std::string, std::string>(
SIP_AUTH_NAME,
getConfigString(accountID, SIP_AUTH_NAME)
SIP_USE_STUN,
getConfigString(accountID, SIP_USE_STUN) == "1" ? "TRUE": "FALSE"
)
);
}
else if (accountType == "IAX") {
a.insert(
std::pair<std::string, std::string>(
SIP_PASSWORD,
getConfigString(accountID, SIP_PASSWORD)
IAX_FULL_NAME,
getConfigString(accountID, IAX_FULL_NAME)
)
);
a.insert(
std::pair<std::string, std::string>(
SIP_HOST_PART,
getConfigString(accountID, SIP_HOST_PART)
IAX_HOST,
getConfigString(accountID, IAX_HOST)
)
);
a.insert(
std::pair<std::string, std::string>(
IAX_USER,
getConfigString(accountID, IAX_USER)
)
);
a.insert(
std::pair<std::string, std::string>(
IAX_PASS,
getConfigString(accountID, IAX_PASS)
)
);
}
else {
// Unknown type
_debug("Unknown account type in getAccountDetails(): %s", accountType.c_str());
}
return a;
return a;
}
void
ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
const std::map< ::DBus::String, ::DBus::String >& details )
const std::map< ::DBus::String, ::DBus::String >& details )
{
std::string accountType = (*details.find(CONFIG_ACCOUNT_TYPE)).second;
setConfig(accountID, CONFIG_ACCOUNT_ALIAS, (*details.find(CONFIG_ACCOUNT_ALIAS)).second);
setConfig(accountID, CONFIG_ACCOUNT_AUTO_REGISTER,
(*details.find(CONFIG_ACCOUNT_AUTO_REGISTER)).second == "TRUE" ? "1": "0" );
setConfig(accountID, CONFIG_ACCOUNT_ENABLE,
(*details.find(CONFIG_ACCOUNT_ENABLE)).second == "TRUE" ? "1": "0" );
setConfig(accountID, CONFIG_ACCOUNT_TYPE, (*details.find(CONFIG_ACCOUNT_TYPE)).second);
setConfig(accountID, CONFIG_ACCOUNT_ALIAS, (*details.find(CONFIG_ACCOUNT_ALIAS)).second);
setConfig(accountID, CONFIG_ACCOUNT_AUTO_REGISTER,
(*details.find(CONFIG_ACCOUNT_AUTO_REGISTER)).second == "TRUE" ? "1": "0" );
setConfig(accountID, CONFIG_ACCOUNT_ENABLE,
(*details.find(CONFIG_ACCOUNT_ENABLE)).second == "TRUE" ? "1": "0" );
setConfig(accountID, CONFIG_ACCOUNT_TYPE, accountType);
if (accountType == "SIP") {
setConfig(accountID, SIP_FULL_NAME, (*details.find(SIP_FULL_NAME)).second);
setConfig(accountID, SIP_USER_PART, (*details.find(SIP_USER_PART)).second);
setConfig(accountID, SIP_AUTH_NAME, (*details.find(SIP_AUTH_NAME)).second);
setConfig(accountID, SIP_PASSWORD, (*details.find(SIP_PASSWORD)).second);
setConfig(accountID, SIP_HOST_PART, (*details.find(SIP_HOST_PART)).second);
setConfig(accountID, SIP_PROXY, (*details.find(SIP_PROXY)).second);
setConfig(accountID, SIP_STUN_SERVER,(*details.find(SIP_STUN_SERVER)).second);
setConfig(accountID, SIP_USE_STUN,
(*details.find(SIP_USE_STUN)).second == "TRUE" ? "1" : "0");
}
else if (accountType == "IAX") {
setConfig(accountID, IAX_FULL_NAME, (*details.find(IAX_FULL_NAME)).second);
setConfig(accountID, IAX_HOST, (*details.find(IAX_HOST)).second);
setConfig(accountID, IAX_USER, (*details.find(IAX_USER)).second);
setConfig(accountID, IAX_PASS, (*details.find(IAX_PASS)).second);
} else {
_debug("Unknown account type in setAccountDetails(): %s", accountType.c_str());
}
}
......
......@@ -21,14 +21,6 @@
#include "account.h"
#define SIP_FULL_NAME "SIP.fullName"
#define SIP_USER_PART "SIP.userPart"
#define SIP_AUTH_NAME "SIP.username"
#define SIP_PASSWORD "SIP.password"
#define SIP_HOST_PART "SIP.hostPart"
#define SIP_PROXY "SIP.proxy"
#define SIP_STUN_SERVER "STUN.STUNserver"
#define SIP_USE_STUN "STUN.useStun"
/**
* A Sip Account specify SIP specific functions and object (SIPCall/SIPVoIPLink)
......
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