gloox  0.9.9.12
Public Member Functions | Static Public Member Functions | List of all members
Stanza Class Reference

#include <stanza.h>

Inheritance diagram for Stanza:
Inheritance graph
[legend]
Collaboration diagram for Stanza:
Collaboration graph
[legend]

Public Member Functions

 Stanza (const Tag *tag)
 Stanza (const std::string &name, const std::string &cdata="", const std::string &xmllang="default", bool incoming=false)
virtual ~Stanza ()
virtual StanzaSubType subtype () const
virtual const JIDfrom () const
virtual const JIDto () const
virtual const std::string & id () const
virtual const std::string & xmlns () const
virtual Presence presence () const
virtual int priority () const
virtual const std::string status (const std::string &lang="default") const
virtual const std::string body (const std::string &lang="default") const
virtual const std::string subject (const std::string &lang="default") const
virtual const std::string errorText (const std::string &lang="default") const
virtual StanzaError error () const
TagerrorAppCondition ()
virtual const std::string & thread () const
void setThread (const std::string &thread)
const std::string & xmlLang () const
void finalize ()
void addExtension (StanzaExtension *se)
const StanzaExtensionListextensions () const
- Public Member Functions inherited from Tag
GLOOX_DEPRECATED_CTOR Tag ()
 Tag (const std::string &name, const std::string &cdata="", bool incoming=false)
 Tag (Tag *parent, const std::string &name, const std::string &cdata="", bool incoming=false)
 Tag (const std::string &name, const std::string &attrib, const std::string &value, bool incoming=false)
 Tag (Tag *parent, const std::string &name, const std::string &attrib, const std::string &value, bool incoming=false)
virtual ~Tag ()
virtual const std::string xml () const
virtual void addAttribute (const std::string &name, const std::string &value)
virtual void addAttribute (const std::string &name, int value)
virtual void addAttribute (const std::string &name, long value)
virtual void setAttributes (const AttributeList &attributes)
virtual void addChild (Tag *child)
virtual void addChildCopy (const Tag *child)
virtual void setCData (const std::string &cdata)
virtual void addCData (const std::string &cdata)
virtual const std::string & name () const
virtual const std::string & cdata () const
virtual AttributeListattributes ()
virtual const AttributeListattributes () const
virtual TagListchildren ()
virtual const TagListchildren () const
virtual const std::string findAttribute (const std::string &name) const
virtual bool hasAttribute (const std::string &name, const std::string &value="") const
virtual TagfindChild (const std::string &name) const
virtual TagfindChild (const std::string &name, const std::string &attr, const std::string &value="") const
virtual bool hasChild (const std::string &name, const std::string &attr="", const std::string &value="") const
virtual TagfindChildWithAttrib (const std::string &attr, const std::string &value="") const
virtual bool hasChildWithAttrib (const std::string &attr, const std::string &value="") const
TagList findChildren (const std::string &name) const
void removeChild (Tag *tag)
virtual GLOOX_DEPRECATED bool empty () const
bool hasChildWithCData (const std::string &name, const std::string &cdata) const
Tagparent () const
virtual StanzaType type () const
virtual Tagclone () const
TagfindTag (const std::string &expression)
Tag::TagList findTagList (const std::string &expression)
bool operator== (const Tag &right) const
bool operator!= (const Tag &right) const
 operator bool () const

Static Public Member Functions

static StanzacreateIqStanza (const JID &to, const std::string &id, StanzaSubType subtype=StanzaIqGet, const std::string &xmlns="", Tag *tag=0)
static StanzacreatePresenceStanza (const JID &to, const std::string &msg="", Presence status=PresenceAvailable, const std::string &xmllang="")
static StanzacreateMessageStanza (const JID &to, const std::string &body, StanzaSubType subtype=StanzaMessageChat, const std::string &subject="", const std::string &thread="", const std::string &xmllang="")
static StanzacreateSubscriptionStanza (const JID &to, const std::string &msg="", StanzaSubType subtype=StanzaS10nSubscribe, const std::string &xmllang="")
- Static Public Member Functions inherited from Tag
static const std::string escape (std::string what)
static const std::string relax (std::string what)

Additional Inherited Members

- Public Types inherited from Tag
typedef std::pair< std::string,
std::string > 
Attribute
typedef std::list< AttributeAttributeList
typedef std::list< Tag * > TagList
- Protected Types inherited from Tag
enum  XPathError { XPNoError, XPExpectedLeftOperand }

