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
This commit is contained in:
marian 2010-05-04 10:00:05 +00:00
parent 26b9bead07
commit ab9274e550
3 changed files with 45 additions and 5 deletions

View File

@ -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
*/

View File

@ -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())

View File

@ -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
};
/**