Yate
JBStream Class Reference

A Jabber stream. More...

#include <yatejabber.h>

Inheritance diagram for JBStream:
RefObject DebugEnabler Mutex GenObject Lockable JBClientStream JBClusterStream JBServerStream

Public Types

enum  Type {
  c2s = 0 , s2s , comp , cluster ,
  TypeCount
}
 
enum  State {
  Idle = 0 , Connecting , WaitStart , Starting ,
  Features , WaitTlsRsp , Securing , Auth ,
  Challenge , Compressing , Register , Running ,
  Destroy
}
 
enum  Flags {
  NoAutoRestart = 0x00000001 , TlsRequired = 0x00000002 , AllowPlainAuth = 0x00000004 , DialbackOnly = 0x00000008 ,
  RegisterUser = 0x00000010 , Compress = 0x00000020 , InError = 0x00000080 , RosterRequested = 0x00000100 ,
  AvailableResource = 0x00000200 , PositivePriority = 0x00000400 , SetCompressed = 0x00010000 , StreamSecured = 0x00020000 ,
  StreamTls = 0x00040000 , StreamAuthenticated = 0x00080000 , StreamRemoteVer1 = 0x00100000 , StreamLocalVer1 = 0x00200000 ,
  StreamWaitBindRsp = 0x01000000 , StreamWaitSessRsp = 0x02000000 , StreamWaitChallenge = 0x04000000 , StreamWaitChgRsp = 0x08000000 ,
  StreamRfc3920Chg = 0x10000000 , StreamCompressed = 0x20000000 , StreamCanCompress = 0x40000000 , StreamFlags = 0x000000ff ,
  InternalFlags = 0xffff0000
}
 

Public Member Functions

virtual ~JBStream ()
 
int type () const
 
int xmlns () const
 
State state () const
 
bool incoming () const
 
bool outgoing () const
 
JBEngineengine () const
 
const char * name () const
 
const Stringid () const
 
bool isId (const String &str)
 
const JabberIDlocal () const
 
void local (JabberID &jid)
 
void setLocal (const char *jid)
 
const JabberIDremote () const
 
void remote (JabberID &jid)
 
bool remoteAddr (SocketAddr &addr)
 
bool localAddr (SocketAddr &addr)
 
int flags () const
 
bool flag (int mask) const
 
void setTlsRequired (bool set)
 
bool haveData ()
 
void connectAddr (String &addr, int &port, String &localip, int &stat, ObjList &srvs, bool *isRedirect=0) const
 
const StringserverHost () const
 
void setRosterRequested (bool ok)
 
bool setAvailableResource (bool ok, bool positive=true)
 
bool readSocket (char *buf, unsigned int len)
 
virtual JBClientStreamclientStream ()
 
virtual JBServerStreamserverStream ()
 
virtual JBClusterStreamclusterStream ()
 
JBEventgetEvent (u_int64_t time=Time::msecNow())
 
bool sendStanza (XmlElement *&xml)
 
bool sendStreamXml (State newState, XmlElement *first, XmlElement *second=0, XmlElement *third=0)
 
void start (XMPPFeatureList *features=0, XmlElement *caps=0, bool useVer1=true)
 
bool authenticated (bool ok, const String &rsp=String::empty(), XMPPError::Type error=XMPPError::NotAuthorized, const char *username=0, const char *id=0, const char *resource=0)
 
void terminate (int location, bool destroy, XmlElement *xml, int error=XMPPError::NoError, const char *reason="", bool final=false, bool genEvent=true, const char *content=0)
 
virtual void connectTerminated (Socket *&sock)
 
virtual bool connecting (bool sync, int stat, ObjList &srvs)
 
virtual void * getObject (const String &name) const
 
const char * stateName () const
 
const char * typeName () const
 
void buildSha1Digest (String &buf, const String &secret)
 
virtual const StringtoString () const
 
- Public Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual const StringtraceId () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- 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 ()
 

Static Public Member Functions

