From af45bb7c8bdd705bc03c536a85500867f7d6e235 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 24 Feb 2014 11:17:52 +0100 Subject: [PATCH 01/13] turn TpCallChannel:state-details to a GVariant Fix fdo#55104. --- telepathy-glib/call-channel.c | 34 ++++++++++++++++------------------ telepathy-glib/call-channel.h | 3 ++- tests/dbus/call-channel.c | 4 +++- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/telepathy-glib/call-channel.c b/telepathy-glib/call-channel.c index ae89c44..ce54c6c 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 = tp_asv_to_vardict (details); g_object_notify ((GObject *) self, "state"); g_object_notify ((GObject *) self, "flags"); @@ -594,7 +594,7 @@ 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, + self->priv->state_details = 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)); @@ -735,7 +735,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 +767,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 +905,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 + * if 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 +1092,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 readable. * * The ::state-changed signal is emitted whenever the * call state changes. @@ -1108,7 +1106,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 +1208,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 +1221,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 +1229,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 #include +#include 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 60cfded..ba8cf8e 100644 --- a/tests/dbus/call-channel.c +++ b/tests/dbus/call-channel.c @@ -202,7 +202,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); @@ -214,6 +214,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); -- 1.8.5.3