soc.2010.detachablepurple: 6d0f25b3: Added exportation of PurpleGroup gobject...

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


----------------------------------------------------------------------
Revision: 6d0f25b33275f33bc3e099bbe8d9aa26d58948da
Parent:   bc886588a0be43d28804bf9bb9cc3259691f7aac
Author:   gillux at soc.pidgin.im
Date:     08/08/10 15:41:18
Branch:   im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/6d0f25b33275f33bc3e099bbe8d9aa26d58948da

Changelog: 

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

Changes against parent bc886588a0be43d28804bf9bb9cc3259691f7aac

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

-------------- next part --------------
============================================================
--- libpurple/dbus-purple.h	f4acffc58b472dc4d7f507df50787008701ae4b3
+++ libpurple/dbus-purple.h	6fd14c0fd4d9e3184ac45b5371e11153ce5b28ea
@@ -38,6 +38,9 @@
 #define DBUS_CONNECTION_PATH      "/im/pidgin/purple/connection"
 #define DBUS_CONNECTION_INTERFACE "im.pidgin.purple.connection"
 
+#define DBUS_GROUP_PATH      "/im/pidgin/purple/group"
+#define DBUS_GROUP_INTERFACE "im.pidgin.purple.group"
+
 #define DBUS_CONSTRUCTOR_PATH      "/im/pidgin/purple/constructor"
 #define DBUS_CONSTRUCTOR_INTERFACE "im.pidgin.purple.constructor"
 
============================================================
--- libpurple/Makefile.am	31b0a421fdd742a80c6a90ae72a9cae805502bb0
+++ libpurple/Makefile.am	661fe27ea7eedd66ec5b6fc4ae9ca6ed330021f7
@@ -210,6 +210,7 @@ purple_builtheaders = \
 	dbus/account-server.h dbus/account-client.h \
 	dbus/blist-server.h dbus/blist-client.h \
 	dbus/connection-server.h dbus/connection-client.h \
+	dbus/group-server.h dbus/group-client.h \
 	dbus/constructor-server.h dbus/constructor-client.h \
 	dbus/callback-server.h dbus/callback-client.h
 
@@ -252,6 +253,12 @@ dbus/connection-client.h: dbus/connectio
 dbus/connection-client.h: dbus/connection.xml
 	$(AM_V_GEN)dbus-binding-tool --prefix=DBUS_purple_connection --mode=glib-client --output=$@ $<
 
+dbus/group-server.h: dbus/group.xml
+	$(AM_V_GEN)dbus-binding-tool --prefix=DBUS_purple_group --mode=glib-server --output=$@ $<
+
+dbus/group-client.h: dbus/group.xml
+	$(AM_V_GEN)dbus-binding-tool --prefix=DBUS_purple_group --mode=glib-client --output=$@ $<
+
 CLEANFILES = \
 	dbus-bindings.c \
 	dbus-client-binding.c \
@@ -268,9 +275,9 @@ dbus_sources  = dbus-server.c dbus-usefu
 # purple dbus server
 
 dbus_sources  = dbus-server.c dbus-useful.c \
-	dbus/constructor.c dbus/callback.c dbus/account.c dbus/connection.c dbus/blist.c
+	dbus/constructor.c dbus/callback.c dbus/account.c dbus/connection.c dbus/blist.c dbus/group.c
 dbus_headers  = dbus-bindings.h dbus-purple.h dbus-server.h dbus-useful.h dbus-define-api.h dbus-types.h \
-	dbus/constructor.h dbus/callback.h dbus/account.h dbus/connection.h dbus/blist.h
+	dbus/constructor.h dbus/callback.h dbus/account.h dbus/connection.h dbus/blist.h dbus/group.h
 
 dbus_exported = dbus-useful.h dbus-define-api.h account.h accountlist.h blist.h buddyicon.h \
                 connection.h conversation.h core.h ft.h log.h notify.h prefs.h roomlist.h \
============================================================
--- libpurple/group.c	6cc987ef69b1f59391842fafba1fe0fc1d8cde18
+++ libpurple/group.c	0efcce7aefa9e23730dd94e864127a3f7e46bae7
@@ -24,6 +24,7 @@
 
 #include "internal.h"
 #include "group.h"
+#include "dbus/group.h"
 #include "dbus-maybe.h"
 #include "debug.h"
 #include "server.h"
@@ -290,6 +291,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);
+
 	priv = PURPLE_GROUP_GET_PRIVATE(group);
 	gname = purple_utf8_strip_unprintables(name);
 
@@ -327,6 +330,7 @@ PurpleGroup *purple_group_new(const char
 	group = g_object_new(PURPLE_TYPE_GROUP,
 			PROP_NAME_S, name,
 			NULL);
+	purple_group_dbus_init(group, name);
 
 	g_signal_emit_by_name(G_OBJECT(group), "new");
 
@@ -422,6 +426,8 @@ purple_group_class_init(PurpleGroupClass
 				_("The name for the group."), NULL,
 				G_PARAM_READWRITE)
 			);
+
+	purple_group_class_dbus_init();
 }
 
 static void
============================================================
--- /dev/null	
+++ libpurple/dbus/group.c	fbcb469c1ac5d833264a2aef642921a8c718b61c
@@ -0,0 +1,67 @@
+/* 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 "group.h"
+#include "dbus/group.h"
+#include "dbus/group-client.h"
+#include "dbus/group-server.h"
+#include "dbus-purple.h"
+#include "dbus-server.h"
+
+static char *
+purple_group_build_dbus_path(const char *name)
+{
+	static unsigned int group_id = 0;
+	gchar *path;
+	gchar *name_valid;
+
+	/* 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
+	 * meaningful, since groups are rarely renamed. */
+	name_valid = purple_dbus_sanitize_dbus_path(name);
+	path = g_strdup_printf(DBUS_GROUP_PATH "/%u_%s", group_id++, name_valid);
+	g_free(name_valid);
+
+	return path;
+}
+
+void
+purple_group_class_dbus_init(void)
+{
+	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);
+	}
+}
+
+void
+purple_group_dbus_init(PurpleGroup *group, const char *name)
+{
+	char* dbus_path;
+
+	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);	
+}
============================================================
--- /dev/null	
+++ libpurple/dbus/group.h	b7d729df4a21138db96b65c77e48d06a2ba92a9c
@@ -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 group class.
+ */
+void purple_group_class_dbus_init(void);
+
+/**
+ * Initialize the dbus data of a new group.
+ */
+void purple_group_dbus_init(PurpleGroup *group, const char *name);
+
+#else /* !HAVE_DBUS */
+
+#define purple_group_class_dbus_init()                            ((void)0)
+#define purple_group_dbus_init(group, name)                       ((void)0)
+
+#endif /* HAVE_DBUS */
============================================================
--- /dev/null	
+++ libpurple/dbus/group.xml	e5c99bad8df58914e34094e58dc56cb0be3d7d31
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/im/pidgin/purple/group">
+	<interface name="im.pidgin.purple.group">
+		<property type="s" name="name" access="readwrite" />
+	</interface>
+</node>


More information about the Commits mailing list