diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2014-04-04 17:54:17 -0400 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-08 19:54:38 +0100 |
commit | bc842c8f24c692932953f00ec8733f0fb59088f1 (patch) | |
tree | a0f0d0e1a7126e97d69e7395680d04a985101382 | |
parent | 6f9cbe42977e608e3bac873f6cc29971998b2ff5 (diff) |
TpSvcInterfaceSkeleton: Handle Get/Set property
We prevent TpSvcDBusProperties interface to be registered so
GDBusConnection will handle that itself using skeleton's vtable.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77144
Reviewed-by: Simon McVittie
-rw-r--r-- | telepathy-glib/dbus.c | 6 | ||||
-rw-r--r-- | telepathy-glib/svc-interface-skeleton.c | 73 |
2 files changed, 76 insertions, 3 deletions
diff --git a/telepathy-glib/dbus.c b/telepathy-glib/dbus.c index eaa719c83..937944adc 100644 --- a/telepathy-glib/dbus.c +++ b/telepathy-glib/dbus.c @@ -41,6 +41,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/proxy.h> #include <telepathy-glib/sliced-gvalue.h> +#include <telepathy-glib/svc-generic.h> #include <telepathy-glib/svc-interface-skeleton-internal.h> #include <telepathy-glib/util.h> @@ -836,6 +837,11 @@ tp_dbus_connection_try_register_object (GDBusConnection *dbus_connection, continue; } + /* We don't want to export Properties interface, TpSvcInterfaceSkeleton + * will handle that itself. */ + if (iface == TP_TYPE_SVC_DBUS_PROPERTIES) + continue; + skeleton = _tp_svc_interface_skeleton_new (object, iface, iinfo); if (!g_dbus_interface_skeleton_export ( diff --git a/telepathy-glib/svc-interface-skeleton.c b/telepathy-glib/svc-interface-skeleton.c index d4dbb5c9f..5fd9de2d9 100644 --- a/telepathy-glib/svc-interface-skeleton.c +++ b/telepathy-glib/svc-interface-skeleton.c @@ -90,10 +90,73 @@ tp_svc_interface_skeleton_method_call (GDBusConnection *connection, g_object_unref (object); } +static GVariant * +tp_svc_interface_skeleton_get_property (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GError **error, + gpointer user_data) +{ + TpSvcInterfaceSkeleton *self = TP_SVC_INTERFACE_SKELETON (user_data); + GObject *object; + GValue value = G_VALUE_INIT; + GVariant *ret = NULL; + + DEBUG ("Get(%s.%s) on %s %p from %s", interface_name, property_name, + object_path, self, sender); + + object = g_weak_ref_get (&self->priv->object); + g_return_val_if_fail (object != NULL, NULL); + + if (tp_dbus_properties_mixin_get (object, interface_name, property_name, + &value, error)) + { + ret = dbus_g_value_build_g_variant (&value); + g_value_unset (&value); + } + + g_object_unref (object); + + return ret; +} + +static gboolean +tp_svc_interface_skeleton_set_property (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GVariant *variant, + GError **error, + gpointer user_data) +{ + TpSvcInterfaceSkeleton *self = TP_SVC_INTERFACE_SKELETON (user_data); + GObject *object; + GValue value = G_VALUE_INIT; + gboolean ret; + + DEBUG ("Set(%s.%s) on %s %p from %s", interface_name, property_name, + object_path, self, sender); + + object = g_weak_ref_get (&self->priv->object); + g_return_val_if_fail (object != NULL, FALSE); + + dbus_g_value_parse_g_variant (variant, &value); + ret = tp_dbus_properties_mixin_set (object, interface_name, property_name, + &value, error); + + g_value_unset (&value); + g_object_unref (object); + + return ret; +} + static GDBusInterfaceVTable vtable = { tp_svc_interface_skeleton_method_call, - NULL, - NULL + tp_svc_interface_skeleton_get_property, + tp_svc_interface_skeleton_set_property }; static GDBusInterfaceVTable * @@ -109,10 +172,14 @@ tp_svc_interface_skeleton_get_properties (GDBusInterfaceSkeleton *skel) GVariant *ret; GHashTable *asv; const gchar *iface_name = self->priv->iinfo->interface_info->name; + GObject *object; + + object = g_weak_ref_get (&self->priv->object); + g_return_val_if_fail (object != NULL, NULL); /* For now assume we have the TpDBusPropertiesMixin if we have * any properties at all. This never returns NULL. */ - asv = tp_dbus_properties_mixin_dup_all ((GObject *) self, iface_name); + asv = tp_dbus_properties_mixin_dup_all (object, iface_name); ret = g_variant_ref_sink (tp_asv_to_vardict (asv)); g_hash_table_unref (asv); |