Yate
Public Types | Static Public Member Functions | Static Public Attributes
XMPPUtils Class Reference

General XMPP utilities. More...

#include <xmpputils.h>

List of all members.

Public Types

enum  Presence {
  Probe, Subscribe, Subscribed, Unavailable,
  Unsubscribe, Unsubscribed, PresenceError, PresenceNone
}
enum  MsgType {
  Chat, GroupChat, HeadLine, Normal,
  MsgError
}
enum  IqType {
  IqSet, IqGet, IqResult, IqError,
  IqCount
}
enum  CommandAction {
  CommExecute, CommCancel, CommPrev, CommNext,
  CommComplete
}
enum  CommandStatus { CommExecuting, CommCompleted, CommCancelled }
enum  AuthMethod {
  AuthNone = 0x00, AuthSHA1 = 0x01, AuthMD5 = 0x02, AuthPlain = 0x04,
  AuthDialback = 0x08
}

Static Public Member Functions

static bool isResponse (const XmlElement &xml)
static XmlElementcreateElement (const char *name, const char *text=0, const String &ns=String::empty())
static XmlElementcreateElement (int type, const char *text=0)
static XmlElementcreateElement (const char *name, int ns, const char *text=0)
static XmlElementcreateElement (int type, int ns, const char *text=0)
static XmlElementcreateElement (const XmlElement &src, bool response, bool result)
static XmlElementcreateIq (IqType type, const char *from=0, const char *to=0, const char *id=0)
static XmlElementcreateIqResult (const char *from, const char *to, const char *id, XmlElement *child=0)
static XmlElementcreateIqError (const char *from, const char *to, XmlElement *&xml, int type, int error, const char *text=0)
static XmlElementcreateVCard (bool get, const char *from, const char *to, const char *id)
static XmlElementcreateCommand (CommandAction action, const char *node, const char *sessionId=0)
static XmlElementcreateIqDisco (bool info, bool req, const char *from, const char *to, const char *id, const char *node=0, const char *cap=0)
static XmlElementcreateIqVersionRes (const char *from, const char *to, const char *id, const char *name, const char *version, const char *os=0)
static XmlElementcreateError (int type, int error, const char *text=0)
static XmlElementcreateError (XmlElement *xml, int type, int error, const char *text=0)
static XmlElementcreateStreamError (int error, const char *text=0)
static XmlElementcreateRegisterQuery (IqType type, const char *from, const char *to, const char *id, XmlElement *child1=0, XmlElement *child2=0, XmlElement *child3=0)
static XmlElementcreateIqAuthGet (const char *id)
static XmlElementcreateIqAuthSet (const char *id, const char *username, const char *resource, const char *authStr, bool digest)
static XmlElementcreateIqAuthOffer (const char *id, bool digest=true, bool plain=false)
static XmlElementcreateRegisterQuery (const char *from, const char *to, const char *id, const char *username, const char *password)
static XmlElementcreateFailure (XMPPNamespace::Type ns, XMPPError::Type error=XMPPError::NoError)
static XmlElementcreateXOobUrl (const char *url, const char *desc=0)
static XmlElementcreateDelay (unsigned int timeSec, const char *from=0, unsigned int fractions=0, const char *text=0)
static bool remove (XmlElement &xml)
static bool required (XmlElement &xml)
static int priority (XmlElement &xml, int defVal=0)
static void setPriority (XmlElement &xml, const char *prio)
static int xmlns (XmlElement &xml)
static bool hasDefaultXmlns (const XmlElement &xml, int ns)
static bool hasXmlns (const XmlElement &xml, int ns)
static bool setXmlns (XmlElement &xml, const String &name=String::empty(), bool addAttr=false, int ns=XMPPNamespace::Count)
static bool setStreamXmlns (XmlElement &xml, bool addAttr=true)
static bool setDbXmlns (XmlElement &xml)
static XmlElementfindFirstChild (const XmlElement &xml, int t=XmlTag::Count, int ns=XMPPNamespace::Count)
static XmlElementfindNextChild (const XmlElement &xml, XmlElement *start, int t=XmlTag::Count, int ns=XMPPNamespace::Count)
static void decodeError (XmlElement *xml, int ns=XMPPNamespace::Count, String *error=0, String *text=0)
static void decodeError (XmlElement *xml, String &error, String &text)
static void encodeDateTimeSec (String &buf, unsigned int timeSec, unsigned int fractions=0)
static unsigned int decodeDateTimeSec (const String &time, unsigned int *fractions=0)
static unsigned int decodeDateTimeSecXDelay (const String &time)
static void print (String &xmlStr, XmlChild &xml, bool verbose)
static void toList (XmlElement &xml, NamedList &dest, const char *prefix)
static bool split (NamedList &dest, const char *src, const char sep, bool nameFirst)
static int decodeFlags (const String &src, const TokenDict *dict)
static void buildFlags (String &dest, int src, const TokenDict *dict)
static bool addChidren (XmlElement *dest, ObjList &list)
static XmlElementcreateEntityCaps (const String &hash, const char *node)
static XmlElementcreateEntityCapsGTalkV1 (const char *node=0, bool muc=false)
static XmlElementcreatePresence (const char *from, const char *to, Presence type=PresenceNone)
static XmlElementcreateMessage (const char *type, const char *from, const char *to, const char *id, const char *body)
static XmlElementcreateMessage (MsgType type, const char *from, const char *to, const char *id, const char *body)
static XmlElementcreateDialbackKey (const char *from, const char *to, const char *key)
static XmlElementcreateDialbackResult (const char *from, const char *to, XMPPError::Type rsp=XMPPError::NoError)
static XmlElementcreateDialbackVerify (const char *from, const char *to, const char *id, const char *key)
static XmlElementcreateDialbackVerifyRsp (const char *from, const char *to, const char *id, XMPPError::Type rsp=XMPPError::NoError)
static int decodeDbRsp (XmlElement *xml)
static XmlElementcreateSubject (const char *subject)
static const Stringsubject (XmlElement &xml)
static XmlElementcreateBody (const char *body, int ns=XMPPNamespace::Count)
static const Stringbody (XmlElement &xml, int ns=XMPPNamespace::Count)
static XmlElementcreateParameter (const char *name, const char *value, const char *tag="parameter")
static XmlElementcreateParameter (const NamedString &pair, const char *tag="parameter")
static int ns (const XmlElement &xml)
static int tag (const XmlElement &xml)
static bool getTag (const XmlElement &xml, int &tag, int &ns)
static bool isTag (const XmlElement &xml, int tag, int ns)
static bool isUnprefTag (const XmlElement &xml, int tag)
static bool isStanza (const XmlElement &xml)
static XmlElementgetXml (GenObject *gen)
static XmlElementgetXml (const String &data)
static XmlElementgetXml (NamedList &list, const char *param="xml", const char *extra="data")
static XmlElementgetPresenceXml (NamedList &list, const char *param="xml", const char *extra="data", Presence type=PresenceNone, bool build=true)
static XmlElementgetChatXml (NamedList &list, const char *param="xml", const char *extra="data", bool build=true)
static int cmpBytes (const String &s1, const String &s2)
static Presence presenceType (const char *text)
static const char * presenceText (Presence presence)
static MsgType msgType (const char *text)
static const char * msgText (MsgType msg)
static IqType iqType (const char *text)
static int authMeth (const char *text, int defVal=AuthNone)

