[next] telepathy-glib: channel-request: use the vardict version of the ' hints' property

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


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

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Wed Feb 19 11:30:09 2014 +0100

channel-request: use the vardict version of the 'hints' property

---

 .../telepathy-glib/telepathy-glib-sections.txt     |    1 -
 telepathy-glib/base-client.c                       |   13 ++++----
 telepathy-glib/channel-request.c                   |   31 ++++----------------
 telepathy-glib/channel-request.h                   |    2 --
 tests/dbus/account-channel-request.c               |   11 ++++---
 tests/dbus/channel-request.c                       |   10 +------
 6 files changed, 20 insertions(+), 48 deletions(-)

diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index 38d67f8..30cb5ce 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -4326,7 +4326,6 @@ tp_channel_request_dup_immutable_properties
 tp_channel_request_get_account
 tp_channel_request_get_user_action_time
 tp_channel_request_get_preferred_handler
-tp_channel_request_get_hints
 tp_channel_request_dup_hints
 <SUBSECTION Standard>
 TP_CHANNEL_REQUEST
diff --git a/telepathy-glib/base-client.c b/telepathy-glib/base-client.c
index 77421c6..9fc9f1a 100644
--- a/telepathy-glib/base-client.c
+++ b/telepathy-glib/base-client.c
@@ -1951,16 +1951,17 @@ delegate_channels_if_needed (TpBaseClient *self,
   for (l = requests; l != NULL; l = g_list_next (l))
     {
       TpChannelRequest *cr = l->data;
-      const GHashTable *hints;
-      gboolean should_delegate;
+      GVariant *hints;
+      gboolean should_delegate = FALSE;
 
-      hints = tp_channel_request_get_hints (cr);
+      hints = tp_channel_request_dup_hints (cr);
       if (hints == NULL)
         continue;
 
-      should_delegate = tp_asv_get_boolean (hints,
-          "im.telepathy.v1.ChannelRequest.DelegateToPreferredHandler",
-          NULL);
+      g_variant_lookup (hints,
+            "im.telepathy.v1.ChannelRequest.DelegateToPreferredHandler", "b",
+            &should_delegate);
+      g_variant_unref (hints);
 
       if (!should_delegate)
         continue;
diff --git a/telepathy-glib/channel-request.c b/telepathy-glib/channel-request.c
index 5903dc1..3b59c4e 100644
--- a/telepathy-glib/channel-request.c
+++ b/telepathy-glib/channel-request.c
@@ -106,7 +106,6 @@ enum {
   PROP_USER_ACTION_TIME,
   PROP_PREFERRED_HANDLER,
   PROP_HINTS,
-  PROP_HINTS_VARDICT
 };
 
 static guint signals[N_SIGNALS] = { 0 };
@@ -180,10 +179,6 @@ tp_channel_request_get_property (GObject *object,
         break;
 
       case PROP_HINTS:
-        g_value_set_boxed (value, tp_channel_request_get_hints (self));
-        break;
-
-      case PROP_HINTS_VARDICT:
         g_value_take_variant (value, tp_channel_request_dup_hints (self));
         break;
 
@@ -419,22 +414,6 @@ tp_channel_request_class_init (TpChannelRequestClass *klass)
   /**
    * TpChannelRequest:hints:
    *
-   * A #TP_HASH_TYPE_STRING_VARIANT_MAP of metadata provided by
-   * the channel requester; or %NULL if #TpChannelRequest:immutable-properties
-   * is not defined or if no hints has been defined.
-   *
-   * Read-only.
-   *
-   * Since: 0.13.14
-   */
-  param_spec = g_param_spec_boxed ("hints", "Hints", "Hints",
-      TP_HASH_TYPE_STRING_VARIANT_MAP,
-      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
-  g_object_class_install_property (object_class, PROP_HINTS, param_spec);
-
-  /**
-   * TpChannelRequest:hints-vardict:
-   *
    * A %G_VARIANT_TYPE_VARDICT of metadata provided by
    * the channel requester; or %NULL if #TpChannelRequest:immutable-properties
    * is not defined or if no hints have been defined.
@@ -443,10 +422,10 @@ tp_channel_request_class_init (TpChannelRequestClass *klass)
    *
    * Since: 0.19.10
    */
-  param_spec = g_param_spec_variant ("hints-vardict", "Hints", "Hints",
+  param_spec = g_param_spec_variant ("hints", "Hints", "Hints",
       G_VARIANT_TYPE_VARDICT, NULL,
       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
-  g_object_class_install_property (object_class, PROP_HINTS_VARDICT,
+  g_object_class_install_property (object_class, PROP_HINTS,
       param_spec);
 
   /**
@@ -654,7 +633,7 @@ tp_channel_request_get_preferred_handler (TpChannelRequest *self)
  *
  * Since: 0.13.14
  */
-const GHashTable *
+static const GHashTable *
 tp_channel_request_get_hints (TpChannelRequest *self)
 {
   g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL);
@@ -670,9 +649,9 @@ tp_channel_request_get_hints (TpChannelRequest *self)
  * tp_channel_request_dup_hints:
  * @self: a #TpChannelRequest
  *
- * Return the #TpChannelRequest:hints-vardict property
+ * Return the #TpChannelRequest:hints property
  *
- * Returns: (transfer full): the value of #TpChannelRequest:hints-vardict
+ * Returns: (transfer full): the value of #TpChannelRequest:hints
  *
  * Since: 0.19.10
  */
diff --git a/telepathy-glib/channel-request.h b/telepathy-glib/channel-request.h
index 2088ede..576764e 100644
--- a/telepathy-glib/channel-request.h
+++ b/telepathy-glib/channel-request.h
@@ -80,8 +80,6 @@ gint64 tp_channel_request_get_user_action_time (TpChannelRequest *self);
 
 const gchar * tp_channel_request_get_preferred_handler (TpChannelRequest *self);
 
-const GHashTable * tp_channel_request_get_hints (TpChannelRequest *self);
-
 _TP_AVAILABLE_IN_0_20
 GVariant *tp_channel_request_dup_hints (TpChannelRequest *self);
 
diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c
index 1199175..ee06a85 100644
--- a/tests/dbus/account-channel-request.c
+++ b/tests/dbus/account-channel-request.c
@@ -616,8 +616,9 @@ create_and_handle_hints_cb (GObject *source,
   Test *test = user_data;
   TpHandleChannelContext *context = NULL;
   GList *reqs;
-  const GHashTable *hints;
+  GVariant *hints;
   TpChannelRequest *req;
+  guint32 badger;
 
   test->channel = tp_account_channel_request_create_and_handle_channel_finish (
       TP_ACCOUNT_CHANNEL_REQUEST (source), result, &context, &test->error);
@@ -635,9 +636,11 @@ create_and_handle_hints_cb (GObject *source,
   req = reqs->data;
   g_assert (TP_IS_CHANNEL_REQUEST (req));
 
-  hints = tp_channel_request_get_hints (req);
-  g_assert_cmpuint (g_hash_table_size ((GHashTable *) hints), ==, 1);
-  g_assert_cmpuint (tp_asv_get_uint32 (hints, "Badger", NULL), ==, 42);
+  hints = tp_channel_request_dup_hints (req);
+  g_assert_cmpuint (g_variant_n_children (hints), ==, 1);
+  g_variant_lookup (hints, "Badger", "u", &badger);
+  g_assert_cmpuint (badger, ==, 42);
+  g_variant_unref (hints);
 
   g_list_foreach (reqs, (GFunc) g_object_unref, NULL);
   g_list_free (reqs);
diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c
index 16c37f3..b5c8f81 100644
--- a/tests/dbus/channel-request.c
+++ b/tests/dbus/channel-request.c
@@ -422,20 +422,12 @@ test_properties (Test *test,
   g_assert_cmpstr (handler, ==, "Badger");
 
   /* Hints */
-  hints = (GHashTable *) tp_channel_request_get_hints (test->cr);
-  g_assert_cmpstr (tp_asv_get_string (hints, "test"), ==, "hi");
-
-  g_object_get (test->cr, "hints", &hints, NULL);
-  g_assert_cmpstr (tp_asv_get_string (hints, "test"), ==, "hi");
-
-  g_hash_table_unref (hints);
-
   vardict = tp_channel_request_dup_hints (test->cr);
   g_assert_cmpstr (tp_vardict_get_string (vardict, "test"), ==, "hi");
   g_variant_unref (vardict);
 
   g_object_get (test->cr,
-      "hints-vardict", &vardict,
+      "hints", &vardict,
       NULL);
   g_assert_cmpstr (tp_vardict_get_string (vardict, "test"), ==, "hi");
   g_variant_unref (vardict);



More information about the telepathy-commits mailing list