Top | ![]() |
![]() |
![]() |
![]() |
Low level representation of a XMPP node. Provides ways to set various parameters on the node, such as content, language, namespaces and prefixes. It also offers methods to lookup children of a node.
gboolean (*wocky_node_each_attr_func) (const gchar *key
,const gchar *value
,const gchar *pref
,const gchar *ns
,gpointer user_data
);
Specifies the type of functions passed to wocky_node_each_attribute()
.
key |
the attribute's key |
|
value |
the attribute's value |
|
pref |
the attribute's prefix |
|
ns |
the attribute's namespace |
|
user_data |
user data passed to |
gboolean (*wocky_node_each_child_func) (WockyNode *node
,gpointer user_data
);
Specifies the type of functions passed to wocky_node_each_child()
.
void wocky_node_each_attribute (WockyNode *node
,wocky_node_each_attr_func func
,gpointer user_data
);
Calls a function for each attribute of a WockyNode.
void wocky_node_each_child (WockyNode *node
,wocky_node_each_child_func func
,gpointer user_data
);
Calls a function for each child of a WockyNode.
const gchar * wocky_node_get_attribute (WockyNode *node
,const gchar *key
);
Returns the value of an attribute in a WockyNode.
const gchar * wocky_node_get_attribute_ns (WockyNode *node
,const gchar *key
,const gchar *ns
);
Returns the value of an attribute in a WockyNode, limiting the search
within a specific namespace. If the namespace is NULL
, this is equivalent
to wocky_node_get_attribute()
.
void wocky_node_set_attribute (WockyNode *node
,const gchar *key
,const gchar *value
);
Sets an attribute in a WockyNode to a specific value.
void wocky_node_set_attributes (WockyNode *node
,const gchar *key
,...
);
Sets attributes in a WockyNode to specific values.
void wocky_node_set_attribute_ns (WockyNode *node
,const gchar *key
,const gchar *value
,const gchar *ns
);
Sets an attribute in a WockyNode, within a specific namespace.
If the namespace is NULL
, this is equivalent to
wocky_node_set_attribute()
.
void wocky_node_set_attribute_n (WockyNode *node
,const gchar *key
,const gchar *value
,gsize value_size
);
Sets a new attribute to a WockyNode, with the supplied values.
void wocky_node_set_attribute_n_ns (WockyNode *node
,const gchar *key
,const gchar *value
,gsize value_size
,const gchar *ns
);
Sets a new attribute to a WockyNode, with the supplied values.
If the namespace is NULL
, this is equivalent to
wocky_node_set_attribute_n()
.
const gchar *
wocky_node_attribute_ns_get_prefix_from_urn
(const gchar *urn
);
Gets the prefix of the namespace identified by the URN.
const gchar *
wocky_node_attribute_ns_get_prefix_from_quark
(GQuark ns
);
Gets the prefix of the namespace identified by the quark.
void wocky_node_attribute_ns_set_prefix (GQuark ns
,const gchar *prefix
);
Sets a desired prefix for a namespace.
WockyNode * wocky_node_get_child (WockyNode *node
,const gchar *name
);
Gets a child of a node, searching by name.
WockyNode * wocky_node_get_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
);
Gets the child of a node, searching by name and limiting the search
to the specified namespace.
If the namespace is NULL
, this is equivalent to wocky_node_get_child()
WockyNode *
wocky_node_get_first_child (WockyNode *node
);
Convenience function to return the first child of a WockyNode.
WockyNode * wocky_node_get_first_child_ns (WockyNode *node
,const gchar *ns
);
Returns the first child of node
whose namespace is ns
, saving you the
bother of faffing around with a WockyNodeIter.
const gchar * wocky_node_get_content_from_child (WockyNode *node
,const gchar *name
);
Retrieves the content from a child of a node, if it exists.
const gchar * wocky_node_get_content_from_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
);
Retrieves the content from a child of a node, if it exists.
WockyNode * wocky_node_add_child (WockyNode *node
,const gchar *name
);
Adds a WockyNode with the specified name to an already existing node.
WockyNode * wocky_node_add_child_ns (WockyNode *node
,const gchar *name
,const gchar *ns
);
Adds a WockyNode with the specified name to an already existing node,
under the specified namespace. If the namespace is NULL
, this is equivalent
to wocky_node_add_child()
.
WockyNode * wocky_node_add_child_ns_q (WockyNode *node
,const gchar *name
,GQuark ns
);
Adds a WockyNode with the specified name to an already existing node,
under the specified namespace. If the namespace is 0, this is equivalent
to wocky_node_add_child()
.
WockyNode * wocky_node_add_child_with_content (WockyNode *node
,const gchar *name
,const char *content
);
Adds a WockyNode with the specified name and containing the specified content to an already existing node.
WockyNode * wocky_node_add_child_with_content_ns (WockyNode *node
,const gchar *name
,const gchar *content
,const gchar *ns
);
Adds a WockyNode with the specified name and the specified content
to an already existing node, under the specified namespace.
If the namespace is NULL
, this is equivalent to
wocky_node_add_child_with_content()
.
WockyNode * wocky_node_add_child_with_content_ns_q (WockyNode *node
,const gchar *name
,const gchar *content
,GQuark ns
);
Adds a WockyNode with the specified name and the specified content
to an already existing node, under the specified namespace.
If the namespace is 0, this is equivalent to
wocky_node_add_child_with_content()
.
const gchar *
wocky_node_get_ns (WockyNode *node
);
Gets the namespace of a WockyNode
gboolean wocky_node_matches_q (WockyNode *node
,const gchar *name
,GQuark ns
);
Checks whether a node has a particular name and namespace.
gboolean wocky_node_matches (WockyNode *node
,const gchar *name
,const gchar *ns
);
Checks whether a node has a particular name and namespace.
const gchar *
wocky_node_get_language (WockyNode *node
);
Gets the language of a WockyNode
void wocky_node_set_language (WockyNode *node
,const gchar *lang
);
Sets the language of a WockyNode.
void wocky_node_set_language_n (WockyNode *node
,const gchar *lang
,gsize lang_size
);
Sets the language of a WockyNode.
void wocky_node_set_content (WockyNode *node
,const gchar *content
);
Sets the content of a WockyNode.
void wocky_node_append_content (WockyNode *node
,const gchar *content
);
Appends some content to the content of a WockyNode.
void wocky_node_append_content_n (WockyNode *node
,const gchar *content
,gsize size
);
Appends a specified number of content bytes to the content of a WockyNode.
gchar *
wocky_node_to_string (WockyNode *node
);
Obtains a string representation of a WockyNode.
WockyNode * wocky_node_new (const char *name
,const gchar *ns
);
Convenience function which creates a WockyNode and sets its
name to name
.
void
wocky_node_free (WockyNode *node
);
Convenience function that frees the passed in WockyNode and all of its children.
gboolean wocky_node_equal (WockyNode *node0
,WockyNode *node1
);
Compares two WockyNodes for equality.
void wocky_node_iter_init (WockyNodeIter *iter
,WockyNode *node
,const gchar *name
,const gchar *ns
);
Initializes an iterator that can be used to iterate over the children of
node
, filtered by name
and ns
WockyNodeIter iter; WockyNode *child; wocky_node_iter_init (&iter, wocky_stanza_get_top_node (stanza), "payload-type", WOCKY_XMPP_NS_JINGLE_RTP); while (wocky_node_iter_next (iter, &child)) { /<!-- -->* do something with the child *<!-- -->/ }
gboolean wocky_node_iter_next (WockyNodeIter *iter
,WockyNode **next
);
Advances iter to the next child that matches its filter. if FALSE
is
returned next is not set and the iterator becomes invalid
void
wocky_node_iter_remove (WockyNodeIter *iter
);
Removes and frees the node returned by the last call to
wocky_node_iter_next()
from its parent. Can only be called after
wocky_node_iter_next()
returned TRUE
, and cannot be called more than once
per successful call to wocky_node_iter_next()
.
void wocky_node_add_build (WockyNode *node
,...
);
Add a node subtree to an existing parent node.
The above examples adds the following subtree under the given node:
<body> Telepathy rocks! </body>
node |
The node under which to add a new subtree |
|
... |
the description of the stanza to build,
terminated with |
WockyNode * wocky_node_add_node_tree (WockyNode *node
,WockyNodeTree *tree
);
Copies the nodes from tree
, and appends them to node
's children.
WockyNode * wocky_node_prepend_node_tree (WockyNode *node
,WockyNodeTree *tree
);
Copies the nodes from tree
, and inserts them as the first child of node
,
before any existing children.
void
wocky_node_init (void
);
Initializes the caches used by WockyNode. This should be always called before using WockyNode structs.
void
wocky_node_deinit (void
);
Releases all the resources used by the WockyNode caches.
Tags for building a stanza using wocky_stanza_build()
or
wocky_node_add_build()
.
Start of a node |
||
Text content of a node |
||
End of a node |
||
A node attribute |
||
A node XML namespace |
||
a WockyNode to assign |
||
|
struct WockyNode { gchar *name; gchar *content; };
A single WockyNode structure that relates to an element in an XMPP stanza.
typedef struct { } WockyNodeIter;
Iterate over a node's children. See wocky_node_iter_init()
for more
details.