/srv/mercurial-server/detachablepurple: e463ae463cba: Rewritten ...
Gilles Bedel
gillux at cpw.pidgin.im
Fri Jun 15 22:01:44 EDT 2012
Changeset: e463ae463cbaf688b5caa394883108ade884a3a6
Author: Gilles Bedel <gillux at cpw.pidgin.im>
Date: 2012-05-20 15:47 +0000
Branch: cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/e463ae463cba
Description:
Rewritten the D-Bus code of PurpleChat,
according to the new gdbus-based API.
diffstat:
libpurple/chat.c | 8 +++++---
libpurple/dbus/chat.c | 43 ++++++++++++++++++++++++-------------------
libpurple/dbus/chat.h | 10 ++--------
3 files changed, 31 insertions(+), 30 deletions(-)
diffs (127 lines):
diff --git a/libpurple/chat.c b/libpurple/chat.c
--- a/libpurple/chat.c
+++ b/libpurple/chat.c
@@ -157,7 +157,8 @@
g_return_if_fail(PURPLE_IS_CHAT(chat));
- PURPLE_DBUS_REMOTELY_SET_PROP(chat, g_value_set_string, G_TYPE_STRING, PROP_ALIAS_S, alias);
+ purple_object_set_prop_on_dbus(PURPLE_OBJECT(chat),
+ PROP_ALIAS_S, &alias);
priv = PURPLE_CHAT_GET_PRIVATE(chat);
@@ -303,7 +304,8 @@
PROP_ALIAS_S, alias,
PROP_COMPONENTS_S, components,
NULL);
- purple_chat_dbus_init(chat);
+ /* Export this new object on D-Bus and propagate any property change. */
+ purple_object_dbus_init(chat, TRUE);
return chat;
}
@@ -394,7 +396,7 @@
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
);
- purple_chat_class_dbus_init();
+ purple_chat_class_dbus_init(klass);
}
PurpleGroup *
diff --git a/libpurple/dbus/chat.c b/libpurple/dbus/chat.c
--- a/libpurple/dbus/chat.c
+++ b/libpurple/dbus/chat.c
@@ -23,42 +23,47 @@
#include "core.h"
#include "chat.h"
#include "dbus/chat.h"
-#include "dbus/chat-client.h"
-#include "dbus/chat-server.h"
+#include "dbus/chat.xml.h"
+#include "dbus/constructor.h"
#include "dbus-purple.h"
#include "dbus-server.h"
+#include "pobject.h"
static char *
-purple_chat_build_dbus_path(void)
+purple_chat_build_dbus_path(PurpleObject *pobject)
{
static unsigned int chat_id = 0;
- /* 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;
-
/* There is nothing to identify chats but this internal id. */
return g_strdup_printf(DBUS_CHAT_PATH "/%u", chat_id++);
}
-void
-purple_chat_class_dbus_init(void)
+static void
+purple_chat_dbus_init(gpointer object)
{
+ PurpleChat *chat = PURPLE_CHAT(object);
+ PurpleObject *pobject = PURPLE_OBJECT(chat);
+
+ /* Publish/listen for the object on the bus. */
+ purple_dbus_connect_object(chat);
+
if (purple_core_is_daemon_mode()) {
- /* Install method introspection data */
- purple_object_type_install_dbus_infos(PURPLE_TYPE_CHAT,
- &dbus_glib_DBUS_purple_chat_object_info);
+ /* Tell the clients about this new chat. */
+ purple_constructor_announce_pobject_creation(pobject);
}
}
void
-purple_chat_dbus_init(PurpleChat *chat)
+purple_chat_class_dbus_init(PurpleChatClass *klass)
{
- char* dbus_path;
+ PurpleObjectClass *pobjclass = PURPLE_OBJECT_CLASS(klass);
- dbus_path = purple_chat_build_dbus_path();
- purple_object_install_dbus_infos(PURPLE_OBJECT(chat),
- DBUS_CHAT_INTERFACE, dbus_path);
- g_free(dbus_path);
+ /* Register our interface. */
+ purple_object_class_register_dbus_iface(pobjclass, PURPLE_TYPE_CHAT,
+ &purple_chat_interface_info);
+ pobjclass->dbus_init = purple_chat_dbus_init;
+ if (purple_core_is_daemon_mode()) {
+ /* Only the daemon has authority on PurpleChat dbus names. */
+ pobjclass->build_dbus_path = purple_chat_build_dbus_path;
+ }
}
diff --git a/libpurple/dbus/chat.h b/libpurple/dbus/chat.h
--- a/libpurple/dbus/chat.h
+++ b/libpurple/dbus/chat.h
@@ -28,19 +28,13 @@
/**
* Initialize the dbus data of the chat class.
*/
-void purple_chat_class_dbus_init(void);
-
-/**
- * Initialize the dbus data of a new chat.
- */
-void purple_chat_dbus_init(PurpleChat *chat);
+void purple_chat_class_dbus_init(PurpleChatClass *klass);
G_END_DECLS
#else /* !HAVE_DBUS */
-#define purple_chat_class_dbus_init() ((void)0)
-#define purple_chat_dbus_init(chat) ((void)0)
+#define purple_chat_class_dbus_init(klass) ((void)0)
#endif /* HAVE_DBUS */
#endif /* _PURPLE_DBUS_CHAT_H */
More information about the Commits
mailing list