Skip to content
Snippets Groups Projects
Commit ba3f9e73 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

[ #60972 ] Port Account to use D-Pointer

parent 323277f7
Branches
Tags
No related merge requests found
...@@ -100,6 +100,7 @@ public: ...@@ -100,6 +100,7 @@ public:
virtual QList<T*> items() const = 0; virtual QList<T*> items() const = 0;
private: private:
// QScopedPointer<AbstractItemBackendInterface> m_P;
AbstractItemBackendInterface<T>* m_pParent; AbstractItemBackendInterface<T>* m_pParent;
QVector<AbstractItemBackendInterface<T>*> m_lChildren; QVector<AbstractItemBackendInterface<T>*> m_lChildren;
}; };
......
This diff is collapsed.
...@@ -39,7 +39,9 @@ class PhoneNumber ; ...@@ -39,7 +39,9 @@ class PhoneNumber ;
class SecurityValidationModel; class SecurityValidationModel;
class Certificate ; class Certificate ;
typedef void (Account::*account_function)(); //Private
class AccountPrivate;
///@enum DtmfType Different method to send the DTMF (key sound) to the peer ///@enum DtmfType Different method to send the DTMF (key sound) to the peer
enum DtmfType { enum DtmfType {
...@@ -115,8 +117,8 @@ class LIB_EXPORT Account : public QObject { ...@@ -115,8 +117,8 @@ class LIB_EXPORT Account : public QObject {
public: public:
///@enum AccountEditState: Manage how and when an account can be reloaded or change state ///@enum EditState: Manage how and when an account can be reloaded or change state
enum class AccountEditState { enum class EditState {
READY = 0, READY = 0,
EDITING = 1, EDITING = 1,
OUTDATED = 2, OUTDATED = 2,
...@@ -125,8 +127,8 @@ class LIB_EXPORT Account : public QObject { ...@@ -125,8 +127,8 @@ class LIB_EXPORT Account : public QObject {
REMOVED = 5 REMOVED = 5
}; };
///@enum AccountEditAction Actions that can be performed on the Account state ///@enum EditAction Actions that can be performed on the Account state
enum class AccountEditAction { enum class EditAction {
NOTHING = 0, NOTHING = 0,
EDIT = 1, EDIT = 1,
RELOAD = 2, RELOAD = 2,
...@@ -313,14 +315,13 @@ class LIB_EXPORT Account : public QObject { ...@@ -313,14 +315,13 @@ class LIB_EXPORT Account : public QObject {
*Perform an action *Perform an action
* @return If the state changed * @return If the state changed
*/ */
bool performAction(Account::AccountEditAction action); bool performAction(Account::EditAction action);
Account::AccountEditState state() const; Account::EditState state() const;
//Getters //Getters
bool isNew() const; bool isNew() const;
const QString id() const; const QString id() const;
const QString toHumanStateName() const; const QString toHumanStateName() const;
const QString accountDetail(const QString& param) const;
const QString alias() const; const QString alias() const;
bool isRegistered() const; bool isRegistered() const;
QModelIndex index() ; QModelIndex index() ;
...@@ -463,53 +464,12 @@ class LIB_EXPORT Account : public QObject { ...@@ -463,53 +464,12 @@ class LIB_EXPORT Account : public QObject {
public Q_SLOTS: public Q_SLOTS:
void setEnabled(bool checked); void setEnabled(bool checked);
private Q_SLOTS:
void slotPresentChanged (bool present );
void slotPresenceMessageChanged(const QString& );
void slotUpdateCertificate ( );
private: private:
//Constructors //Constructors
Account(); Account();
//Attributes QScopedPointer<AccountPrivate> d_ptr;
QString m_AccountId ; Q_DECLARE_PRIVATE(Account)
QHash<QString,QString> m_hAccountDetails;
PhoneNumber* m_pAccountNumber ;
//Setters
void setAccountDetails (const QHash<QString,QString>& m );
bool setAccountDetail (const QString& param, const QString& val );
//State actions
void nothing() {};
void edit() {m_CurrentState = AccountEditState::EDITING ;emit changed(this);};
void modify() {m_CurrentState = AccountEditState::MODIFIED;emit changed(this);};
void remove() {m_CurrentState = AccountEditState::REMOVED ;emit changed(this);};
void cancel() {m_CurrentState = AccountEditState::READY ;emit changed(this);};
void outdate() {m_CurrentState = AccountEditState::OUTDATED;emit changed(this);};
void reload();
void save();
void reloadMod() {reload();modify();};
CredentialModel* m_pCredentials ;
AudioCodecModel* m_pAudioCodecs ;
VideoCodecModel* m_pVideoCodecs ;
RingToneModel* m_pRingToneModel ;
KeyExchangeModel* m_pKeyExchangeModel;
SecurityValidationModel* m_pSecurityValidationModel;
AccountEditState m_CurrentState;
static const account_function stateMachineActionsOnState[6][7];
//Cached account details (as they are called too often for the hash)
QString m_HostName;
QString m_LastErrorMessage;
int m_LastErrorCode;
int m_VoiceMailCount;
Certificate* m_pCaCert;
Certificate* m_pTlsCert;
Certificate* m_pPrivateKey;
Q_SIGNALS: Q_SIGNALS:
///The account state (Invalid,Trying,Registered) changed ///The account state (Invalid,Trying,Registered) changed
......
...@@ -195,7 +195,7 @@ void AccountListModel::accountChanged(const QString& account,const QString& stat ...@@ -195,7 +195,7 @@ void AccountListModel::accountChanged(const QString& account,const QString& stat
} }
foreach (Account* acc, m_lAccounts) { foreach (Account* acc, m_lAccounts) {
const int idx =accountIds.indexOf(acc->id()); const int idx =accountIds.indexOf(acc->id());
if (idx == -1 && (acc->state() == Account::AccountEditState::READY || acc->state() == Account::AccountEditState::REMOVED)) { if (idx == -1 && (acc->state() == Account::EditState::READY || acc->state() == Account::EditState::REMOVED)) {
m_lAccounts.remove(idx); m_lAccounts.remove(idx);
emit dataChanged(index(idx - 1, 0), index(m_lAccounts.size()-1, 0)); emit dataChanged(index(idx - 1, 0), index(m_lAccounts.size()-1, 0));
emit layoutChanged(); emit layoutChanged();
...@@ -268,9 +268,9 @@ void AccountListModel::update() ...@@ -268,9 +268,9 @@ void AccountListModel::update()
for (int i = 0; i < tmp.size(); i++) { for (int i = 0; i < tmp.size(); i++) {
Account* current = tmp[i]; Account* current = tmp[i];
if (!current->isNew() && (current->state() != Account::AccountEditState::NEW if (!current->isNew() && (current->state() != Account::EditState::NEW
&& current->state() != Account::AccountEditState::MODIFIED && current->state() != Account::EditState::MODIFIED
&& current->state() != Account::AccountEditState::OUTDATED)) && current->state() != Account::EditState::OUTDATED))
removeAccount(current); removeAccount(current);
} }
//ask for the list of accounts ids to the configurationManager //ask for the list of accounts ids to the configurationManager
...@@ -304,7 +304,7 @@ void AccountListModel::updateAccounts() ...@@ -304,7 +304,7 @@ void AccountListModel::updateAccounts()
emit dataChanged(index(size()-1,0),index(size()-1,0)); emit dataChanged(index(size()-1,0),index(size()-1,0));
} }
else { else {
acc->performAction(Account::AccountEditAction::RELOAD); acc->performAction(Account::EditAction::RELOAD);
} }
} }
emit accountListUpdated(); emit accountListUpdated();
...@@ -319,7 +319,7 @@ void AccountListModel::save() ...@@ -319,7 +319,7 @@ void AccountListModel::save()
//create or update each account from accountList //create or update each account from accountList
for (int i = 0; i < size(); i++) { for (int i = 0; i < size(); i++) {
Account* current = (*this)[i]; Account* current = (*this)[i];
current->performAction(Account::AccountEditAction::SAVE); current->performAction(Account::EditAction::SAVE);
} }
//remove accounts that are in the configurationManager but not in the client //remove accounts that are in the configurationManager but not in the client
...@@ -375,8 +375,8 @@ void AccountListModel::registerAllAccounts() ...@@ -375,8 +375,8 @@ void AccountListModel::registerAllAccounts()
///Cancel all modifications ///Cancel all modifications
void AccountListModel::cancel() { void AccountListModel::cancel() {
foreach (Account* a, getAccounts()) { foreach (Account* a, getAccounts()) {
if (a->state() == Account::AccountEditState::MODIFIED || a->state() == Account::AccountEditState::OUTDATED) if (a->state() == Account::EditState::MODIFIED || a->state() == Account::EditState::OUTDATED)
a->performAction(Account::AccountEditAction::CANCEL); a->performAction(Account::EditAction::CANCEL);
} }
m_lDeletedAccounts.clear(); m_lDeletedAccounts.clear();
} }
......
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
Q_PROPERTY(bool presenceSubscribeSupported READ isPresenceSubscribeSupported ) Q_PROPERTY(bool presenceSubscribeSupported READ isPresenceSubscribeSupported )
friend class Account; friend class Account;
friend class AccountPrivate;
//Static getter and destructor //Static getter and destructor
static AccountListModel* instance(); static AccountListModel* instance();
static void destroy(); static void destroy();
...@@ -107,17 +108,18 @@ private: ...@@ -107,17 +108,18 @@ private:
QStringList m_lDeletedAccounts; QStringList m_lDeletedAccounts;
Account* m_pIP2IP ; Account* m_pIP2IP ;
public Q_SLOTS:
void update ();
void updateAccounts();
void registerAllAccounts();
private Q_SLOTS: private Q_SLOTS:
void accountChanged(const QString& account,const QString& state, int code); void accountChanged(const QString& account,const QString& state, int code);
void accountChanged(Account* a); void accountChanged(Account* a);
void slotVoiceMailNotify( const QString& accountID , int count ); void slotVoiceMailNotify( const QString& accountID , int count );
void slotAccountPresenceEnabledChanged(bool state); void slotAccountPresenceEnabledChanged(bool state);
public Q_SLOTS:
void update ();
void updateAccounts();
void registerAllAccounts();
Q_SIGNALS: Q_SIGNALS:
///The account list changed ///The account list changed
void accountListUpdated(); void accountListUpdated();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment