[next] telepathy-glib: turn TpCallChannel:state-details to a GVariant

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Fri Mar 7 02:22:28 PST 2014


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

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Mon Feb 24 11:17:52 2014 +0100

turn TpCallChannel:state-details to a GVariant

Fix fdo#55104.

---

 telepathy-glib/call-channel.c |   37 ++++++++++++++++++-------------------
 telepathy-glib/call-channel.h |    3 ++-
 tests/dbus/call-channel.c     |    4 +++-
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/telepathy-glib/call-channel.c b/telepathy-glib/call-channel.c
index ae89c44..9de9007 100644
--- a/telepathy-glib/call-channel.c
+++ b/telepathy-glib/call-channel.c
@@ -76,7 +76,7 @@ struct _TpCallChannelPrivate
   GPtrArray *contents;
   TpCallState state;
   TpCallFlags flags;
-  GHashTable *state_details;
+  GVariant *state_details;
   TpCallStateReason *state_reason;
   gboolean hardware_streaming;
   /* TpContact -> TpCallMemberFlags */
@@ -405,12 +405,12 @@ call_state_changed_cb (TpChannel *channel,
       flags);
 
   tp_clear_pointer (&self->priv->state_reason, _tp_call_state_reason_unref);
-  tp_clear_pointer (&self->priv->state_details, g_hash_table_unref);
+  tp_clear_pointer (&self->priv->state_details, g_variant_unref);
 
   self->priv->state = state;
   self->priv->flags = flags;
   self->priv->state_reason = _tp_call_state_reason_new (reason);
-  self->priv->state_details = g_hash_table_ref (details);
+  self->priv->state_details = g_variant_ref_sink (tp_asv_to_vardict (details));
 
   g_object_notify ((GObject *) self, "state");
   g_object_notify ((GObject *) self, "flags");
@@ -594,8 +594,9 @@ got_all_properties_cb (TpProxy *proxy,
       "CallState", NULL);
   self->priv->flags = tp_asv_get_uint32 (properties,
       "CallFlags", NULL);
