cpw.gillux.detachablepurple: 0e42fd64: Rewritten the D-Bus code of PurpleChat,
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Sun May 20 13:20:56 EDT 2012
----------------------------------------------------------------------
Revision: 0e42fd6430d516e4c65abe0ea0294db1a03d9509
Parent: 8b2a57abea7719acc42d2309265faca15c46c495
Author: gillux at soc.pidgin.im
Date: 05/20/12 11:47:00
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/0e42fd6430d516e4c65abe0ea0294db1a03d9509
Changelog:
Rewritten the D-Bus code of PurpleChat,
according to the new gdbus-based API.
Changes against parent 8b2a57abea7719acc42d2309265faca15c46c495
patched libpurple/chat.c
patched libpurple/dbus/chat.c
patched libpurple/dbus/chat.h
-------------- next part --------------
============================================================
--- libpurple/chat.c 4b54e8c762f2344f3d102532fc02409f6e1eb22a
+++ libpurple/chat.c 86e234a684797a2c2b6c5a99a108a2d743bb935d
@@ -157,7 +157,8 @@ void purple_chat_set_alias(PurpleChat *c
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 @@ PurpleChat *purple_chat_new(PurpleAccoun
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 @@ purple_chat_class_init(PurpleChatClass *
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
);
- purple_chat_class_dbus_init();
+ purple_chat_class_dbus_init(klass);
}
PurpleGroup *
============================================================
--- libpurple/dbus/chat.c 4d7858d2e9b56671efa5802167f8a846f89f3c9e
+++ libpurple/dbus/chat.c 0764a2b82db053fafd980d3966c6d838f8dbe560
@@ -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;
+ }
}
============================================================
--- libpurple/dbus/chat.h 6f2769e6c313c82dba87757226a74701a63b54de
+++ libpurple/dbus/chat.h 9f7e2b4e28e04f40135026821ff34310b8d59c6f
@@ -28,19 +28,13 @@ G_BEGIN_DECLS
/**
* Initialize the dbus data of the chat class.
*/
-void purple_chat_class_dbus_init(void);
+void purple_chat_class_dbus_init(PurpleChatClass *klass);
-/**
- * Initialize the dbus data of a new chat.
- */
-void purple_chat_dbus_init(PurpleChat *chat);
-
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