static Type lookupType (const char *text, Type defVal=TypeCount)
 
- 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 ()
 

Public Attributes

SASLm_sasl
 

Static Public Attributes

static const TokenDict s_stateName []
 
static const TokenDict s_flagName []
 
static const TokenDict s_typeName []
 

Protected Member Functions

 JBStream (JBEngine *engine, Socket *socket, Type t, bool ssl=false)
 
 JBStream (JBEngine *engine, Type t, const JabberID &local, const JabberID &remote, const char *name=0, const NamedList *params=0, const char *serverHost=0)
 
virtual void destroyed ()
 
virtual bool canProcess (u_int64_t time)
 
virtual void process (u_int64_t time)
 
virtual bool processRunning (XmlElement *xml, const JabberID &from, const JabberID &to)
 
virtual void checkTimeouts (u_int64_t time)
 
virtual void resetConnection (Socket *sock=0)
 
virtual XmlElementbuildPing (const String &stanzaId)
 
virtual XmlElementbuildStreamStart ()
 
virtual bool processStart (const XmlElement *xml, const JabberID &from, const JabberID &to)
 
virtual bool processAuth (XmlElement *xml, const JabberID &from, const JabberID &to)
 
virtual bool processCompressing (XmlElement *xml, const JabberID &from, const JabberID &to)
 
virtual bool processRegister (XmlElement *xml, const JabberID &from, const JabberID &to)
 
bool processStreamStart (const XmlElement *xml)
 
bool handleCompressReq (XmlElement *xml)
 
bool streamError (XmlElement *xml)
 
bool getJids (XmlElement *xml, JabberID &from, JabberID &to)
 
bool checkStanzaRecv (XmlElement *xml, JabberID &from, JabberID &to)
 
void changeState (State newState, u_int64_t time=Time::msecNow())
 
XmlElementcheckCompress ()
 
void checkPendingEvent ()
 
bool sendPending (bool streamOnly=false)
 
bool writeSocket (const void *data, unsigned int &len)
 
void updateFromRemoteDef ()
 
XMPPFeaturefirstRequiredFeature ()
 
bool dropXml (XmlElement *&xml, const char *reason)
 
bool destroyDropXml (XmlElement *&xml, XMPPError::Type error, const char *reason)
 
void setFlags (int mask)
 
void resetFlags (int mask)
 
void setSecured ()
 
void setIdleTimer (u_int64_t msecNow=Time::msecNow())
 
void resetPing ()
 
XmlElementsetNextPing (bool force)
 
void generateIdIndex (String &buf, const char *extra=0)
 
- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
- Protected Member Functions inherited from DebugEnabler
void debugName (const char *name)
 

Protected Attributes

State m_state
 
String m_id
 
JabberID m_local
 
JabberID m_remote
 
String m_serverHost
 
int m_flags
 
XMPPNamespace::Type m_xmlns
 
XMPPFeatureList m_features
 
JBEventm_lastEvent
 
ObjList m_events
 
ObjList m_pending
 
unsigned int m_stanzaIndex
 
u_int64_t m_setupTimeout
 
u_int64_t m_startTimeout
 
u_int64_t m_pingTimeout
 
u_int64_t m_pingInterval
 
u_int64_t m_nextPing
 
u_int64_t m_idleTimeout
 
u_int64_t m_connectTimeout
 
unsigned int m_restart
 
u_int64_t m_timeToFillRestart
 
String m_pingId
 

Friends

class JBEngine
 
class JBEvent
 

Detailed Description

A Jabber stream.

Base class for all Jabber streams. Basic stream data processing: send/receive XML elements, keep stream state, generate events

Member Enumeration Documentation

◆ Flags

enum Flags

Stream behaviour options

◆ State

enum State

Stream state enumeration

◆ Type

enum Type

Stream type enumeration

Constructor & Destructor Documentation

◆ ~JBStream()

virtual ~JBStream ( )
virtual

Destructor. Gracefully close the stream and the socket

