[next] telepathy-glib: account-channel-request: remove 'request' property

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


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

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Wed Feb 19 10:56:04 2014 +0100

account-channel-request: remove 'request' property

---

 telepathy-glib/account-channel-request.c |  107 +++++++++---------------------
 tests/dbus/account-channel-request.c     |    4 --
 2 files changed, 32 insertions(+), 79 deletions(-)

diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index 79dad5d..459aff9 100644
--- a/telepathy-glib/account-channel-request.c
+++ b/telepathy-glib/account-channel-request.c
@@ -108,7 +108,6 @@ G_DEFINE_TYPE(TpAccountChannelRequest,
 
 enum {
     PROP_ACCOUNT = 1,
-    PROP_REQUEST,
     PROP_REQUEST_VARDICT,
     PROP_USER_ACTION_TIME,
     PROP_CHANNEL_REQUEST,
@@ -238,10 +237,6 @@ tp_account_channel_request_get_property (GObject *object,
         g_value_set_object (value, self->priv->account);
         break;
 
-      case PROP_REQUEST:
-        g_value_set_boxed (value, self->priv->request);
-        break;
-
       case PROP_REQUEST_VARDICT:
         g_value_take_variant (value,
             tp_account_channel_request_dup_request (self));
@@ -276,25 +271,6 @@ tp_account_channel_request_set_property (GObject *object,
         self->priv->account = g_value_dup_object (value);
         break;
 
-      case PROP_REQUEST:
-        /* If this property remains unset, GObject will set it to a NULL
-         * value. Ignore that, so request-vardict can be set instead. */
-        if (g_value_get_boxed (value) == NULL)
-          return;
-
-        /* Construct-only and mutually exclusive with request-vardict */
-        g_return_if_fail (self->priv->request == NULL);
-
-        /* We do not use tp_asv_new() and friends, because in principle,
-         * the request can contain user-defined keys. */
-        self->priv->request = g_hash_table_new_full (g_str_hash, g_str_equal,
-            g_free, (GDestroyNotify) tp_g_value_slice_free);
-        tp_g_hash_table_update (self->priv->request,
-            g_value_get_boxed (value),
-            (GBoxedCopyFunc) g_strdup,
-            (GBoxedCopyFunc) tp_g_value_slice_dup);
-        break;
-
       case PROP_REQUEST_VARDICT:
           {
             GHashTable *hash;
@@ -381,26 +357,6 @@ tp_account_channel_request_class_init (
       param_spec);
 
   /**
-   * TpAccountChannelRequest:request:
-   *
-   * The desired D-Bus properties for the channel, represented as a
-   * #GHashTable where the keys are strings and the values are #GValue.
-   *
-   * When constructing a new object, one of
-   * #TpAccountChannelRequest:request or
-   * #TpAccountChannelRequest:request-vardict must be set to a non-%NULL
-   * value, and the other must remain unspecified.
-   *
-   * Since: 0.11.12
-   */
-  param_spec = g_param_spec_boxed ("request", "GHashTable",
-      "A dictionary containing desirable properties for the channel",
-      TP_HASH_TYPE_STRING_VARIANT_MAP,
-      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-  g_object_class_install_property (object_class, PROP_REQUEST,
-      param_spec);
-
-  /**
    * TpAccountChannelRequest:request-vardict:
    *
    * The desired D-Bus properties for the channel.
@@ -1645,20 +1601,19 @@ tp_account_channel_request_new_text (
     gint64 user_action_time)
 {
   TpAccountChannelRequest *self;
-  GHashTable *request;
+  GVariantDict dict;
 
   g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
 
-  request = tp_asv_new (
-      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT,
-      NULL);
+  g_variant_dict_init (&dict, NULL);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_CHANNEL_TYPE, "s",
+      TP_IFACE_CHANNEL_TYPE_TEXT);
 
   self = g_object_new (TP_TYPE_ACCOUNT_CHANNEL_REQUEST,
       "account", account,
-      "request", request,
+      "request-vardict", g_variant_dict_end (&dict),
       "user-action-time", user_action_time,
       NULL);
-  g_hash_table_unref (request);
   return self;
 }
 
@@ -1763,21 +1718,21 @@ tp_account_channel_request_new_audio_call (
     gint64 user_action_time)
 {
   TpAccountChannelRequest *self;
-  GHashTable *request;
+  GVariantDict dict;
 
   g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
 
-  request = tp_asv_new (
-      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CALL1,
-      TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, G_TYPE_BOOLEAN, TRUE,
-      NULL);
+  g_variant_dict_init (&dict, NULL);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_CHANNEL_TYPE, "s",
+      TP_IFACE_CHANNEL_TYPE_CALL1);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, "b",
+      TRUE);
 
   self = g_object_new (TP_TYPE_ACCOUNT_CHANNEL_REQUEST,
       "account", account,
-      "request", request,
+      "request-vardict", g_variant_dict_end (&dict),
       "user-action-time", user_action_time,
       NULL);
-  g_hash_table_unref (request);
   return self;
 }
 
@@ -1812,22 +1767,23 @@ tp_account_channel_request_new_audio_video_call (
     gint64 user_action_time)
 {
   TpAccountChannelRequest *self;
-  GHashTable *request;
+  GVariantDict dict;
 
   g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
 
-  request = tp_asv_new (
-      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CALL1,
-      TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, G_TYPE_BOOLEAN, TRUE,
-      TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO, G_TYPE_BOOLEAN, TRUE,
-      NULL);
+  g_variant_dict_init (&dict, NULL);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_CHANNEL_TYPE, "s",
+      TP_IFACE_CHANNEL_TYPE_CALL1);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, "b",
+      TRUE);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO, "b",
+      TRUE);
 
   self = g_object_new (TP_TYPE_ACCOUNT_CHANNEL_REQUEST,
       "account", account,
-      "request", request,
+      "request-vardict", g_variant_dict_end (&dict),
       "user-action-time", user_action_time,
       NULL);
-  g_hash_table_unref (request);
   return self;
 }
 
@@ -1868,7 +1824,7 @@ tp_account_channel_request_new_file_transfer (
     gint64 user_action_time)
 {
   TpAccountChannelRequest *self;
-  GHashTable *request;
+  GVariantDict dict;
 
   g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
   g_return_val_if_fail (!tp_str_empty (filename), NULL);
@@ -1877,20 +1833,21 @@ tp_account_channel_request_new_file_transfer (
   if (mime_type == NULL)
     mime_type = "application/octet-stream";
 
-  request = tp_asv_new (
-      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
-          TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1,
-      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_FILENAME, G_TYPE_STRING, filename,
-      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_CONTENT_TYPE, G_TYPE_STRING, mime_type,
-      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_SIZE, G_TYPE_UINT64, size,
-      NULL);
+  g_variant_dict_init (&dict, NULL);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_CHANNEL_TYPE, "s",
+      TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_FILENAME,
+      "s", filename);
+  g_variant_dict_insert (&dict,
+      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_CONTENT_TYPE, "s", mime_type);
+  g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_SIZE, "t",
+      size);
 
   self = g_object_new (TP_TYPE_ACCOUNT_CHANNEL_REQUEST,
       "account", account,
-      "request", request,
+      "request-vardict", g_variant_dict_end (&dict),
       "user-action-time", user_action_time,
       NULL);
-  g_hash_table_unref (request);
   return self;
 }
 
diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c
index 787e705..95edc2d 100644
--- a/tests/dbus/account-channel-request.c
+++ b/tests/dbus/account-channel-request.c
@@ -471,14 +471,10 @@ test_handle_ensure_success (Test *test,
   g_variant_unref (vardict);
 
   g_object_get (req,
-      "request", &asv,
       "request-vardict", &vardict,
       NULL);
-  g_assert_cmpstr (tp_asv_get_string (asv,
-      TP_PROP_CHANNEL_TARGET_ID), ==, "alice");
   g_assert_cmpstr (tp_vardict_get_string (vardict,
       TP_PROP_CHANNEL_TARGET_ID), ==, "alice");
-  g_hash_table_unref (asv);
   g_variant_unref (vardict);
 
   tp_account_channel_request_ensure_and_handle_channel_async (req,



More information about the telepathy-commits mailing list