Yate
JBEngine Class Reference

A Jabber engine. More...

#include <yatejabber.h>

Inheritance diagram for JBEngine:
DebugEnabler Mutex GenObject Lockable JBClientEngine JBServerEngine

Public Member Functions

 JBEngine (const char *name="jbengine")
 
virtual ~JBEngine ()
 
unsigned int streamReadBuffer () const
 
bool exiting () const
 
void setExiting ()
 
unsigned int redirectMax () const
 
bool hasClientTls () const
 
JBRemoteDomainDefremoteDomainDef (const String &domain)
 
virtual void destruct ()
 
virtual void initialize (const NamedList &params)
 
virtual void cleanup (bool final=false, bool waitTerminate=true)
 
bool acceptConn (Socket *sock, SocketAddr &remote, JBStream::Type t, bool ssl=false)
 
virtual JBStreamfindStream (const String &id, JBStream::Type hint=JBStream::TypeCount)
 
ObjListfindClientStreams (bool in, const JabberID &jid, int flags=0xffffffff)
 
ObjListfindClientStreams (bool in, const JabberID &jid, const ObjList &resources, int flags=0xffffffff)
 
JBClientStreamfindClientStream (bool in, const JabberID &jid)
 
virtual unsigned int dropAll (JBStream::Type type=JBStream::TypeCount, const JabberID &local=JabberID::empty(), const JabberID &remote=JabberID::empty(), XMPPError::Type error=XMPPError::NoError, const char *reason=0)
 
virtual void buildStreamName (String &name, const JBStream *stream)
 
virtual bool hasDomain (const String &domain)
 
virtual void processEvent (JBEvent *ev)
 
virtual void returnEvent (JBEvent *ev, XMPPError::Type error=XMPPError::NoError, const char *reason=0)
 
virtual void encryptStream (JBStream *stream)
 
virtual void connectStream (JBStream *stream)
 
virtual void compressStream (JBStream *stream, const String &formats)
 
virtual void buildDialbackKey (const String &id, const String &local, const String &remote, String &key)
 
bool checkDupId (JBStream *stream)
 
virtual void printXml (const JBStream *stream, bool send, XmlChild &xml) const
 
virtual void printXml (const JBStream *stream, bool send, XmlFragment &frag) const
 
- Public Member Functions inherited from DebugEnabler
 DebugEnabler (int level=TelEngine::debugLevel(), bool enabled=true)
 
int debugLevel () const
 
int debugLevel (int level)
 
bool debugEnabled () const
 
void debugEnabled (bool enable)
 
const char * debugName () const
 
bool debugAt (int level) const
 
bool debugChained () const
 
void debugChain (const DebugEnabler *chain=0)
 
void debugCopy (const DebugEnabler *original=0)
 
- 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 Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
virtual void * getObject (const String &name) const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Protected Member Functions

virtual void addStream (JBStream *stream)
 
virtual void removeStream (JBStream *stream, bool delObj=true)
 
virtual void stopStreamSets (bool waitTerminate=true)
 
virtual void getStreamList (RefPointer< JBStreamSetList > &list, int type)
 
void getStreamLists (RefPointer< JBStreamSetList > list[JBStream::TypeCount], int type=JBStream::TypeCount)
 
JBStreamfindStream (const String &id, JBStreamSetList *list)
 
- Protected Member Functions inherited from DebugEnabler
void debugName (const char *name)
 

Protected Attributes

bool m_exiting
 
JBRemoteDomainDef m_remoteDomain
 
ObjList m_remoteDomains
 
unsigned char m_restartMax
 
unsigned int m_restartUpdInterval
 
unsigned int m_setupTimeout
 
unsigned int m_startTimeout
 
unsigned int m_connectTimeout
 
unsigned int m_srvTimeout
 
unsigned int m_pingInterval
 
unsigned int m_pingTimeout
 
unsigned int m_idleTimeout
 
unsigned int m_pptTimeoutC2s
 
unsigned int m_pptTimeout
 
unsigned int m_streamReadBuffer
 
unsigned int m_maxIncompleteXml
 
unsigned int m_redirectMax
 
bool m_hasClientTls
 
int m_printXml
 
bool m_initialized
 

Friends

class JBStream
 
class JBConnect
 
class JBStreamSetProcessor
 

Additional Inherited Members

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

Detailed Description

A Jabber engine.

This class holds a Jabber engine

Constructor & Destructor Documentation

