telepathy-glib: Add tp_dbus_tube_channel_dup_parameters_vardict()
Simon McVittie
smcv at kemper.freedesktop.org
Mon Sep 17 09:09:01 PDT 2012
Module: telepathy-glib
Branch: master
Commit: f77747947fa02ce9ff21ac866e07e10589cd1814
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=f77747947fa02ce9ff21ac866e07e10589cd1814
Author: Chandni Verma <chandniverma2112 at gmail.com>
Date: Mon Sep 17 21:18:52 2012 +0530
Add tp_dbus_tube_channel_dup_parameters_vardict()
[applied with documentation adjustments -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55024
Reviewed-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
---
docs/reference/telepathy-glib-sections.txt | 1 +
telepathy-glib/dbus-tube-channel.c | 31 ++++++++++++++++++++++++++++
telepathy-glib/dbus-tube-channel.h | 3 ++
tests/dbus/dbus-tube.c | 22 +++++++++++++++++++
4 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index d277555..b482fe3 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -6417,6 +6417,7 @@ TpDBusTubeChannel
TpDBusTubeChannelClass
TP_DBUS_TUBE_CHANNEL_FEATURE_CORE
tp_dbus_tube_channel_get_parameters
+tp_dbus_tube_channel_dup_parameters_vardict
tp_dbus_tube_channel_get_service_name
tp_dbus_tube_channel_offer_async
tp_dbus_tube_channel_offer_finish
diff --git a/telepathy-glib/dbus-tube-channel.c b/telepathy-glib/dbus-tube-channel.c
index c8156ab..e872c9d 100644
--- a/telepathy-glib/dbus-tube-channel.c
+++ b/telepathy-glib/dbus-tube-channel.c
@@ -97,6 +97,7 @@
#include "telepathy-glib/automatic-client-factory-internal.h"
#include "telepathy-glib/channel-internal.h"
#include "telepathy-glib/debug-internal.h"
+#include "telepathy-glib/variant-util-internal.h"
#include <stdio.h>
#include <glib/gstdio.h>
@@ -512,6 +513,36 @@ tp_dbus_tube_channel_get_parameters (TpDBusTubeChannel *self)
}
/**
+ * tp_dbus_tube_channel_dup_parameters_vardict
+ * @self: a #TpDBusTubeChannel
+ *
+ * Return the parameters of the dbus-tube channel in a variant of
+ * type %G_VARIANT_TYPE_VARDICT whose keys are strings representing
+ * parameter names and values are variants representing corresponding
+ * parameter values set by the offerer when offering this channel.
+ *
+ * The GVariant returned is %NULL if this is an outgoing tube that has not
+ * yet been offered or the parameters property has not been set.
+ *
+ * Use g_variant_lookup(), g_variant_lookup_value(), or tp_vardict_get_uint32()
+ * and similar functions for convenient access to the values.
+ *
+ * Returns: (transfer full): a new reference to a #GVariant
+ *
+ * Since: 0.UNRELEASED
+ */
+GVariant *
+tp_dbus_tube_channel_dup_parameters_vardict (TpDBusTubeChannel *self)
+{
+ g_return_val_if_fail (TP_IS_DBUS_TUBE_CHANNEL (self), NULL);
+
+ if (self->priv->parameters == NULL)
+ return NULL;
+
+ return _tp_asv_to_vardict (self->priv->parameters);
+}
+
+/**
* TP_DBUS_TUBE_CHANNEL_FEATURE_CORE:
*
* Expands to a call to a function that returns a quark representing the
diff --git a/telepathy-glib/dbus-tube-channel.h b/telepathy-glib/dbus-tube-channel.h
index 7d08eae..1171afd 100644
--- a/telepathy-glib/dbus-tube-channel.h
+++ b/telepathy-glib/dbus-tube-channel.h
@@ -69,6 +69,9 @@ const gchar * tp_dbus_tube_channel_get_service_name (TpDBusTubeChannel *self);
_TP_AVAILABLE_IN_0_18
GHashTable * tp_dbus_tube_channel_get_parameters (TpDBusTubeChannel *self);
+_TP_AVAILABLE_IN_UNRELEASED
+GVariant * tp_dbus_tube_channel_dup_parameters_vardict (TpDBusTubeChannel *self);
+
/* Outgoing tube methods */
_TP_AVAILABLE_IN_0_18
diff --git a/tests/dbus/dbus-tube.c b/tests/dbus/dbus-tube.c
index 71f4784..27ac21c 100644
--- a/tests/dbus/dbus-tube.c
+++ b/tests/dbus/dbus-tube.c
@@ -180,11 +180,24 @@ check_parameters (GHashTable *parameters)
}
static void
+check_parameters_vardict (GVariant *parameters_vardict)
+{
+ guint32 badger_value;
+
+ g_assert (parameters_vardict != NULL);
+
+ g_assert (g_variant_lookup (parameters_vardict, "badger",
+ "u", &badger_value));
+ g_assert_cmpuint (badger_value, ==, 42);
+}
+
+static void
test_properties (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
gchar *service;
GHashTable *parameters;
+ GVariant *parameters_vardict;
/* Outgoing tube */
create_tube_service (test, TRUE, TRUE);
@@ -198,10 +211,13 @@ test_properties (Test *test,
/* Parameters */
parameters = tp_dbus_tube_channel_get_parameters (test->tube);
+ parameters_vardict = tp_dbus_tube_channel_dup_parameters_vardict (
+ test->tube);
/* NULL as the tube has not be offered yet */
g_assert (parameters == NULL);
g_object_get (test->tube, "parameters", ¶meters, NULL);
g_assert (parameters == NULL);
+ g_assert (parameters_vardict == NULL);
/* Incoming tube */
create_tube_service (test, FALSE, FALSE);
@@ -211,7 +227,13 @@ test_properties (Test *test,
check_parameters (parameters);
g_object_get (test->tube, "parameters", ¶meters, NULL);
check_parameters (parameters);
+
+ parameters_vardict = tp_dbus_tube_channel_dup_parameters_vardict (
+ test->tube);
+ check_parameters_vardict (parameters_vardict);
+
g_hash_table_unref (parameters);
+ g_variant_unref (parameters_vardict);
}
static void
More information about the telepathy-commits
mailing list