[maemo-commits] [maemo-commits] r16040 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Sep 5 17:12:08 EEST 2008
Author: pvanhoof
Date: 2008-09-05 17:12:06 +0300 (Fri, 05 Sep 2008)
New Revision: 16040

Added:
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/README.plugin-runner
Modified:
   projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/Makefile.am
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugin-runner.c
Log:
2008-09-05  Philip Van Hoof  <pvanhoof at gnome.org>

        * daemon/plugin-runner.c
        * daemon/manager.c
        * daemon/README.plugin-runner
        * daemon/Makefile.am: Making the pluginrunner work again



Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog	2008-09-05 13:38:32 UTC (rev 16039)
+++ projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog	2008-09-05 14:12:06 UTC (rev 16040)
@@ -1,5 +1,12 @@
 2008-09-05  Philip Van Hoof  <pvanhoof at gnome.org>
 
+	* daemon/plugin-runner.c
+	* daemon/manager.c
+	* daemon/README.plugin-runner
+	* daemon/Makefile.am: Making the pluginrunner work again
+
+2008-09-05  Philip Van Hoof  <pvanhoof at gnome.org>
+
 	* daemon/plugins/gdkpixbuf-plugin.c
 	* daemon/thumbnailer.c
 	* daemon/manager.c

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/Makefile.am
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/Makefile.am	2008-09-05 13:38:32 UTC (rev 16039)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/Makefile.am	2008-09-05 14:12:06 UTC (rev 16040)
@@ -6,7 +6,7 @@
 	$(GMODULE_CFLAGS) \
 	$(GIO_CFLAGS) \
 	$(DBUS_CFLAGS) \
-	-DTHUMBNAILERS_DIR=\""$(datadir)/thumbnailers"\" \
+	-DTHUMBNAILERS_DIR=\""/usr/share/thumbnailers"\" \
 	-DPLUGINS_DIR=\""$(libdir)/hildon-thumbnailer/plugins"\"
 
 

Added: projects/haf/branches/hildon-thumbnail/daemonize/daemon/README.plugin-runner
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/README.plugin-runner	2008-09-05 13:38:32 UTC (rev 16039)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/README.plugin-runner	2008-09-05 14:12:06 UTC (rev 16040)
@@ -0,0 +1,17 @@
+Put a file like this in 
+
+/usr/share/dbus-1/services :
+
+[D-BUS Service]
+Name=com.nokia.hildon.thumbnail.pluginrunner.Thumbnailer
+Exec=/opt/thumbnailer/libexec/hildon-thumbnailer-plugin-runner -m gdkpixbuf -b com.nokia.hildon.thumbnail.pluginrunner.Thumbnailer -p /com/nokia/hildon/thumbnail/pluginrunner/Thumbnailer
+
+And a file like this in 
+
+/usr/share/thumbnailers/com.nokia.hildon.thumbnail.pluginrunner.Thumbnailer.service :
+
+[D-BUS Thumbnailer]
+Name=com.nokia.hildon.thumbnail.pluginrunner.Thumbnailer
+mimetypes=image/png;image/jpeg
+comment=free comment
+

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c	2008-09-05 13:38:32 UTC (rev 16039)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c	2008-09-05 14:12:06 UTC (rev 16040)
@@ -190,7 +190,8 @@
 	g_hash_table_iter_init (&iter, pre);
 
 	while (g_hash_table_iter_next (&iter, &pkey, &pvalue))  {
-		gchar *k = pkey, *v = pvalue;
+		gchar *k = pkey;
+		ValueInfo *v = pvalue;
 		gchar *oname = NULL;
 
 		if (!override) {
@@ -199,8 +200,8 @@
 				oname = (gchar *) dbus_g_proxy_get_bus_name (proxy);
 		}
 
-		if (!oname || g_ascii_strcasecmp (v, oname) != 0)
-			manager_add (object, k, v);
+		if (!oname || g_ascii_strcasecmp (v->name, oname) != 0)
+			manager_add (object, k, v->name);
 	}
 
 	g_hash_table_unref (pre);
@@ -410,6 +411,8 @@
 			       "connection", connection,
 			       NULL);
 
