|
|
This class is a general XMPP utilities
enum Presence { Probe, Subscribe, Subscribed, Unavailable, Unsubscribe, Unsubscribed, PresenceError, PresenceNone } | Presence |
Presence type enumeration
enum MsgType { Chat, GroupChat, HeadLine, Normal, MsgError, } | MsgType |
Message type enumeration
enum IqType { IqSet, IqGet, IqResult, IqError, IqCount } | IqType |
Iq type enumeration
enum CommandAction { CommExecute, CommCancel, CommPrev, CommNext, CommComplete, } | CommandAction |
Command action enumeration
enum CommandStatus { CommExecuting, CommCompleted, CommCancelled, } | CommandStatus |
Command status enumeration
enum AuthMethod { AuthNone = 0x00, AuthSHA1 = 0x01, AuthMD5 = 0x02, AuthPlain = 0x04, AuthDialback = 0x08, } | AuthMethod |
Authentication methods
inline bool isResponse (const XmlElement& xml)
| isResponse |
[static]
Check if an xml element has type 'result' or 'error'
Parameters:
xml | The element to check |
Returns: True if the element is a response one
inline XmlElement* createElement (const char* name, const char* text = 0,
const String& ns = String::empty())
| createElement |
[static]
Create an XML element
Parameters:
name | Element's name |
text | Optional text for the element |
ns | Optional element namespace |
Returns: A valid XmlElement pointer
inline XmlElement* createElement (int type, const char* text = 0)
| createElement |
[static]
Create an XML element
Parameters:
type | Element's type |
text | Optional text for the element |
Returns: A valid XmlElement pointer
inline XmlElement* createElement (const char* name, int ns,
const char* text = 0)
| createElement |
[static]
Create an XML element with an 'xmlns' attribute
Parameters:
name | Element's name |
ns | Optional 'xmlns' attribute as enumeration |
text | Optional text for the element |
Returns: A valid XmlElement pointer
inline XmlElement* createElement (int type, int ns, const char* text = 0)
| createElement |
[static]
Create an XML element with an 'xmlns' attribute
Parameters:
type | Element's type |
ns | 'xmlns' attribute as enumeration |
text | Optional text for the element |
Returns: A valid XmlElement pointer
XmlElement* createElement (const XmlElement& src, bool response, bool result)
| createElement |
[static]
Partially build an XML element from another one. Copy tag and 'to', 'from', 'type', 'id' attributes
Parameters:
src | Source element |
response | True to reverse 'to' and 'from' attributes |
result | True to set type to "result", false to set it to "error". Ignored if response is false |
XmlElement* createIq (IqType type, const char* from = 0,
const char* to = 0, const char* id = 0)
| createIq |
[static]
Create an 'iq' element
Parameters:
type | Iq type as enumeration |
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
Returns: A valid XmlElement pointer
inline XmlElement* createIqResult (const char* from, const char* to,
const char* id, XmlElement* child = 0)
| createIqResult |
[static]
Create an 'iq' result element
Parameters:
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
child | Optional element child (will be consumed) |
Returns: A valid XmlElement pointer
XmlElement* createIqError (const char* from, const char* to, XmlElement*& xml,
int type, int error, const char* text = 0)
| createIqError |
[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:
from | The 'from' attribute |
to | The 'to' attribute |
xml | Received element |
type | Error type |
error | The error |
text | Optional text to add to the error element |
Returns: A valid XmlElement pointer or 0 if xml
XmlElement* createVCard (bool get, const char* from, const char* to, const char* id)
| createVCard |
[static]
Create an 'iq' element with a 'vcard' child
Parameters:
get | True to set the iq's type to 'get', false to set it to 'set' |
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
Returns: A valid XmlElement pointer
XmlElement* createCommand (CommandAction action, const char* node,
const char* sessionId = 0)
| createCommand |
[static]
Create a 'command' element
Parameters:
action | The command action |
node | The command |
sessionId | Optional session ID for the command |
Returns: A valid XmlElement pointer
XmlElement* createIqDisco (bool info, bool req, const char* from, const char* to,
const char* id, const char* node = 0, const char* cap = 0)
| createIqDisco |
[static]
Create a disco info/items 'iq' element with a 'query' child
Parameters:
info | True to create a query info request. False to create a query items request |
req | True to create a request (type=get), false to create a response (type=result) |
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
node | Optional 'node' attribute |
cap | Optional capability to be set as 'node' suffix |
Returns: A valid XmlElement pointer
XmlElement* createIqVersionRes (const char* from, const char* to,
const char* id, const char* name, const char* version, const char* os = 0)
| createIqVersionRes |
[static]
Create a version 'iq' result as defined in XEP-0092
Parameters:
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
name | Program name |
version | Program version |
os | Optional operating system |
Returns: A valid XmlElement pointer
XmlElement* createError (int type, int error, const char* text = 0)
| createError |
[static]
Create a 'error' element
Parameters:
type | Error type |
error | The error |
text | Optional text to add to the error element |
Returns: A valid XmlElement pointer
XmlElement* createError (XmlElement* xml, int type, int error,
const char* text = 0)
| createError |
[static]
Create an error from a received element. Consume the received element. Reverse 'to' and 'from' attributes
Parameters:
xml | Received element |
type | Error type |
error | The error |
text | Optional text to add to the error element |
Returns: A valid XmlElement pointer or 0 if xml is 0
XmlElement* createStreamError (int error, const char* text = 0)
| createStreamError |
[static]
Create a 'stream:error' element
Parameters:
error | The XMPP defined condition |
text | Optional text to add to the error |
Returns: A valid XmlElement pointer
XmlElement* createRegisterQuery (IqType type, const char* from,
const char* to, const char* id,
XmlElement* child1 = 0, XmlElement* child2 = 0, XmlElement* child3 = 0)
| createRegisterQuery |
[static]
Build a register query element
Parameters:
type | Iq type as enumeration |
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
child1 | Optional child of query element |
child2 | Optional child of query element |
child3 | Optional child of query element |
Returns: Valid XmlElement pointer
inline XmlElement* createIqAuthGet (const char* id)
| createIqAuthGet |
[static]
Build a jabber:iq:auth 'iq' get element
Parameters:
id | Element 'id' attribute |
Returns: A valid XmlElement pointer
XmlElement* createIqAuthSet (const char* id, const char* username,
const char* resource, const char* authStr, bool digest)
| createIqAuthSet |
[static]
Build a jabber:iq:auth 'iq' set element
Parameters:
id | Element 'id' attribute |
username | The username |
resource | The resource |
authStr | Authentication string |
digest | True if authentication string is a digest, false if it's a plain password |
Returns: A valid XmlElement pointer
XmlElement* createIqAuthOffer (const char* id, bool digest = true,
bool plain = false)
| createIqAuthOffer |
[static]
Build a jabber:iq:auth 'iq' offer in response to a 'get' request
Parameters:
id | Element 'id' attribute |
digest | Offer digest authentication |
plain | Offer plain password authentication |
Returns: A valid XmlElement pointer
inline XmlElement* createRegisterQuery (const char* from,
const char* to, const char* id,
const char* username, const char* password)
| createRegisterQuery |
[static]
Build an register query element used to create/set username/password
Parameters:
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
username | The username |
password | The password |
Returns: Valid XmlElement pointer
inline XmlElement* createFailure (XMPPNamespace::Type ns,
XMPPError::Type error = XMPPError::NoError)
| createFailure |
[static]
Create a failure element
Parameters:
ns | Element namespace |
error | Optional error |
Returns: XmlElement pointer
inline XmlElement* createXOobUrl (const char* url, const char* desc = 0)
| createXOobUrl |
[static]
Create an 'x' jabber:x:oob url element as described in XEP-0066
Parameters:
url | The URL |
desc | Optional description |
Returns: XmlElement pointer
XmlElement* createDelay (unsigned int timeSec, const char* from = 0,
unsigned int fractions = 0, const char* text = 0)
| createDelay |
[static]
Create a 'delay' element as defined in XEP-0203
Parameters:
timeSec | The time to encode (in seconds) |
from | Optional 'from' attribute |
fractions | Optional second fractions |
text | Optional xml element text |
Returns: XmlElement pointer
inline bool remove (XmlElement& xml)
| remove |
[static]
Check if an element has a child with 'remove' tag
Parameters:
xml | The element to check |
Returns: True if the element has a child with 'remove' tag
inline bool required (XmlElement& xml)
| required |
[static]
Check if an element has a child with 'required' tag
Parameters:
xml | The element to check |
Returns: True if the element has a child with 'required' tag
int priority (XmlElement& xml, int defVal = 0)
| priority |
[static]
Check if an element has a child with 'priority' tag
Parameters:
xml | The element to check |
defVal | Default value to return if not found or invalid integer |
Returns: Element priority
inline void setPriority (XmlElement& xml, const char* prio)
| setPriority |
[static]
Add a 'priority' child to an element
Parameters:
xml | The element to set |
prio | Priority text |
inline int xmlns (XmlElement& xml)
| xmlns |
[static]
Get an element's namespace
Parameters:
xml | Element |
Returns: Element namespace as enumeration
inline bool hasDefaultXmlns (const XmlElement& xml, int ns)
| hasDefaultXmlns |
[static]
Check if the given element has a given default namespace
Parameters:
xml | Element to check |
ns | Namespace value to check |
Returns: True if the given element has the requested default namespace
inline bool hasXmlns (const XmlElement& xml, int ns)
| hasXmlns |
[static]
Check if the given element has a given namespace
Parameters:
xml | Element to check |
ns | Namespace value to check |
Returns: True if the given element is in the requested namespace
inline bool setXmlns (XmlElement& xml, const String& name = String::empty(),
bool addAttr = false, int ns = XMPPNamespace::Count)
| setXmlns |
[static]
Set an element's namespace
Parameters:
xml | Element |
name | Namespace attribute name |
addAttr | True to add the namespace attribute value |
ns | Namespace value as enumeration |
Returns: True on success
inline bool setStreamXmlns (XmlElement& xml, bool addAttr = true)
| setStreamXmlns |
[static]
Set the 'stream' namespace to an element
Parameters:
xml | Element |
addAttr | True to add the xmlns attribute |
Returns: True on success
inline bool setDbXmlns (XmlElement& xml)
| setDbXmlns |
[static]
Set the 'db' namespace to an element
Parameters:
xml | Element |
Returns: True on success
XmlElement* findFirstChild (const XmlElement& xml, int t = XmlTag::Count,
int ns = XMPPNamespace::Count)
| findFirstChild |
[static]
Find an element's first child element in a given namespace
Parameters:
xml | Element |
t | Optional element tag as enumeration |
ns | Optional element namespace as enumeration |
Returns: XmlElement pointer or 0 if not found
XmlElement* findNextChild (const XmlElement& xml, XmlElement* start,
int t = XmlTag::Count, int ns = XMPPNamespace::Count)
| findNextChild |
[static]
Find an element's next child element
Parameters:
xml | Element |
start | Starting child |
t | Optional element tag as enumeration |
ns | Optional element namespace as enumeration |
Returns: XmlElement pointer or 0 if not found
void decodeError (XmlElement* xml, int ns = XMPPNamespace::Count,
String* error = 0, String* text = 0)
| decodeError |
[static]
Find an error child of a given element and decode it
Parameters:
xml | The element |
ns | Expected error condition namespace. If not set, defaults to stream error namespace if the element is a stream error or to stanza error namespace otherwise |
error | Optional string to be filled with error tag |
text | Optional string to be filled with error text |
void decodeError (XmlElement* xml, String& error, String& text)
| decodeError |
[static]
Decode a stream error or stanza error
Parameters:
xml | The element |
error | The error condition |
text | The stanza's error or error text |
void encodeDateTimeSec (String& buf, unsigned int timeSec,
unsigned int fractions = 0)
| encodeDateTimeSec |
[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:
buf | Destination string |
timeSec | The time to encode (in seconds) |
fractions | Optional second fractions |
unsigned int decodeDateTimeSec (const String& time, unsigned int* fractions = 0)
| decodeDateTimeSec |
[static]
Decode a date/time profile as defined in XEP-0082 and XML Schema Part 2: Datatypes Second Edition to EPOCH time
Parameters:
time | The date/time string |
fractions | Pointer to integer to be filled with second fractions, if present |
Returns: The decoded time in seconds, -1 on error
unsigned int decodeDateTimeSecXDelay (const String& time)
| decodeDateTimeSecXDelay |
[static]
Decode a date/time stamp as defined in XEP-0091 (jabber:x:delay)
Parameters:
time | The date/time string |
Returns: The decoded time in seconds, -1 on error
void print (String& xmlStr, XmlChild& xml, bool verbose)
|
[static]
Print an XmlElement to a string
Parameters:
xmlStr | The destination string |
xml | The xml to print |
verbose | True to print XML data on multiple lines |
void toList (XmlElement& xml, NamedList& dest, const char* prefix)
| toList |
[static]
Put an element's name, text and attributes to a list of parameters
Parameters:
xml | The element |
dest | Destination list |
prefix | Prefix to add to parameters |
bool split (NamedList& dest, const char* src, const char sep,
bool nameFirst)
| split |
[static]
Split a string at a delimiter character and fills a named list with its parts Skip empty parts
Parameters:
dest | The destination NamedList |
src | Pointer to the string |
sep | The delimiter |
nameFirst | True to add the parts as name and index as value. False to do the other way |
int decodeFlags (const String& src, const TokenDict* dict)
| decodeFlags |
[static]
Decode a comma separated list of flags and put them into an integer mask
Parameters:
src | Source string |
dict | Dictionary containing flag names and values |
Returns: The mask of found flags
void buildFlags (String& dest, int src, const TokenDict* dict)
| buildFlags |
[static]
Encode a mask of flags to a comma separated list of names
Parameters:
dest | Destination string |
src | Source mask |
dict | Dictionary containing flag names and values |
bool addChidren (XmlElement* dest, ObjList& list)
| addChidren |
[static]
Add child elements from a list to a destination element
Parameters:
dest | Destination XmlElement |
list | A list containing XML elements |
Returns: True if at least one child was added
XmlElement* createEntityCaps (const String& hash, const char* node)
| createEntityCaps |
[static]
Create a 'c' entity capability element as defined in XEP 0115
Parameters:
hash | The 'ver' attribute |
node | The 'node' attribute |
Returns: XmlElement pointer or 0 on failure
XmlElement* createEntityCapsGTalkV1 ()
| createEntityCapsGTalkV1 |
[static]
Create a 'c' entity capability element as defined by GTalk
Returns: A valid XmlElement pointer
XmlElement* createPresence (const char* from,
const char* to, Presence type = PresenceNone)
| createPresence |
[static]
Create an 'presence' element
Parameters:
from | The 'from' attribute |
to | The 'to' attribute |
type | Presence type as enumeration |
Returns: A valid XmlElement pointer
XmlElement* createMessage (const char* type, const char* from,
const char* to, const char* id, const char* body)
| createMessage |
[static]
Create a 'message' element
Parameters:
type | Message type string |
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
body | The message body |
Returns: A valid XmlElement pointer
inline XmlElement* createMessage (MsgType type, const char* from,
const char* to, const char* id, const char* body)
| createMessage |
[static]
Create a 'message' element
Parameters:
type | Message type as enumeration |
from | The 'from' attribute |
to | The 'to' attribute |
id | The 'id' attribute |
body | The message body |
Returns: A valid XmlElement pointer
XmlElement* createDialbackKey (const char* from, const char* to,
const char* key)
| createDialbackKey |
[static]
Build a dialback 'db:result' xml element used to send a dialback key
Parameters:
from | The sender |
to | The recipient |
key | The dialback key |
Returns: XmlElement pointer
XmlElement* createDialbackResult (const char* from, const char* to,
XMPPError::Type rsp = XMPPError::NoError)
| createDialbackResult |
[static]
Build a dialback 'db:result' xml element used to send a dialback key response
Parameters:
from | The sender |
to | The recipient |
rsp | The 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
XmlElement* createDialbackVerify (const char* from, const char* to,
const char* id, const char* key)
| createDialbackVerify |
[static]
Build a dialback 'db:verify' xml element
Parameters:
from | The sender |
to | The recipient |
id | The 'id' attribute (stream id) |
key | The dialback key |
Returns: XmlElement pointer
XmlElement* createDialbackVerifyRsp (const char* from, const char* to,
const char* id, XMPPError::Type rsp = XMPPError::NoError)
| createDialbackVerifyRsp |
[static]
Build a dialback 'db:verify' response xml element
Parameters:
from | The sender |
to | The recipient |
id | The 'id' attribute (stream id) |
rsp | The 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
int decodeDbRsp (XmlElement* xml)
| decodeDbRsp |
[static]
Decode a dialback verify or result response element
Parameters:
xml | The element |
Returns: The response as enumeration: NoError if valid, NotAuthorized if invalid or any other error if set in the response
inline XmlElement* createSubject (const char* subject)
| createSubject |
[static]
Build a 'subject' xml element
Parameters:
subject | Element text |
Returns: XmlElement pointer
inline const String& subject (XmlElement& xml)
| subject |
[static]
Get an element's subject (the text of the first 'subject' child)
Parameters:
xml | The element |
Returns: Element subject or an empty string
inline XmlElement* createBody (const char* body, int ns = XMPPNamespace::Count)
| createBody |
[static]
Build a 'body' xml element
Parameters:
body | Element text |
ns | Optional namespace |
Returns: XmlElement pointer
const String& body (XmlElement& xml, int ns = XMPPNamespace::Count)
| body |
[static]
Retrieve the text of an element's body child
Parameters:
xml | The element |
ns | Optional body namespace to match (default: match parent's namespace) |
Returns: Body or empty string
inline XmlElement* createParameter (const char* name, const char* value,
const char* tag = "parameter")
| createParameter |
[static]
Build a name/value parameter xml element
Parameters:
name | The 'name' attribute |
value | The value parameter |
tag | Optional element tag (defaults to 'parameter') |
Returns: XmlElement pointer
inline XmlElement* createParameter (const NamedString& pair,
const char* tag = "parameter")
| createParameter |
[static]
Build a name/value parameter xml element
Parameters:
pair | The name/value pair |
tag | Optional element tag (defaults to 'parameter') |
Returns: XmlElement pointer
inline int ns (const XmlElement& xml)
| ns |
[static]
Get an element's namespace
Parameters:
xml | The element |
Returns: The namespace integer value as XMPPNamespace value
inline int tag (const XmlElement& xml)
| tag |
[static]
Get an XML tag enumeration value associated with an element's tag
Parameters:
xml | The element to check |
Returns: Xml tag as enumeration
inline bool getTag (const XmlElement& xml, int& tag, int& ns)
| getTag |
[static]
Get an XML element's tag and namespace
Parameters:
xml | The element to check |
tag | Element tag as enumeration |
ns | Element namespace as enumeration |
Returns: True if data was succesfully retrieved
inline bool isTag (const XmlElement& xml, int tag, int ns)
| isTag |
[static]
Check if an xml element has a given tag (without prefix) and namespace
Parameters:
xml | The element to check |
tag | Tag to check |
ns | Namespace to check |
Returns: True if the element has the requested tag and namespace
inline bool isUnprefTag (const XmlElement& xml, int tag)
| isUnprefTag |
[static]
Check if an xml element has a given tag (without prefix)
Parameters:
xml | The element to check |
tag | Tag to check |
Returns: True if the element has the requested tag
inline bool isStanza (const XmlElement& xml)
| isStanza |
[static]
Check if a given element is a stanza one ('iq', 'message' or 'presence')
Parameters:
xml | The element to check |
Returns: True if the element is a stanza
XmlElement* getXml (GenObject* gen)
| getXml |
[static]
Retrieve an xml element from a NamedPointer. Release NamedPointer ownership if found
Parameters:
gen | The object to be processed |
Returns: XmlElement pointer or 0
XmlElement* getXml (const String& data)
| getXml |
[static]
Parse a string to an XmlElement
Parameters:
data | XML data to parse |
Returns: XmlElement pointer or 0 if the string is an invalid xml or contains more then one element
XmlElement* getXml (NamedList& list, const char* param = "xml",
const char* extra = "data")
| getXml |
[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:
list | The list of parameters |
param | The name of the parameter with the xml element |
extra | Optional parameter containing xml string data |
Returns: XmlElement pointer or 0
XmlElement* getPresenceXml (NamedList& list, const char* param = "xml",
const char* extra = "data", Presence type = PresenceNone, bool build = true)
| getPresenceXml |
[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:
list | The list of parameters |
param | The name of the parameter with the xml element |
extra | Optional parameter containing xml string data |
type | Presence type to build |
build | True to build a message stanza if an element is not found |
Returns: XmlElement pointer or 0
XmlElement* getChatXml (NamedList& list, const char* param = "xml",
const char* extra = "data", bool build = true)
| getChatXml |
[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:
list | The list of parameters |
param | The name of the parameter with the xml element |
extra | Optional parameter containing xml string data |
build | True to build a message stanza if an element is not found |
Returns: XmlElement pointer or 0
int cmpBytes (const String& s1, const String& s2)
| cmpBytes |
[static]
Byte compare 2 strings.
Parameters:
s1 | The first string |
s2 | The second string |
Returns: Return -1 if s1 < s2, 1 if s1 > s2 or 0 if the 2 strings are equal
inline Presence presenceType (const char* text)
| presenceType |
[static]
Get the type of a 'presence' stanza as enumeration
Parameters:
text | The text to check |
Returns: Presence type as enumeration
inline const char* presenceText (Presence presence)
| presenceText |
[static]
Get the text from a presence type
Parameters:
presence | The presence type |
Returns: The associated text or 0
inline MsgType msgType (const char* text)
| msgType |
[static]
Get the type of a 'message' stanza
Parameters:
text | The text to check |
Returns: Message type as enumeration
inline const char* msgText (MsgType msg)
| msgText |
[static]
Get the text from a message type
Parameters:
msg | The message type |
Returns: The associated text or 0
inline IqType iqType (const char* text)
| iqType |
[static]
Get the type of an 'iq' stanza as enumeration
Parameters:
text | The text to check |
Returns: Iq type as enumeration
inline int authMeth (const char* text, int defVal = AuthNone)
| authMeth |
[static]
Get the authentication method associated with a given text
Parameters:
text | The text to check |
defVal | Default value to return if not found |
Returns: Authentication method
static XMPPNamespace s_ns | s_ns |
static XMPPError s_error | s_error |
static XmlTag s_tag | s_tag |
static const TokenDict s_presence[] | s_presence[] |
static const TokenDict s_msg[] | s_msg[] |
static const TokenDict s_iq[] | s_iq[] |
static const TokenDict s_commandAction[] | s_commandAction[] |
static const TokenDict s_commandStatus[] | s_commandStatus[] |
static const TokenDict s_authMeth[] | s_authMeth[] |
Generated by: paulc on bussard on Tue Mar 8 18:42:27 2011, using kdoc 2.0a54. |