[next] telepathy-glib: dbus-tube-channel: store parameters as a GVariant

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Thu Feb 27 06:07:36 PST 2014


Module: telepathy-glib
Branch: next
Commit: bb0440cb21270e225a6ae4dc19ead30ea12034cc
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=bb0440cb21270e225a6ae4dc19ead30ea12034cc

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

dbus-tube-channel: store parameters as a GVariant

---

 telepathy-glib/dbus-tube-channel.c |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/telepathy-glib/dbus-tube-channel.c b/telepathy-glib/dbus-tube-channel.c
index c3704ce..6ef193a 100644
--- a/telepathy-glib/dbus-tube-channel.c
+++ b/telepathy-glib/dbus-tube-channel.c
@@ -108,7 +108,7 @@ G_DEFINE_TYPE (TpDBusTubeChannel, tp_dbus_tube_channel, TP_TYPE_CHANNEL)
 
 struct _TpDBusTubeChannelPrivate
 {
-  GHashTable *parameters;
+  GVariant *parameters;
   TpTubeChannelState state;
 
   GSimpleAsyncResult *result;
@@ -126,7 +126,7 @@ tp_dbus_tube_channel_dispose (GObject *obj)
 {
   TpDBusTubeChannel *self = (TpDBusTubeChannel *) obj;
 
-  tp_clear_pointer (&self->priv->parameters, g_hash_table_unref);
+  tp_clear_pointer (&self->priv->parameters, g_variant_unref);
   /* If priv->result isn't NULL, it owns a ref to self. */
   g_warn_if_fail (self->priv->result == NULL);
   tp_clear_pointer (&self->priv->address, g_free);
@@ -309,12 +309,11 @@ tp_dbus_tube_channel_constructed (GObject *obj)
         {
           DEBUG ("Incoming tube doesn't have Tube.Parameters property");
 
-          self->priv->parameters = tp_asv_new (NULL, NULL);
+          self->priv->parameters = g_variant_new ("a{sv}", NULL);
         }
       else
         {
-          self->priv->parameters = g_boxed_copy (
-              TP_HASH_TYPE_STRING_VARIANT_MAP, params);
+          self->priv->parameters = _tp_asv_to_vardict (params);
         }
     }
 
@@ -524,7 +523,7 @@ tp_dbus_tube_channel_dup_parameters (TpDBusTubeChannel *self)
   if (self->priv->parameters == NULL)
       return NULL;
 
-  return _tp_asv_to_vardict (self->priv->parameters);
+  return g_variant_ref (self->priv->parameters);
 }
 
 /**
@@ -576,6 +575,7 @@ proxy_prepare_offer_cb (GObject *source,
   TpDBusTubeChannel *self = (TpDBusTubeChannel *) source;
   GVariant *params = user_data;
   GError *error = NULL;
+  GHashTable *params_asv;
 
   if (!tp_proxy_prepare_finish (source, result, &error))
     {
@@ -594,20 +594,24 @@ proxy_prepare_offer_cb (GObject *source,
 
   g_assert (self->priv->parameters == NULL);
   if (params != NULL)
-    self->priv->parameters = _tp_asv_from_vardict (params);
+    self->priv->parameters = g_variant_ref (params);
   else
-    self->priv->parameters = tp_asv_new (NULL, NULL);
+    self->priv->parameters = g_variant_new ("a{sv}", NULL);
 
   g_object_notify (G_OBJECT (self), "parameters");
 
+  params_asv = _tp_asv_from_vardict (self->priv->parameters);
+
   /* TODO: provide a way to use TP_SOCKET_ACCESS_CONTROL_LOCALHOST if you're in
    * an environment where you need to disable authentication. tp-glib can't
    * guess this for you.
    */
   tp_cli_channel_type_dbus_tube1_call_offer (TP_CHANNEL (self), -1,
-      self->priv->parameters, TP_SOCKET_ACCESS_CONTROL_CREDENTIALS,
+      params_asv, TP_SOCKET_ACCESS_CONTROL_CREDENTIALS,
       dbus_tube_offer_cb, NULL, NULL, G_OBJECT (self));
 
+  g_hash_table_unref (params_asv);
+
 out:
   tp_clear_pointer (&params, g_variant_unref);
 }



More information about the telepathy-commits mailing list