soc.2010.detachablepurple: 7c1aafef: Added exportation of PurpleBuddy gobject...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Mon Aug 9 23:58:32 EDT 2010


----------------------------------------------------------------------
Revision: 7c1aafef03bc2c6f9444e61b688f353c9a5bc9cb
Parent:   d7d5defab1d263ef7b696d4b4c24d44bd3c24b8a
Author:   gillux at soc.pidgin.im
Date:     08/08/10 22:41:30
Branch:   im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/7c1aafef03bc2c6f9444e61b688f353c9a5bc9cb

Changelog: 

Added exportation of PurpleBuddy gobjects, with properties and without methods.

Changes against parent d7d5defab1d263ef7b696d4b4c24d44bd3c24b8a

  added    libpurple/dbus/buddy.c
  added    libpurple/dbus/buddy.h
  added    libpurple/dbus/buddy.xml
  patched  libpurple/Makefile.am
  patched  libpurple/buddy.c
  patched  libpurple/dbus-purple.h

-------------- next part --------------
============================================================
--- libpurple/dbus-purple.h	dd1a18d203d757b87bdbea550fbab466902ee259
+++ libpurple/dbus-purple.h	01198506582871dca3b684735daed5bfdd86b20c
@@ -35,6 +35,9 @@
 #define DBUS_BLIST_PATH      "/im/pidgin/purple/blist"
 #define DBUS_BLIST_INTERFACE "im.pidgin.purple.blist"
 
+#define DBUS_BUDDY_PATH      "/im/pidgin/purple/buddy"
+#define DBUS_BUDDY_INTERFACE "im.pidgin.purple.buddy"
+
 #define DBUS_CONNECTION_PATH      "/im/pidgin/purple/connection"
 #define DBUS_CONNECTION_INTERFACE "im.pidgin.purple.connection"
 
============================================================
--- libpurple/Makefile.am	e6d43fb62de10ff75226978f97107258ae1f77ee
+++ libpurple/Makefile.am	337d503c340b6b75e49bd4872db5612764f42411
@@ -209,6 +209,7 @@ purple_builtheaders = \
 	purple.h version.h marshallers.h \
 	dbus/account-server.h dbus/account-client.h \
 	dbus/blist-server.h dbus/blist-client.h \
+	dbus/buddy-server.h dbus/buddy-client.h \
 	dbus/connection-server.h dbus/connection-client.h \
 	dbus/contact-server.h dbus/contact-client.h \
 	dbus/group-server.h dbus/group-client.h \
@@ -248,6 +249,12 @@ dbus/blist-client.h: dbus/blist.xml
 dbus/blist-client.h: dbus/blist.xml
 	$(AM_V_GEN)dbus-binding-tool --prefix=DBUS_purple_blist --mode=glib-client --output=$@ $<
 
+dbus/buddy-server.h: dbus/buddy.xml
+	$(AM_V_GEN)dbus-binding-tool --prefix=DBUS_purple_buddy --mode=glib-server --output=$@ $<
+
+dbus/buddy-client.h: dbus/buddy.xml
+	$(AM_V_GEN)dbus-binding-tool --prefix=DBUS_purple_buddy --mode=glib-client --output=$@ $<
+
 dbus/connection-server.h: dbus/connection.xml
 	$(AM_V_GEN)dbus-binding-tool --prefix=DBUS_purple_connection --mode=glib-server --output=$@ $<
 
@@ -285,6 +292,7 @@ dbus_sources  = dbus-server.c dbus-usefu
 	dbus/constructor.c \
 	dbus/callback.c \
 	dbus/account.c \
+	dbus/buddy.c \
 	dbus/connection.c \
 	dbus/contact.c \
 	dbus/blist.c \
@@ -294,6 +302,7 @@ dbus_headers  = dbus-bindings.h dbus-pur
 	dbus/constructor.h \
 	dbus/callback.h \
 	dbus/account.h \
+	dbus/buddy.h \
 	dbus/connection.h \
 	dbus/contact.h \
 	dbus/blist.h \
============================================================
--- libpurple/buddy.c	a2e529a6f13c4e1f6ddcb5fdeebe5e6d53f1ce0a
+++ libpurple/buddy.c	2e09a076b9fe4f8980309aeb4ee5c0e5765e6148
@@ -31,6 +31,7 @@
 #include "util.h"
 #include "xmlnode.h"
 #include "buddy.h"
+#include "dbus/buddy.h"
 
 #define PURPLE_BUDDY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PURPLE_TYPE_BUDDY, PurpleBuddyPrivate))
 typedef struct _PurpleBuddyPrivate PurpleBuddyPrivate;
