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  IqType {
  IqSet, IqGet, IqResult, IqError,
  IqCount
}
enum  CommandAction {
  CommExecute, CommCancel, CommPrev, CommNext,
  CommComplete
}
enum  CommandStatus { CommExecuting, CommCompleted, CommCancelled }

Static Public Member Functions

static XMLElementcreateElement (const char *name, XMPPNamespace::Type ns, const char *text=0)
static XMLElementcreateElement (XMLElement::Type type, XMPPNamespace::Type ns, const char *text=0)
static XMLElementcreateIq (IqType type, const char *from, const char *to, const char *id)
static XMLElementcreateIqBind (const char *from, const char *to, const char *id, const ObjList &resources)
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 XMLElementcreateIdentity (const char *category, const char *type, const char *name)
static XMLElementcreateIqDisco (const char *from, const char *to, const char *id, bool info=true)
static XMLElementcreateDiscoInfoRes (const char *from, const char *to, const char *id, JIDFeatureList *features, JIDIdentity *identity)
static XMLElementcreateError (XMPPError::ErrorType type, XMPPError::Type error, const char *text=0)
static XMLElementcreateError (XMLElement *xml, XMPPError::ErrorType type, XMPPError::Type error, const char *text=0)
static XMLElementcreateStreamError (XMPPError::Type 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 XMLElementcreateRegisterQuery (const char *from, const char *to, const char *id, const char *username, const char *password)
static bool hasXmlns (XMLElement &element, XMPPNamespace::Type ns)
static void decodeError (XMLElement *element, 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 void print (String &xmlStr, XMLElement &element, const char *indent=0)
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 IqType iqType (const char *text)

Static Public Attributes

static TokenDict s_iq []
static TokenDict s_commandAction []
static TokenDict s_commandStatus []

Detailed Description

General XMPP utilities.

This class is a general XMPP utilities


Member Enumeration Documentation

Command action enumeration

Command status enumeration

enum IqType

Iq 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 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 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* createDiscoInfoRes ( const char *  from,
const char *  to,
const char *  id,
JIDFeatureList features,
JIDIdentity identity 
) [static]

Create an 'iq' of type 'result' element with a 'query' child in response to a disco info request

Parameters:
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
featuresFeatures to be added to response
identityThe identity of the entity sending the response
Returns:
A valid XMLElement pointer

Referenced by XMPPUserRoster::createDiscoInfoResult().

static XMLElement* createElement ( XMLElement::Type  type,
XMPPNamespace::Type  ns,
const char *  text = 0 
) [static]

Create an XML element with an 'xmlns' attribute

Parameters:
typeElement's type
ns'xmlns' attribute
textOptional text for the element
Returns:
A valid XMLElement pointer
static XMLElement* createElement ( const char *  name,
XMPPNamespace::Type  ns,
const char *  text = 0 
) [static]

Create an XML element with an 'xmlns' attribute

Parameters:
nameElement's name
ns'xmlns' attribute
textOptional text for the element
Returns:
A valid XMLElement pointer
static XMLElement* createError ( XMPPError::ErrorType  type,
XMPPError::Type  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,
XMPPError::ErrorType  type,
XMPPError::Type  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* createIdentity ( const char *  category,
const char *  type,
const char *  name 
) [static]

Create an 'identity' element

Parameters:
categoryThe 'category' attribute
typeThe 'type' attribute
nameThe 'name' attribute
Returns:
A valid XMLElement pointer
static XMLElement* createIq ( IqType  type,
const char *  from,
const char *  to,
const char *  id 
) [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* createIqBind ( const char *  from,
const char *  to,
const char *  id,
const ObjList resources 
) [static]

Create an 'iq' element with a 'bind' child containing the resources

Parameters:
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
resourcesThe resources to bind (strings)
Returns:
A valid XMLElement pointer
static XMLElement* createIqDisco ( const char *  from,
const char *  to,
const char *  id,
bool  info = true 
) [static]

Create an 'iq' of type 'get' element with a 'query' child

Parameters:
fromThe 'from' attribute
toThe 'to' attribute
idThe 'id' attribute
infoTrue to create a query info request. False to create a query items request
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 ( XMPPError::Type  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* 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 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 void decodeError ( XMLElement element,
String error,
String text 
) [static]

Decode a received stream error or stanza error

Parameters:
elementThe received 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
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 bool hasXmlns ( XMLElement element,
XMPPNamespace::Type  ns 
) [static]

Check if the given element has an attribute 'xmlns' equal to a given value

Parameters:
elementElement to check
nsNamespace value to check
Returns:
True if the given element has the requested namespace
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 void print ( String xmlStr,
XMLElement element,
const char *  indent = 0 
) [static]

Print an XMLElement to a string

Parameters:
xmlStrThe destination string
elementThe element to print
indentThe indent. 0 if it is the root element
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

Member Data Documentation

Keep the command actions

Keep the command status

TokenDict s_iq[] [static]

Keep the types of 'iq' stanzas


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