Detailed Description

This is an abstraction of a XMPP stanza.

You can create a new Stanza from an existing Tag (or another stanza).

Author
Jakob Schroeter js@ca.nosp@m.maya.nosp@m..net
Since
0.4

Definition at line 39 of file stanza.h.

Constructor & Destructor Documentation

Stanza ( const Tag tag)

Creates a new Stanza from a deep copy of the given Tag.

Parameters
tagThe Tag to create the Stanza from.
Since
0.7
Note
While the signature of this constructor in 0.7 is the the same as in older versions, semantics have changed. The copy created by this constructor is no longer a shallow one. You have to make sure the copy is deleted properly.

Definition at line 32 of file stanza.cpp.

Stanza ( const std::string &  name,
const std::string &  cdata = "",
const std::string &  xmllang = "default",
bool  incoming = false 
)

Creates a new Stanza with given name and optional CData.

Parameters
nameThe name of the root tag.
cdataInitial XML character data for the tag.
xmllangThe value of the xmllang attribute. The stanza's primary language.
incomingIndicates whether tag names, attributes, attribute values, and cdata shall be escaped (false, default) or not (true).

Definition at line 24 of file stanza.cpp.

~Stanza ( )
virtual

Virtual destructor.

Definition at line 48 of file stanza.cpp.

Member Function Documentation

void addExtension ( StanzaExtension se)

Use this function to add a StanzaExtension to this Stanza.

Parameters
seThe StanzaExtension to add.
Note
The Stanza will become the owner of the StanzaExtension and will delete it after using it.
Since
0.9

Definition at line 301 of file stanza.cpp.

virtual const std::string body ( const std::string &  lang = "default") const
inlinevirtual

Returns the body of a message stanza for the given language if available. If the requested language is not available, the default body (without a xml:lang attribute) will be returned.

Parameters
langThe language identifier for the desired language. It must conform to section 2.12 of the XML specification and RFC 3066. If empty, the default body will be returned, if any.
Returns
The body of a message stanza. Empty for non-message stanzas.

Definition at line 134 of file stanza.h.

Stanza * createIqStanza ( const JID to,
const std::string &  id,
StanzaSubType  subtype = StanzaIqGet,
const std::string &  xmlns = "",
Tag tag = 0 
)
static

Creates a new IQ stanza.

Parameters
toThe receiver of the stanza.
idAn ID for the stanza. Best is to use ClientBase::getID() as input.
subtypeThe IQ type. Only StanzaIq* types are valid.
xmlnsIf this is non-empty, a child element named 'query' will be included, with this value as value of the 'xmlns' attribute.
tagIf this if not NULL, and xmlns is not empty, this Tag will be included as child tag of the 'query' element.
Since
0.7

Definition at line 307 of file stanza.cpp.

Stanza * createMessageStanza ( const JID to,
const std::string &  body,
StanzaSubType  subtype = StanzaMessageChat,
const std::string &  subject = "",
const std::string &  thread = "",
const std::string &  xmllang = "" 
)
static

Creates a new message stanza.

Parameters
toThe receiver of the message.
bodyThe message's body.
subtypeThe message type. Only StanzaMessage* types are valid.
subjectThe message's subject.
threadThe message's conversation thread id.
xmllangThe message's language.
Since
0.7

Definition at line 382 of file stanza.cpp.

Stanza * createPresenceStanza ( const JID to,
const std::string &  msg = "",
Presence  status = PresenceAvailable,
const std::string &  xmllang = "" 
)
static

Creates a new presence stanza. to can be an empty JID. This makes the created stanza a broadcast stanza sent to all contacts in the roster.

Parameters
toThe receiver of the stanza.
msgAn optional message.
statusThe status.
xmllangThe status message's language.
Since
0.7

Definition at line 343 of file stanza.cpp.

Stanza * createSubscriptionStanza ( const JID to,
const std::string &  msg = "",
StanzaSubType  subtype = StanzaS10nSubscribe,
const std::string &  xmllang = "" 
)
static

Creates a new subscription stanza.

Parameters
toThe recipient of the subscription stanza.
msgAn optional message.
subtypeThe subscription type. Only StanzaS10n* types are vaild.
xmllangThe message's language.
Since
0.7

Definition at line 427 of file stanza.cpp.

