Yate
JBEntityCapsList Class Reference

Entity capability list manager. More...

#include <yatejabber.h>

Inheritance diagram for JBEntityCapsList:
ObjList Mutex GenObject Lockable

Public Member Functions

 JBEntityCapsList ()
 
JBEntityCapsfindCaps (const String &id)
 
void expire (u_int64_t msecNow=Time::msecNow())
 
bool processRsp (XmlElement *rsp, const String &id, bool ok)
 
void requestCaps (JBStream *stream, const char *from, const char *to, const String &id, char version, const char *node, const char *data)
 
XmlDocumenttoDocument (const char *rootName="entitycaps")
 
void fromDocument (XmlDocument &doc, const char *rootName="entitycaps")
 
virtual bool processCaps (String &capsId, XmlElement *xml, JBStream *stream, const char *from, const char *to)
 
void addCaps (NamedList &list, const String &id)
 
virtual void addCaps (NamedList &list, JBEntityCaps &caps)
 
bool loadXmlDoc (const char *file, DebugEnabler *enabler=0)
 
bool saveXmlDoc (const char *file, DebugEnabler *enabler=0)
 
- Public Member Functions inherited from ObjList
 ObjList ()
 
virtual ~ObjList ()
 
virtual void * getObject (const String &name) const
 
unsigned int length () const
 
unsigned int count () const
 
GenObjectget () const
 
GenObjectset (const GenObject *obj, bool delold=true)
 
ObjListnext () const
 
ObjListlast () const
 
ObjListskipNull () const
 
ObjListskipNext () const
 
GenObjectat (int index) const
 
ObjListoperator+ (int index) const
 
GenObjectoperator[] (signed int index) const
 
GenObjectoperator[] (unsigned int index) const
 
GenObjectoperator[] (const String &str) const
 
ObjListfind (const GenObject *obj) const
 
ObjListfind (const String &str) const
 
int index (const GenObject *obj) const
 
int index (const String &str) const
 
ObjListinsert (const GenObject *obj, bool compact=true)
 
ObjListappend (const GenObject *obj, bool compact=true)
 
ObjListsetUnique (const GenObject *obj, bool compact=true)
 
GenObjectremove (bool delobj=true)
 
GenObjectremove (GenObject *obj, bool delobj=true)
 
GenObjectremove (const String &str, bool delobj=true)
 
void clear ()
 
void compact ()
 
bool autoDelete ()
 
void setDelete (bool autodelete)
 
void sort (int(*callbackCompare)(GenObject *obj1, GenObject *obj2, void *context), void *context=0)
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
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 ()
 

Static Public Member Functions

static bool decodeCaps (const XmlElement &xml, char &version, String *&node, String *&ver, String *&ext)
 
- Static Public Member Functions inherited from ObjList
static const ObjListempty ()
 
- 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 ()
 

Public Attributes

bool m_enable
 

Protected Member Functions

virtual void capsAdded (JBEntityCaps *caps)
 

Protected Attributes

unsigned int m_reqIndex
 
String m_reqPrefix
 
ObjList m_requests
 

Detailed Description

Entity capability list manager.

This class holds data and offer entity capability services. Implements XEP 0115 support

Constructor & Destructor Documentation

◆ JBEntityCapsList()

JBEntityCapsList ( )
inline

Constructor

References m_enable, Time::msecNow(), and Mutex::Mutex().

Member Function Documentation

◆ addCaps() [1/2]

void addCaps ( NamedList & list,
const String & id )
inline

Add capabilities to a list. This method is thread safe

Parameters
listDestination list
idEntity caps id

References addCaps(), findCaps(), and Mutex::lock().

Referenced by addCaps().

◆ addCaps() [2/2]

virtual void addCaps ( NamedList & list,
JBEntityCaps & caps )
virtual

Add capabilities to a list. This method is not thread safe

Parameters
listDestination list
capsEntity caps to add

◆ capsAdded()

virtual void capsAdded ( JBEntityCaps * caps)
inlineprotectedvirtual

Caps list item add notification for descendants. This method is called when processing responses with the list locked

Parameters
capsChanged caps object. 0 if none specified

◆ decodeCaps()

static bool decodeCaps ( const XmlElement & xml,
char & version,
String *& node,
String *& ver,
String *& ext )
static

Check if an XML element has a 'c' entity capability child and decode it

Parameters
xmlThe element to process
versionEntity caps version
nodeEntity node attribute
verEntity ver attribute
extEntity ext attribute if version is less the 1.4
Returns
True if a child was succesfully decoded

◆ expire()

void expire ( u_int64_t msecNow = Time::msecNow())

Expire pending requests. This method is thread safe

Parameters
msecNowCurrent time

References Time::msecNow().

◆ findCaps()

JBEntityCaps * findCaps ( const String & id)
inline

Retrieve an entity caps object. This method is not thread safe

Parameters
idThe id to find
Returns
JBEntityCaps pointer or 0

References ObjList::ObjList(), ObjList::skipNext(), and ObjList::skipNull().

Referenced by addCaps().

◆ fromDocument()

void fromDocument ( XmlDocument & doc,
const char * rootName = "entitycaps" )

Build this list from an XML document. This method is thread safe

Parameters
docDocument to build from
rootNameDocument root element name (it will be checked if set)
Returns
XmlDocument pointer

◆ loadXmlDoc()

bool loadXmlDoc ( const char * file,
DebugEnabler * enabler = 0 )

Load (reset) this list from an XML document file. This method is thread safe

Parameters
fileThe file to load
enablerThe debug enabler used to output messages
Returns
True on success

◆ processCaps()

virtual bool processCaps ( String & capsId,
XmlElement * xml,
JBStream * stream,
const char * from,
const char * to )
virtual

Process an element containing an entity capabily child. Request capabilities if not found in the list. This method is thread safe

Parameters
capsIdString to be filled with entity caps object id (empty if an entity caps child is not found in element )
xmlXML element to process
streamThe stream used to request capabilities
fromThe 'from' attribute of the request stanza
toThe 'to' attribute of the request stanza
Returns
True if processed (already found, added or request sent)

◆ processRsp()

bool processRsp ( XmlElement * rsp,
const String & id,
bool ok )

Process a response. This method is thread safe

Parameters
rspThe element to process
idThe element's id
okTrue if the response is a result one, false if it's an error
Returns
True if the element was processed (handled)

◆ requestCaps()

void requestCaps ( JBStream * stream,
const char * from,
const char * to,
const String & id,
char version,
const char * node,
const char * data )

Request entity capabilities. This method is thread safe

Parameters
streamThe stream to send the request
fromThe 'from' attribute
toThe 'to' attribute
idEntity caps id
versionEntity caps version
nodeEntity node
dataEntity caps data

◆ saveXmlDoc()

bool saveXmlDoc ( const char * file,
DebugEnabler * enabler = 0 )

Save this list to an XML document file. This method is thread safe

Parameters
fileThe file to save
enablerThe debug enabler used to output messages
Returns
True on success

◆ toDocument()

XmlDocument * toDocument ( const char * rootName = "entitycaps")

Build an XML document from this list. This method is thread safe

Parameters
rootNameDocument root element name
Returns
XmlDocument pointer

Member Data Documentation

◆ m_enable

bool m_enable

Enabled flag

Referenced by JBEntityCapsList().


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