◆ JBEngine()

JBEngine ( const char * name = "jbengine")

Constructor

Parameters
nameEngine name

◆ ~JBEngine()

virtual ~JBEngine ( )
virtual

Destructor

Member Function Documentation

◆ acceptConn()

bool acceptConn ( Socket * sock,
SocketAddr & remote,
JBStream::Type t,
bool ssl = false )

Accept an incoming stream connection. Build a stream. Don't delete the socket if false is returned

Parameters
sockAccepted socket
remoteRemote ip and port
tExpected stream type
sslTrue if the socket is already using SSL/TLS
Returns
True on success

◆ addStream()

virtual void addStream ( JBStream * stream)
protectedvirtual

Add a stream to one of the stream lists

Parameters
streamThe stream to add

Reimplemented in JBClientEngine, and JBServerEngine.

◆ buildDialbackKey()

virtual void buildDialbackKey ( const String & id,
const String & local,
const String & remote,
String & key )
virtual

Build a dialback key

Parameters
idThe stream id
localLocal domain
remoteRemote domain
keyThe dialback key

◆ buildStreamName()

virtual void buildStreamName ( String & name,
const JBStream * stream )
inlinevirtual

Build an internal stream name

Parameters
nameDestination buffer
streamStream requesting it

Reimplemented in JBServerEngine.

◆ checkDupId()

bool checkDupId ( JBStream * stream)

Check if an outgoing stream exists with the same id and remote peer

Parameters
streamThe calling stream
Returns
True if a duplicate is found

◆ cleanup()

virtual void cleanup ( bool final = false,
bool waitTerminate = true )
virtual

Stop connect threads. Drop all streams. Stop all stream sets. Release memory if final

Parameters
finalTrue if called from destructor
waitTerminateTrue to wait for all streams to terminate

Reimplemented in JBClientEngine, and JBServerEngine.

◆ compressStream()

virtual void compressStream ( JBStream * stream,
const String & formats )
virtual

Start stream compression

Parameters
streamThe stream to compress
formatsSupported formats

◆ connectStream()

virtual void connectStream ( JBStream * stream)
virtual

Connect an outgoing stream

Parameters
streamThe stream to connect

◆ destruct()

virtual void destruct ( )
virtual

Cleanup streams. Stop all threads owned by this engine. Release memory

Reimplemented from GenObject.

◆ dropAll()

virtual unsigned int dropAll ( JBStream::Type type = JBStream::TypeCount,
const JabberID & local = JabberID::empty(),
const JabberID & remote = JabberID::empty(),
XMPPError::Type error = XMPPError::NoError,
const char * reason = 0 )
virtual

Terminate all streams matching type and/or local/remote jid

Parameters
typeStream type. Match all stream types if unknown
localOptional local jid to match
remoteOptional remote jid to match
errorOptional error to be sent to the client
reasonOptional error text to be sent to the client
Returns
The number of stream terminated

References JabberID::empty().

Referenced by setExiting().

◆ encryptStream()

virtual void encryptStream ( JBStream * stream)
virtual

Start stream TLS

Parameters
streamThe stream to enchrypt

◆ exiting()

bool exiting ( ) const
inline

Check if this engine is exiting

Returns
True if this engine is exiting

◆ findClientStream()

JBClientStream * findClientStream ( bool in,
const JabberID & jid )

Find a c2s stream by its local or remote jid. This method is thread safe

Parameters
inTrue for incoming, false for outgoing
jidJID to compare (the local one for outgoing, remote jid for incoming)
Returns
Referenced JBClientStream pointer or 0

◆ findClientStreams() [1/2]

ObjList * findClientStreams ( bool in,
const JabberID & jid,
const ObjList & resources,
int flags = 0xffffffff )

Find all c2s streams whose local or remote bare jid matches a given one and their resource is found in the given list. Ignore destroying streams. This method is thread safe

Parameters
inTrue for incoming, false for outgoing
jidJID to compare (the local one for outgoing, remote jid for incoming)
resourcesThe list of resources to match
flagsOptional stream flag to match
Returns
List of referenced JBClientStream pointers or 0

◆ findClientStreams() [2/2]

ObjList * findClientStreams ( bool in,
const JabberID & jid,
int flags = 0xffffffff )

Find all c2s streams whose local or remote bare jid matches a given one. Ignore destroying streams. This method is thread safe

