[next] telepathy-glib: tp_dbus_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: d6036943603a175af58aecbbf0005038230eb4e0
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=d6036943603a175af58aecbbf0005038230eb4e0

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Thu Feb 20 11:03:32 2014 +0100

tp_dbus_tube_channel_offer_async: take a GVariant as parameters

---

 telepathy-glib/dbus-tube-channel.c |   15 +++++++++------
 telepathy-glib/dbus-tube-channel.h |    2 +-
 tests/dbus/dbus-tube.c             |    9 +++++----
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/telepathy-glib/dbus-tube-channel.c b/telepathy-glib/dbus-tube-channel.c
index 361d666..c3704ce 100644
--- a/telepathy-glib/dbus-tube-channel.c
+++ b/telepathy-glib/dbus-tube-channel.c
@@ -574,7 +574,7 @@ proxy_prepare_offer_cb (GObject *source,
     gpointer user_data)
 {
   TpDBusTubeChannel *self = (TpDBusTubeChannel *) source;
-  GHashTable *params = user_data;
+  GVariant *params = user_data;
   GError *error = NULL;
 
   if (!tp_proxy_prepare_finish (source, result, &error))
@@ -594,7 +594,7 @@ proxy_prepare_offer_cb (GObject *source,
 
   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);
 
@@ -609,13 +609,14 @@ proxy_prepare_offer_cb (GObject *source,
       dbus_tube_offer_cb, NULL, NULL, G_OBJECT (self));
 
 out:
-  tp_clear_pointer (&params, g_hash_table_unref);
+  tp_clear_pointer (&params, g_variant_unref);
 }
 
 /**
  * tp_dbus_tube_channel_offer_async:
  * @self: an outgoing #TpDBusTubeChannel
- * @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
  *
@@ -624,11 +625,13 @@ out:
  * tp_dbus_tube_channel_offer_finish() to get the #GDBusConnection that will
  * be used to communicate through the tube.
  *
+ * @params is consumed if it is floating.
+ *
  * Since: 0.18.0
  */
 void
 tp_dbus_tube_channel_offer_async (TpDBusTubeChannel *self,
-    GHashTable *params,
+    GVariant *params,
     GAsyncReadyCallback callback,
     gpointer user_data)
 {
@@ -644,7 +647,7 @@ tp_dbus_tube_channel_offer_async (TpDBusTubeChannel *self,
 
   /* We need CORE to be prepared as we rely on State changes */
   tp_proxy_prepare_async (self, features, proxy_prepare_offer_cb,
-      params != NULL ? g_hash_table_ref (params) : params);
+      params != NULL ? g_variant_ref_sink (params) : params);
 }
 
 /**
diff --git a/telepathy-glib/dbus-tube-channel.h b/telepathy-glib/dbus-tube-channel.h
index 63d6404..ec63721 100644
--- a/telepathy-glib/dbus-tube-channel.h
+++ b/telepathy-glib/dbus-tube-channel.h
@@ -73,7 +73,7 @@ GVariant * tp_dbus_tube_channel_dup_parameters (TpDBusTubeChannel *self);
 
 _TP_AVAILABLE_IN_0_18
 void tp_dbus_tube_channel_offer_async (TpDBusTubeChannel *self,
-    GHashTable *params,
+    GVariant *params,
     GAsyncReadyCallback callback,
     gpointer user_data);
 
diff --git a/tests/dbus/dbus-tube.c b/tests/dbus/dbus-tube.c
index 33fcf2b..ff0f3e2 100644
--- a/tests/dbus/dbus-tube.c
+++ b/tests/dbus/dbus-tube.c
@@ -349,20 +349,21 @@ test_offer (Test *test,
     gconstpointer data)
 {
   const TpTestsDBusTubeChannelOpenMode open_mode = GPOINTER_TO_UINT (data);
-  GHashTable *params;
+  GVariantDict params;
   GVariant *variant;
 
   /* Outgoing tube */
   create_tube_service (test, TRUE, TRUE);
   tp_tests_dbus_tube_channel_set_open_mode (test->tube_chan_service, open_mode);
 
-  params = tp_asv_new ("badger", G_TYPE_UINT, 42, NULL);
+  g_variant_dict_init (&params, NULL);
+  g_variant_dict_insert (&params, "badger", "u", 42);
 
   g_signal_connect (test->tube_chan_service, "new-connection",
       G_CALLBACK (new_connection_cb), test);
 
-  tp_dbus_tube_channel_offer_async (test->tube, params, tube_offer_cb, test);
-  g_hash_table_unref (params);
+  tp_dbus_tube_channel_offer_async (test->tube, g_variant_dict_end (&params),
+      tube_offer_cb, test);
 
   test->wait = 2;
   g_main_loop_run (test->mainloop);



More information about the telepathy-commits mailing list