◆ JBStream() [1/2]

JBStream ( JBEngine * engine,
Socket * socket,
Type t,
bool ssl = false )
protected

Constructor. Build an incoming stream from a socket

Parameters
engineEngine owning this stream
socketThe socket
tStream type as enumeration
sslTrue if the socket is already using SSL/TLS

References engine().

◆ JBStream() [2/2]

JBStream ( JBEngine * engine,
Type t,
const JabberID & local,
const JabberID & remote,
const char * name = 0,
const NamedList * params = 0,
const char * serverHost = 0 )
protected

Constructor. Build an outgoing stream

Parameters
engineEngine owning this stream
tStream type as enumeration
localLocal party jabber id
remoteRemote party jabber id
nameOptional stream name
paramsOptional stream parameters
serverHostOptional server host to use instead of jid domain

References engine(), local(), name(), remote(), and serverHost().

Member Function Documentation

◆ authenticated()

bool authenticated ( bool ok,
const String & rsp = String::empty(),
XMPPError::Type error = XMPPError::NotAuthorized,
const char * username = 0,
const char * id = 0,
const char * resource = 0 )

Auth event result. This method should be called by the upper layer when processing an Auth event This method is thread safe

Parameters
okTrue if the remote party was authenticated, false if authentication failed
rspOptional success response content. Ignored if not authenticated
errorFailure reason. Ignored if authenticated
usernameAuthenticated user
idNon SASL auth response id
resourceClient resource to set when non SASL authentication is used
Returns
False if stream state is incorrect

References String::empty().

◆ buildPing()

virtual XmlElement * buildPing ( const String & stanzaId)
protectedvirtual

Build a ping iq stanza

Parameters
stanzaIdStanza id
Returns
0

Reimplemented in JBClientStream.

◆ buildSha1Digest()

void buildSha1Digest ( String & buf,
const String & secret )
inline

Build a SHA1 digest from stream id and secret

Parameters
bufDestination buffer
secretThe secret

References Hasher::hexDigest(), and String::toLower().

◆ buildStreamStart()

virtual XmlElement * buildStreamStart ( )
protectedvirtual

Build a stream start XML element

Returns
XmlElement pointer

Reimplemented in JBClusterStream, and JBServerStream.

◆ canProcess()

virtual bool canProcess ( u_int64_t time)
protectedvirtual

Check if stream state processor can continue. This method is called from getEvent() with the stream locked

Parameters
timeCurrent time
Returns
True to indicate stream availability to process its state, false to return the last event, if any

◆ changeState()

void changeState ( State newState,
u_int64_t time = Time::msecNow() )
protected

Change stream state. Reset state depending data

Parameters
newStateThe new stream state
timeCurrent time

References Time::msecNow().

◆ checkCompress()

XmlElement * checkCompress ( )
protected

Check if the stream compress flag is set and compression was offered by remote party

Returns
Compress request XmlElement pointer or 0

◆ checkPendingEvent()

void checkPendingEvent ( )
protected

Check for pending events. Set the last event

◆ checkStanzaRecv()

bool checkStanzaRecv ( XmlElement * xml,
JabberID & from,
JabberID & to )
protected

Check if a received element is a presence, message or iq qualified by the stream namespace and the stream is not authenticated. Validate 'from' for c2s streams Validate s2s 'to' domain and 'from' jid Fix 'from' or 'to' is needed

Parameters
xmlReceived xml element (will be consumed if false is returned)
fromThe sender of the stanza
toStanza recipient
Returns
False if the element was consumed (error was sent or stream termination was initiated)

◆ checkTimeouts()

virtual void checkTimeouts ( u_int64_t time)
protectedvirtual

Check stream timeouts. This method is called from getEvent() with the stream locked, after the process() method returned without setting the last event

Parameters
timeCurrent time

◆ clientStream()

virtual JBClientStream * clientStream ( )
inlinevirtual

Get a client stream from this one

Returns
JBClientStream pointer or 0

Reimplemented in JBClientStream.

