# class ClientAccount

An account. More...

Full name | `TelEngine::ClientAccount`
Definition | `#include <yatecbase.h>`
Inherits | TelEngine::Mutex [public ], TelEngine::RefObject [public ]
List of all Methods

Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- explicit ClientAccount (const char* proto, const char* user, const char* host, bool startup, ClientContact* contact = 0)
- explicit ClientAccount (const NamedList& params, ClientContact* contact = 0)
- inline const NamedList& params () const
- inline ObjList& contacts ()
- inline ObjList& mucs ()
- inline ClientContact* contact () const
- void setContact (ClientContact* contact)
- inline const String& protocol () const
- inline bool hasChat () const
- inline bool hasPresence () const
- inline bool startup () const
- inline void startup (bool ok)
- virtual const String& toString () const
- ClientResource* resource (bool ref)
- inline ClientResource& resource () const
- void setResource (ClientResource* res)
- bool save (bool ok = true, bool savePwd = true)
- virtual ClientContact* findContact (const String& id, bool ref = false)
- virtual ClientContact* findContact (const String* name = 0, const String* uri = 0, const String* skipId = 0, bool ref = false)
- virtual ClientContact* findContact (const String& id, const String& resid, bool ref = false)
- virtual ClientContact* findContactByUri (const String& uri, bool ref = false)
- virtual MucRoom* findRoom (const String& id, bool ref = false)
- virtual MucRoom* findRoomByUri (const String& uri, bool ref = false)
- virtual ClientContact* findAnyContact (const String& id, bool ref = false)
- virtual ClientContact* appendContact (const String& id, const char* name, const char* uri = 0)
- virtual ClientContact* appendContact (const NamedList& params)
- virtual ClientContact* removeContact (const String& id, bool delObj = true)
- virtual void clearRooms (bool saved, bool temp)
- virtual Message* userlogin (bool login, const char* msg = "user.login")
- virtual Message* userData (bool update, const String& data, const char* msg = "user.data")
- virtual void fillItemParams (NamedList& list)
- inline const String& dataDir () const
- virtual bool setupDataDir (String* errStr = 0, bool saveAcc = true)
- virtual bool loadDataDirCfg (Configuration* cfg = 0, const char* file = "account.conf")
- virtual void loadContacts (Configuration* cfg = 0)
- virtual bool clearDataDir (String* errStr = 0)

#### Public Members

- NamedList m_params
- Configuration m_cfg

#### Protected Methods

- virtual void destroyed ()
- virtual void appendContact (ClientContact* contact, bool muc = false)

#### Protected Members

- ObjList m_contacts
- ObjList m_mucs

## Detailed Description

This class holds an account

explicit ClientAccount (const char* proto, const char* user, const char* host, bool startup, ClientContact* contact = 0)

### ClientAccount

Constructor

Parameters:

proto | The account's protocol
user | The account's username
host | The account's host
startup | True if the account should login at startup
contact | Optional account's own contact

explicit ClientAccount (const NamedList& params, ClientContact* contact = 0)

### ClientAccount

Constructor. Build an account from a list of parameters

Parameters:

params | The list of parameters used to build this account. The list's name will be used as account id
contact | Optional account's own contact

inline const NamedList& params ()

### params

[const]

Get this account's parameters

Returns: This account's parameter list

inline ObjList& contacts ()

### contacts

Get this account's contacts. The caller should lock the account while browsing the list

Returns: This account's contacts list

inline ObjList& mucs ()

### mucs

Get this account's muc rooms. The caller should lock the account while browsing the list

Returns: This account's mucs list

inline ClientContact* contact ()

### contact

[const]

Retrieve account own contact

Returns: ClientContact pointer

void setContact (ClientContact* contact)

### setContact

Set or reset account own contact

Parameters:

contact | New account contact (may be NULL to reset it)

inline const String& protocol ()

### protocol

[const]

Retrieve the account's protocol

Returns: The account's protocol

inline bool hasChat ()

### hasChat

[const]

Check if the account's protocol has chat support

Returns: True if this account has chat support

inline bool hasPresence ()

### hasPresence

[const]

Check if the account's protocol has presence support

Returns: True if this account has presence support

inline bool startup ()

### startup

[const]

Check if the account should be logged in at startup

Returns: True if the account should be logged in at startup

inline void startup (bool ok)

### startup

Set the account's startup login flag

Parameters:

ok | The account's startup login flag value

const String& toString ()

### toString

[const virtual]

Get a string representation of this object

Returns: The account's compare id

Reimplemented from GenObject.

ClientResource* resource (bool ref)

### resource

Get this account's resource

Returns: ClientResource pointer

inline ClientResource& resource ()

### resource

[const]

Get this account's resource

Returns: ClientResource reference

void setResource (ClientResource* res)

### setResource

Set this account's resource

Parameters:

res | The new account's resource (ignored if 0)

bool save (bool ok = true, bool savePwd = true)

### save

Save or remove this account to/from client accounts file. Parameters starting with "internal." are not saved

Parameters:

ok | True to save, false to remove
savePwd | True to save the password

Returns: True on success

ClientContact* findContact (const String& id, bool ref = false)

### findContact

[virtual]

Find a contact by its id

Parameters:

id | The id of the desired contact
ref | True to obtain a referenced pointer

Returns: ClientContact pointer (may be account's own contact) or 0 if not found

ClientContact* findContact (const String* name = 0, const String* uri = 0, const String* skipId = 0, bool ref = false)

### findContact

[virtual]

Find a contact by name and/or uri. Account own contact is ignored

Parameters:

name | Optional name to check (may be a pointer to an empty string)
uri | Optional uri to check (may be a pointer to an empty string)
skipId | Optional contact to skip
ref | True to obtain a referenced pointer

Returns: ClientContact pointer or 0 if not found

ClientContact* findContact (const String& id, const String& resid, bool ref = false)

### findContact

[virtual]

Find a contact having a given id and resource

Parameters:

id | The id of the desired contact
resid | The id of the desired resource
ref | True to obtain a referenced pointer

Returns: ClientContact pointer or 0 if not found

ClientContact* findContactByUri (const String& uri, bool ref = false)

### findContactByUri

[virtual]

Find a contact by its URI (build an id from account and uri)

Parameters:

uri | The contact's uri
ref | True to get a referenced pointer

Returns: ClientContact pointer or 0 if not found

MucRoom* findRoom (const String& id, bool ref = false)

### findRoom

[virtual]

Find a MUC room by its id

Parameters:

id | Room id
ref | True to obtain a referenced pointer

Returns: MucRoom pointer or 0 if not found

MucRoom* findRoomByUri (const String& uri, bool ref = false)

### findRoomByUri

[virtual]

Find a MUC room by its uri

Parameters:

uri | Room uri
ref | True to obtain a referenced pointer

Returns: MucRoom pointer or 0 if not found

ClientContact* findAnyContact (const String& id, bool ref = false)

### findAnyContact

[virtual]

Find any contact (regular or MUC room) by its id

Parameters:

id | The id of the desired contact
ref | True to obtain a referenced pointer

Returns: ClientContact pointer (may be account's own contact) or 0 if not found

ClientContact* appendContact (const String& id, const char* name, const char* uri = 0)

### appendContact

[virtual]

Build a contact and append it to the list

Parameters:

id | The contact's id
name | The contact's name
uri | Optional contact URI

Returns: ClientContact pointer or 0 if a contact with the given id already exists

ClientContact* appendContact (const NamedList& params)

### appendContact

[virtual]

Build a contact and append it to the list

Parameters:

params | Contact parameters

Returns: ClientContact pointer or 0 if a contact with the same id already exists

ClientContact* removeContact (const String& id, bool delObj = true)

### removeContact

[virtual]

Remove a contact from list. Reset contact's owner

Parameters:

id | The contact's id
delObj | True to delete the object if found

Returns: ClientContact pointer if found and not deleted or 0

void clearRooms (bool saved, bool temp)

### clearRooms

[virtual]

Clear MUC rooms. This method is thread safe

Parameters:

saved | True to clear saved rooms
temp | True to clear temporary rooms

Message* userlogin (bool login, const char* msg = "user.login")

### userlogin

[virtual]

Build a login/logout message from account's data

Parameters:

login | True to login, false to logout
msg | Optional message name. Default to 'user.login'

Returns: A valid Message pointer

Message* userData (bool update, const String& data, const char* msg = "user.data")

### userData

[virtual]

Build a message used to update or query account userdata. Add account MUC rooms if data is 'chatrooms' and update

Parameters:

update | True to update, false to query
data | Data to update or query
msg | Optional message name. Default to 'user.data'

Returns: A valid Message pointer

void fillItemParams (NamedList& list)

### fillItemParams

[virtual]

Fill a list used to update a account's list item

Parameters:

list | Parameter list to fill

inline const String& dataDir ()

### dataDir

[const]

Retrieve account data directory

Returns: Account data directory

bool setupDataDir (String* errStr = 0, bool saveAcc = true)

### setupDataDir

[virtual]

Set account directory in application data directory. Make sure it exists. Move all files from the old one if changed

Parameters:

errStr | Optional string to be filled with error string
saveAcc | Save data directory parameter in client accounts

Returns: True on success

bool loadDataDirCfg (Configuration* cfg = 0, const char* file = "account.conf")

### loadDataDirCfg

[virtual]

Load configuration file from data directory

Parameters:

cfg | Optional configuration file to load. Load account's conf file if 0
file | File name. Defaults to 'account.conf'

Returns: True on success

void loadContacts (Configuration* cfg = 0)

### loadContacts

[virtual]

Load contacts from configuration file

Parameters:

cfg | Optional configuration file to load. Load from account's conf file if 0

bool clearDataDir (String* errStr = 0)

### clearDataDir

[virtual]

Clear account data directory

Parameters:

errStr | Optional string to be filled with error string

Returns: True if all files were succesfully removed

NamedList m_params

### m_params

Configuration m_cfg

### m_cfg

void destroyed ()

### destroyed

[protected virtual]

Reimplemented from RefObject.

void appendContact (ClientContact* contact, bool muc = false)

### appendContact

[protected virtual]

ObjList m_contacts

### m_contacts

[protected]

ObjList m_mucs

### m_mucs

[protected]

Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54.