virtual StanzaError error ( ) const
inlinevirtual

Returns the stanza error condition, if any.

Returns
The stanza error condition.

Definition at line 165 of file stanza.h.

Tag* errorAppCondition ( )
inline

This function can be used to retrieve the application-specific error condition of a stanza error.

Returns
The application-specific error element of a stanza error. 0 if no respective element was found or no error occured.

Definition at line 172 of file stanza.h.

virtual const std::string errorText ( const std::string &  lang = "default") const
inlinevirtual

Returns the text of a error stanza for the given language if available. If the requested language is not available, the default text (without a xml:lang attribute) will be returned.

Parameters
langThe language identifier for the desired language. It must conform to section 2.12 of the XML specification and RFC 3066. If empty, the default subject will be returned, if any.
Returns
The text of an error stanza. Empty for non-error stanzas.

Definition at line 158 of file stanza.h.

const StanzaExtensionList& extensions ( ) const
inline

Returns the list of the Stanza's extensions.

Returns
The list of the Stanza's extensions.

Definition at line 215 of file stanza.h.

void finalize ( )
inline

Use this function to parse the content of the Tag and determine type, etc. of the Stanza. This feels kind of hackish... You only need to call this if you are constructing a bare Stanza from scratch. Stanzas provided by gloox are fully parsed.

Deprecated:

Definition at line 200 of file stanza.h.

virtual const JID& from ( ) const
inlinevirtual

Returns the JID the stanza comes from.

Returns
The origin of the stanza.

Definition at line 78 of file stanza.h.

virtual const std::string& id ( ) const
inlinevirtual

Returns the id of the stanza, if set.

Returns
The ID of the stanza.

Definition at line 90 of file stanza.h.

virtual Presence presence ( ) const
inlinevirtual

Returns the presence 'show' type of a presence stanza.

Returns
The presence type of the sender.

Definition at line 102 of file stanza.h.

virtual int priority ( ) const
inlinevirtual

Returns the remote entity resource's presence priority if the stanza is a presence stanza. If the stanza is not a presence stanza or if no priority information was included, a value below -128 is returned, which is an illegal value for the priority. Legal range is between -128 and +127.

Returns
The priority information contained in the stanza, if any, or a value below -128.

Definition at line 111 of file stanza.h.

void setThread ( const std::string &  thread)
inline

Sets the Stanza's thread ID. Only useful for message stanzas.

Parameters
threadThe thread ID.
Since
0.9

Definition at line 185 of file stanza.h.

virtual const std::string status ( const std::string &  lang = "default") const
inlinevirtual

Returns the status text of a presence stanza for the given language if available. If the requested language is not available, the default status text (without a xml:lang attribute) will be returned.

Parameters
langThe language identifier for the desired language. It must conform to section 2.12 of the XML specification and RFC 3066. If empty, the default body will be returned, if any.
Returns
The status text set by the sender.

Definition at line 122 of file stanza.h.

virtual const std::string subject ( const std::string &  lang = "default") const
inlinevirtual

Returns the subject of a message stanza for the given language if available. If the requested language is not available, the default subject (without a xml:lang attribute) will be returned.

Parameters
langThe language identifier for the desired language. It must conform to section 2.12 of the XML specification and RFC 3066. If empty, the default subject will be returned, if any.
Returns
The subject of a message stanza. Empty for non-message stanzas.

Definition at line 146 of file stanza.h.

virtual StanzaSubType subtype ( ) const
inlinevirtual

Returns the sub-type of the stanza.

Returns
The sub-type of the stanza.

Definition at line 72 of file stanza.h.

virtual const std::string& thread ( ) const
inlinevirtual

Returns the thread ID of a message stanza.

Returns
The thread ID of a message stanza. Empty for non-message stanzas.

Definition at line 178 of file stanza.h.

virtual const JID& to ( ) const
inlinevirtual

Returns the receiver of the stanza.

Returns
The stanza's destination.

Definition at line 84 of file stanza.h.

const std::string& xmlLang ( ) const
inline

Retrieves the value of the xml:lang attribute of this stanza. Default is 'en'.

Definition at line 191 of file stanza.h.

virtual const std::string& xmlns ( ) const
inlinevirtual

Returns the value of the xmlns attribute of the first child node.

Returns
The namespace of the IQ stanza.

Definition at line 96 of file stanza.h.


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