From ff7a237232afe8bfe7304d4524397b173b527e1f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 19 Sep 2012 14:07:52 +0100 Subject: [PATCH 14/15] tp_channel_request_dup_hints: add --- docs/reference/telepathy-glib-sections.txt | 1 + telepathy-glib/channel-request.c | 48 ++++++++++++++++++++++++++++ telepathy-glib/channel-request.h | 3 ++ tests/dbus/channel-request.c | 11 +++++++ 4 files changed, 63 insertions(+) diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index d339032..805c2ca 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -5531,6 +5531,7 @@ 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 tp_cli_channel_request_callback_for_cancel tp_cli_channel_request_call_cancel diff --git a/telepathy-glib/channel-request.c b/telepathy-glib/channel-request.c index 69f44e9..639a223 100644 --- a/telepathy-glib/channel-request.c +++ b/telepathy-glib/channel-request.c @@ -40,6 +40,7 @@ #include "telepathy-glib/deprecated-internal.h" #include "telepathy-glib/proxy-internal.h" #include "telepathy-glib/simple-client-factory-internal.h" +#include "telepathy-glib/variant-util-internal.h" #include "telepathy-glib/_gen/tp-cli-channel-request-body.h" /** @@ -109,6 +110,7 @@ enum { PROP_USER_ACTION_TIME, PROP_PREFERRED_HANDLER, PROP_HINTS, + PROP_HINTS_VARDICT }; static guint signals[N_SIGNALS] = { 0 }; @@ -192,6 +194,10 @@ tp_channel_request_get_property (GObject *object, 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; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -475,6 +481,23 @@ tp_channel_request_class_init (TpChannelRequestClass *klass) 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. + * + * Read-only. + * + * Since: 0.UNRELEASED + */ + param_spec = g_param_spec_variant ("hints-vardict", "Hints", "Hints", + G_VARIANT_TYPE_VARDICT, NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_HINTS_VARDICT, + param_spec); + + /** * TpChannelRequest::succeeded: * @self: the channel request proxy * @@ -775,3 +798,28 @@ tp_channel_request_get_hints (TpChannelRequest *self) return tp_asv_get_boxed (self->priv->immutable_properties, TP_PROP_CHANNEL_REQUEST_HINTS, TP_HASH_TYPE_STRING_VARIANT_MAP); } + +/** + * tp_channel_request_dup_hints: + * @self: a #TpChannelRequest + * + * Return the #TpChannelRequest:hints-vardict property + * + * Returns: (transfer full): the value of #TpChannelRequest:hints-vardict + * + * Since: 0.UNRELEASED + */ +GVariant * +tp_channel_request_dup_hints (TpChannelRequest *self) +{ + const GHashTable *hints; + + g_return_val_if_fail (TP_IS_CHANNEL_REQUEST (self), NULL); + + hints = tp_channel_request_get_hints (self); + + if (hints == NULL) + return NULL; + + return _tp_asv_to_vardict (hints); +} diff --git a/telepathy-glib/channel-request.h b/telepathy-glib/channel-request.h index 85a9437..7fcbf325 100644 --- a/telepathy-glib/channel-request.h +++ b/telepathy-glib/channel-request.h @@ -96,6 +96,9 @@ const gchar * tp_channel_request_get_preferred_handler (TpChannelRequest *self); const GHashTable * tp_channel_request_get_hints (TpChannelRequest *self); +_TP_AVAILABLE_IN_UNRELEASED +GVariant *tp_channel_request_dup_hints (TpChannelRequest *self); + G_END_DECLS #include diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c index 5d83182..779a110 100644 --- a/tests/dbus/channel-request.c +++ b/tests/dbus/channel-request.c @@ -350,6 +350,7 @@ test_properties (Test *test, TpAccount *account; gint64 user_action_time; const gchar *handler; + GVariant *vardict; hints = tp_asv_new ("test", G_TYPE_STRING, "hi", NULL); @@ -402,6 +403,16 @@ test_properties (Test *test, 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, + NULL); + g_assert_cmpstr (tp_vardict_get_string (vardict, "test"), ==, "hi"); + g_variant_unref (vardict); } int -- 1.7.10.4