◆ clusterStream()

virtual JBClusterStream * clusterStream ( )
inlinevirtual

Get a cluster stream from this one

Returns
JBClusterStream pointer

Reimplemented in JBClusterStream.

◆ connectAddr()

void connectAddr ( String & addr,
int & port,
String & localip,
int & stat,
ObjList & srvs,
bool * isRedirect = 0 ) const

Retrieve connection address(es), port and status This method is not thread safe

Parameters
addrThe remote ip
portThe remote port
localipLocal ip to bind
statCurrent connect status
isRedirectOptional pointer to be set to true if returned address is a redirect one
srvsList to copy stream SRV records

◆ connecting()

virtual bool connecting ( bool sync,
int stat,
ObjList & srvs )
virtual

Connecting notification. Start connect timer for synchronous connect This method is thread safe

Parameters
syncTrue if the connection is synchronous
statCurrent status of the connect thread
srvsCurrent list of SRV records in the connect thread
Returns
True if accepted

◆ connectTerminated()

virtual void connectTerminated ( Socket *& sock)
virtual

Outgoing stream connect terminated notification. Send stream start if everithing is ok

Parameters
sockThe connected socket, will be consumed and zeroed

◆ destroyDropXml()

bool destroyDropXml ( XmlElement *& xml,
XMPPError::Type error,
const char * reason )
inlineprotected

Terminate (destroy) the stream. Drop (delete) received XML element

Parameters
xmlThe element to delete
errorTerminate error
reasonDrop reason
Returns
False

References dropXml(), and terminate().

◆ destroyed()

virtual void destroyed ( )
protectedvirtual

Close the stream. Release memory

Reimplemented from RefObject.

Reimplemented in JBClientStream, and JBServerStream.

◆ dropXml()

bool dropXml ( XmlElement *& xml,
const char * reason )
protected

Drop (delete) received XML element

Parameters
xmlThe element to delete
reasonThe reason
Returns
True

Referenced by destroyDropXml().

◆ engine()

◆ firstRequiredFeature()

XMPPFeature * firstRequiredFeature ( )
protected

Retrieve the first required feature in the list

Returns
XMPPFeature pointer or 0

◆ flag()

bool flag ( int mask) const
inline

Check if a given option (or option mask) is set

Parameters
maskThe flag(s) to check
Returns
True if set

Referenced by JBServerStream::adjustDbRsp(), and JBServerStream::dialback().

◆ flags()

int flags ( ) const
inline

Get the stream flags

Returns
Stream flags

◆ generateIdIndex()

void generateIdIndex ( String & buf,
const char * extra = 0 )
inlineprotected

Generate a stanza index from stream id and current stanza index Set the ping timeout if an element is returned

Parameters
bufDestination string
extraOptional extra string

References id().

◆ getEvent()

JBEvent * getEvent ( u_int64_t time = Time::msecNow())

Stream state processor. This method is thread safe

Parameters
timeCurrent time
Returns
JBEvent pointer or 0

References Time::msecNow().

◆ getJids()

bool getJids ( XmlElement * xml,
JabberID & from,
JabberID & to )
protected

Retrieve and check the 'from' and 'to' JIDs from a receive element

Parameters
xmlReceived xml element
fromJabber ID to set from the 'from' attribute
toJabber ID to set from the 'to' attribute
Returns
False if stream termination was initiated (the xml will be consumed)

◆ getObject()

virtual void * getObject ( const String & name) const
virtual

Get an object from this stream

Parameters
nameThe name of the object to get

Reimplemented from RefObject.

References name().

◆ handleCompressReq()

bool handleCompressReq ( XmlElement * xml)
protected

Handle an already checked (tag and namespace) compress request Respond to it. Change stream state on success

Parameters
xmlReceived xml element (will be consumed)
Returns
False if stream termination was initiated

◆ haveData()

bool haveData ( )

Check if the stream has valid pending data (received xml elements in queue or pending events or pending xml elements that can still be sent). This method is thread safe

