cpw.gillux.detachablepurple: 916b38c7: Modified the purple_constructor_pack_pob...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Fri May 25 15:47:11 EDT 2012
----------------------------------------------------------------------
Revision: 916b38c70b2aa2f73c3d627dd51b1f31cb69d4fb
Parent: 8a1a8492fb4a53c9ee4f0379289ca9cc33bfc1fa
Author: gillux at soc.pidgin.im
Date: 05/25/12 14:18:38
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/916b38c70b2aa2f73c3d627dd51b1f31cb69d4fb
Changelog:
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.
Changes against parent 8a1a8492fb4a53c9ee4f0379289ca9cc33bfc1fa
patched libpurple/dbus/constructor.c
patched libpurple/dbus/constructor.h
-------------- next part --------------
============================================================
--- libpurple/dbus/constructor.c 25027943ec5e29fb50e0ed9eeb0190a18134f728
+++ libpurple/dbus/constructor.c 8fd4f72f72f3176239e9a3bc16ae5e5d47dd8d88
@@ -188,10 +188,10 @@ purple_constructor_new_proxy_object(GTyp
}
/* 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 @@ purple_constructor_pack_pobject_props(Pu
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 @@ purple_constructor_pack_pobject_props(Pu
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_crea
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. */
============================================================
--- libpurple/dbus/constructor.h 39f24ed4cea780acc66489e57db1b2379f87ff8b
+++ libpurple/dbus/constructor.h 7b165aeaadc4c82f70cd98963ddb28a68b5b4916
@@ -82,9 +82,10 @@ void purple_constructor_announce_pobject
* "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