/srv/mercurial-server/detachablepurple: 11ab45ab0d4d: Going mult...
Gilles Bedel
gillux at cpw.pidgin.im
Fri Jun 15 22:01:40 EDT 2012
Changeset: 11ab45ab0d4d0e7adbdc8ef3d88e0039913339ad
Author: Gilles Bedel <gillux at cpw.pidgin.im>
Date: 2012-05-20 13:35 +0000
Branch: cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/11ab45ab0d4d
Description:
Going multi-interface. Adapted PurpleConstructor's pack_pobject_properties()
function so that it packs all the properties of all the interfaces of the
given object.
diffstat:
libpurple/dbus/constructor.c | 44 ++++++++++++++++++++++++++++++++------------
1 files changed, 32 insertions(+), 12 deletions(-)
diffs (62 lines):
diff --git a/libpurple/dbus/constructor.c b/libpurple/dbus/constructor.c
--- a/libpurple/dbus/constructor.c
+++ b/libpurple/dbus/constructor.c
@@ -192,26 +192,46 @@
GVariantBuilder builder;
GParamSpec *pspec;
GVariant *prop;
+ GDBusInterfaceInfo *ifaceinfo;
GDBusPropertyInfo **props_info;
char *prop_name;
+ PurpleObjectClass *pobjclass = PURPLE_OBJECT_GET_CLASS(pobject);
+ GType type;
g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
- props_info = PURPLE_OBJECT_GET_CLASS(pobject)->dbus_ifaceinfo->properties;
- for (; *props_info; props_info++) {
- prop_name = (*props_info)->name;
- if (!prop_name)
+
+ /* Step from the most derived type to PurpleObject's direct child
+ * type and retreive each D-Bus property list. */
+ for (type = G_OBJECT_TYPE(pobject);
+ type != PURPLE_TYPE_OBJECT && type != 0;
+ type = g_type_parent(type))
+ {
+ ifaceinfo = g_datalist_id_get_data(&pobjclass->dbus_ifaceinfos,
+ g_type_qname(type));
+ if (!ifaceinfo)
continue;
- pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(pobject),
- prop_name);
- if (!pspec)
+ props_info = ifaceinfo->properties;
+ if (!props_info)
continue;
- prop = purple_object_get_dbus_property(pobject, prop_name);
- if (!prop)
- continue;
- prop = g_variant_new("(sv)", prop_name, prop);
- g_variant_builder_add_value(&builder, prop);
+ for (; *props_info; props_info++) {
+ prop_name = (*props_info)->name;
+ if (!prop_name)
+ continue;
+
+ pspec = g_object_class_find_property
+ (G_OBJECT_GET_CLASS(pobject), prop_name);
+ if (!pspec)
+ continue;
+
+ prop = purple_object_get_dbus_property
+ (pobject, prop_name);
+ if (!prop)
+ continue;
+ prop = g_variant_new("(sv)", prop_name, prop);
+ g_variant_builder_add_value(&builder, prop);
+ }
}
return g_variant_builder_end(&builder);
}
More information about the Commits
mailing list