Static Public Attributes

static XMPPNamespace s_ns
static XMPPError s_error
static XmlTag s_tag
static const TokenDict s_presence []
static const TokenDict s_msg []
static const TokenDict s_iq []
static const TokenDict s_commandAction []
static const TokenDict s_commandStatus []
static const TokenDict s_authMeth []

Detailed Description

General XMPP utilities.

This class is a general XMPP utilities


Member Enumeration Documentation

enum AuthMethod

Authentication methods

Command action enumeration

Command status enumeration

enum IqType

Iq type enumeration

enum MsgType

Message type enumeration

enum Presence

Presence type enumeration


Member Function Documentation

static bool addChidren ( XmlElement dest,
ObjList list 
) [static]

Add child elements from a list to a destination element

Parameters:
destDestination XmlElement
listA list containing XML elements
Returns:
True if at least one child was added
static int authMeth ( const char *  text,
int  defVal = AuthNone 
) [inline, static]

Get the authentication method associated with a given text

Parameters:
textThe text to check
defValDefault value to return if not found
Returns:
Authentication method

References TelEngine::lookup().

static const String& body ( XmlElement xml,
int  ns = XMPPNamespace::Count 
) [static]

Retrieve the text of an element's body child

Parameters:
xmlThe element
nsOptional body namespace to match (default: match parent's namespace)
Returns:
Body or empty string
static void buildFlags ( String dest,
int  src,
const TokenDict dict 
) [static]

Encode a mask of flags to a comma separated list of names

Parameters:
destDestination string
srcSource mask
dictDictionary containing flag names and values
static int cmpBytes ( const String s1,
const String s2 
) [static]

Byte compare 2 strings.

Parameters:
s1The first string
s2The second string
Returns:
Return less then 0 if s1 < s2, greater then 0 if s1 > s2 or 0 if the 2 strings are equal
static XmlElement* createBody ( const char *  body,
int  ns = XMPPNamespace::Count 
) [inline, static]

Build a 'body' xml element

Parameters:
bodyElement text
nsOptional namespace
Returns:
XmlElement pointer
static XmlElement* createCommand ( CommandAction  action,
const char *  node,
const char *  sessionId = 0 
) [static]

Create a 'command' element

Parameters:
actionThe command action
nodeThe command
sessionIdOptional session ID for the command
Returns:
A valid XmlElement pointer
static XmlElement* createDelay ( unsigned int  timeSec,
const char *  from = 0,
unsigned int  fractions = 0,
const char *  text = 0 
) [static]

Create a 'delay' element as defined in XEP-0203

Parameters:
timeSecThe time to encode (in seconds)
fromOptional 'from' attribute
fractionsOptional second fractions
textOptional xml element text
Returns:
XmlElement pointer
static XmlElement* createDialbackKey ( const char *  from,
const char *  to,
const char *  key 
) [static]

Build a dialback 'db:result' xml element used to send a dialback key

Parameters:
fromThe sender
toThe recipient
keyThe dialback key
Returns:
XmlElement pointer
static XmlElement* createDialbackResult ( const char *  from,
const char *  to,
XMPPError::Type  rsp = XMPPError::NoError 
) [static]

Build a dialback 'db:result' xml element used to send a dialback key response

Parameters:
fromThe sender
toThe recipient
rspThe response as enumeration: set it to NoError if valid, NotAuthorized if invalid or any other error to send a db:result error type
Returns:
XmlElement pointer
static XmlElement* createDialbackVerify ( const char *  from,
const char *  to,
const char *  id,
const char *  key 
) [static]

Build a dialback 'db:verify' xml element

Parameters:
fromThe sender
toThe recipient
idThe 'id' attribute (stream id)
keyThe dialback key
Returns:
XmlElement pointer
static XmlElement* createDialbackVerifyRsp ( const char *  from,
const char *  to,
const char *  id,
XMPPError::Type  rsp = XMPPError::NoError 
) [static]

Build a dialback 'db:verify' response xml element

Parameters:
fromThe sender
toThe recipient
idThe 'id' attribute (stream id)
rspThe response as enumeration: set it to NoError if valid, NotAuthorized if invalid or any other error to send a db:verify error type
Returns:
XmlElement pointer
static XmlElement* createElement ( const char *  name,
const char *  text = 0,
const String ns = String::empty() 
) [inline, static]

Create an XML element

Parameters:
nameElement's name
textOptional text for the element
nsOptional element namespace
Returns:
A valid XmlElement pointer

References XmlElement::addText(), String::empty(), TelEngine::null(), and XmlElement::setXmlns().

static XmlElement* createElement ( int  type,
const char *  text = 0 
) [inline, static]

Create an XML element

Parameters:
typeElement's type
textOptional text for the element
Returns:
A valid XmlElement pointer

References XMPPUtils::createElement().

Referenced by XMPPUtils::createElement().

static XmlElement* createElement ( const char *  name,
int  ns,
const char *  text = 0 
) [inline, static]

Create an XML element with an 'xmlns' attribute

Parameters:
nameElement's name
nsOptional 'xmlns' attribute as enumeration
textOptional text for the element
Returns:
A valid XmlElement pointer

References String::empty().

static XmlElement* createElement ( int  type,
int  ns,
const char *  text = 0 
) [inline, static]

Create an XML element with an 'xmlns' attribute

Parameters:
typeElement's type
ns'xmlns' attribute as enumeration
textOptional text for the element
Returns:
A valid XmlElement pointer

References XMPPUtils::createElement().

Referenced by XMPPUtils::createElement().

static XmlElement* createElement ( const XmlElement src,
bool  response,
bool  result 
) [static]

Partially build an XML element from another one. Copy tag and 'to', 'from', 'type', 'id' attributes

Parameters:
srcSource element
responseTrue to reverse 'to' and 'from' attributes
resultTrue to set type to "result", false to set it to "error". Ignored if response is false
static XmlElement* createEntityCaps ( const String hash,
const char *  node 
) [static]

Create a 'c' entity capability element as defined in XEP 0115

Parameters:
hashThe 'ver' attribute
nodeThe 'node' attribute
Returns:
XmlElement pointer or 0 on failure
static XmlElement* createEntityCapsGTalkV1 ( const char *  node = 0,
bool  muc = false 
) [static]

Create a 'c' entity capability element as defined by GTalk

Parameters:
nodeOptional node attribute, defaults to GTalk's node
mucAdvertise MUC capability
Returns:
A valid XmlElement pointer
static XmlElement* createError ( int  type,
int  error,
const char *  text = 0 
) [static]

Create a 'error' element

Parameters:
typeError type
errorThe error
textOptional text to add to the error element
Returns:
A valid XmlElement pointer
static XmlElement* createError ( XmlElement xml,
int  type,
int  error,
const char *  text = 0 
) [static]

Create an error from a received element. Consume the received element. Reverse 'to' and 'from' attributes

Parameters:
xmlReceived element
typeError type
errorThe error
textOptional text to add to the error element
Returns:
A valid XmlElement pointer or 0 if xml is 0
static XmlElement* createFailure ( XMPPNamespace::Type  ns,
XMPPError::Type  error = XMPPError::NoError 
) [inline, static]

Create a failure element

Parameters:
nsElement namespace
errorOptional error
Returns:
XmlElement pointer

References XmlElement::addChild().

static XmlElement* createIq ( IqType  type,
const char *  from = 0,
const char *  to = 0,
const char *  id = 0 
) [static]

Create an 'iq' element

Parameters:
typeIq type as enumeration
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
Returns:
A valid XmlElement pointer
static XmlElement* createIqAuthGet ( const char *  id) [inline, static]

Build a jabber:iq:auth 'iq' get element

Parameters:
idElement 'id' attribute
Returns:
A valid XmlElement pointer

References XmlElement::addChild().

static XmlElement* createIqAuthOffer ( const char *  id,
bool  digest = true,
bool  plain = false 
) [static]

Build a jabber:iq:auth 'iq' offer in response to a 'get' request

Parameters:
idElement 'id' attribute
digestOffer digest authentication
plainOffer plain password authentication
Returns:
A valid XmlElement pointer
static XmlElement* createIqAuthSet ( const char *  id,
const char *  username,
const char *  resource,
const char *  authStr,
bool  digest 
) [static]

Build a jabber:iq:auth 'iq' set element

Parameters:
idElement 'id' attribute
usernameThe username
resourceThe resource
authStrAuthentication string
digestTrue if authentication string is a digest, false if it's a plain password
Returns:
A valid XmlElement pointer
static XmlElement* createIqDisco ( bool  info,
bool  req,
const char *  from,
const char *  to,
const char *  id,
const char *  node = 0,
const char *  cap = 0 
) [static]

Create a disco info/items 'iq' element with a 'query' child

Parameters:
infoTrue to create a query info request. False to create a query items request
reqTrue to create a request (type=get), false to create a response (type=result)
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
nodeOptional 'node' attribute
capOptional capability to be set as 'node' suffix
Returns:
A valid XmlElement pointer
static XmlElement* createIqError ( const char *  from,
const char *  to,
XmlElement *&  xml,
int  type,
int  error,
const char *  text = 0 
) [static]

Create an 'iq' error from a received element. Consume the received element. Add the given element to the error stanza if the 'id' attribute is missing

Parameters:
fromThe 'from' attribute
toThe 'to' attribute
xmlReceived element
typeError type
errorThe error
textOptional text to add to the error element
Returns:
A valid XmlElement pointer or 0 if xml
static XmlElement* createIqResult ( const char *  from,
const char *  to,
const char *  id,
XmlElement child = 0 
) [inline, static]

Create an 'iq' result element

Parameters:
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
childOptional element child (will be consumed)
Returns:
A valid XmlElement pointer

References XmlElement::addChild().

static XmlElement* createIqVersionRes ( const char *  from,
const char *  to,
const char *  id,
const char *  name,
const char *  version,
const char *  os = 0 
) [static]

Create a version 'iq' result as defined in XEP-0092

Parameters:
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
nameProgram name
versionProgram version
osOptional operating system
Returns:
A valid XmlElement pointer
static XmlElement* createMessage ( const char *  type,
const char *  from,
const char *  to,
const char *  id,
const char *  body 
) [static]

Create a 'message' element

Parameters:
typeMessage type string
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
bodyThe message body
Returns:
A valid XmlElement pointer
static XmlElement* createMessage ( MsgType  type,
const char *  from,
const char *  to,
const char *  id,
const char *  body 
) [inline, static]

Create a 'message' element

Parameters:
typeMessage type as enumeration
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
bodyThe message body
Returns:
A valid XmlElement pointer

References XMPPUtils::createMessage().

Referenced by XMPPUtils::createMessage().

static XmlElement* createParameter ( const char *  name,
const char *  value,
const char *  tag = "parameter" 
) [inline, static]

Build a name/value parameter xml element

Parameters:
nameThe 'name' attribute
valueThe value parameter
tagOptional element tag (defaults to 'parameter')
Returns:
XmlElement pointer

References XmlElement::setAttributeValid().

static XmlElement* createParameter ( const NamedString pair,
const char *  tag = "parameter" 
) [inline, static]

Build a name/value parameter xml element

Parameters:
pairThe name/value pair
tagOptional element tag (defaults to 'parameter')
Returns:
XmlElement pointer

References XMPPUtils::createParameter(), and NamedString::name().

Referenced by XMPPUtils::createParameter().

static XmlElement* createPresence ( const char *  from,
const char *  to,
Presence  type = PresenceNone 
) [static]

Create an 'presence' element

Parameters:
fromThe 'from' attribute
toThe 'to' attribute
typePresence type as enumeration
Returns:
A valid XmlElement pointer
static XmlElement* createRegisterQuery ( IqType  type,
const char *  from,
const char *  to,
const char *  id,
XmlElement child1 = 0,
XmlElement child2 = 0,
XmlElement child3 = 0 
) [static]

Build a register query element

Parameters:
typeIq type as enumeration
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
child1Optional child of query element
child2Optional child of query element
child3Optional child of query element
Returns:
Valid XmlElement pointer
static XmlElement* createRegisterQuery ( const char *  from,
const char *  to,
const char *  id,
const char *  username,
const char *  password 
) [inline, static]

Build an register query element used to create/set username/password

Parameters:
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
usernameThe username
passwordThe password
Returns:
Valid XmlElement pointer
static XmlElement* createStreamError ( int  error,
const char *  text = 0 
) [static]

Create a 'stream:error' element

Parameters:
errorThe XMPP defined condition
textOptional text to add to the error
Returns:
A valid XmlElement pointer
static XmlElement* createSubject ( const char *  subject) [inline, static]

Build a 'subject' xml element

Parameters:
subjectElement text
Returns:
XmlElement pointer
static XmlElement* createVCard ( bool  get,
const char *  from,
const char *  to,
const char *  id 
) [static]

Create an 'iq' element with a 'vcard' child

Parameters:
getTrue to set the iq's type to 'get', false to set it to 'set'
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
Returns:
A valid XmlElement pointer
static XmlElement* createXOobUrl ( const char *  url,
const char *  desc = 0 
) [inline, static]

Create an 'x' jabber:x:oob url element as described in XEP-0066

Parameters:
urlThe URL
descOptional description
Returns:
XmlElement pointer

References XmlElement::addChild().

static unsigned int decodeDateTimeSec ( const String time,
unsigned int *  fractions = 0 
) [static]

Decode a date/time profile as defined in XEP-0082 and XML Schema Part 2: Datatypes Second Edition to EPOCH time

Parameters:
timeThe date/time string
fractionsPointer to integer to be filled with second fractions, if present
Returns:
The decoded time in seconds, -1 on error
static unsigned int decodeDateTimeSecXDelay ( const String time) [static]

Decode a date/time stamp as defined in XEP-0091 (jabber:x:delay)

Parameters:
timeThe date/time string
Returns:
The decoded time in seconds, -1 on error
static int decodeDbRsp ( XmlElement xml) [static]

Decode a dialback verify or result response element

Parameters:
xmlThe element
Returns:
The response as enumeration: NoError if valid, NotAuthorized if invalid or any other error if set in the response
static void decodeError ( XmlElement xml,
int  ns = XMPPNamespace::Count,
String error = 0,
String text = 0 
) [static]

Find an error child of a given element and decode it

Parameters:
xmlThe element
nsExpected error condition namespace. If not set, defaults to stream error namespace if the element is a stream error or to stanza error namespace otherwise
errorOptional string to be filled with error tag
textOptional string to be filled with error text
static void decodeError ( XmlElement xml,
String error,
String text 
) [static]

Decode a stream error or stanza error

Parameters:
xmlThe element
errorThe error condition
textThe stanza's error or error text
static int decodeFlags ( const String src,
const TokenDict dict 
) [static]

Decode a comma separated list of flags and put them into an integer mask

Parameters:
srcSource string
dictDictionary containing flag names and values
Returns:
The mask of found flags

Referenced by XMPPDirVal::replace().

static void encodeDateTimeSec ( String buf,
unsigned int  timeSec,
unsigned int  fractions = 0 
) [static]

Encode EPOCH time given in seconds to a date/time profile as defined in XEP-0082 and XML Schema Part 2: Datatypes Second Edition

Parameters:
bufDestination string
timeSecThe time to encode (in seconds)
fractionsOptional second fractions
static XmlElement* findFirstChild ( const XmlElement xml,
int  t = XmlTag::Count,
int  ns = XMPPNamespace::Count 
) [static]

Find an element's first child element in a given namespace

Parameters:
xmlElement
tOptional element tag as enumeration
nsOptional element namespace as enumeration
Returns:
XmlElement pointer or 0 if not found
static XmlElement* findNextChild ( const XmlElement xml,
XmlElement start,
int  t = XmlTag::Count,
int  ns = XMPPNamespace::Count 
) [static]

Find an element's next child element

Parameters:
xmlElement
startStarting child
tOptional element tag as enumeration
nsOptional element namespace as enumeration
Returns:
XmlElement pointer or 0 if not found
static XmlElement* getChatXml ( NamedList list,
const char *  param = "xml",
const char *  extra = "data",
bool  build = true 
) [static]

Retrieve a chat (message) xml element from a list parameter. Clear the given parameter from list if an XmlElement is found. Try to build (parse) from an extra parameter if not found. Build a message stanza from parameters if an element is not found

Parameters:
listThe list of parameters
paramThe name of the parameter with the xml element
extraOptional parameter containing xml string data
buildTrue to build a message stanza if an element is not found
Returns:
XmlElement pointer or 0
static XmlElement* getPresenceXml ( NamedList list,
const char *  param = "xml",
const char *  extra = "data",
Presence  type = PresenceNone,
bool  build = true 
) [static]

Retrieve a presence xml element from a list parameter. Clear the given parameter from list if an XmlElement is found. Try to build (parse) from an extra parameter if not found. Build a presence stanza from parameters if an element is not found

Parameters:
listThe list of parameters
paramThe name of the parameter with the xml element
extraOptional parameter containing xml string data
typePresence type to build
buildTrue to build a message stanza if an element is not found
Returns:
XmlElement pointer or 0
static bool getTag ( const XmlElement xml,
int &  tag,
int &  ns 
) [inline, static]

Get an XML element's tag and namespace

Parameters:
xmlThe element to check
tagElement tag as enumeration
nsElement namespace as enumeration
Returns:
True if data was succesfully retrieved

References XmlElement::getTag().

static XmlElement* getXml ( GenObject gen) [static]

Retrieve an xml element from a NamedPointer. Release NamedPointer ownership if found

Parameters:
genThe object to be processed
Returns:
XmlElement pointer or 0
static XmlElement* getXml ( const String data) [static]

Parse a string to an XmlElement

Parameters:
dataXML data to parse
Returns:
XmlElement pointer or 0 if the string is an invalid xml or contains more then one element
static XmlElement* getXml ( NamedList list,
const char *  param = "xml",
const char *  extra = "data" 
) [static]

Retrieve an xml element from a list parameter. Clear the given parameter from list if an XmlElement is found Try to build (parse) from an extra parameter if not found

Parameters:
listThe list of parameters
paramThe name of the parameter with the xml element
extraOptional parameter containing xml string data
Returns:
XmlElement pointer or 0
static bool hasDefaultXmlns ( const XmlElement xml,
int  ns 
) [inline, static]

Check if the given element has a given default namespace

Parameters:
xmlElement to check
nsNamespace value to check
Returns:
True if the given element has the requested default namespace

References XmlElement::s_ns, and XmlElement::xmlnsAttribute().

static bool hasXmlns ( const XmlElement xml,
int  ns 
) [inline, static]

Check if the given element has a given namespace

Parameters:
xmlElement to check
nsNamespace value to check
Returns:
True if the given element is in the requested namespace

References XmlElement::hasXmlns().

static IqType iqType ( const char *  text) [inline, static]

Get the type of an 'iq' stanza as enumeration

Parameters:
textThe text to check
Returns:
Iq type as enumeration

References TelEngine::lookup().

static bool isResponse ( const XmlElement xml) [inline, static]

Check if an xml element has type 'result' or 'error'

Parameters:
xmlThe element to check
Returns:
True if the element is a response one

References XmlElement::getAttribute().

static bool isStanza ( const XmlElement xml) [inline, static]

Check if a given element is a stanza one ('iq', 'message' or 'presence')

Parameters:
xmlThe element to check
Returns:
True if the element is a stanza
static bool isTag ( const XmlElement xml,
int  tag,
int  ns 
) [inline, static]

Check if an xml element has a given tag (without prefix) and namespace

Parameters:
xmlThe element to check
tagTag to check
nsNamespace to check
Returns:
True if the element has the requested tag and namespace
static bool isUnprefTag ( const XmlElement xml,
int  tag 
) [inline, static]

Check if an xml element has a given tag (without prefix)

Parameters:
xmlThe element to check
tagTag to check
Returns:
True if the element has the requested tag

References XmlElement::unprefixedTag().

static const char* msgText ( MsgType  msg) [inline, static]

Get the text from a message type

Parameters:
msgThe message type
Returns:
The associated text or 0

References TelEngine::lookup().

static MsgType msgType ( const char *  text) [inline, static]

Get the type of a 'message' stanza

Parameters:
textThe text to check
Returns:
Message type as enumeration

References TelEngine::lookup().

static int ns ( const XmlElement xml) [inline, static]

Get an element's namespace

Parameters:
xmlThe element
Returns:
The namespace integer value as XMPPNamespace value

References XmlElement::xmlns().

static const char* presenceText ( Presence  presence) [inline, static]

Get the text from a presence type

Parameters:
presenceThe presence type
Returns:
The associated text or 0

References TelEngine::lookup().

static Presence presenceType ( const char *  text) [inline, static]

Get the type of a 'presence' stanza as enumeration

Parameters:
textThe text to check
Returns:
Presence type as enumeration

References TelEngine::lookup().

static void print ( String xmlStr,
XmlChild xml,
bool  verbose 
) [static]

Print an XmlElement to a string

Parameters:
xmlStrThe destination string
xmlThe xml to print
verboseTrue to print XML data on multiple lines
static int priority ( XmlElement xml,
int  defVal = 0 
) [static]

Check if an element has a child with 'priority' tag

Parameters:
xmlThe element to check
defValDefault value to return if not found or invalid integer
Returns:
Element priority
static bool remove ( XmlElement xml) [inline, static]

Check if an element has a child with 'remove' tag

Parameters:
xmlThe element to check
Returns:
True if the element has a child with 'remove' tag
static bool required ( XmlElement xml) [inline, static]

Check if an element has a child with 'required' tag

Parameters:
xmlThe element to check
Returns:
True if the element has a child with 'required' tag
static bool setDbXmlns ( XmlElement xml) [inline, static]

Set the 'db' namespace to an element

Parameters:
xmlElement
Returns:
True on success
static void setPriority ( XmlElement xml,
const char *  prio 
) [inline, static]

Add a 'priority' child to an element

Parameters:
xmlThe element to set
prioPriority text

References XmlElement::addChild().

static bool setStreamXmlns ( XmlElement xml,
bool  addAttr = true 
) [inline, static]

Set the 'stream' namespace to an element

Parameters:
xmlElement
addAttrTrue to add the xmlns attribute
Returns:
True on success
static bool setXmlns ( XmlElement xml,
const String name = String::empty(),
bool  addAttr = false,
int  ns = XMPPNamespace::Count 
) [inline, static]

Set an element's namespace

Parameters:
xmlElement
nameNamespace attribute name
addAttrTrue to add the namespace attribute value
nsNamespace value as enumeration
Returns:
True on success

References XmlElement::setXmlns().

static bool split ( NamedList dest,
const char *  src,
const char  sep,
bool  nameFirst 
) [static]

Split a string at a delimiter character and fills a named list with its parts Skip empty parts

Parameters:
destThe destination NamedList
srcPointer to the string
sepThe delimiter
nameFirstTrue to add the parts as name and index as value. False to do the other way
static const String& subject ( XmlElement xml) [inline, static]

Get an element's subject (the text of the first 'subject' child)

Parameters:
xmlThe element
Returns:
Element subject or an empty string

References String::empty(), and XmlElement::getText().

static int tag ( const XmlElement xml) [inline, static]

Get an XML tag enumeration value associated with an element's tag

Parameters:
xmlThe element to check
Returns:
Xml tag as enumeration

References XmlElement::getTag().

static void toList ( XmlElement xml,
NamedList dest,
const char *  prefix 
) [static]

Put an element's name, text and attributes to a list of parameters

Parameters:
xmlThe element
destDestination list
prefixPrefix to add to parameters
static int xmlns ( XmlElement xml) [inline, static]

Get an element's namespace

Parameters:
xmlElement
Returns:
Element namespace as enumeration

References XmlElement::xmlns().


Member Data Documentation

const TokenDict s_authMeth[] [static]

Authentication methods names

const TokenDict s_commandAction[] [static]

Keep the command actions

const TokenDict s_commandStatus[] [static]

Keep the command status

XMPPError s_error [static]

Errors

const TokenDict s_iq[] [static]

Keep the types of 'iq' stanzas

const TokenDict s_msg[] [static]

Keep the types of 'message' stanzas

XMPPNamespace s_ns [static]

Namespaces

const TokenDict s_presence[] [static]

Keep the types of 'presence' stanzas

XmlTag s_tag [static]

XML tags


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