Yate
Public Types | Public Member Functions | Static Public Member Functions | Friends
JBEvent Class Reference

A Jabber stream event. More...

#include <yatejabber.h>

Inheritance diagram for JBEvent:
RefObject GenObject

List of all members.

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)

Static Public Member Functions

static const char * lookup (int type)

Friends

class JBStream
class JBClientStream
class JBServerStream

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

enum Type

Event type enumeration


Constructor & Destructor Documentation

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
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
virtual ~JBEvent ( ) [virtual]

Destructor. Delete the XML element if valid


Member Function Documentation

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
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
XmlElement* child ( ) const [inline]

Get the first child of the underlying element if any

Returns:
XmlElement pointer or 0

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

Returns:
JBClientStream pointer or 0

Get a cluster stream from event's stream

Returns:
JBClusterStream pointer or 0
XmlElement* element ( ) const [inline]

Get the underlying XmlElement

Returns:
XmlElement pointer or 0
const JabberID& from ( ) const [inline]

Get the 'from' attribute of a received stanza

Returns:
The 'from' attribute
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
static const char* lookup ( int  type) [inline, static]

Get the name of an event type

Returns:
The name an event type

References TelEngine::lookup().

const char* name ( ) const [inline]

Get the event name

Returns:
The name of this event

References TelEngine::lookup().

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

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

Returns:
JBServerStream pointer or 0
const String& stanzaType ( ) const [inline]

Get the element's 'type' attribute if any

Returns:
The element's 'type' attribute
JBStream* stream ( ) const [inline]

Get the stream that generated this event

Returns:
The stream that generated this event
const String& text ( ) const [inline]

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

Returns:
The event's text
const JabberID& to ( ) const [inline]

Get the 'to' attribute of a received stanza

Returns:
The 'to' attribute
int type ( ) const [inline]

Get the event type

Returns:
The type of this event as enumeration

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