Commit 3bd1cb01 authored by Emmanuel Lepage's avatar Emmanuel Lepage

[#7121] Polishing library (over). Indentation, spacing and naming are now consistent

parent 3a2a4e94
......@@ -100,7 +100,7 @@ QString SFLPhoneEngine::getCallStateName(call_state state)
void SFLPhoneEngine::updateHistory()
{
foreach (Call* oldCall, historyCalls) {
foreach (Call* oldCall, getHistory()) {
historyCall[oldCall->getCallId()]["Name"] = oldCall->getPeerName();
historyCall[oldCall->getCallId()]["Number"] = oldCall->getPeerPhoneNumber();
historyCall[oldCall->getCallId()]["Date"] = oldCall->getStopTimeStamp();
......
......@@ -78,8 +78,8 @@ AccountView* AccountView::buildExistingAccountFromId(QString _accountId)
//Account* a = Account::buildExistingAccountFromId( _accountId);
ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
AccountView* a = new AccountView();
a->accountId = new QString(_accountId);
a->accountDetails = new MapStringString( configurationManager.getAccountDetails(_accountId).value() );
a->m_pAccountId = new QString(_accountId);
a->m_pAccountDetails = new MapStringString( configurationManager.getAccountDetails(_accountId).value() );
a->initItem();
return a;
}
......@@ -88,7 +88,7 @@ AccountView* AccountView::buildNewAccountFromAlias(QString alias)
{
//Account* a = Account::buildNewAccountFromAlias(alias);
AccountView* a = new AccountView();
a->accountDetails = new MapStringString();
a->m_pAccountDetails = new MapStringString();
a->setAccountDetail(ACCOUNT_ALIAS,alias);
a->initItem();
return a;
......
......@@ -510,7 +510,7 @@ void CallView::conferenceRemoved(const QString &confId)
///Clear the list of old calls //TODO Clear them from the daemon
void CallView::clearHistory()
{
historyCalls.clear();
m_pHistoryCalls.clear();
}
void CallView::conferenceCreatedSignal(const QString& confId)
......
......@@ -27,155 +27,182 @@
#include "sflphone_const.h"
#include "configurationmanager_interface_singleton.h"
///Match state name to user readable string
const QString account_state_name(QString & s)
{
if(s == QString(ACCOUNT_STATE_REGISTERED))
return "Registered";
if(s == QString(ACCOUNT_STATE_UNREGISTERED))
return "Not Registered";
if(s == QString(ACCOUNT_STATE_TRYING))
return "Trying...";
if(s == QString(ACCOUNT_STATE_ERROR))
return "Error";
if(s == QString(ACCOUNT_STATE_ERROR_AUTH))
return "Authentication Failed";
if(s == QString(ACCOUNT_STATE_ERROR_NETWORK))
return "Network unreachable";
if(s == QString(ACCOUNT_STATE_ERROR_HOST))
return "Host unreachable";
if(s == QString(ACCOUNT_STATE_ERROR_CONF_STUN))
return "Stun configuration error";
if(s == QString(ACCOUNT_STATE_ERROR_EXIST_STUN))
return "Stun server invalid";
return "Invalid";
}
//Constructors
Account::Account():accountId(NULL),accountDetails(NULL)
{
}
#include <unistd.h>
if(s == QString(ACCOUNT_STATE_REGISTERED) )
return "Registered" ;
if(s == QString(ACCOUNT_STATE_UNREGISTERED) )
return "Not Registered" ;
if(s == QString(ACCOUNT_STATE_TRYING) )
return "Trying..." ;
if(s == QString(ACCOUNT_STATE_ERROR) )
return "Error" ;
if(s == QString(ACCOUNT_STATE_ERROR_AUTH) )
return "Authentication Failed" ;
if(s == QString(ACCOUNT_STATE_ERROR_NETWORK) )
return "Network unreachable" ;
if(s == QString(ACCOUNT_STATE_ERROR_HOST) )
return "Host unreachable" ;
if(s == QString(ACCOUNT_STATE_ERROR_CONF_STUN) )
return "Stun configuration error" ;
if(s == QString(ACCOUNT_STATE_ERROR_EXIST_STUN) )
return "Stun server invalid" ;
return "Invalid" ;
}
///Constructors
Account::Account():m_pAccountId(NULL),m_pAccountDetails(NULL)
{
}
///Build an account from it'id
Account* Account::buildExistingAccountFromId(QString _accountId)
{
qDebug() << "Building an account from id: " << _accountId;
ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
Account* a = new Account();
a->accountId = new QString(_accountId);
a->m_pAccountId = new QString(_accountId);
MapStringString* aDetails = new MapStringString(configurationManager.getAccountDetails(_accountId).value());
//MapStringString* accountDetails = &configurationManager.getAccountDetails(_accountId).value(); //SegFault???
if (!aDetails->count()) {
qDebug() << "Account not found";
return NULL;
}
a->accountDetails = aDetails;
a->m_pAccountDetails = aDetails;
return a;
}
///Build an account from it's name / alias
Account* Account::buildNewAccountFromAlias(QString alias)
{
qDebug() << "Building an account from alias: " << alias;
Account* a = new Account();
a->accountDetails = new MapStringString();
a->m_pAccountDetails = new MapStringString();
a->setAccountDetail(ACCOUNT_ALIAS,alias);
return a;
}
///Destructor
Account::~Account()
{
delete accountId;
//delete accountDetails;
//delete item;
delete m_pAccountId;
}
//Getters
/*****************************************************************************
* *
* Getters *
* *
****************************************************************************/
///IS this account new
bool Account::isNew() const
{
return (accountId == NULL);
return (m_pAccountId == NULL);
}
///Get this account ID
const QString & Account::getAccountId() const
{
if (isNew())
qDebug() << "Error : getting AccountId of a new account.";
if (!accountId) {
if (!m_pAccountId) {
qDebug() << "Account not configured";
return ""; //WARNING May explode
}
return *accountId;
return *m_pAccountId;
}
///Get this account details
MapStringString& Account::getAccountDetails() const
{
return *accountDetails;
return *m_pAccountDetails;
}
///Get current state
QString Account::getStateName(QString & state)
{
return account_state_name(state);
}
///Get an account detail
QString Account::getAccountDetail(QString param) const
{
if (!accountDetails) {
if (!m_pAccountDetails) {
qDebug() << "The account list is not set";
return NULL; //May crash, but better than crashing now
}
if (accountDetails->find(param) != accountDetails->end())
return (*accountDetails)[param];
if (m_pAccountDetails->find(param) != m_pAccountDetails->end())
return (*m_pAccountDetails)[param];
else {
qDebug() << "Account details not found, there is " << accountDetails->count() << " details available";
qDebug() << "Account details not found, there is " << m_pAccountDetails->count() << " details available";
return NULL;
}
}
///Get the alias
QString Account::getAlias() const
{
return getAccountDetail(ACCOUNT_ALIAS);
}
///Is this account enabled
bool Account::isEnabled() const
{
qDebug() << "isEnabled = " << getAccountDetail(ACCOUNT_ENABLED);
return (getAccountDetail(ACCOUNT_ENABLED) == ACCOUNT_ENABLED_TRUE);
}
///Is this account registered
bool Account::isRegistered() const
{
qDebug() << "isRegistered = " << getAccountDetail(ACCOUNT_STATUS);
return (getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED);
}
//Setters
/*****************************************************************************
* *
* Setters *
* *
****************************************************************************/
///Set account details
void Account::setAccountDetails(MapStringString m)
{
*accountDetails = m;
*m_pAccountDetails = m;
}
///Set a specific detail
void Account::setAccountDetail(QString param, QString val)
{
(*accountDetails)[param] = val;
(*m_pAccountDetails)[param] = val;
}
///Set the account id
void Account::setAccountId(QString id)
{
qDebug() << "accountId = " << accountId;
qDebug() << "accountId = " << m_pAccountId;
if (! isNew())
qDebug() << "Error : setting AccountId of an existing account.";
accountId = new QString(id);
m_pAccountId = new QString(id);
}
///Set account enabled
void Account::setEnabled(bool checked)
{
setAccountDetail(ACCOUNT_ENABLED, checked ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE);
}
bool Account::isEnabled() const
{
qDebug() << "isEnabled = " << getAccountDetail(ACCOUNT_ENABLED);
return (getAccountDetail(ACCOUNT_ENABLED) == ACCOUNT_ENABLED_TRUE);
}
bool Account::isRegistered() const
{
qDebug() << "isRegistered = " << getAccountDetail(ACCOUNT_STATUS);
return (getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED);
}
/*****************************************************************************
* *
* Mutator *
* *
****************************************************************************/
///Update the account
void Account::updateState()
{
qDebug() << "updateState";
......@@ -187,10 +214,16 @@ void Account::updateState()
}
}
//Operators
/*****************************************************************************
* *
* Operator *
* *
****************************************************************************/
///Are both account the same
bool Account::operator==(const Account& a)const
{
return *accountId == *a.accountId;
return *m_pAccountId == *a.m_pAccountId;
}
......@@ -61,8 +61,8 @@ class LIB_EXPORT Account : public QObject {
protected:
Account();
QString * accountId;
MapStringString* accountDetails;
QString* m_pAccountId;
MapStringString* m_pAccountDetails;
public slots:
void setEnabled(bool checked);
......
......@@ -17,7 +17,7 @@
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
**************************************************************************/
#include "AccountList.h"
#include "sflphone_const.h"
......@@ -25,54 +25,93 @@
//Constructors
///Constructors
AccountList::AccountList(QStringList & _accountIds)
{
// firstAccount = QString();
accounts = new QVector<Account*>();
m_pAccounts = new QVector<Account*>();
for (int i = 0; i < _accountIds.size(); ++i) {
(*accounts) += Account::buildExistingAccountFromId(_accountIds[i]);
(*m_pAccounts) += Account::buildExistingAccountFromId(_accountIds[i]);
}
}
///Constructors
AccountList::AccountList(bool fill)
{
accounts = new QVector<Account *>();
m_pAccounts = new QVector<Account *>();
if(fill)
updateAccounts();
}
///Destructor
AccountList::~AccountList()
{
delete m_pAccounts;
}
/*****************************************************************************
* *
* Mutator *
* *
****************************************************************************/
///Update accounts
void AccountList::update()
{
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
Account * current;
for (int i = 0; i < accounts->size(); i++) {
current = (*accounts)[i];
if (!(*accounts)[i]->isNew())
for (int i = 0; i < m_pAccounts->size(); i++) {
current = (*m_pAccounts)[i];
if (!(*m_pAccounts)[i]->isNew())
removeAccount(current);
}
//ask for the list of accounts ids to the configurationManager
QStringList accountIds = configurationManager.getAccountList().value();
for (int i = 0; i < accountIds.size(); ++i) {
accounts->insert(i, Account::buildExistingAccountFromId(accountIds[i]));
m_pAccounts->insert(i, Account::buildExistingAccountFromId(accountIds[i]));
}
}
///Update accounts
void AccountList::updateAccounts()
{
qDebug() << "updateAccounts";
ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
QStringList accountIds = configurationManager.getAccountList().value();
accounts->clear();
m_pAccounts->clear();
for (int i = 0; i < accountIds.size(); ++i) {
qDebug() << "updateAccounts " << accountIds[i];
(*accounts) += Account::buildExistingAccountFromId(accountIds[i]);
(*m_pAccounts) += Account::buildExistingAccountFromId(accountIds[i]);
}
emit accountListUpdated();
}
/*****************************************************************************
* *
* Getters *
* *
****************************************************************************/
///Get all accounts
QVector<Account*> & AccountList::getAccounts()
{
return *m_pAccounts;
}
///Get a single account
const Account* AccountList::getAccountAt (int i) const
{
return (*m_pAccounts)[i];
}
///Get a single account
Account* AccountList::getAccountAt (int i)
{
return (*m_pAccounts)[i];
}
///Get a serialized string of all accounts
QString AccountList::getOrderedList() const
{
QString order;
......@@ -82,13 +121,37 @@ QString AccountList::getOrderedList() const
return order;
}
///Get account using its ID
Account* AccountList::getAccountById(const QString & id) const
{
if(id.isEmpty())
return NULL;
for (int i = 0; i < m_pAccounts->size(); ++i) {
if (!(*m_pAccounts)[i]->isNew() && (*m_pAccounts)[i]->getAccountId() == id)
return (*m_pAccounts)[i];
}
return NULL;
}
///Get account with a specific state
QVector<Account*> AccountList::getAccountsByState(QString & state)
{
QVector<Account *> v;
for (int i = 0; i < m_pAccounts->size(); ++i) {
if ((*m_pAccounts)[i]->getAccountDetail(ACCOUNT_STATUS) == state)
v += (*m_pAccounts)[i];
}
return v;
}
///Get a list of all registerred account
QVector<Account*> AccountList::registeredAccounts() const
{
qDebug() << "registeredAccounts";
QVector<Account*> registeredAccounts;
Account* current;
for (int i = 0; i < accounts->count(); ++i) {
current = (*accounts)[i];
for (int i = 0; i < m_pAccounts->count(); ++i) {
current = (*m_pAccounts)[i];
if(current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) {
qDebug() << current->getAlias() << " : " << current;
registeredAccounts.append(current);
......@@ -97,11 +160,12 @@ QVector<Account*> AccountList::registeredAccounts() const
return registeredAccounts;
}
///Get the first registerred account (default account)
Account* AccountList::firstRegisteredAccount() const
{
Account* current;
for (int i = 0; i < accounts->count(); ++i) {
current = (*accounts)[i];
for (int i = 0; i < m_pAccounts->count(); ++i) {
current = (*m_pAccounts)[i];
if(current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) {
return current;
}
......@@ -112,73 +176,46 @@ Account* AccountList::firstRegisteredAccount() const
return NULL;
}
AccountList::~AccountList()
{
delete accounts;
}
//Getters
QVector<Account*> & AccountList::getAccounts()
{
return *accounts;
}
const Account* AccountList::getAccountAt (int i) const
{
return (*accounts)[i];
}
Account* AccountList::getAccountAt (int i)
{
return (*accounts)[i];
}
Account* AccountList::getAccountById(const QString & id) const
{
if(id.isEmpty())
return NULL;
for (int i = 0; i < accounts->size(); ++i) {
if (!(*accounts)[i]->isNew() && (*accounts)[i]->getAccountId() == id)
return (*accounts)[i];
}
return NULL;
}
QVector<Account*> AccountList::getAccountsByState(QString & state)
{
QVector<Account *> v;
for (int i = 0; i < accounts->size(); ++i) {
if ((*accounts)[i]->getAccountDetail(ACCOUNT_STATUS) == state)
v += (*accounts)[i];
}
return v;
}
///Get the account size
int AccountList::size() const
{
return accounts->size();
return m_pAccounts->size();
}
//Setters
/*****************************************************************************
* *
* Setters *
* *
****************************************************************************/
///Add an account
Account* AccountList::addAccount(QString & alias)
{
Account* a = Account::buildNewAccountFromAlias(alias);
(*accounts) += a;
(*m_pAccounts) += a;
return a;
}
///Remove an account
void AccountList::removeAccount(Account* account)
{
accounts->remove(accounts->indexOf(account));
m_pAccounts->remove(m_pAccounts->indexOf(account));
}
/*****************************************************************************
* *
* Operator *
* *
****************************************************************************/
///Get the accoutn from its index
const Account* AccountList::operator[] (int i) const
{
return (*accounts)[i];
return (*m_pAccounts)[i];
}
///Get the accoutn from its index
Account* AccountList::operator[] (int i)
{
return (*accounts)[i];
return (*m_pAccounts)[i];
}
......@@ -34,7 +34,7 @@ class LIB_EXPORT AccountList : public QObject{
private:
QVector<Account*>* accounts;
QVector<Account*>* m_pAccounts;
public:
......
This diff is collapsed.
......@@ -117,14 +117,14 @@ private:
//Call attributes
QString account;
QString callId;
QString confId;
QString peerPhoneNumber;
QString peerName;
history_state historyState;
QDateTime * startTime;
QDateTime * stopTime;
QString m_pAccount;
QString m_pCallId;
QString m_pConfId;
QString m_pPeerPhoneNumber;
QString m_pPeerName;
history_state m_pHistoryState;
QDateTime* m_pStartTime;
QDateTime* m_pStopTime;
/*
QWidget * historyItemWidget;
......@@ -184,81 +184,75 @@ private:
//Automate functions
// See actionPerformedFunctionMap and stateChangedFunctionMap
// to know when it is called.
void nothing();
void accept();
void refuse();
void acceptTransf();
void acceptHold();
void hangUp();
void cancel();
void hold();
void call();
void transfer();
void unhold();
void switchRecord();
void setRecord();
void start();
void startStop();
void stop();
void startWeird();
void warning();
void nothing ();
void accept ();
void refuse ();
void acceptTransf ();
void acceptHold ();
void hangUp ();
void cancel ();
void hold ();
void call ();
void transfer ();
void unhold ();
void switchRecord ();
void setRecord ();
void start ();
void startStop ();
void stop ();
void startWeird ();
void warning ();
public:
Call(QString confId, QString account);
//Constructors & Destructors
Call(QString confId, QString account);
~Call();
// void initCallItemWidget();
static Call* buildDialingCall(QString callId, const QString & peerName, QString account = "");
static Call* buildIncomingCall(const QString & callId);
static Call* buildRingingCall(const QString & callId);
static Call* buildHistoryCall(const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type);
static Call* buildExistingCall(QString callId);
static history_state getHistoryStateFromType(QString type);
static QString getTypeFromHistoryState(history_state historyState);
static call_state getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType);
static history_state getHistoryStateFromDaemonCallState(QString daemonCallState, QString daemonCallType);
static Call* buildDialingCall (QString callId, const QString & peerName, QString account = "" );
static Call* buildIncomingCall (const QString & callId );
static Call* buildRingingCall (const QString & callId );
static Call* buildHistoryCall (const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type );
static Call* buildExistingCall (QString callId );
//Static getters
static history_state getHistoryStateFromType ( QString type );
static QString getTypeFromHistoryState ( history_state historyState );
static call_state getStartStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType );
static history_state getHistoryStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType );
//Getters
call_state getState() const;
QString getCallId() const;
QString getPeerPhoneNumber() const;
QString getPeerName() const;
call_state getCurrentState() const;
history_state getHistoryState() const;
bool getRecording() const;
QString getAccountId() const;
bool isHistory() const;
QString getStopTimeStamp() const;
QString getStartTimeStamp() const;
QString getCurrentCodecName();
bool isSecure();
bool isConference() const;
call_state getState () const;
QString getCallId () const;
QString getPeerPhoneNumber () const;
QString getPeerName () const;
call_state getCurrentState () const;
history_state getHistoryState () const;
bool getRecording () const;
QString getAccountId () const;
bool isHistory () const;
QString getStopTimeStamp () const;
QString getStartTimeStamp () const;
QString getCurrentCodecName () const;
bool isSecure () const;
bool isConference () const;
QString getConfId () const;
QString getTransferNumber () const;
QString getCallNumber () const;
//Automated function
call_state stateChanged(const QString & newState);
call_state actionPerformed(call_action action);
//Setters
void setConference(bool value);
QString getConfId() const;
void setConfId(QString value);