Yate
JBEvent Class Reference

A Jabber stream event. More...

#include <yatejabber.h>

Inheritance diagram for JBEvent:
RefObject GenObject

Public Types

enum  Type {
  Terminated , Destroy , Start , Auth ,
  Bind , Running , Message , Presence ,
  Iq , DbResult , DbVerify , RegisterOk ,
  RegisterFailed , Unknown
}
 

Public Member Functions

 JBEvent (Type type, JBStream *stream, XmlElement *element, const JabberID &from, const JabberID &to, XmlElement *child=0)
 
 JBEvent (Type type, JBStream *stream, XmlElement *element, XmlElement *child=0)
 
virtual ~JBEvent ()
 
int type () const
 
const char * name () const
 
const StringstanzaType () const
 
const JabberIDfrom () const
 
const JabberIDto () const
 
const Stringid () const
 
const Stringtext () const
 
JBStreamstream () const
 
JBClientStreamclientStream ()
 
JBServerStreamserverStream ()
 
JBClusterStreamclusterStream ()
 
XmlElementelement () const
 
XmlElementchild () const
 
XmlElementreleaseXml (bool del=false)
 
XmlElementbuildIqResult (bool addTags, XmlElement *child=0)
 
bool sendIqResult (XmlElement *child=0)
 
XmlElementbuildIqError (bool addTags, XMPPError::Type error, const char *reason=0, XMPPError::ErrorType type=XMPPError::TypeModify)
 
bool sendStanzaError (XMPPError::Type error, const char *reason=0, XMPPError::ErrorType type=XMPPError::TypeModify)
 
void releaseStream (bool release=false)
 
- 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 ()
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Static Public Member Functions

static const char * lookup (int type)
 
- 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 ()
 

Friends

class JBStream
 
class JBClientStream
 
class JBServerStream
 

Additional Inherited Members

- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
virtual void destroyed ()
 

Detailed Description

A Jabber stream event.

This class holds a Jabber stream event. Stream events are raised by streams and sent by the engine to the proper service

Member Enumeration Documentation

◆ Type

enum Type

Event type enumeration

Constructor & Destructor Documentation

◆ JBEvent() [1/2]

JBEvent ( Type type,
JBStream * stream,
XmlElement * element,
const JabberID & from,
const JabberID & to,
XmlElement * child = 0 )
inline

Constructor. Constructs an event from a stream

Parameters
typeType of this event
streamThe stream that generated the event
elementElement that generated the event
fromAlready parsed source JID
toAlready parsed destination JID
childOptional type depending element's child

References child(), element(), from(), stream(), to(), and type().

◆ JBEvent() [2/2]

JBEvent ( Type type,
JBStream * stream,
XmlElement * element,
XmlElement * child = 0 )
inline

Constructor. Constructs an event from a stream

Parameters
typeType of this event
streamThe stream that generated the event
elementElement that generated the event
childOptional type depending element's child

References child(), element(), stream(), and type().

◆ ~JBEvent()

virtual ~JBEvent ( )
virtual

Destructor. Delete the XML element if valid

Member Function Documentation

◆ buildIqError()

XmlElement * buildIqError ( bool addTags,
XMPPError::Type error,
const char * reason = 0,
XMPPError::ErrorType type = XMPPError::TypeModify )

Build an 'iq' error stanza from event data The event's element will be released and added to the error one if the id is empty

Parameters
addTagsTrue to add the 'from' and 'to' attributes
errorError to be returned to the event's XML sender
reasonOptional text to be attached to the error
typeError type
Returns
True on success

References type().

◆ buildIqResult()

XmlElement * buildIqResult ( bool addTags,
XmlElement * child = 0 )

Build an 'iq' result stanza from event data

Parameters
addTagsTrue to add the 'from' and 'to' attributes
childOptional 'iq' child (will be consumed)
Returns
True on success

References child().

◆ child()

XmlElement * child ( ) const
inline

Get the first child of the underlying element if any

Returns
XmlElement pointer or 0

Referenced by buildIqResult(), JBEvent(), JBEvent(), and sendIqResult().

◆ clientStream()

JBClientStream * clientStream ( )

Get a client-to-server stream from the event's stream

Returns
JBClientStream pointer or 0

◆ clusterStream()

JBClusterStream * clusterStream ( )

Get a cluster stream from event's stream

Returns
JBClusterStream pointer or 0

◆ element()

XmlElement * element ( ) const
inline

Get the underlying XmlElement

Returns
XmlElement pointer or 0

Referenced by JBEvent(), and JBEvent().

◆ from()

const JabberID & from ( ) const
inline

Get the 'from' attribute of a received stanza

Returns
The 'from' attribute

Referenced by JBEvent().

◆ id()

const String & id ( ) const
inline

Get the sender's id for Write... events or the 'id' attribute if the event carries a received stanza

Returns
The event id

◆ lookup()

static const char * lookup ( int type)
inlinestatic

Get the name of an event type

Returns
The name an event type

References type().

Referenced by name().

◆ name()

const char * name ( ) const
inline

Get the event name

Returns
The name of this event

References lookup(), and type().

◆ releaseStream()

void releaseStream ( bool release = false)

Release the link with the stream to let the stream continue with events

Parameters
releaseTrue to release the reference to the stream

◆ releaseXml()

XmlElement * releaseXml ( bool del = false)

Delete the underlying XmlElement(s). Release the ownership. The caller will own the returned pointer

Parameters
delTrue to delete all xml elements owned by this event
Returns
XmlElement pointer if not deleted or 0

◆ sendIqResult()

bool sendIqResult ( XmlElement * child = 0)

Build and send a stanza 'result' from enclosed 'iq' element Release the element on success

Parameters
childOptional 'iq' child (will be consumed)
Returns
True on success

References child().

◆ sendStanzaError()

bool sendStanzaError ( XMPPError::Type error,
const char * reason = 0,
XMPPError::ErrorType type = XMPPError::TypeModify )

Build and send a stanza error from enclosed element Release the element on success

Parameters
errorError to be returned to the event's XML sender
reasonOptional text to be attached to the error
typeError type
Returns
True on success

References type().

◆ serverStream()

JBServerStream * serverStream ( )

Get a server-to-server stream from the event's stream

Returns
JBServerStream pointer or 0

◆ stanzaType()

const String & stanzaType ( ) const
inline

Get the element's 'type' attribute if any

Returns
The element's 'type' attribute

◆ stream()

JBStream * stream ( ) const
inline

Get the stream that generated this event

Returns
The stream that generated this event

Referenced by JBEvent(), and JBEvent().

◆ text()

const String & text ( ) const
inline

The stanza's text or termination reason for Terminated/Destroy events

Returns
The event's text

◆ to()

const JabberID & to ( ) const
inline

Get the 'to' attribute of a received stanza

Returns
The 'to' attribute

Referenced by JBEvent().

◆ type()

int type ( ) const
inline

Get the event type

Returns
The type of this event as enumeration

Referenced by buildIqError(), JBEvent(), JBEvent(), lookup(), name(), and sendStanzaError().


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