cpw.gillux.detachablepurple: d38da818: Rewritten the D-Bus code of PurpleContac...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Sun May 20 13:22:01 EDT 2012


----------------------------------------------------------------------
Revision: d38da818f337b2f561158a1253c90daa414d53be
Parent:   0e42fd6430d516e4c65abe0ea0294db1a03d9509
Author:   gillux at soc.pidgin.im
Date:     05/20/12 11:48:32
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/d38da818f337b2f561158a1253c90daa414d53be

Changelog: 

Rewritten the D-Bus code of PurpleContact,
according to the new gdbus-based API.

Changes against parent 0e42fd6430d516e4c65abe0ea0294db1a03d9509

  patched  libpurple/contact.c
  patched  libpurple/dbus/contact.c
  patched  libpurple/dbus/contact.h

-------------- next part --------------
============================================================
--- libpurple/contact.c	abeb6ea293d53e1d2c142de33fab1bbf28e5ca88
+++ libpurple/contact.c	3394d461038dc911ae16f7c6412819359c6e3239
@@ -212,7 +212,8 @@ PurpleContact *purple_contact_new()
 	PurpleContact *contact;
 
 	contact = g_object_new(PURPLE_TYPE_CONTACT, NULL);
-	purple_contact_dbus_init(contact);
+	/* Export this new object on D-Bus and propagate any property change. */
+	purple_object_dbus_init(contact, TRUE);
 
 	return contact;
 }
@@ -512,7 +513,7 @@ purple_contact_class_init(PurpleContactC
 	parent_class = g_type_class_peek_parent(klass);
 	obj_class->finalize = purple_contact_finalize;
 
-	purple_contact_class_dbus_init();
+	purple_contact_class_dbus_init(klass);
 }
 
 static void
============================================================
--- libpurple/dbus/contact.c	85b147c710ede1139ed0bd32f39c0c2ca307475e
+++ libpurple/dbus/contact.c	84e050d4f165b3db7ef436b0a1878a16920150ea
@@ -21,45 +21,46 @@
 
 #include "internal.h"
 #include "core.h"
-#include "contact.h"
+#include "dbus/constructor.h"
 #include "dbus/contact.h"
-#include "dbus/contact-client.h"
-#include "dbus/contact-server.h"
+#include "dbus/contact.xml.h"
 #include "dbus-purple.h"
 #include "dbus-server.h"
+#include "pobject.h"
 
 static char *
-purple_contact_build_dbus_path(void)
+purple_contact_build_dbus_path(PurpleObject *pobj)
 {
 	static unsigned int contact_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;
-
 	/* Contacts have nothing unique nor that identify themselves
 	 * at the time they are created. So we use a poor id. */
 	return g_strdup_printf(DBUS_CONTACT_PATH "/%u", contact_id++);
 }
 
-void
-purple_contact_class_dbus_init(void)
+static void
+purple_contact_dbus_init(gpointer object)
 {
+	PurpleContact *contact = PURPLE_CONTACT(object);
+	PurpleObject *pobject = PURPLE_OBJECT(contact);
+
 	if (purple_core_is_daemon_mode()) {
-		/* Install method introspection data */
-		purple_object_type_install_dbus_infos(PURPLE_TYPE_CONTACT,
-				&dbus_glib_DBUS_purple_contact_object_info);
+		/* Tell the clients about this new contact. */
+		purple_constructor_announce_pobject_creation(pobject);
 	}
 }
 
 void
-purple_contact_dbus_init(PurpleContact *contact)
+purple_contact_class_dbus_init(PurpleContactClass *klass)
 {
-	char* dbus_path;
+	PurpleObjectClass *pobjclass = PURPLE_OBJECT_CLASS(klass);
 
-	dbus_path = purple_contact_build_dbus_path();
-	purple_object_install_dbus_infos(PURPLE_OBJECT(contact),
-					DBUS_CONTACT_INTERFACE, dbus_path);
-	g_free(dbus_path);	
+	/* Register our interface. */
+	purple_object_class_register_dbus_iface(pobjclass, PURPLE_TYPE_CONTACT,
+	                                       &purple_contact_interface_info);
+	pobjclass->dbus_init = purple_contact_dbus_init;
+	if (purple_core_is_daemon_mode()) {
+		/* Only the daemon has authority on PurpleContact dbus names. */
+		pobjclass->build_dbus_path = purple_contact_build_dbus_path;
+	}
 }
============================================================
--- libpurple/dbus/contact.h	d5ab2d53ff0e61c9f96d15f6fb325dfa37f49274
+++ libpurple/dbus/contact.h	becad50f5b2fceb32de31cb2a28b4953d7f3dc68
@@ -28,19 +28,13 @@ G_BEGIN_DECLS
 /**
  * Initialize the dbus data of the contact class.
  */
-void purple_contact_class_dbus_init(void);
+void purple_contact_class_dbus_init(PurpleContactClass *klass);
 
-/**
- * Initialize the dbus data of a new contact.
- */
-void purple_contact_dbus_init(PurpleContact *contact);
-
 G_END_DECLS
 
 #else /* !HAVE_DBUS */
 
-#define purple_contact_class_dbus_init()                            ((void)0)
-#define purple_contact_dbus_init(contact)                           ((void)0)
+#define purple_contact_class_dbus_init(klass)                       ((void)0)
 
 #endif /* HAVE_DBUS */
 #endif /* _PURPLE_DBUS_CONTACT_H */


More information about the Commits mailing list