[next] telepathy-glib: tp_channel_request_dup_immutable_properties: add

Simon McVittie smcv at kemper.freedesktop.org
Mon Oct 8 08:23:25 PDT 2012


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

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Wed Sep 19 14:20:51 2012 +0100

tp_channel_request_dup_immutable_properties: add

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55101

https://bugs.freedesktop.org/show_bug.cgi?id=55103

---

 docs/reference/telepathy-glib-sections.txt |    1 +
 telepathy-glib/channel-request.c           |   50 ++++++++++++++++++++++++++++
 telepathy-glib/channel-request.h           |    3 ++
 tests/dbus/channel-request.c               |   10 +++++
 4 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 8c2949c..de86b22 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -5523,6 +5523,7 @@ tp_channel_request_new
 tp_channel_request_init_known_interfaces
 tp_channel_request_set_channel_factory
 tp_channel_request_get_immutable_properties
+tp_channel_request_dup_immutable_properties
 tp_channel_request_get_account
 tp_channel_request_get_user_action_time
 tp_channel_request_get_preferred_handler
diff --git a/telepathy-glib/channel-request.c b/telepathy-glib/channel-request.c
index 639a223..a50892f 100644
--- a/telepathy-glib/channel-request.c
+++ b/telepathy-glib/channel-request.c
@@ -106,6 +106,7 @@ enum {
 enum {
   PROP_CHANNEL_FACTORY = 1,
   PROP_IMMUTABLE_PROPERTIES,
+  PROP_IMMUTABLE_PROPERTIES_VARDICT,
   PROP_ACCOUNT,
   PROP_USER_ACTION_TIME,
   PROP_PREFERRED_HANDLER,
@@ -176,6 +177,11 @@ tp_channel_request_get_property (GObject *object,
         g_value_set_boxed (value, self->priv->immutable_properties);
         break;
 
+      case PROP_IMMUTABLE_PROPERTIES_VARDICT:
+        g_value_take_variant (value,
+            tp_channel_request_dup_immutable_properties (self));
+        break;
+
       case PROP_ACCOUNT:
         g_value_set_object (value, tp_channel_request_get_account (self));
         break;
@@ -414,6 +420,28 @@ tp_channel_request_class_init (TpChannelRequestClass *klass)
       param_spec);
 
   /**
+   * TpChannelRequest:immutable-properties-vardict:
+   *
+   * The immutable D-Bus properties of this channel request, represented by a
+   * %G_VARIANT_TYPE_VARDICT where the keys are
+   * D-Bus interface name + "." + property name.
+   *
+   * Note that this property is set only if the immutable properties have been
+   * set during the construction of the #TpChannelRequest.
+   *
+   * Read-only except during construction.
+   *
+   * Since: 0.UNRELEASED
+   */
+  param_spec = g_param_spec_variant ("immutable-properties-vardict",
+      "Immutable D-Bus properties",
+      "A map D-Bus interface + \".\" + property name => variant",
+      G_VARIANT_TYPE_VARDICT, NULL,
+      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class,
+      PROP_IMMUTABLE_PROPERTIES_VARDICT, param_spec);
+
+  /**
    * TpChannelRequest:account:
    *
    * The #TpAccount on which this request was made, not guaranteed
@@ -686,6 +714,28 @@ tp_channel_request_get_immutable_properties (TpChannelRequest *self)
   return self->priv->immutable_properties;
 }
 
+/**
+ * tp_channel_request_dup_immutable_properties:
+ * @self: a #TpChannelRequest
+ *
+ * Return the #TpChannelRequest:immutable-properties-vardict property.
+ *
+ * Returns: (transfer full): the value of
+ * #TpChannelRequest:immutable-properties-vardict
+ *
+ * Since: 0.UNRELEASED
+ */
+GVariant *
+tp_channel_request_dup_immutable_properties (TpChannelRequest *self)
+{
+  g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL);
+
+  if (self->priv->immutable_properties == NULL)
+    return NULL;
+
+  return _tp_asv_to_vardict (self->priv->immutable_properties);
+}
+
 void
 _tp_channel_request_ensure_immutable_properties (TpChannelRequest *self,
     GHashTable *immutable_properties)
diff --git a/telepathy-glib/channel-request.h b/telepathy-glib/channel-request.h
index 7fcbf32..61e2cd8 100644
--- a/telepathy-glib/channel-request.h
+++ b/telepathy-glib/channel-request.h
@@ -88,6 +88,9 @@ void tp_channel_request_set_channel_factory (TpChannelRequest *self,
 const GHashTable * tp_channel_request_get_immutable_properties (
     TpChannelRequest *self);
 
+_TP_AVAILABLE_IN_UNRELEASED
+GVariant *tp_channel_request_dup_immutable_properties (TpChannelRequest *self);
+
 TpAccount * tp_channel_request_get_account (TpChannelRequest *self);
 
 gint64 tp_channel_request_get_user_action_time (TpChannelRequest *self);
diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c
index 779a110..c09d939 100644
--- a/tests/dbus/channel-request.c
+++ b/tests/dbus/channel-request.c
@@ -317,6 +317,7 @@ test_immutable_properties (Test *test,
 {
   gboolean ok;
   GHashTable *props;
+  GVariant *vardict;
 
   props = tp_asv_new ("badger", G_TYPE_UINT, 42,
       NULL);
@@ -337,6 +338,15 @@ test_immutable_properties (Test *test,
   g_assert_cmpuint (tp_asv_get_uint32 (props, "badger", NULL), ==, 42);
 
   g_hash_table_unref (props);
+
+  vardict = tp_channel_request_dup_immutable_properties (test->cr);
+  g_assert_cmpuint (tp_vardict_get_uint32 (vardict, "badger", NULL), ==, 42);
+  g_variant_unref (vardict);
+
+  g_object_get (test->cr,
+      "immutable-properties-vardict", &vardict, NULL);
+  g_assert_cmpuint (tp_vardict_get_uint32 (vardict, "badger", NULL), ==, 42);
+  g_variant_unref (vardict);
 }
 
 #define ACCOUNT_PATH TP_ACCOUNT_OBJECT_PATH_BASE "a/b/c"



More information about the telepathy-commits mailing list