[next] telepathy-glib: tp_stream_tube_channel_offer_async: take a GVariant as parameters
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Thu Feb 27 06:07:36 PST 2014
Module: telepathy-glib
Branch: next
Commit: 8f9d91ce5de4312753a3b646e795a1d24dc1a27b
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=8f9d91ce5de4312753a3b646e795a1d24dc1a27b
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Thu Feb 20 11:03:32 2014 +0100
tp_stream_tube_channel_offer_async: take a GVariant as parameters
---
telepathy-glib/stream-tube-channel.c | 18 ++++++++++++++----
telepathy-glib/stream-tube-channel.h | 2 +-
tests/dbus/stream-tube.c | 9 +++++----
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/telepathy-glib/stream-tube-channel.c b/telepathy-glib/stream-tube-channel.c
index 93164fb..13f9893 100644
--- a/telepathy-glib/stream-tube-channel.c
+++ b/telepathy-glib/stream-tube-channel.c
@@ -1147,7 +1147,7 @@ _channel_offered (TpChannel *channel,
static void
_offer_with_address (TpStreamTubeChannel *self,
- GHashTable *params)
+ GVariant *params)
{
GValue *addressv = NULL;
GError *error = NULL;
@@ -1176,7 +1176,7 @@ _offer_with_address (TpStreamTubeChannel *self,
g_assert (self->priv->parameters == NULL);
if (params != NULL)
- self->priv->parameters = g_hash_table_ref (params);
+ self->priv->parameters = _tp_asv_from_vardict (params);
else
self->priv->parameters = tp_asv_new (NULL, NULL);
@@ -1306,7 +1306,8 @@ service_incoming_cb (GSocketService *service,
/**
* tp_stream_tube_channel_offer_async:
* @self: an outgoing #TpStreamTubeChannel
- * @params: (allow-none) (transfer none): parameters of the tube, or %NULL
+ * @params: (allow-none): a #%G_VARIANT_TYPE_VARDICT representing the parameters
+ * of the tube, or %NULL
* @callback: a callback to call when the tube has been offered
* @user_data: data to pass to @callback
*
@@ -1318,11 +1319,13 @@ service_incoming_cb (GSocketService *service,
* #TpStreamTubeConnection each time a contact establishes a connection to
* the tube.
*
+ * @params is consumed if it is floating.
+ *
* Since: 0.13.2
*/
void
tp_stream_tube_channel_offer_async (TpStreamTubeChannel *self,
- GHashTable *params,
+ GVariant *params,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -1425,6 +1428,13 @@ tp_stream_tube_channel_offer_async (TpStreamTubeChannel *self,
g_socket_service_start (self->priv->service);
_offer_with_address (self, params);
+
+ if (params != NULL)
+ {
+ /* consume the floating ref */
+ g_variant_ref_sink (params);
+ g_variant_unref (params);
+ }
}
/**
diff --git a/telepathy-glib/stream-tube-channel.h b/telepathy-glib/stream-tube-channel.h
index e21ca8b..db2d5bd 100644
--- a/telepathy-glib/stream-tube-channel.h
+++ b/telepathy-glib/stream-tube-channel.h
@@ -79,7 +79,7 @@ TpStreamTubeConnection * tp_stream_tube_channel_accept_finish (
/* Outgoing tube methods */
void tp_stream_tube_channel_offer_async (TpStreamTubeChannel *self,
- GHashTable *params,
+ GVariant *params,
GAsyncReadyCallback callback,
gpointer user_data);
diff --git a/tests/dbus/stream-tube.c b/tests/dbus/stream-tube.c
index 80292c5..533b348 100644
--- a/tests/dbus/stream-tube.c
+++ b/tests/dbus/stream-tube.c
@@ -554,7 +554,7 @@ test_offer_success (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
guint i = GPOINTER_TO_UINT (data);
- GHashTable *params;
+ GVariantDict params;
GSocketAddress *address;
GSocketClient *client;
TpHandle bob_handle;
@@ -579,10 +579,11 @@ test_offer_success (Test *test,
create_tube_service (test, TRUE, contexts[i].address_type,
contexts[i].access_control, contexts[i].contact);
- params = tp_asv_new ("badger", G_TYPE_UINT, 42, NULL);
+ g_variant_dict_init (¶ms, NULL);
+ g_variant_dict_insert (¶ms, "badger", "u", 42);
- tp_stream_tube_channel_offer_async (test->tube, params, tube_offer_cb, test);
- g_hash_table_unref (params);
+ tp_stream_tube_channel_offer_async (test->tube, g_variant_dict_end (¶ms),
+ tube_offer_cb, test);
parameters_vardict = tp_stream_tube_channel_dup_parameters (
test->tube);
More information about the telepathy-commits
mailing list