From ab9274e5506204a5b674ce81a2cee0e3e533fb83 Mon Sep 17 00:00:00 2001 From: marian Date: Tue, 4 May 2010 10:00:05 +0000 Subject: [PATCH] The ClientAccountList can now keep an account owning locally stored contacts. Fixed comments. git-svn-id: http://voip.null.ro/svn/yate@3277 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/Client.cpp | 15 +++++++++++++++ engine/ClientLogic.cpp | 4 ++-- yatecbase.h | 31 ++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/engine/Client.cpp b/engine/Client.cpp index 6302f82a..dd22f0c2 100644 --- a/engine/Client.cpp +++ b/engine/Client.cpp @@ -3567,10 +3567,24 @@ void ClientAccount::appendContact(ClientContact* contact) /** * ClientAccountList */ +// Destructor +ClientAccountList::~ClientAccountList() +{ + TelEngine::destruct(m_localContacts); +} + +// Check if a contact is locally stored +bool ClientAccountList::isLocalContact(ClientContact* c) const +{ + return m_localContacts && c && c->account() == m_localContacts; +} + // Find an account ClientAccount* ClientAccountList::findAccount(const String& id, bool ref) { Lock lock(this); + if (m_localContacts && m_localContacts->toString() == id) + return (!ref || m_localContacts->ref()) ? m_localContacts : 0; ObjList* obj = m_accounts.find(id); if (!obj) return 0; @@ -3617,6 +3631,7 @@ void ClientAccountList::removeAccount(const String& id) obj->remove(); } + /** * ClientContact */ diff --git a/engine/ClientLogic.cpp b/engine/ClientLogic.cpp index 1dc06235..f38c0b90 100644 --- a/engine/ClientLogic.cpp +++ b/engine/ClientLogic.cpp @@ -414,7 +414,7 @@ bool ClientLogic::debug(const String& name, bool active, Window* wnd) /** * DefaultLogic */ -// constructor +// Constructor DefaultLogic::DefaultLogic(const char* name, int prio) : ClientLogic(name,prio), m_accShowAdvanced(false) { @@ -1211,7 +1211,7 @@ bool DefaultLogic::updateContact(const NamedList& params, bool save, bool update return true; } -// Called when the user wants to save account data +// Called when the user wants to save contact data bool DefaultLogic::acceptContact(NamedList* params, Window* wnd) { if (!Client::self()) diff --git a/yatecbase.h b/yatecbase.h index 1fddd5a7..ad53d636 100644 --- a/yatecbase.h +++ b/yatecbase.h @@ -2940,12 +2940,19 @@ class YATE_API ClientAccountList : public String, public Mutex public: /** * Constructor - * @param name List's name used for debug purposes + * @param name List's name used for debug purposes + * @param localContacts Optional account owning locally stored contacts */ - inline ClientAccountList(const char* name) - : String(name), Mutex(true,"ClientAccountList") + inline ClientAccountList(const char* name, ClientAccount* localContacts = 0) + : String(name), Mutex(true,"ClientAccountList"), + m_localContacts(localContacts) {} + /** + * Destructor + */ + ~ClientAccountList(); + /** * Get the accounts list * @return The accounts list @@ -2953,6 +2960,20 @@ public: inline ObjList& accounts() { return m_accounts; } + /** + * Retrieve the account owning locally stored contacts + * @return ClientAccount pointer or 0 + */ + inline ClientAccount* localContacts() const + { return m_localContacts; } + + /** + * Check if a contact is locally stored + * @param c The contact to check + * @return True if the contact owner is the account owning locally stored contacts + */ + bool isLocalContact(ClientContact* c) const; + /** * Find an account * @param id The account's id @@ -2993,6 +3014,10 @@ public: protected: ObjList m_accounts; + +private: + ClientAccountList() {} // Avoid using the default constructor + ClientAccount* m_localContacts; // Account owning locally stored contacts }; /**