@@ -167,6 +168,8 @@ void purple_buddy_set_alias(PurpleBuddy 
 
 	g_return_if_fail(buddy != NULL);
 
+	PURPLE_DBUS_REMOTELY_SET_PROP(buddy, g_value_set_string, G_TYPE_STRING, PROP_ALIAS_S, alias);
+
 	if ((alias != NULL) && (*alias != '\0'))
 		new_alias = purple_utf8_strip_unprintables(alias);
 
@@ -204,6 +207,8 @@ void purple_buddy_set_name(PurpleBuddy *
 {
 	PurpleBuddyPrivate *priv = PURPLE_BUDDY_GET_PRIVATE(buddy);
 	g_return_if_fail(buddy);
+	PURPLE_DBUS_REMOTELY_SET_PROP(buddy, g_value_set_string, G_TYPE_STRING, PROP_NAME_S, name);
+
 	priv = PURPLE_BUDDY_GET_PRIVATE(buddy);
 
 	if(priv->name)
@@ -535,6 +540,7 @@ PurpleBuddy *purple_buddy_new(PurpleAcco
 			PROP_NAME_S, name,
 			PROP_ALIAS_S, alias,
 			NULL);
+	purple_buddy_dbus_init(buddy, name);
 
 	if (parent)
 		purple_blist_node_add_child(parent, PURPLE_BLIST_NODE(buddy));
@@ -663,6 +669,8 @@ purple_buddy_class_init(PurpleBuddyClass
 				_("The alias for the buddy."), NULL,
 				G_PARAM_READWRITE)
 			);
+
+	purple_buddy_class_dbus_init();
 }
 
 static void
============================================================
--- /dev/null	
+++ libpurple/dbus/buddy.c	cf170f12fb8e6f07caef65d441fe04a31d468b08
@@ -0,0 +1,66 @@
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#include "internal.h"
+#include "core.h"
+#include "buddy.h"
+#include "dbus/buddy.h"
+#include "dbus/buddy-client.h"
+#include "dbus/buddy-server.h"
+#include "dbus-purple.h"
+#include "dbus-server.h"
+
+static char *
+purple_buddy_build_dbus_path(const char *name)
+{
+	static unsigned int buddy_id = 0;
+	gchar *path;
+	gchar *name_valid;
+
+	/* Buddy names arn't unique, so we use an id. We also append the buddy
+	 * name, to make a meaningful path. */
+	name_valid = purple_dbus_sanitize_dbus_path(name);
+	path = g_strdup_printf(DBUS_BUDDY_PATH "/%u_%s", buddy_id++, name_valid);
+	g_free(name_valid);
+
+	return path;
+}
+
+void
+purple_buddy_class_dbus_init(void)
+{
+	if (purple_core_is_daemon_mode()) {
+		/* Install method introspection data */
+		purple_object_type_install_dbus_infos(PURPLE_TYPE_BUDDY,
+				&dbus_glib_DBUS_purple_buddy_object_info);
+	}
+}
+
+void
+purple_buddy_dbus_init(PurpleBuddy *buddy, const char *name)
+{
+	char* dbus_path;
+
+	dbus_path = purple_buddy_build_dbus_path(name);
+	purple_object_install_dbus_infos(PURPLE_OBJECT(buddy),
+	                                 DBUS_BUDDY_INTERFACE, dbus_path);
+	g_free(dbus_path);	
+}
============================================================
--- /dev/null	
+++ libpurple/dbus/buddy.h	11d2323b01379364bef803052c52ead7b1bc8fa5
@@ -0,0 +1,39 @@
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#ifdef HAVE_DBUS
+
+/**
+ * Initialize the dbus data of the buddy class.
+ */
+void purple_buddy_class_dbus_init(void);
+
+/**
+ * Initialize the dbus data of a new buddy.
+ */
+void purple_buddy_dbus_init(PurpleBuddy *buddy, const char *name);
+
+#else /* !HAVE_DBUS */
+
+#define purple_buddy_class_dbus_init()                            ((void)0)
+#define purple_buddy_dbus_init(buddy, name)                       ((void)0)
+
+#endif /* HAVE_DBUS */
============================================================
--- /dev/null	
+++ libpurple/dbus/buddy.xml	2b54cd50a1d900eeff57bea8db5804da9a59aca7
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/im/pidgin/purple/buddy">
+	<interface name="im.pidgin.purple.buddy">
+		<property type="s" name="alias"   access="readwrite" />
+		<property type="s" name="name"    access="readwrite" />
+	</interface>
+</node>


More information about the Commits mailing list