diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-09-19 15:39:14 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-09-26 13:44:39 +0200 |
commit | 426d2e6f389b5a691b6eb03a0a740bcbef173749 (patch) | |
tree | 3f29198af70a568ec7411b57fb6c6916a736dbc1 /telepathy-glib/stream-tube-channel.c | |
parent | d7a526defeb0341805f739818e419c08cd47cf2a (diff) | |
download | telepathy-glib-426d2e6f389b5a691b6eb03a0a740bcbef173749.tar.gz |
TpStreamTubeChannel: add parameters-vardict and its getter
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55095
https://bugs.freedesktop.org/show_bug.cgi?id=55024
Diffstat (limited to 'telepathy-glib/stream-tube-channel.c')
-rw-r--r-- | telepathy-glib/stream-tube-channel.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/telepathy-glib/stream-tube-channel.c b/telepathy-glib/stream-tube-channel.c index 171fcdbdf..013997813 100644 --- a/telepathy-glib/stream-tube-channel.c +++ b/telepathy-glib/stream-tube-channel.c @@ -59,6 +59,7 @@ #include <telepathy-glib/stream-tube-connection-internal.h> #include <telepathy-glib/util-internal.h> #include <telepathy-glib/util.h> +#include <telepathy-glib/variant-util-internal.h> #define DEBUG_FLAG TP_DEBUG_CHANNEL #include "telepathy-glib/channel-internal.h" @@ -177,7 +178,8 @@ struct _TpStreamTubeChannelPrivate enum { PROP_SERVICE = 1, - PROP_PARAMETERS + PROP_PARAMETERS, + PROP_PARAMETERS_VARDICT }; enum /* signals */ @@ -289,6 +291,11 @@ tp_stream_tube_channel_get_property (GObject *object, g_value_set_boxed (value, self->priv->parameters); break; + case PROP_PARAMETERS_VARDICT: + g_value_take_variant (value, + tp_stream_tube_channel_dup_parameters_vardict (self)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -431,6 +438,11 @@ tp_stream_tube_channel_class_init (TpStreamTubeChannelClass *klass) * * Will be %NULL for outgoing tubes until the tube has been offered. * + * In high-level language bindings, use + * #TpStreamTubeChannel:parameters-vardict or + * tp_stream_tube_channel_dup_parameters_vardict() to get the same + * information in a more convenient format. + * * Since: 0.13.2 */ param_spec = g_param_spec_boxed ("parameters", "Parameters", @@ -440,6 +452,22 @@ tp_stream_tube_channel_class_init (TpStreamTubeChannelClass *klass) g_object_class_install_property (gobject_class, PROP_PARAMETERS, param_spec); /** + * TpStreamTubeChannel:parameters-vardict: + * + * A %G_VARIANT_TYPE_VARDICT representing the parameters of the tube. + * + * Will be %NULL for outgoing tubes until the tube has been offered. + * + * Since: 0.UNRELEASED + */ + param_spec = g_param_spec_variant ("parameters-vardict", "Parameters", + "The parameters of the stream tube", + G_VARIANT_TYPE_VARDICT, NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (gobject_class, PROP_PARAMETERS_VARDICT, + param_spec); + + /** * TpStreamTubeChannel::incoming: * @self: the #TpStreamTubeChannel * @tube_connection: the #TpStreamTubeConnection for the connection @@ -1250,6 +1278,7 @@ _offer_with_address (TpStreamTubeChannel *self, self->priv->parameters = tp_asv_new (NULL, NULL); g_object_notify (G_OBJECT (self), "parameters"); + g_object_notify (G_OBJECT (self), "parameters-vardict"); /* Call Offer */ tp_cli_channel_type_stream_tube_call_offer (TP_CHANNEL (self), -1, @@ -1552,3 +1581,33 @@ tp_stream_tube_channel_get_parameters (TpStreamTubeChannel *self) { return self->priv->parameters; } + +/** + * tp_stream_tube_channel_dup_parameters_vardict: + * @self: a #TpStreamTubeChannel + * + * 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_stream_tube_channel_dup_parameters_vardict (TpStreamTubeChannel *self) +{ + g_return_val_if_fail (TP_IS_STREAM_TUBE_CHANNEL (self), NULL); + + if (self->priv->parameters == NULL) + return NULL; + + return _tp_asv_to_vardict (self->priv->parameters); +} |