diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-10-05 15:58:15 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-10-08 10:51:35 +0100 |
commit | 99990babb32af5ebcf6912bb533ac001b12b085d (patch) | |
tree | e37c9aa327c409cabf035f2f3fc65fb8d65c91ef | |
parent | 70cf7cfcc62418264e3aeb0c346857440a9dfd8f (diff) | |
download | telepathy-glib-99990babb32af5ebcf6912bb533ac001b12b085d.tar.gz |
_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 <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55666
Reviewed-by: Xavier Claessens <xavier.claessens@collabora.co.uk>
-rw-r--r-- | telepathy-glib/dbus-properties-mixin-internal.h | 34 | ||||
-rw-r--r-- | telepathy-glib/dbus-properties-mixin.c | 46 |
2 files changed, 68 insertions, 12 deletions
diff --git a/telepathy-glib/dbus-properties-mixin-internal.h b/telepathy-glib/dbus-properties-mixin-internal.h new file mode 100644 index 000000000..344d15174 --- /dev/null +++ b/telepathy-glib/dbus-properties-mixin-internal.h @@ -0,0 +1,34 @@ +/*<private_header>*/ +/* + * 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 <telepathy-glib/dbus-properties-mixin.h> + +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 5ae17cd08..6e26ab23d 100644 --- a/telepathy-glib/dbus-properties-mixin.c +++ b/telepathy-glib/dbus-properties-mixin.c @@ -21,6 +21,7 @@ #include "config.h" #include <telepathy-glib/dbus-properties-mixin.h> +#include "telepathy-glib/dbus-properties-mixin-internal.h" #include <telepathy-glib/errors.h> #include <telepathy-glib/svc-generic.h> @@ -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 } |