summaryrefslogtreecommitdiff
path: root/telepathy-glib
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-05-03 11:17:01 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-05-07 15:33:36 +0200
commit95118745bbc376323c18f9afe9c0363b417073f3 (patch)
tree0073d54aadd66d89058885614cd190a09bb1e353 /telepathy-glib
parent46647279c39411342628cea211d994150fcc336f (diff)
downloadtelepathy-glib-95118745bbc376323c18f9afe9c0363b417073f3.tar.gz
add tp_channel_dispatch_operation_handle_with_{async,finish}
Diffstat (limited to 'telepathy-glib')
-rw-r--r--telepathy-glib/channel-dispatch-operation.c100
-rw-r--r--telepathy-glib/channel-dispatch-operation.h11
2 files changed, 111 insertions, 0 deletions
diff --git a/telepathy-glib/channel-dispatch-operation.c b/telepathy-glib/channel-dispatch-operation.c
index 815b129d5..3f315a418 100644
--- a/telepathy-glib/channel-dispatch-operation.c
+++ b/telepathy-glib/channel-dispatch-operation.c
@@ -991,3 +991,103 @@ tp_channel_dispatch_operation_borrow_immutable_properties (
{
return self->priv->immutable_properties;
}
+
+static void
+handle_with_cb (TpChannelDispatchOperation *self,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ GSimpleAsyncResult *result = user_data;
+
+ if (error != NULL)
+ {
+ DEBUG ("HandleWith failed: %s", error->message);
+ g_simple_async_result_set_from_error (result, error);
+ }
+
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+}
+
+/**
+ * tp_channel_dispatch_operation_handle_with_async:
+ * @self: a #TpChannelDispatchOperation
+ * @handler: The well-known bus name (starting with #TP_CLIENT_BUS_NAME_BASE)
+ * of the channel handler that should handle the channel, or %NULL
+ * if the client has no preferred channel handler
+ * @callback: a callback to call when the call returns
+ * @user_data: data to pass to @callback
+ *
+ * Called by an approver to accept a channel bundle and request that the
+ * given handler be used to handle it.
+ *
+ * If successful, this method will cause the #TpProxy::invalidated signal
+ * to be emitted.
+ *
+ * However, this method may fail because the dispatch has already been
+ * completed and the object has already gone. If this occurs, it indicates
+ * that another approver has asked for the bundle to be handled by a
+ * particular handler. The approver MUST NOT attempt to interact with
+ * the channels further in this case, unless it is separately
+ * invoked as the handler.
+ *
+ * Approvers which are also channel handlers SHOULD use
+ * tp_channel_dispatch_operation_claim_async() instead
+ * of tp_channel_dispatch_operation_handle_with_async() to request
+ * that they can handle a channel bundle themselves.
+ *
+ * Since: 0.11.UNRELEASED
+ */
+void
+tp_channel_dispatch_operation_handle_with_async (
+ TpChannelDispatchOperation *self,
+ const gchar *handler,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ g_return_if_fail (TP_IS_CHANNEL_DISPATCH_OPERATION (self));
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback, user_data, tp_channel_dispatch_operation_handle_with_async);
+
+ tp_cli_channel_dispatch_operation_call_handle_with (self, -1,
+ handler != NULL ? handler: "",
+ handle_with_cb, result, NULL, G_OBJECT (self));
+}
+
+/**
+ * tp_channel_dispatch_operation_handle_with_finish:
+ * @self: a #TpChannelDispatchOperation
+ * @result: a #GAsyncResult
+ * @error: a #GError to fill
+ *
+ * Finishes an async call to HandleWith().
+ *
+ * Returns: %TRUE if the HandleWith() call was successful, otherwise %FALSE
+ *
+ * Since: 0.11.UNRELEASED
+ */
+gboolean
+tp_channel_dispatch_operation_handle_with_finish (
+ TpChannelDispatchOperation *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple;
+
+ g_return_val_if_fail (TP_IS_CHANNEL_DISPATCH_OPERATION (self), FALSE);
+ g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ G_OBJECT (self), tp_channel_dispatch_operation_handle_with_async),
+ FALSE);
+
+ simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ if (g_simple_async_result_propagate_error (simple, error))
+ return FALSE;
+
+ return TRUE;
+}
diff --git a/telepathy-glib/channel-dispatch-operation.h b/telepathy-glib/channel-dispatch-operation.h
index 82918d76a..147dde350 100644
--- a/telepathy-glib/channel-dispatch-operation.h
+++ b/telepathy-glib/channel-dispatch-operation.h
@@ -97,6 +97,17 @@ GStrv tp_channel_dispatch_operation_borrow_possible_handlers (
GHashTable * tp_channel_dispatch_operation_borrow_immutable_properties (
TpChannelDispatchOperation *self);
+void tp_channel_dispatch_operation_handle_with_async (
+ TpChannelDispatchOperation *self,
+ const gchar *handler,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean tp_channel_dispatch_operation_handle_with_finish (
+ TpChannelDispatchOperation *self,
+ GAsyncResult *result,
+ GError **error);
+
G_END_DECLS
#include <telepathy-glib/_gen/tp-cli-channel-dispatch-operation.h>