/srv/mercurial-server/detachablepurple: 8439f5f4b318: Make pack_...
Gilles Bedel
gillux at cpw.pidgin.im
Fri Jun 15 22:01:43 EDT 2012
Changeset: 8439f5f4b318502d5ed98eaa26a1cf2678fb2073
Author: Gilles Bedel <gillux at cpw.pidgin.im>
Date: 2012-05-20 15:16 +0000
Branch: cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/8439f5f4b318
Description:
Make pack_pobject_properties() and pack_pobject() public,
so that others may easily send PurpleObjects on D-Bus.
diffstat:
libpurple/dbus/constructor.c | 17 +++++++++--------
libpurple/dbus/constructor.h | 20 ++++++++++++++++++++
2 files changed, 29 insertions(+), 8 deletions(-)
diffs (89 lines):
diff --git a/libpurple/dbus/constructor.c b/libpurple/dbus/constructor.c
--- a/libpurple/dbus/constructor.c
+++ b/libpurple/dbus/constructor.c
@@ -192,8 +192,8 @@
}
/* Packs all the exported properties of a PurpleObject into an a(sv) GVariant. */
-static GVariant*
-pack_pobject_properties(PurpleObject *pobject)
+GVariant *
+purple_constructor_pack_pobject_props(PurpleObject *pobject)
{
GVariantBuilder builder;
GParamSpec *pspec;
@@ -242,13 +242,13 @@
return g_variant_builder_end(&builder);
}
-static GVariant*
-pack_pobject(gpointer obj)
+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),
- pack_pobject_properties(pobj));
+ purple_constructor_pack_pobject_props(pobj));
}
static gpointer
@@ -307,7 +307,8 @@
g_variant_builder_init(&builder, (const GVariantType *) "a(oa(sv))");
while (all) {
PurpleAccount *account = all->data;
- g_variant_builder_add_value(&builder, pack_pobject(account));
+ g_variant_builder_add_value
+ (&builder, purple_constructor_pack_pobject(account));
all = all->next;
}
return g_variant_new("(@a(oa(sv)))", g_variant_builder_end(&builder));
@@ -343,7 +344,7 @@
params = g_variant_new("(so at a(sv))",
G_OBJECT_TYPE_NAME(pobj),
purple_object_get_dbus_path(pobj),
- pack_pobject_properties(pobj));
+ purple_constructor_pack_pobject_props(pobj));
purple_object_emit_dbus_signal(PURPLE_OBJECT(con),
purple_constructor_interface_info.name,
"PurpleObjectCreated", params, NULL);
@@ -379,7 +380,7 @@
{
PurpleAccount *account;
account = purple_account_new(username, protocol_id);
- return pack_pobject(account);
+ return purple_constructor_pack_pobject(account);
}
PurpleAccount *
diff --git a/libpurple/dbus/constructor.h b/libpurple/dbus/constructor.h
--- a/libpurple/dbus/constructor.h
+++ b/libpurple/dbus/constructor.h
@@ -67,6 +67,26 @@
void purple_constructor_announce_pobject_creation(PurpleObject *pobj);
/**
+ * Packs all the exported properties of all the D-Bus interfaces added with
+ * purple_object_class_register_dbus_iface() of the PurpleObject into an
+ * "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.
+ */
+GVariant *purple_constructor_pack_pobject_props(PurpleObject *pobject);
+
+/**
+ * Packs a PurpleObject instance into an "(oa(sv))" GVariant. "o" is the
+ * D-Bus path of of the object, and "a(sv)" is its properties packed with
+ * purple_constructor_pack_pobject_props().
+ *
+ * @param pobject A PurpleObject instance.
+ * @return An "(oa(sv))" GVariant defining the object.
+ */
+GVariant *purple_constructor_pack_pobject(gpointer pobject);
+
+/**
* What's get actually called when you call NewAccount over dbus.
*/
gboolean DBUS_purple_constructor_new_account(PurpleConstructor *con, gchar* username, gchar* protocol_id, gchar **account_path, GError** error);
More information about the Commits
mailing list