Returns
True if the stream have pending data, false otherwise

◆ id()

const String & id ( ) const
inline

Get the stream id

Returns
The stream id

Referenced by generateIdIndex().

◆ incoming()

bool incoming ( ) const
inline

Get the stream direction

Returns
True if the stream is an incoming one

◆ isId()

bool isId ( const String & str)
inline

Check if the stream id equals a given string. This method is thread safe

Parameters
strThe string to check
Returns
True if the given string equals this stream's id

References Mutex::lock().

◆ local() [1/2]

const JabberID & local ( ) const
inline

Get the JID of the local side of this stream

Returns
The JID of the local side of this stream

Referenced by JBClusterStream::JBClusterStream(), JBServerStream::JBServerStream(), JBServerStream::JBServerStream(), JBStream(), and JBServerStream::startComp().

◆ local() [2/2]

void local ( JabberID & jid)
inline

Get the JID of the local side of this stream. This method is thread safe

Parameters
jidThe JID to be filled with the local side of this stream

References Mutex::lock().

◆ localAddr()

bool localAddr ( SocketAddr & addr)
inline

Get the local address This method is thread safe

Parameters
addrThe socket address to be filled with local address
Returns
True on success

References Mutex::lock().

◆ lookupType()

static Type lookupType ( const char * text,
Type defVal = TypeCount )
inlinestatic

Get the stream type associated with a given text

Parameters
textStream type text to find
defValValue to return if not found
Returns
The stream type associated with a given text

References s_typeName.

◆ name()

const char * name ( ) const
inline

Get the stream's name

Returns
The stream's name

Referenced by getObject(), JBClientStream::JBClientStream(), JBServerStream::JBServerStream(), and JBStream().

◆ outgoing()

bool outgoing ( ) const
inline

Get the stream direction

Returns
True if the stream is an outgoing one

Referenced by JBServerStream::dialback().

◆ process()

virtual void process ( u_int64_t time)
protectedvirtual

Process stream state. Get XML from parser's queue and process it This method is called from getEvent() with the stream locked

Parameters
timeCurrent time

◆ processAuth()

virtual bool processAuth ( XmlElement * xml,
const JabberID & from,
const JabberID & to )
protectedvirtual

Process elements in Auth state

Parameters
xmlReceived element (will be consumed)
fromAlready parsed source JID
toAlready parsed destination JID
Returns
False if stream termination was initiated

Reimplemented in JBClientStream, and JBServerStream.

◆ processCompressing()

virtual bool processCompressing ( XmlElement * xml,
const JabberID & from,
const JabberID & to )
protectedvirtual

Process elements in Compressing state

Parameters
xmlReceived element (will be consumed)
fromAlready parsed source JID
toAlready parsed destination JID
Returns
False if stream termination was initiated

◆ processRegister()

virtual bool processRegister ( XmlElement * xml,
const JabberID & from,
const JabberID & to )
protectedvirtual

Process elements in Register state

Parameters
xmlReceived element (will be consumed)
fromAlready parsed source JID
toAlready parsed destination JID
Returns
False if stream termination was initiated

Reimplemented in JBClientStream.

◆ processRunning()

virtual bool processRunning ( XmlElement * xml,
const JabberID & from,
const JabberID & to )
protectedvirtual

Process elements in Running state

Parameters
xmlReceived element (will be consumed)
fromAlready parsed source JID
toAlready parsed destination JID
Returns
False if stream termination was initiated

Reimplemented in JBClientStream, JBClusterStream, and JBServerStream.

◆ processStart()

virtual bool processStart ( const XmlElement * xml,
const JabberID & from,
const JabberID & to )
protectedvirtual

Process stream start elements while waiting for them

Parameters
xmlReceived xml element
fromThe 'from' attribute
toThe 'to' attribute
Returns
False if stream termination was initiated

Reimplemented in JBClientStream, JBClusterStream, and JBServerStream.

◆ processStreamStart()

