From 225f935a136c20c7d2f2af657840d5782a3b09f2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Oct 2012 15:58:15 +0100 Subject: [PATCH 3/4] _tp_dbus_properties_mixin_get_all: expose to internal code The self-handle test can't exercise certain situations without this, except by pretending to be an obsolete CM, which means we don't test the non-obsolete code path properly. Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55666 --- telepathy-glib/dbus-properties-mixin-internal.h | 34 +++++++++++++++++ telepathy-glib/dbus-properties-mixin.c | 46 +++++++++++++++++------ 2 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 telepathy-glib/dbus-properties-mixin-internal.h diff --git a/telepathy-glib/dbus-properties-mixin-internal.h b/telepathy-glib/dbus-properties-mixin-internal.h new file mode 100644 index 0000000..344d151 --- /dev/null +++ b/telepathy-glib/dbus-properties-mixin-internal.h @@ -0,0 +1,34 @@ +/**/ +/* + * dbus-properties-mixin-internal.h - D-Bus core Properties - internal API + * Copyright (C) 2008-2012 Collabora Ltd. + * Copyright (C) 2008 Nokia Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __TP_DBUS_PROPERTIES_MIXIN_INTERNAL_H__ +#define __TP_DBUS_PROPERTIES_MIXIN_INTERNAL_H__ + +#include + +G_BEGIN_DECLS + +GHashTable *_tp_dbus_properties_mixin_get_all (GObject *self, + const gchar *interface_name); + +G_END_DECLS + +#endif /* #ifndef __TP_DBUS_PROPERTIES_MIXIN_H__ */ diff --git a/telepathy-glib/dbus-properties-mixin.c b/telepathy-glib/dbus-properties-mixin.c index 5ae17cd..6e26ab2 100644 --- a/telepathy-glib/dbus-properties-mixin.c +++ b/telepathy-glib/dbus-properties-mixin.c @@ -21,6 +21,7 @@ #include "config.h" #include +#include "telepathy-glib/dbus-properties-mixin-internal.h" #include #include @@ -1147,12 +1148,22 @@ _tp_dbus_properties_mixin_get (TpSvcDBusProperties *iface, } } -static void -_tp_dbus_properties_mixin_get_all (TpSvcDBusProperties *iface, - const gchar *interface_name, - DBusGMethodInvocation *context) +/* + * _tp_dbus_properties_mixin_get_all: + * @self: an object with this mixin + * @interface_name: a D-Bus interface name + * + * Get all the properties of a particular interface. This implementation + * never returns an error: it will return an empty map if the interface + * is unknown. + * + * Returns: (transfer container) (element-type utf8 GObject.Value): a map + * from property name (without the interface name) to value + */ +GHashTable * +_tp_dbus_properties_mixin_get_all (GObject *self, + const gchar *interface_name) { - GObject *self = G_OBJECT (iface); TpDBusPropertiesMixinIfaceImpl *iface_impl; TpDBusPropertiesMixinIfaceInfo *iface_info; TpDBusPropertiesMixinPropImpl *prop_impl; @@ -1164,7 +1175,7 @@ _tp_dbus_properties_mixin_get_all (TpSvcDBusProperties *iface, interface_name); if (iface_impl == NULL || iface_impl->getter == NULL) - goto out; /* no properties, but we need to return that */ + return values; iface_info = iface_impl->mixin_priv; @@ -1184,7 +1195,17 @@ _tp_dbus_properties_mixin_get_all (TpSvcDBusProperties *iface, g_hash_table_insert (values, (gchar *) prop_impl->name, value); } -out: + return values; +} + +static void +_tp_dbus_properties_mixin_get_all_dbus (TpSvcDBusProperties *iface, + const gchar *interface_name, + DBusGMethodInvocation *context) +{ + GHashTable *values = _tp_dbus_properties_mixin_get_all (G_OBJECT (iface), + interface_name); + tp_svc_dbus_properties_return_from_get_all (context, values); g_hash_table_unref (values); } @@ -1329,10 +1350,11 @@ tp_dbus_properties_mixin_iface_init (gpointer g_iface, { TpSvcDBusPropertiesClass *cls = g_iface; -#define IMPLEMENT(x) \ - tp_svc_dbus_properties_implement_##x (cls, _tp_dbus_properties_mixin_##x) - IMPLEMENT (get); - IMPLEMENT (get_all); - IMPLEMENT (set); +#define IMPLEMENT(x, suffix) \ + tp_svc_dbus_properties_implement_##x (cls, \ + _tp_dbus_properties_mixin_##x##suffix) + IMPLEMENT (get,); + IMPLEMENT (get_all,_dbus); + IMPLEMENT (set,); #undef IMPLEMENT } -- 1.7.10.4