diff options
author | Chandni Verma <chandniverma2112@gmail.com> | 2012-09-17 21:00:52 +0530 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-09-17 17:01:26 +0100 |
commit | f77747947fa02ce9ff21ac866e07e10589cd1814 (patch) | |
tree | 0b94136bb3f45952ab9b0024973752fd66c718e7 | |
parent | 046f1e6139a1d2278d90566df475e15b2b9d2602 (diff) |
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@collabora.co.uk>
-rw-r--r-- | docs/reference/telepathy-glib-sections.txt | 1 | ||||
-rw-r--r-- | telepathy-glib/dbus-tube-channel.c | 31 | ||||
-rw-r--r-- | telepathy-glib/dbus-tube-channel.h | 3 | ||||
-rw-r--r-- | 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 d277555a7..b482fe30f 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 c8156abde..e872c9da7 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 7d08eaed9..1171afd76 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 71f47849a..27ac21cf6 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 |