bool processStreamStart ( const XmlElement * xml)
protected

Check if a received stream start element is correct. Check namespaces and set stream version Check and set the id for outgoing streams Generate an id for incoming streams Terminate the stream if this conditions are met

Parameters
xmlReceived xml element
Returns
False if stream termination was initiated

◆ readSocket()

bool readSocket ( char * buf,
unsigned int len )

Read data from socket. Send it to the parser. Terminate the stream on socket or parser error

Parameters
bufDestination buffer
lenBuffer length (must be greater then 1)
Returns
True if data was received

◆ remote() [1/2]

const JabberID & remote ( ) const
inline

Get the JID of the remote side of this stream

Returns
The JID of the remote side of this stream

Referenced by JBClusterStream::JBClusterStream(), JBServerStream::JBServerStream(), JBServerStream::JBServerStream(), JBStream(), and JBServerStream::startComp().

◆ remote() [2/2]

void remote ( JabberID & jid)
inline

Get the JID of the remote side of this stream. This method is thread safe

Parameters
jidThe JID to be filled with the remote side of this stream

References Mutex::lock().

◆ remoteAddr()

bool remoteAddr ( SocketAddr & addr)
inline

Get the remote party's address This method is thread safe

Parameters
addrThe socket address to be filled with remote party's address
Returns
True on success

References Mutex::lock().

◆ resetConnection()

virtual void resetConnection ( Socket * sock = 0)
protectedvirtual

Reset the stream's connection. Build a new XML parser if the socket is valid Release the old connection

Parameters
sockThe new socket

◆ resetFlags()

void resetFlags ( int mask)
protected

Reset stream flag mask

Parameters
maskThe bit mask to reset

Referenced by setTlsRequired().

◆ resetPing()

void resetPing ( )
protected

Reset ping data

◆ sendPending()

bool sendPending ( bool streamOnly = false)
protected

Send pending stream XML or stanzas Terminate the stream on error

Parameters
streamOnlyTry to send only existing stream related XML elements
Returns
True on success

◆ sendStanza()

bool sendStanza ( XmlElement *& xml)

Send a stanza ('iq', 'message' or 'presence') or dialback elements in Running state. This method is thread safe

Parameters
xmlElement to send (will be consumed and zeroed)
Returns
True on success

◆ sendStreamXml()

bool sendStreamXml ( State newState,
XmlElement * first,
XmlElement * second = 0,
XmlElement * third = 0 )

Send stream related XML when negotiating the stream or some other stanza in non Running state All elements will be consumed This method is thread safe

Parameters
newStateThe new stream state to set on success
firstThe first element to send
secondOptional second element to send
thirdOptional third element to send
Returns
True on success

◆ serverHost()

const String & serverHost ( ) const
inline

Retrieve server host when connecting. This method is not thread safe

Returns
Server host if set, remote jid's domain otherwise

Referenced by JBClientStream::JBClientStream(), and JBStream().

◆ serverStream()

virtual JBServerStream * serverStream ( )
inlinevirtual

Get a server stream from this one

Returns
JBServerStream pointer or 0

Reimplemented in JBServerStream.

◆ setAvailableResource()

bool setAvailableResource ( bool ok,
bool positive = true )

Set/reset AvailableResource/PositivePriority flags This method is thread safe

Parameters
okTrue to set, false to reset it
positiveTrue if an available resource has positive priority
Returns
True if changed

◆ setFlags()

void setFlags ( int mask)
protected

Set stream flag mask

Parameters
maskThe bit mask to set

Referenced by setSecured(), and setTlsRequired().

◆ setIdleTimer()

void setIdleTimer ( u_int64_t msecNow = Time::msecNow())
protected

Set the idle timer in Running state

Parameters
msecNowCurrent time in milliseconds

References Time::msecNow().

◆ setLocal()

void setLocal ( const char * jid)
inline

Set the local party's JID

Parameters
jidLocal party's jid to set

◆ setNextPing()