+	manager_check (object);
+
 	dbus_g_object_type_install_info (G_OBJECT_TYPE (object), 
 					 &dbus_glib_manager_object_info);
 

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugin-runner.c
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugin-runner.c	2008-09-05 13:38:32 UTC (rev 16039)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugin-runner.c	2008-09-05 14:12:06 UTC (rev 16040)
@@ -28,9 +28,6 @@
 
 #include "hildon-thumbnail-plugin.h"
 
-#define DAEMON_SERVICE      "org.freedesktop.Thumbnailer"
-#define DAEMON_PATH         "/org/freedesktop/Thumbnailer"
-#define DAEMON_INTERFACE    "org.freedesktop.Thumbnailer"
 
 #define MANAGER_SERVICE      "org.freedesktop.Thumbnailer"
 #define MANAGER_PATH         "/org/freedesktop/Thumbnailer/Manager"
@@ -228,10 +225,36 @@
 	g_object_unref (manager_proxy);
 }
 
+static gchar *module_name;
+static gboolean dynamic_register = FALSE;
+static gchar *bus_name;
+static gchar *bus_path;
 
+static GOptionEntry entries_daemon[] = {
+	{ "module-name", 'm', G_OPTION_FLAG_REVERSE|G_OPTION_FLAG_OPTIONAL_ARG, 
+	  G_OPTION_ARG_STRING, &module_name, 
+	  "Module to load (eg. gdkpixbuif) ", 
+	  NULL },
+	{ "bus-name", 'b', 0, 
+	  G_OPTION_ARG_STRING, &bus_name, 
+	  "Busname to use (eg. com.company.Thumbnailer) ", 
+	  NULL },
+	{ "bus-path", 'p', 0, 
+	  G_OPTION_ARG_STRING, &bus_path, 
+	  "Buspath to use (eg. /com/company/Thumbnailer) ", 
+	  NULL },
+	{ "dynamic-register", 'd', 0, 
+	  G_OPTION_ARG_NONE, &dynamic_register, 
+	  "Dynamic registration using org.freedesktop.Thumbnailer.Manager", 
+	  NULL },
+	{ NULL }
+};
+
 int 
 main (int argc, char **argv) 
 {
+	GOptionContext *context = NULL;
+	GOptionGroup *group;
 	DBusGConnection *connection;
 	DBusGProxy *proxy;
 	GError *error = NULL;
@@ -245,12 +268,27 @@
 	if (!g_thread_supported ())
 		g_thread_init (NULL);
 
-	if (argc < 2) {
-		g_print ("Usage: %s MODULE [dynamic]\nThe [dynamic] option stands for 'do a dynamic register \nusing a org.freedesktop.Thumbnailer.Manager.Register()'\n", argv[0]);
-		return 0;
+	context = g_option_context_new ("- start a plugin as a standalone daemon");
+
+	/* Daemon group */
+	group = g_option_group_new ("daemon", 
+				    "Daemon Options",
+				    "Show daemon options", 
+				    NULL, 
+				    NULL);
+	g_option_group_add_entries (group, entries_daemon);
+	g_option_context_add_group (context, group);
+
+	g_option_context_parse (context, &argc, &argv, &error);
+	g_option_context_free (context);
+
+	if (error) {
+		g_printerr ("Invalid arguments, %s\n", error->message);
+		g_error_free (error);
+		return -1;
 	}
 
-	module = hildon_thumbnail_plugin_load (argv[1]);
+	module = hildon_thumbnail_plugin_load (module_name);
 
 	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
 
@@ -259,7 +297,7 @@
 					   DBUS_PATH_DBUS,
 					   DBUS_INTERFACE_DBUS);
 
-	org_freedesktop_DBus_request_name (proxy, DAEMON_SERVICE,
+	org_freedesktop_DBus_request_name (proxy, bus_name,
 					   DBUS_NAME_FLAG_DO_NOT_QUEUE,
 					   &result, &error);
 
@@ -268,13 +306,13 @@
 			       "module", module,
 			       NULL);
 
-	daemon_start (DAEMON (object), argc > 2);
+	daemon_start (DAEMON (object), dynamic_register);
 
 	dbus_g_object_type_install_info (G_OBJECT_TYPE (object), 
 					 &dbus_glib_plugin_runner_object_info);
 
 	dbus_g_connection_register_g_object (connection, 
-					     DAEMON_PATH, 
+					     bus_path, 
 					     object);
 
 


More information about the maemo-commits mailing list