From 42f147f5771a4e9d83a46769a037e352e4b21e55 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Thu, 16 Jun 2011 16:58:25 +0100 Subject: CallChannel: add Hold high-level API --- telepathy-yell/call-channel.c | 74 +++++++++++++++++++++++++++++++++++++++++++ telepathy-yell/call-channel.h | 10 ++++++ 2 files changed, 84 insertions(+) diff --git a/telepathy-yell/call-channel.c b/telepathy-yell/call-channel.c index 96dbb14..3963509 100644 --- a/telepathy-yell/call-channel.c +++ b/telepathy-yell/call-channel.c @@ -1001,3 +1001,77 @@ tpy_call_channel_dtmf_stop_tone (TpyCallChannel *self) tp_cli_channel_interface_dtmf_call_stop_tone (TP_CHANNEL (self), -1, 0, on_dtmf_tone_cb, "stoping tone", NULL, G_OBJECT (self)); } + +gboolean +tpy_call_channel_has_hold (TpyCallChannel *self) +{ + g_return_val_if_fail (TPY_IS_CALL_CHANNEL (self), FALSE); + + return tp_proxy_has_interface_by_id (self, + TP_IFACE_QUARK_CHANNEL_INTERFACE_HOLD); +} + +/** + * tpy_call_channel_held_finish: + * @self: a #TpyCallChannel + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes to change the hold status of the call. + * + * Since: + */ +gboolean +tpy_call_channel_held_finish (TpyCallChannel *self, + GAsyncResult *result, + GError **error) +{ + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), + error)) + return FALSE; + + g_return_val_if_fail (g_simple_async_result_is_valid (result, + G_OBJECT (self), tpy_call_channel_held_async), + FALSE); + + return g_simple_async_result_get_op_res_gboolean ( + G_SIMPLE_ASYNC_RESULT (result)); +} + +static void +on_request_hold_cb (TpChannel *proxy, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + TpyCallChannel *self = TPY_CALL_CHANNEL (proxy); + + if (error != NULL) + { + DEBUG ("Failed to change hold status: %s", error->message); + + g_simple_async_result_set_from_error (self->priv->result, error); + } + + g_simple_async_result_set_op_res_gboolean (self->priv->result, + error == NULL); + g_simple_async_result_complete (self->priv->result); + tp_clear_object (&self->priv->result); +} + +void +tpy_call_channel_held_async (TpyCallChannel *self, + gboolean held, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail (TPY_IS_CALL_CHANNEL (self)); + g_return_if_fail (self->priv->result == NULL); + + self->priv->result = g_simple_async_result_new (G_OBJECT (self), callback, + user_data, tpy_call_channel_held_async); + + tp_cli_channel_interface_hold_call_request_hold (TP_CHANNEL (self), + -1, held, + on_request_hold_cb, NULL, NULL, G_OBJECT (self)); +} diff --git a/telepathy-yell/call-channel.h b/telepathy-yell/call-channel.h index a4ff982..d35af86 100644 --- a/telepathy-yell/call-channel.h +++ b/telepathy-yell/call-channel.h @@ -115,6 +115,16 @@ void tpy_call_channel_dtmf_start_tone (TpyCallChannel *self, void tpy_call_channel_dtmf_stop_tone (TpyCallChannel *self); +gboolean tpy_call_channel_has_hold (TpyCallChannel *self); + +void tpy_call_channel_held_async (TpyCallChannel *self, + gboolean held, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean tpy_call_channel_held_finish (TpyCallChannel *self, + GAsyncResult *result, + GError **error); + G_END_DECLS #endif -- cgit v1.2.3