XmlElement * setNextPing ( bool force)
protected

Set the time of the next ping if there is any timeout and we don't have a ping in progress. Set the ping timeout if an element is returned

Parameters
forceTrue to set it even if already set
Returns
XmlElement containing the ping to send, 0 if no ping is going to be sent or 'force' is true

◆ setRosterRequested()

void setRosterRequested ( bool ok)

Set/reset RosterRequested flag This method is thread safe

Parameters
okTrue to set, false to reset it

◆ setSecured()

void setSecured ( )
inlineprotected

Set secured flag. Remove feature from list

References setFlags().

◆ setTlsRequired()

void setTlsRequired ( bool set)
inline

Set or reset the TLS required flag This method is not thread safe

Parameters
setTrue to set, false to reset the flag

References Mutex::lock(), resetFlags(), and setFlags().

◆ start()

void start ( XMPPFeatureList * features = 0,
XmlElement * caps = 0,
bool useVer1 = true )

Start the stream. This method should be called by the upper layer when processing an incoming stream Start event This method is thread safe

Parameters
featuresOptional features to advertise to the remote party of an incoming stream. The caller is responsable of freeing it. If processed, list's elements will be moved to stream's features list
capsOptional entity capabilities to be added to the stream features. Ignored for outgoing streams
useVer1Advertise RFC3920 version. Ignored for outgoing streams

◆ state()

State state ( ) const
inline

Get the stream state

Returns
The stream state as enumeration.

Referenced by stateName().

◆ stateName()

const char * stateName ( ) const
inline

Get the name of a stream state

Returns
The name of the stream state

References s_stateName, and state().

◆ streamError()

bool streamError ( XmlElement * xml)
protected

Check if a received element is a stream error one

Parameters
xmlReceived xml element
Returns
True if stream termination was initiated (the xml will be consumed)

◆ terminate()

void terminate ( int location,
bool destroy,
XmlElement * xml,
int error = XMPPError::NoError,
const char * reason = "",
bool final = false,
bool genEvent = true,
const char * content = 0 )

Terminate the stream. Send stream end tag or error. Reset the stream. Deref stream if destroying. This method is thread safe

Parameters
locationThe terminate request location: -1: upper layer, 0: internal, 1: remote
destroyTrue to destroy. False to terminate
xmlReceived XML element. The element will be consumed
errorTermination reason. Set it to NoError to send stream end tag
reasonOptional text to be added to the error stanza
finalTrue if called from destructor
genEventTrue to generate terminated event
contentOptional sent error condition element text

Referenced by destroyDropXml().

◆ toString()

virtual const String & toString ( ) const
virtual

Get the string representation of this stream

Returns
Stream name

Reimplemented from GenObject.

◆ type()

int type ( ) const
inline

Get the type of this stream. See the protocol enumeration of the engine

Returns
The type of this stream

Referenced by typeName().

◆ typeName()

const char * typeName ( ) const
inline

Get the name of a stream type

Returns
The name of the stream type

References s_typeName, and type().

◆ updateFromRemoteDef()

void updateFromRemoteDef ( )
protected

Update stream flags and remote connection data from engine

◆ writeSocket()

bool writeSocket ( const void * data,
unsigned int & len )
protected

Write data to socket. Terminate the stream on socket error

Parameters
dataBuffer to sent
lenThe number of bytes to send. Filled with actually sent bytes on exit
Returns
True on success, false on failure

◆ xmlns()

int xmlns ( ) const
inline

Retrieve this stream's default namespace

Returns
The stream default namespace

Member Data Documentation

◆ m_sasl

SASL* m_sasl

SASL authentication data

◆ s_flagName

const TokenDict s_flagName[]
static

Dictionary keeping the flag names

◆ s_stateName

const TokenDict s_stateName[]
static

Dictionary keeping the stream state names

Referenced by stateName().

◆ s_typeName

const TokenDict s_typeName[]
static

Dictionary keeping the stream type names

Referenced by lookupType(), and typeName().


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