cpw.gillux.detachablepurple: 2898899e: Rewritten the D-Bus code of PurpleGroup,
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Sun May 20 13:21:10 EDT 2012
----------------------------------------------------------------------
Revision: 2898899e908498f21ddbfc829c4e9181e72feec9
Parent: d38da818f337b2f561158a1253c90daa414d53be
Author: gillux at soc.pidgin.im
Date: 05/20/12 11:50:32
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/2898899e908498f21ddbfc829c4e9181e72feec9
Changelog:
Rewritten the D-Bus code of PurpleGroup,
according to the new gdbus-based API.
Changes against parent d38da818f337b2f561158a1253c90daa414d53be
patched libpurple/dbus/group.c
patched libpurple/dbus/group.h
patched libpurple/group.c
-------------- next part --------------
============================================================
--- libpurple/group.c 5a9c00e357a22ca6d5e33e5efcfc18670a0452b9
+++ libpurple/group.c cb72a8250ec2456af6abdf8f697071cfa50d4fba
@@ -299,7 +299,8 @@ purple_group_set_name(PurpleGroup *group
g_return_if_fail(group != NULL);
- PURPLE_DBUS_REMOTELY_SET_PROP(group, g_value_set_string, G_TYPE_STRING, PROP_NAME_S, name);
+ purple_object_set_prop_on_dbus(PURPLE_OBJECT(group),
+ PROP_NAME_S, &name);
priv = PURPLE_GROUP_GET_PRIVATE(group);
gname = purple_utf8_strip_unprintables(name);
@@ -330,8 +331,10 @@ PurpleGroup *purple_group_new(const char
group = g_object_new(PURPLE_TYPE_GROUP,
PROP_NAME_S, name,
NULL);
- purple_group_dbus_init(group, name);
+ /* Export this new object on D-Bus and propagate any property change. */
+ purple_object_dbus_init(group, TRUE);
+
g_signal_emit_by_name(G_OBJECT(group), "new");
return group;
@@ -427,7 +430,7 @@ purple_group_class_init(PurpleGroupClass
G_PARAM_READWRITE)
);
- purple_group_class_dbus_init();
+ purple_group_class_dbus_init(klass);
}
static void
============================================================
--- libpurple/dbus/group.c 6b6d688beec045fb42e9f93f9b840eae6169b798
+++ libpurple/dbus/group.c 8e9d13eecf23ad63371390e8250c9b85c4f62b57
@@ -21,24 +21,22 @@
#include "internal.h"
#include "core.h"
-#include "group.h"
+#include "dbus/constructor.h"
#include "dbus/group.h"
-#include "dbus/group-client.h"
-#include "dbus/group-server.h"
+#include "dbus/group.xml.h"
#include "dbus-purple.h"
#include "dbus-server.h"
+#include "pobject.h"
static char *
-purple_group_build_dbus_path(const char *name)
+purple_group_build_dbus_path(PurpleObject *pobject)
{
static unsigned int group_id = 0;
+ const char *name;
gchar *path;
gchar *name_valid;
- /* In remote mode we have no way to build the object path.
- * We will set it later. */
- if (purple_core_is_remote_mode())
- return NULL;
+ name = purple_group_get_name(PURPLE_GROUP(pobject));
/* Group names are unique but they can change, whereas dbus path names
* can't. So we use an id, with the group name appended, to make it
@@ -50,23 +48,34 @@ purple_group_build_dbus_path(const char
return path;
}
-void
-purple_group_class_dbus_init(void)
+static void
+purple_group_dbus_init(gpointer object)
{
+ PurpleGroup *group = PURPLE_GROUP(object);
+ PurpleObject *pobject = PURPLE_OBJECT(group);
+
+ /* Publish/listen for the object on the bus. */
+ purple_dbus_connect_object(group);
+
if (purple_core_is_daemon_mode()) {
- /* Install method introspection data */
- purple_object_type_install_dbus_infos(PURPLE_TYPE_GROUP,
- &dbus_glib_DBUS_purple_group_object_info);
+ /* Tell the clients about this new group. */
+ purple_constructor_announce_pobject_creation(pobject);
+ } else if (purple_core_is_remote_mode()) {
+ g_signal_emit_by_name(G_OBJECT(group), "new");
}
}
void
-purple_group_dbus_init(PurpleGroup *group, const char *name)
+purple_group_class_dbus_init(PurpleGroupClass *klass)
{
- char* dbus_path;
+ PurpleObjectClass *pobjclass = PURPLE_OBJECT_CLASS(klass);
- dbus_path = purple_group_build_dbus_path(name);
- purple_object_install_dbus_infos(PURPLE_OBJECT(group),
- DBUS_GROUP_INTERFACE, dbus_path);
- g_free(dbus_path);
+ /* Register our interface. */
+ purple_object_class_register_dbus_iface(pobjclass, PURPLE_TYPE_GROUP,
+ &purple_group_interface_info);
+ pobjclass->dbus_init = purple_group_dbus_init;
+ if (purple_core_is_daemon_mode()) {
+ /* Only the daemon has authority on PurpleGroup dbus names. */
+ pobjclass->build_dbus_path = purple_group_build_dbus_path;
+ }
}
============================================================
--- libpurple/dbus/group.h 770a57cd0f602c1c37b0f08375902df5cddcabec
+++ libpurple/dbus/group.h 4da7f2581da5a2d8f324d38532df7c2a89485e20
@@ -28,19 +28,13 @@ G_BEGIN_DECLS
/**
* Initialize the dbus data of the group class.
*/
-void purple_group_class_dbus_init(void);
+void purple_group_class_dbus_init(PurpleGroupClass *klass);
-/**
- * Initialize the dbus data of a new group.
- */
-void purple_group_dbus_init(PurpleGroup *group, const char *name);
-
G_END_DECLS
#else /* !HAVE_DBUS */
-#define purple_group_class_dbus_init() ((void)0)
-#define purple_group_dbus_init(group, name) ((void)0)
+#define purple_group_class_dbus_init(klass) ((void)0)
#endif /* HAVE_DBUS */
#endif /* _PURPLE_DBUS_GROUP_H */
More information about the Commits
mailing list