[next] telepathy-glib: TpSvcInterfaceSkeleton: Handle Get/Set property
Simon McVittie
smcv at kemper.freedesktop.org
Tue Apr 8 12:11:45 PDT 2014
Module: telepathy-glib
Branch: next
Commit: bc842c8f24c692932953f00ec8733f0fb59088f1
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=bc842c8f24c692932953f00ec8733f0fb59088f1
Author: Xavier Claessens <xavier.claessens at collabora.com>
Date: Fri Apr 4 17:54:17 2014 -0400
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
---
telepathy-glib/dbus.c | 6 +++
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 eaa719c..937944a 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 d4dbb5c..5fd9de2 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);
More information about the telepathy-commits
mailing list