Yate
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
ClientAccount Class Reference

An account. More...

#include <yatecbase.h>

Inheritance diagram for ClientAccount:
RefObject Mutex GenObject Lockable

Public Member Functions

 ClientAccount (const char *proto, const char *user, const char *host, bool startup, ClientContact *contact=0)
 
 ClientAccount (const NamedList &params, ClientContact *contact=0)
 
const NamedListparams () const
 
ObjListcontacts ()
 
ObjListmucs ()
 
ClientContactcontact () const
 
void setContact (ClientContact *contact)
 
const Stringprotocol () const
 
bool hasChat () const
 
bool hasPresence () const
 
bool startup () const
 
void startup (bool ok)
 
virtual const StringtoString () const
 
ClientResourceresource (bool ref)
 
ClientResourceresource () const
 
void setResource (ClientResource *res)
 
bool save (bool ok=true, bool savePwd=true)
 
virtual ClientContactfindContact (const String &id, bool ref=false)
 
virtual ClientContactfindContact (const String *name=0, const String *uri=0, const String *skipId=0, bool ref=false)
 
virtual ClientContactfindContact (const String &id, const String &resid, bool ref=false)
 
virtual ClientContactfindContactByUri (const String &uri, bool ref=false)
 
virtual MucRoomfindRoom (const String &id, bool ref=false)
 
virtual MucRoomfindRoomByUri (const String &uri, bool ref=false)
 
virtual ClientContactfindAnyContact (const String &id, bool ref=false)
 
virtual ClientContactappendContact (const String &id, const char *name, const char *uri=0)
 
virtual ClientContactappendContact (const NamedList &params)
 
virtual ClientContactremoveContact (const String &id, bool delObj=true)
 
virtual void clearRooms (bool saved, bool temp)
 
virtual Messageuserlogin (bool login, const char *msg="user.login")
 
virtual MessageuserData (bool update, const String &data, const char *msg="user.data")
 
virtual void fillItemParams (NamedList &list)
 
const StringdataDir () 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 Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual void * getObject (const String &name) const
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- Public Member Functions inherited from Mutex
 Mutex (bool recursive=false, const char *name=0)
 
 Mutex (const Mutex &original)
 
 ~Mutex ()
 
Mutexoperator= (const Mutex &original)
 
virtual bool lock (long maxwait=-1)
 
virtual bool unlock ()
 
virtual bool locked () const
 
const char * owner () const
 
bool recursive () const
 
- Public Member Functions inherited from Lockable
virtual ~Lockable ()
 
virtual bool check (long maxwait=-1)
 
virtual bool unlockAll ()
 

Public Attributes

NamedList m_params
 
Configuration m_cfg
 

Protected Member Functions

virtual void destroyed ()
 
virtual void appendContact (ClientContact *contact, bool muc=false)
 
- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 

Protected Attributes

ObjList m_contacts
 
ObjList m_mucs
 

Friends

class ClientContact
 
class MucRoom
 

Additional Inherited Members

- Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
 
static bool efficientIncDec ()
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 
- Static Public Member Functions inherited from Mutex
static int count ()
 
static int locks ()
 
static bool efficientTimedLock ()
 
- Static Public Member Functions inherited from Lockable
static void wait (unsigned long maxwait)
 
static unsigned long wait ()
 
static void startUsingNow ()
 
static void enableSafety (bool safe=true)
 
static bool safety ()
 

Detailed Description

An account.

This class holds an account

Constructor & Destructor Documentation

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

Constructor

Parameters
protoThe account's protocol
userThe account's username
hostThe account's host
startupTrue if the account should login at startup
contactOptional account's own contact
ClientAccount ( const NamedList params,
ClientContact contact = 0 
)
explicit

Constructor. Build an account from a list of parameters

Parameters
paramsThe list of parameters used to build this account. The list's name will be used as account id
contactOptional account's own contact

Member Function Documentation

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

Build a contact and append it to the list

Parameters
idThe contact's id
nameThe contact's name
uriOptional contact URI
Returns
ClientContact pointer or 0 if a contact with the given id already exists
virtual ClientContact* appendContact ( const NamedList params)
virtual

Build a contact and append it to the list

Parameters
paramsContact parameters
Returns
ClientContact pointer or 0 if a contact with the same id already exists
virtual bool clearDataDir ( String errStr = 0)
virtual

Clear account data directory

Parameters
errStrOptional string to be filled with error string
Returns
True if all files were succesfully removed
virtual void clearRooms ( bool  saved,
bool  temp 
)
virtual

Clear MUC rooms. This method is thread safe

Parameters
savedTrue to clear saved rooms
tempTrue to clear temporary rooms
ClientContact* contact ( ) const
inline

Retrieve account own contact

Returns
ClientContact pointer
ObjList& contacts ( )
inline

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

Returns
This account's contacts list
const String& dataDir ( ) const
inline

Retrieve account data directory

Returns
Account data directory

References TelEngine::YSTRING().

virtual void destroyed ( )
protectedvirtual

Pre-destruction notification, called just before the object is deleted. Unlike in the destructor it is safe to call virtual methods here. Reimplementing this method allows to perform any object cleanups.

