diff options
author | Will Thompson <will@willthompson.co.uk> | 2012-01-30 15:41:24 +0000 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2012-01-30 15:44:12 +0000 |
commit | 10e528fb92452b21ac67a0685ed16c24ea66cba7 (patch) | |
tree | 7ca1b750105f4580862bf962887d6ab4aa0cbb48 /wocky/wocky-pep-service.c | |
parent | 2a8023ac04fdd4a3321f08c9664e63998e8689a3 (diff) |
PepService: return <item> node from get()
Diffstat (limited to 'wocky/wocky-pep-service.c')
-rw-r--r-- | wocky/wocky-pep-service.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/wocky/wocky-pep-service.c b/wocky/wocky-pep-service.c index c9302d2..854a088 100644 --- a/wocky/wocky-pep-service.c +++ b/wocky/wocky-pep-service.c @@ -400,6 +400,8 @@ wocky_pep_service_get_async (WockyPepService *self, * wocky_pep_service_get_finish: * @self: a #WockyPepService object * @result: a #GAsyncResult + * @item: (out) (allow-none): on success, the first <item> element + * in the result, or %NULL if @self has no published items. * @error: a location to store a #GError if an error occurs * * Finishes an asynchronous operation to get the PEP node, @@ -411,17 +413,35 @@ wocky_pep_service_get_async (WockyPepService *self, WockyStanza * wocky_pep_service_get_finish (WockyPepService *self, GAsyncResult *result, + WockyNode **item, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + WockyStanza *reply; if (g_simple_async_result_propagate_error (simple, error)) return NULL; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self), wocky_pep_service_get_async), NULL); + reply = WOCKY_STANZA (g_simple_async_result_get_op_res_gpointer (simple)); + + if (item != NULL) + { + WockyNode *pubsub_node = wocky_node_get_child_ns ( + wocky_stanza_get_top_node (reply), "pubsub", WOCKY_XMPP_NS_PUBSUB); + WockyNode *items_node = NULL; + + if (pubsub_node != NULL) + items_node = wocky_node_get_child (pubsub_node, "items"); + + if (items_node != NULL) + *item = wocky_node_get_child (items_node, "item"); + else + *item = NULL; + } - return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)); + return g_object_ref (reply); } /** |