-  self->priv->state_details = g_hash_table_ref (tp_asv_get_boxed (properties,
-      "CallStateDetails", TP_HASH_TYPE_STRING_VARIANT_MAP));
+  self->priv->state_details = g_variant_ref_sink (
+      tp_asv_to_vardict (tp_asv_get_boxed (properties,
+          "CallStateDetails", TP_HASH_TYPE_STRING_VARIANT_MAP)));
   self->priv->state_reason = _tp_call_state_reason_new (tp_asv_get_boxed (properties,
       "CallStateReason", TP_STRUCT_TYPE_CALL_STATE_REASON));
   members = tp_asv_get_boxed (properties,
@@ -735,7 +736,7 @@ tp_call_channel_dispose (GObject *obj)
   g_assert (self->priv->core_result == NULL);
 
   tp_clear_pointer (&self->priv->contents, g_ptr_array_unref);
-  tp_clear_pointer (&self->priv->state_details, g_hash_table_unref);
+  tp_clear_pointer (&self->priv->state_details, g_variant_unref);
   tp_clear_pointer (&self->priv->state_reason, _tp_call_state_reason_unref);
   tp_clear_pointer (&self->priv->members, g_hash_table_unref);
   tp_clear_pointer (&self->priv->initial_audio_name, g_free);
@@ -767,7 +768,7 @@ tp_call_channel_get_property (GObject *object,
         break;
 
       case PROP_STATE_DETAILS:
-        g_value_set_boxed (value, self->priv->state_details);
+        g_value_set_variant (value, self->priv->state_details);
         break;
 
       case PROP_STATE_REASON:
@@ -905,14 +906,12 @@ tp_call_channel_class_init (TpCallChannelClass *klass)
   /**
    * TpCallChannel:state-details:
    *
-   * Detailed infoermation about #TpCallChannel:state. It is a #GHashTable
-   * mapping gchar*->GValue, it can be accessed using the tp_asv_* functions.
-   *
-   * Since: 0.17.5
+   * Detailed information about #TpCallChannel:state. It is a #GVariant
+   * of type #G_VARIANT_TYPE_VARDICT.
    */
-  param_spec = g_param_spec_boxed ("state-details", "State details",
+  param_spec = g_param_spec_variant ("state-details", "State details",
       "The details of the call",
-      G_TYPE_HASH_TABLE,
+      G_VARIANT_TYPE_VARDICT, NULL,
       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (gobject_class,
       PROP_STATE_DETAILS, param_spec);
@@ -1094,8 +1093,8 @@ tp_call_channel_class_init (TpCallChannelClass *klass)
    * @state: the new #TpCallState
    * @flags: the new #TpCallFlags
    * @reason: the #TpCallStateReason for the change
-   * @details: (element-type utf8 GObject.Value): additional details as a
-   *   #GHashTable readable using the tp_asv_* functions.
+   * @details: additional details as a
+   * #GVariant of type #G_VARIANT_TYPE_VARDICT.
    *
    * The ::state-changed signal is emitted whenever the
    * call state changes.
@@ -1108,7 +1107,7 @@ tp_call_channel_class_init (TpCallChannelClass *klass)
       0, NULL, NULL, NULL,
       G_TYPE_NONE,
       4, G_TYPE_UINT, G_TYPE_UINT, TP_TYPE_CALL_STATE_REASON,
-      G_TYPE_HASH_TABLE);
+      G_TYPE_VARIANT);
 
   /**
    * TpCallChannel::members-changed:
@@ -1210,7 +1209,7 @@ tp_call_channel_get_contents (TpCallChannel *self)
  * @self: a #TpCallChannel
  * @flags: (out) (allow-none) (transfer none): a place to set the value of
  *  #TpCallChannel:flags
- * @details: (out) (allow-none) (transfer none): a place to set the value of
+ * @details: (out) (allow-none) (transfer full): a place to set the value of
  *  #TpCallChannel:state-details
  * @reason: (out) (allow-none) (transfer none): a place to set the value of
  *  #TpCallChannel:state-reason
@@ -1223,7 +1222,7 @@ tp_call_channel_get_contents (TpCallChannel *self)
 TpCallState
 tp_call_channel_get_state (TpCallChannel *self,
     TpCallFlags *flags,
-    GHashTable **details,
+    GVariant **details,
     TpCallStateReason **reason)
 {
   g_return_val_if_fail (TP_IS_CALL_CHANNEL (self), TP_CALL_STATE_UNKNOWN);
@@ -1231,7 +1230,7 @@ tp_call_channel_get_state (TpCallChannel *self,
   if (flags != NULL)
     *flags = self->priv->flags;
   if (details != NULL)
-    *details = self->priv->state_details;
+    *details = g_variant_ref (self->priv->state_details);
   if (reason != NULL)
     *reason = self->priv->state_reason;
 
diff --git a/telepathy-glib/call-channel.h b/telepathy-glib/call-channel.h
index a43d93b..8fb01db 100644
--- a/telepathy-glib/call-channel.h
+++ b/telepathy-glib/call-channel.h
@@ -27,6 +27,7 @@
 
 #include <telepathy-glib/channel.h>
 #include <telepathy-glib/defs.h>
+#include <telepathy-glib/variant-util.h>
 
 G_BEGIN_DECLS
 
@@ -87,7 +88,7 @@ GPtrArray *tp_call_channel_get_contents (TpCallChannel *self);
 _TP_AVAILABLE_IN_0_18
 TpCallState tp_call_channel_get_state (TpCallChannel *self,
     TpCallFlags *flags,
-    GHashTable **details,
+    GVariant **details,
     TpCallStateReason **reason);
 _TP_AVAILABLE_IN_0_18
 gboolean tp_call_channel_has_hardware_streaming (TpCallChannel *self);
diff --git a/tests/dbus/call-channel.c b/tests/dbus/call-channel.c
index 8281fee..eda2f1b 100644
--- a/tests/dbus/call-channel.c
+++ b/tests/dbus/call-channel.c
@@ -203,7 +203,7 @@ assert_call_properties (TpCallChannel *channel,
 {
   TpCallState state;
   TpCallFlags flags;
-  GHashTable *details;
+  GVariant *details;
   TpCallStateReason *r;
 
   state = tp_call_channel_get_state (channel, &flags, &details, &r);
@@ -215,6 +215,8 @@ assert_call_properties (TpCallChannel *channel,
   g_assert_cmpstr (r->dbus_reason, ==, dbus_reason);
   if (check_call_flags)
     g_assert_cmpuint (flags, ==, call_flags);
+  g_assert (details != NULL);
+  g_variant_unref (details);
 
   /* Hard-coded properties */
   g_assert_cmpint (tp_call_channel_has_hardware_streaming (channel), ==, FALSE);



More information about the telepathy-commits mailing list