Reimplemented from RefObject.

virtual void fillItemParams ( NamedList list)
virtual

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

Parameters
listParameter list to fill
virtual ClientContact* findAnyContact ( const String id,
bool  ref = false 
)
virtual

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

Parameters
idThe id of the desired contact
refTrue to obtain a referenced pointer
Returns
ClientContact pointer (may be account's own contact) or 0 if not found
virtual ClientContact* findContact ( const String id,
bool  ref = false 
)
virtual

Find a contact by its id

Parameters
idThe id of the desired contact
refTrue to obtain a referenced pointer
Returns
ClientContact pointer (may be account's own contact) or 0 if not found

Referenced by ClientAccountList::isLocalContact().

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

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

Parameters
nameOptional name to check (may be a pointer to an empty string)
uriOptional uri to check (may be a pointer to an empty string)
skipIdOptional contact to skip
refTrue to obtain a referenced pointer
Returns
ClientContact pointer or 0 if not found
virtual ClientContact* findContact ( const String id,
const String resid,
bool  ref = false 
)
virtual

Find a contact having a given id and resource

Parameters
idThe id of the desired contact
residThe id of the desired resource
refTrue to obtain a referenced pointer
Returns
ClientContact pointer or 0 if not found
virtual ClientContact* findContactByUri ( const String uri,
bool  ref = false 
)
virtual

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

Parameters
uriThe contact's uri
refTrue to get a referenced pointer
Returns
ClientContact pointer or 0 if not found
virtual MucRoom* findRoom ( const String id,
bool  ref = false 
)
virtual

Find a MUC room by its id

Parameters
idRoom id
refTrue to obtain a referenced pointer
Returns
MucRoom pointer or 0 if not found
virtual MucRoom* findRoomByUri ( const String uri,
bool  ref = false 
)
virtual

Find a MUC room by its uri

Parameters
uriRoom uri
refTrue to obtain a referenced pointer
Returns
MucRoom pointer or 0 if not found
bool hasChat ( ) const
inline

Check if the account's protocol has chat support

Returns
True if this account has chat support

References ClientAccount::protocol(), and TelEngine::YSTRING().

bool hasPresence ( ) const
inline

Check if the account's protocol has presence support

Returns
True if this account has presence support

References ClientAccount::protocol(), and TelEngine::YSTRING().

virtual void loadContacts ( Configuration cfg = 0)
virtual

Load contacts from configuration file

Parameters
cfgOptional configuration file to load. Load from account's conf file if 0
virtual bool loadDataDirCfg ( Configuration cfg = 0,
const char *  file = "account.conf" 
)
virtual

Load configuration file from data directory

Parameters
cfgOptional configuration file to load. Load account's conf file if 0
fileFile name. Defaults to 'account.conf'
Returns
True on success
ObjList& mucs ( )
inline

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

Returns
This account's mucs list
const NamedList& params ( ) const
inline

Get this account's parameters

Returns
This account's parameter list
const String& protocol ( ) const
inline

Retrieve the account's protocol

Returns
The account's protocol

References TelEngine::YSTRING().

Referenced by ClientAccount::hasChat(), and ClientAccount::hasPresence().

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

Remove a contact from list. Reset contact's owner

Parameters
idThe contact's id
delObjTrue to delete the object if found
Returns
ClientContact pointer if found and not deleted or 0
ClientResource* resource ( bool  ref)

Get this account's resource

Returns
ClientResource pointer
ClientResource& resource ( ) const
inline

Get this account's resource

Returns
ClientResource reference
bool save ( bool  ok = true,
bool  savePwd = true 
)

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

Parameters
okTrue to save, false to remove
savePwdTrue to save the password
Returns
True on success
void setContact ( ClientContact contact)

Set or reset account own contact

Parameters
contactNew account contact (may be NULL to reset it)
void setResource ( ClientResource res)

Set this account's resource

Parameters
resThe new account's resource (ignored if 0)
virtual bool setupDataDir ( String errStr = 0,
bool  saveAcc = true 
)
virtual

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

Parameters
errStrOptional string to be filled with error string
saveAccSave data directory parameter in client accounts
Returns
True on success
bool startup ( ) const
inline

Check if the account should be logged in at startup

Returns
True if the account should be logged in at startup

References NamedList::getBoolValue(), and TelEngine::YSTRING().

void startup ( bool  ok)
inline

Set the account's startup login flag

Parameters
okThe account's startup login flag value

References String::boolText(), and NamedList::setParam().

virtual const String& toString ( ) const
inlinevirtual

Get a string representation of this object

Returns
The account's compare id

Reimplemented from GenObject.

Referenced by ClientContact::accountName().

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

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

Parameters
updateTrue to update, false to query
dataData to update or query
msgOptional message name. Default to 'user.data'
Returns
A valid Message pointer
virtual Message* userlogin ( bool  login,
const char *  msg = "user.login" 
)
virtual

Build a login/logout message from account's data

Parameters
loginTrue to login, false to logout
msgOptional message name. Default to 'user.login'
Returns
A valid Message pointer

The documentation for this class was generated from the following file: