| Top |
WockyStanza * wocky_stanza_build (WockyStanzaType type,WockyStanzaSubType sub_type,const gchar *from,const gchar *to,...);
Build a XMPP stanza from a list of arguments. For example, the following invocation:
1 2 3 4 5 6 7 8 9 10 11 |
wocky_stanza_build ( WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE, "alice@<!-- -->collabora.co.uk", "bob@<!-- -->collabora.co.uk", WOCKY_NODE_START, "html", WOCKY_NODE_XMLNS, "http://www.w3.org/1999/xhtml", WOCKY_NODE, "body", WOCKY_NODE_ATTRIBUTE, "textcolor", "red", WOCKY_NODE_TEXT, "Telepathy rocks!", WOCKY_NODE_END, WOCKY_NODE_END, NULL); |
produces this stanza:
1 2 3 4 5 6 7 |
<message from='alice@<!-- -->collabora.co.uk' to='bob@<!-- -->collabora.co.uk'> <html xmlns='http://www.w3.org/1999/xhtml'> <body textcolor='red'> Telepathy rocks! </body> </html> </message> |
You may optionally use mnemonic ASCII characters in place of the build tags, to better reflect the structure of the stanza in C source. For example, the above stanza could be written as:
1 2 3 4 5 6 7 8 9 |
wocky_stanza_build ( WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE, "alice@<!-- -->collabora.co.uk", "bob@<!-- -->collabora.co.uk", '(', "html", ':', "http://www.w3.org/1999/xhtml", '(', "body", '@', "textcolor", "red", '$', "Telepathy rocks!", ')', ')' NULL); |
type |
The type of stanza to build |
|
sub_type |
The stanza's subtype; valid values depend on |
|
from |
The sender's JID, or |
|
to |
The target's JID, or |
|
... |
the description of the stanza to build,
terminated with |
WockyStanza * wocky_stanza_build_to_contact (WockyStanzaType type,WockyStanzaSubType sub_type,const gchar *from,WockyContact *to,...);
void wocky_stanza_get_type_info (WockyStanza *stanza,WockyStanzaType *type,WockyStanzaSubType *sub_type);
gboolean wocky_stanza_has_type (WockyStanza *stanza,WockyStanzaType expected_type);
WockyStanza * wocky_stanza_build_va (WockyStanzaType type,WockyStanzaSubType sub_type,const gchar *from,const gchar *to,va_list ap);
WockyStanza * wocky_stanza_build_iq_result_va (WockyStanza *iq,va_list ap);
WockyStanza * wocky_stanza_build_iq_error (WockyStanza *iq,...);
Builds an error reply to iq
containing the given body. This function also
adds the child element of iq
to the reply, as recommended by RFC3920 §9.2.3
‘IQ Semantics’.
No <error/> element is added to the reply. To add a
standard stanza error, plus message, consider using
wocky_stanza_error_to_node(). To add a more complicated error with an
application-specific condition, specify it when calling this function. For
example:
1 2 3 4 5 6 7 8 |
WockyStanza *reply = wocky_stanza_build_iq_error (iq, '(', "error", '@', "type", "cancel", '(', "feature-not-implemented", ':', WOCKY_XMPP_NS_STANZAS, ')', '(', "unsupported", ':', WOCKY_XMPP_NS_PUBSUB_ERRORS, '@', "feature", "subscribe", ')', ')', NULL); |
iq |
a stanza of type WOCKY_STANZA_TYPE_IQ and sub-type either WOCKY_STANZA_SUB_TYPE_SET or WOCKY_STANZA_SUB_TYPE_GET |
|
... |
a |
WockyStanza * wocky_stanza_build_iq_error_va (WockyStanza *iq,va_list ap);
gboolean wocky_stanza_extract_errors (WockyStanza *stanza,WockyXmppErrorType *type,GError **core,GError **specialized,WockyNode **specialized_node);
Given a message, iq or presence stanza with type='error', breaks it down
into values describing the error. type
and core
are guaranteed to be set;
specialized
and specialized_node
will be set if a recognised
application-specific error is found, and the latter will be set to NULL if
no application-specific error is found.
Any or all of the out parameters may be NULL to ignore the value. The
value stored in specialized_node
is borrowed from stanza
, and is only
valid as long as the latter is alive.
stanza |
a message/iq/presence stanza |
|
type |
location at which to store the error type |
|
core |
location at which to store an error in the domain WOCKY_XMPP_ERROR |
|
specialized |
location at which to store an error in an application-specific domain, if one is found |
|
specialized_node |
location at which to store the node representing an application-specific error, if one is found |
gboolean wocky_stanza_extract_stream_error (WockyStanza *stanza,GError **stream_error);
stanza |
a stanza |
|
stream_error |
location at which to store an error in domain WOCKY_XMPP_STREAM_ERROR, if one is found. |
void wocky_stanza_set_to_contact (WockyStanza *self,WockyContact *contact);
void wocky_stanza_set_from_contact (WockyStanza *self,WockyContact *contact);
XMPP stanza types.
XMPP stanza sub types.
|
no sub type |
||
|
"available" stanza sub type |
||
|
"normal" stanza sub type |
||
|
"chat" stanza sub type |
||
|
"groupchat" stanza sub type |
||
|
"headline" stanza sub type |
||
|
"unavailable" stanza sub type |
||
|
"probe" stanza sub type |
||
|
"subscribe" stanza sub type |
||
|
"unsubscribe" stanza sub type |
||
|
"subscribed" stanza sub type |
||
|
"unsubscribed" stanza sub type |
||
|
"get" stanza sub type |
||
|
"set" stanza sub type |
||
|
"result" stanza sub type |
||
|
"error" stanza sub type |
||
|
unknown stanza sub type |