tracker r1750 - in branches/indexer-split: . src/libtracker-common src/tracker-indexer src/tracker-indexer/modules



Author: mr
Date: Tue Jun 24 14:10:21 2008
New Revision: 1750
URL: http://svn.gnome.org/viewvc/tracker?rev=1750&view=rev

Log:
	* src/libtracker-common/Makefile.am:
	* src/libtracker-common/tracker-config.c: 
	* src/tracker-indexer/Makefile.am:
	* src/tracker-indexer/modules/Makefile.am: Monitor config file for
	changes and reload if it does.


Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/libtracker-common/Makefile.am
   branches/indexer-split/src/libtracker-common/tracker-config.c
   branches/indexer-split/src/tracker-indexer/Makefile.am
   branches/indexer-split/src/tracker-indexer/modules/Makefile.am

Modified: branches/indexer-split/src/libtracker-common/Makefile.am
==============================================================================
--- branches/indexer-split/src/libtracker-common/Makefile.am	(original)
+++ branches/indexer-split/src/libtracker-common/Makefile.am	Tue Jun 24 14:10:21 2008
@@ -6,6 +6,7 @@
 	$(DBUS_CFLAGS)				\
 	$(UNAC_CFLAGS)				\
 	$(PANGO_CFLAGS)				\
+	$(GIO_CFLAGS)				\
 	$(GLIB2_CFLAGS)
 
 noinst_LTLIBRARIES = libtracker-common.la
@@ -61,5 +62,6 @@
 	$(DBUS_LIBS)				\
 	$(UNAC_LIBS)				\
 	$(PANGO_LIBS)				\
+	$(GIO_LIBS)				\
 	$(GLIB2_LIBS)
 

Modified: branches/indexer-split/src/libtracker-common/tracker-config.c
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-config.c	(original)
+++ branches/indexer-split/src/libtracker-common/tracker-config.c	Tue Jun 24 14:10:21 2008
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 
 #include <glib.h>
+#include <gio/gio.h>
 
 #include "tracker-language.h"
 #include "tracker-config.h"
@@ -115,6 +116,9 @@
 typedef struct _TrackerConfigPriv TrackerConfigPriv;
 
 struct _TrackerConfigPriv {
+	GFile        *file;
+	GFileMonitor *monitor;
+
 	/* General */
 	gint	  verbosity;
 	gint	  initial_sleep;
@@ -172,8 +176,8 @@
 				 guint	       param_id,
 				 const GValue *value,
 				 GParamSpec   *pspec);
+static void config_load         (TrackerConfig *config);
 
-/* GObject properties */
 enum {
 	PROP_0,
 
@@ -577,6 +581,14 @@
 	g_free (priv->language);
 	g_free (priv->email_client);
 
+	if (priv->monitor) {
+		g_object_unref (priv->monitor);
+	}
+
+	if (priv->file) {
+		g_object_unref (priv->file);
+	}
+
 	(G_OBJECT_CLASS (tracker_config_parent_class)->finalize) (object);
 }
 
@@ -1369,8 +1381,39 @@
 }
 
 static void
+config_changed_cb (GFileMonitor     *monitor,
+		   GFile            *file,
+		   GFile            *other_file,
+		   GFileMonitorEvent event_type,
+		   gpointer          user_data)  
+{
+	TrackerConfig *config;
+	gchar         *filename;
+
+	config = TRACKER_CONFIG (user_data);
+
+	/* Do we recreate if the file is deleted? */
+
+	switch (event_type) {
+	case G_FILE_MONITOR_EVENT_CHANGED:
+	case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+		filename = g_file_get_path (file);
+		g_message ("Config file changed:'%s', reloading settings...", 
+			   filename); 
+		g_free (filename);
+
+		config_load (config);
+		break;
+
+	default:
+		break;
+	}
+}
+
+static void
 config_load (TrackerConfig *config)
 {
+	TrackerConfigPriv *priv;
 	GKeyFile *key_file;
 	GError	 *error = NULL;
 	gchar	 *filename;
@@ -1389,6 +1432,27 @@
 	filename = g_build_filename (directory, "tracker.cfg", NULL);
 	g_free (directory);
 
+	priv = GET_PRIV (config);
+
+	/* Add file monitoring for changes */
+	if (!priv->file) {
+		priv->file = g_file_new_for_path (filename);
+	}
+
+	if (!priv->monitor) {
+		g_message ("Setting up monitor for changes to config file:'%s'", 
+			   filename);
+
+		priv->monitor = g_file_monitor_file (priv->file,
+						     G_FILE_MONITOR_NONE,
+						     NULL,
+						     NULL);
+		
+		g_signal_connect (priv->monitor, "changed",
+				  G_CALLBACK (config_changed_cb), 
+				  config);
+	}
+
 	/* Load options */
 	g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &error);
 	if (error) {

Modified: branches/indexer-split/src/tracker-indexer/Makefile.am
==============================================================================
--- branches/indexer-split/src/tracker-indexer/Makefile.am	(original)
+++ branches/indexer-split/src/tracker-indexer/Makefile.am	Tue Jun 24 14:10:21 2008
@@ -9,6 +9,8 @@
 	-I$(top_srcdir)/src						\
 	$(DBUS_CFLAGS)							\
 	$(GMODULE_CFLAGS)						\
+	$(GTHREAD_LIBS)							\
+	$(GIO_LIBS)							\
 	$(GLIB2_CFLAGS)
 
 bin_PROGRAMS = tracker-indexer
@@ -39,6 +41,7 @@
 	$(DBUS_LIBS)							\
 	$(GMODULE_LIBS)							\
 	$(GTHREAD_LIBS)							\
+	$(GIO_LIBS)							\
 	$(GLIB2_LIBS)							\
 	-lz								\
 	-lm

Modified: branches/indexer-split/src/tracker-indexer/modules/Makefile.am
==============================================================================
--- branches/indexer-split/src/tracker-indexer/modules/Makefile.am	(original)
+++ branches/indexer-split/src/tracker-indexer/modules/Makefile.am	Tue Jun 24 14:10:21 2008
@@ -8,6 +8,7 @@
 	-DINDEXER_MODULES_DIR=\"$(indexer_modulesdir)\"			\
 	-I$(top_srcdir)/src						\
 	$(GMODULE_CFLAGS)						\
+	$(GIO_LIBS)							\
 	$(GLIB2_CFLAGS)
 
 indexer_modules_LTLIBRARIES = 						\
@@ -20,6 +21,7 @@
 libtracker_indexer_applications_la_LDFLAGS = $(module_flags)
 libtracker_indexer_applications_la_LIBADD = 				\
 	$(GMODULE_LIBS)							\
+	$(GIO_LIBS)							\
 	$(GLIB2_LIBS)
 
 # Files module
@@ -29,6 +31,7 @@
 	$(top_builddir)/src/libtracker-db/libtracker-db.la		\
 	$(top_builddir)/src/xdgmime/libxdgmime.la			\
 	$(GMODULE_LIBS)							\
+	$(GIO_LIBS)							\
 	$(GLIB2_LIBS)
 
 # Instant messaging module
@@ -36,4 +39,5 @@
 libtracker_indexer_gaim_conversations_la_LDFLAGS = $(module_flags)
 libtracker_indexer_gaim_conversations_la_LIBADD = 			\
 	$(GMODULE_LIBS)							\
+	$(GIO_LIBS)							\
 	$(GLIB2_LIBS)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]