Parameters
inTrue for incoming, false for outgoing
jidJID to compare (the local one for outgoing, remote jid for incoming)
flagsOptional stream flag to match
Returns
List of referenced JBClientStream pointers or 0

◆ findStream() [1/2]

virtual JBStream * findStream ( const String & id,
JBStream::Type hint = JBStream::TypeCount )
virtual

Find a stream by its name. This method is thread safe

Parameters
idThe internal id of the stream to find
hintOptional stream type hint
Returns
Referenced JBStream pointer or 0

◆ findStream() [2/2]

JBStream * findStream ( const String & id,
JBStreamSetList * list )
protected

Find a stream by its name in a given set list

Parameters
idThe name of the stream to find
listThe list to search for a stream
Returns
Referenced JBStream pointer or 0

◆ getStreamList()

virtual void getStreamList ( RefPointer< JBStreamSetList > & list,
int type )
inlineprotectedvirtual

Retrieve the list of streams of a given type. Descendant must implement it

Parameters
listThe destination list to set
typeStream type

Reimplemented in JBClientEngine, and JBServerEngine.

Referenced by getStreamLists().

◆ getStreamLists()

void getStreamLists ( RefPointer< JBStreamSetList > list[JBStream::TypeCount],
int type = JBStream::TypeCount )
inlineprotected

Retrieve all streams

Parameters
listThe destination list to set. The first index will be filled with the c2s streams list, the second index will be set to the s2s stream list
typeOptional stream type

References getStreamList().

◆ hasClientTls()

bool hasClientTls ( ) const
inline

Check if TLS is available for outgoing streams

Returns
True if TLS is available for outgoing streams

◆ hasDomain()

virtual bool hasDomain ( const String & domain)
inlinevirtual

Check if a domain is serviced by this engine

Parameters
domainDomain to check
Returns
True if the given domain is serviced by this engine

◆ initialize()

virtual void initialize ( const NamedList & params)
virtual

Initialize the engine's parameters. Start private streams if requested

Parameters
paramsEngine's parameters

◆ printXml() [1/2]

virtual void printXml ( const JBStream * stream,
bool send,
XmlChild & xml ) const
virtual

Print XML to output

Parameters
streamStream requesting the operation
sendTrue if sending, false if receiving
xmlXML to print

◆ printXml() [2/2]

virtual void printXml ( const JBStream * stream,
bool send,
XmlFragment & frag ) const
virtual

Print an XML fragment to output

Parameters
streamStream requesting the operation
sendTrue if sending, false if receiving
fragXML fragment to print

◆ processEvent()

virtual void processEvent ( JBEvent * ev)
virtual

Process an event. The default implementation will return the event to this engine

Parameters
evThe event to process

◆ redirectMax()

unsigned int redirectMax ( ) const
inline

Retrieve maximum redirect counter for outgoing streams

Returns
Maximum redirect counter for outgoing streams

◆ remoteDomainDef()

JBRemoteDomainDef * remoteDomainDef ( const String & domain)
inline

Find a remote domain definition. Return the default settings if not found. This method is not thread safe

Parameters
domainThe domain to find
Returns
Valid JBRemoteDomainDef pointer

References ObjList::find(), and ObjList::get().

◆ removeStream()

virtual void removeStream ( JBStream * stream,
bool delObj = true )
protectedvirtual

Remove a stream

Parameters
streamThe stream to remove
delObjTrue to release the stream, false to remove it from list without releasing it

Reimplemented in JBClientEngine, and JBServerEngine.

◆ returnEvent()

virtual void returnEvent ( JBEvent * ev,
XMPPError::Type error = XMPPError::NoError,
const char * reason = 0 )
virtual

Return an event to this engine. The default implementation will send an error if apropriate and delete the event

Parameters
evThe event to return
errorOptional error to be returned to the event's XML sender
reasonOptional text to be attached to the error

◆ setExiting()

void setExiting ( )
inline

Set the exiting flag. Terminate all streams

References dropAll(), and JabberID::empty().

◆ stopStreamSets()

virtual void stopStreamSets ( bool waitTerminate = true)
inlineprotectedvirtual

Stop all stream sets

Parameters
waitTerminateTrue to wait for all streams to terminate

Reimplemented in JBClientEngine, and JBServerEngine.

◆ streamReadBuffer()

unsigned int streamReadBuffer ( ) const
inline

Retrieve the stream read buffer length

Returns
Stream read buffer length

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