/srv/mercurial-server/detachablepurple: a12062f5b5aa: Modified t...
Gilles Bedel
gillux at cpw.pidgin.im
Fri Jun 15 22:01:49 EDT 2012
Changeset: a12062f5b5aa02900d44c69245985b9d73e4ca8e
Author: Gilles Bedel <gillux at cpw.pidgin.im>
Date: 2012-05-25 18:18 +0000
Branch: cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/a12062f5b5aa
Description:
Modified the purple_constructor_pack_pobject_props() function so that
it can be properly used with purple_object_emit_dbus_signal() and its
variable parameters. Actually g_variant_new("a...", ...) expects a
GVariantBuilder, not a GVariant.
diffstat:
libpurple/dbus/constructor.c | 23 +++++++++++++----------
libpurple/dbus/constructor.h | 5 +++--
2 files changed, 16 insertions(+), 12 deletions(-)
diffs (85 lines):
diff --git a/libpurple/dbus/constructor.c b/libpurple/dbus/constructor.c
--- a/libpurple/dbus/constructor.c
+++ b/libpurple/dbus/constructor.c
@@ -188,10 +188,10 @@
}
/* Packs all the exported properties of a PurpleObject into an a(sv) GVariant. */
-GVariant *
+GVariantBuilder *
purple_constructor_pack_pobject_props(PurpleObject *pobject)
{
- GVariantBuilder builder;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(sv)"));
GParamSpec *pspec;
GVariant *prop;
GDBusInterfaceInfo *ifaceinfo;
@@ -200,8 +200,6 @@
PurpleObjectClass *pobjclass = PURPLE_OBJECT_GET_CLASS(pobject);
GType type;
- g_variant_builder_init(&builder, (const GVariantType *) "a(sv)");
-
/* 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);
@@ -232,19 +230,22 @@
if (!prop)
continue;
prop = g_variant_new("(sv)", prop_name, prop);
- g_variant_builder_add_value(&builder, prop);
+ g_variant_builder_add_value(builder, prop);
}
}
- return g_variant_builder_end(&builder);
+ return builder;
}
GVariant *
purple_constructor_pack_pobject(gpointer obj)
{
PurpleObject *pobj = PURPLE_OBJECT(obj);
- return g_variant_new("(o at a(sv))",
- purple_object_get_dbus_path(pobj),
- purple_constructor_pack_pobject_props(pobj));
+ GVariantBuilder *props = purple_constructor_pack_pobject_props(pobj);
+ GVariant *pobject = g_variant_new("(oa(sv))",
+ purple_object_get_dbus_path(pobj),
+ props);
+ g_variant_builder_unref(props);
+ return pobject;
}
static void
@@ -416,12 +417,14 @@
purple_constructor_announce_pobject_creation(PurpleObject *pobj)
{
PurpleConstructor *con = purple_constructor_get_instance();
+ GVariantBuilder *props = purple_constructor_pack_pobject_props(pobj);
purple_object_emit_dbus_signal(PURPLE_OBJECT(con),
purple_constructor_interface_info.name,
"PurpleObjectCreated",
G_OBJECT_TYPE_NAME(pobj),
purple_object_get_dbus_path(pobj),
- purple_constructor_pack_pobject_props(pobj));
+ props);
+ g_variant_builder_unref(props);
}
/* "PurpleObjectCreated" signal handler. */
diff --git a/libpurple/dbus/constructor.h b/libpurple/dbus/constructor.h
--- a/libpurple/dbus/constructor.h
+++ b/libpurple/dbus/constructor.h
@@ -82,9 +82,10 @@
* "a(sv)" GVariant ("s" is the property name, "v" is the property value).
*
* @param pobject A PurpleObject.
- * @return An "a(sv)" GVariant containing the properties.
+ * @return An "a(sv)" GVariantBuilder containing the properties. Must be freed
+ * with g_variant_builder_unref()
*/
-GVariant *purple_constructor_pack_pobject_props(PurpleObject *pobject);
+GVariantBuilder *purple_constructor_pack_pobject_props(PurpleObject *pobject);
/**
* Packs a PurpleObject instance into an "(oa(sv))" GVariant. "o" is the
More information about the Commits
mailing list