[tracker] Make libinotify non-optional



commit ff1e9579c00bfe79aea084708483e185b6d55b23
Author: Rob Taylor <rob taylor codethink co uk>
Date:   Mon Jul 6 17:20:47 2009 +0100

    Make libinotify non-optional

 configure.ac                           |   10 +--
 src/Makefile.am                        |    6 +-
 src/tracker-miner-fs/Makefile.am       |    6 +-
 src/tracker-miner-fs/tracker-monitor.c |  188 --------------------------------
 tests/tracker-miner-fs/Makefile.am     |    5 +-
 5 files changed, 5 insertions(+), 210 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 499fc5a..62b9589 100644
--- a/configure.ac
+++ b/configure.ac
@@ -608,14 +608,7 @@ fi
 #  libinotify
 ####################################################################
 
-have_inotify=no
-AC_CHECK_HEADERS([sys/inotify.h],[have_inotify=yes])
-
-AM_CONDITIONAL(HAVE_INOTIFY, test "$have_inotify" = "yes")
-
-if test "$have_inotify" = "yes" ; then
-   AC_DEFINE(HAVE_INOTIFY, 1, [Define if we have inotify])
-fi
+AC_CHECK_HEADERS([sys/inotify.h])
 
 ####################################################################
 #  SQLite check
@@ -1441,7 +1434,6 @@ Build Configuration:
 	Enable unit tests:			$have_unit_tests
 	Enable unac accent stripper:	  	$have_unac
 
-	Support for file monitoring:           	gio (w/ libinotify: $have_inotify)
 	Support for ioprio:			$have_ioprio
 	Support for HAL:                    	$have_hal
 	Support for DeviceKit-power:           	$have_devkit_power
diff --git a/src/Makefile.am b/src/Makefile.am
index 08ed1d1..eb623a4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,5 @@
 include $(top_srcdir)/Makefile.decl
 
-if HAVE_INOTIFY
-build_libinotify = libinotify
-endif
-
 if HAVE_TRACKER_PREFERENCES
 build_tracker_preferences = tracker-preferences
 endif
@@ -22,7 +18,7 @@ endif
 
 SUBDIRS = 					\
 	libstemmer				\
-	$(build_libinotify)			\
+	libinotify				\
 	rasqal		 			\
 	libtracker-common 			\
 	libtracker-db				\
diff --git a/src/tracker-miner-fs/Makefile.am b/src/tracker-miner-fs/Makefile.am
index 9967a9e..bee975d 100644
--- a/src/tracker-miner-fs/Makefile.am
+++ b/src/tracker-miner-fs/Makefile.am
@@ -19,9 +19,7 @@ INCLUDES =								\
 	$(GCOV_CFLAGS)							\
 	$(RAPTOR_CFLAGS)
 
-if HAVE_INOTIFY
-inotify_libs = $(top_builddir)/src/libinotify/libinotify.la
-endif
+
 
 libtracker_moduledir = $(libdir)/tracker-$(TRACKER_API_VERSION)
 libtracker_moduleincludedir=$(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-module/
@@ -70,8 +68,8 @@ tracker_miner_fs_LDADD =						\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
 	$(top_builddir)/src/libtracker/libtrackerclient- TRACKER_API_VERSION@.la \
 	$(top_builddir)/src/libstemmer/libstemmer.la	 		\
+	$(top_builddir)/src/libinotify/libinotify.la			\
 	$(tracker_store_win_libs)					\
-	$(inotify_libs)							\
 	$(DBUS_LIBS)							\
 	$(GMODULE_LIBS)							\
 	$(GTHREAD_LIBS)							\
diff --git a/src/tracker-miner-fs/tracker-monitor.c b/src/tracker-miner-fs/tracker-monitor.c
index 892c7b4..410b56c 100644
--- a/src/tracker-miner-fs/tracker-monitor.c
+++ b/src/tracker-miner-fs/tracker-monitor.c
@@ -28,11 +28,8 @@
 #include <libtracker-common/tracker-status.h>
 #include <libtracker-common/tracker-module-config.h>
 
-#ifdef HAVE_INOTIFY
 #include <sys/inotify.h>
 #include <libinotify/libinotify.h>
-#define USE_LIBINOTIFY
-#endif /* HAVE_INOTIFY */
 
 #include "tracker-monitor.h"
 #include "tracker-dbus.h"
@@ -77,13 +74,11 @@ struct _TrackerMonitorPrivate {
 	guint	       unpause_timeout_id;
 #endif /* PAUSE_ON_IO */
 
-#ifdef USE_LIBINOTIFY
 	GHashTable    *event_pairs;
 	guint	       event_pairs_timeout_id;
 
 	GHashTable    *cached_events;
 	guint	       cached_events_timeout_id;
-#endif /* USE_LIBINOTIFY */
 };
 
 typedef struct {
@@ -120,11 +115,9 @@ static EventData *    event_data_new               (GFile          *file,
 static void           event_data_free              (gpointer        data);
 static guint          get_inotify_limit            (void);
 
-#ifdef USE_LIBINOTIFY
 static INotifyHandle *libinotify_monitor_directory (TrackerMonitor *monitor,
 						    GFile          *file);
 static void           libinotify_monitor_cancel    (gpointer        data);
-#endif /* USE_LIBINOTIFY */
 
 static guint signals[LAST_SIGNAL] = { 0, };
 
@@ -226,7 +219,6 @@ tracker_monitor_init (TrackerMonitor *object)
 				       g_free,
 				       (GDestroyNotify) g_hash_table_unref);
 
-#ifdef USE_LIBINOTIFY
 	/* We have a hash table with cookies so we can pair up move
 	 * events.
 	 */
@@ -245,7 +237,6 @@ tracker_monitor_init (TrackerMonitor *object)
 				       (GEqualFunc) g_file_equal,
 				       g_object_unref,
 				       event_data_free);
-#endif /* USE_LIBINOTIFY */
 
 	all_modules = tracker_module_config_get_modules ();
 
@@ -253,19 +244,11 @@ tracker_monitor_init (TrackerMonitor *object)
 		GHashTable *monitors;
 
 		/* Create monitors table for this module */
-#ifdef USE_LIBINOTIFY
 		monitors =
 			g_hash_table_new_full (g_file_hash,
 					       (GEqualFunc) g_file_equal,
 					       (GDestroyNotify) g_object_unref,
 					       (GDestroyNotify) libinotify_monitor_cancel);
-#else  /* USE_LIBINOTIFY */
-		monitors =
-			g_hash_table_new_full (g_file_hash,
-					       (GEqualFunc) g_file_equal,
-					       (GDestroyNotify) g_object_unref,
-					       (GDestroyNotify) g_file_monitor_cancel);
-#endif /* USE_LIBINOTIFY */
 
 		g_hash_table_insert (priv->modules, g_strdup (l->data), monitors);
 	}
@@ -367,7 +350,6 @@ tracker_monitor_finalize (GObject *object)
 	}
 #endif /* PAUSE_ON_IO */
 
-#ifdef USE_LIBINOTIFY
 	if (priv->cached_events_timeout_id) {
 		g_source_remove (priv->cached_events_timeout_id);
 	}
@@ -378,7 +360,6 @@ tracker_monitor_finalize (GObject *object)
 
 	g_hash_table_unref (priv->cached_events);
 	g_hash_table_unref (priv->event_pairs);
-#endif /* USE_LIBINOTIFY */
 
 	g_hash_table_unref (priv->modules);
 
@@ -605,7 +586,6 @@ unpause_cb (gpointer data)
 
 #endif /* PAUSE_ON_IO */
 
-#ifdef USE_LIBINOTIFY
 
 static gchar *
 libinotify_monitor_event_to_string (guint32 event_type)
@@ -1357,145 +1337,6 @@ libinotify_monitor_cancel (gpointer data)
 	inotify_monitor_remove (data);
 }
 
-#else  /* USE_LIBINOTIFY */
-
-static const gchar *
-monitor_event_to_string (GFileMonitorEvent event_type)
-{
-	switch (event_type) {
-	case G_FILE_MONITOR_EVENT_CHANGED:
-		return "G_FILE_MONITOR_EVENT_CHANGED";
-	case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
-		return "G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT";
-	case G_FILE_MONITOR_EVENT_DELETED:
-		return "G_FILE_MONITOR_EVENT_DELETED";
-	case G_FILE_MONITOR_EVENT_CREATED:
-		return "G_FILE_MONITOR_EVENT_CREATED";
-	case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
-		return "G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED";
-	case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
-		return "G_FILE_MONITOR_EVENT_PRE_UNMOUNT";
-	case G_FILE_MONITOR_EVENT_UNMOUNTED:
-		return "G_FILE_MONITOR_EVENT_UNMOUNTED";
-	}
-
-	return "unknown";
-}
-
-static void
-monitor_event_cb (GFileMonitor	    *file_monitor,
-		  GFile		    *file,
-		  GFile		    *other_file,
-		  GFileMonitorEvent  event_type,
-		  gpointer	     user_data)
-{
-	TrackerMonitor *monitor;
-	const gchar    *module_name;
-	gchar	       *str1;
-	gchar	       *str2;
-	gboolean	is_directory;
-
-	monitor = user_data;
-
-	if (G_UNLIKELY (!monitor->private->enabled)) {
-		g_debug ("Silently dropping monitor event, monitor disabled for now");
-		return;
-	}
-
-	module_name = get_module_name_from_gfile (monitor,
-						  file,
-						  &is_directory);
-	if (!module_name) {
-		return;
-	}
-
-	str1 = g_file_get_path (file);
-
-	if (other_file) {
-		str2 = g_file_get_path (other_file);
-	} else {
-		str2 = NULL;
-	}
-
-	g_message ("Received monitor event:%d->'%s' for file:'%s' and other file:'%s'",
-		   event_type,
-		   monitor_event_to_string (event_type),
-		   str1,
-		   str2 ? str2 : "");
-
-#ifdef PAUSE_ON_IO
-	if (monitor->private->unpause_timeout_id != 0) {
-		g_source_remove (monitor->private->unpause_timeout_id);
-	} else {
-		g_message ("Pausing indexing because we are "
-			   "receiving monitor events");
-
-		tracker_status_set_is_paused_for_io (TRUE);
-	}
-
-	monitor->private->unpause_timeout_id =
-		g_timeout_add_seconds (PAUSE_ON_IO_SECONDS,
-				       unpause_cb,
-				       monitor);
-#endif /* PAUSE_ON_IO */
-
-	switch (event_type) {
-	case G_FILE_MONITOR_EVENT_CHANGED:
-		if (!monitor->private->use_changed_event) {
-			/* Do nothing */
-			break;
-		}
-
-	case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
-	case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
-		g_signal_emit (monitor,
-			       signals[ITEM_UPDATED], 0,
-			       module_name,
-			       file,
-			       is_directory);
-		break;
-
-	case G_FILE_MONITOR_EVENT_DELETED:
-		if (is_directory) {
-			tracker_monitor_remove (monitor,
-						module_name,
-						file);
-		}
-
-		g_signal_emit (monitor,
-			       signals[ITEM_DELETED], 0,
-			       module_name,
-			       file,
-			       is_directory);
-		break;
-
-	case G_FILE_MONITOR_EVENT_CREATED:
-		g_signal_emit (monitor,
-			       signals[ITEM_CREATED], 0,
-			       module_name,
-			       file,
-			       is_directory);
-		break;
-
-	case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
-		g_signal_emit (monitor,
-			       signals[ITEM_DELETED], 0,
-			       module_name,
-			       file,
-			       is_directory);
-		break;
-
-	case G_FILE_MONITOR_EVENT_UNMOUNTED:
-		/* Do nothing */
-		break;
-	}
-
-	g_free (str1);
-	g_free (str2);
-}
-
-#endif /* USE_LIBINOTIFY */
-
 TrackerMonitor *
 tracker_monitor_new (TrackerConfig *config)
 {
@@ -1537,12 +1378,7 @@ tracker_monitor_add (TrackerMonitor *monitor,
 		     const gchar    *module_name,
 		     GFile	    *file)
 {
-#ifdef USE_LIBINOTIFY
 	INotifyHandle *file_monitor;
-#else  /* USE_LIBINOTIFY */
-	GFileMonitor *file_monitor;
-	GError	     *error = NULL;
-#endif /* USE_LIBINOTIFY */
 	GHashTable   *monitors;
 	GSList	     *ignored_roots;
 	GSList	     *l;
@@ -1600,7 +1436,6 @@ tracker_monitor_add (TrackerMonitor *monitor,
 	 *
 	 * Also, we assume ALL paths passed are directories.
 	 */
-#ifdef USE_LIBINOTIFY
 	file_monitor = libinotify_monitor_directory (monitor, file);
 
 	if (!file_monitor) {
@@ -1613,29 +1448,6 @@ tracker_monitor_add (TrackerMonitor *monitor,
 	g_hash_table_insert (monitors,
 			     g_object_ref (file),
 			     file_monitor);
-#else  /* USE_LIBINOTIFY */
-	file_monitor = g_file_monitor_directory (file,
-						 G_FILE_MONITOR_WATCH_MOUNTS,
-						 NULL,
-						 &error);
-
-	if (error) {
-		g_warning ("Could not add monitor for path:'%s', %s",
-			   path,
-			   error->message);
-		g_free (path);
-		g_error_free (error);
-		return FALSE;
-	}
-
-	g_signal_connect (file_monitor, "changed",
-			  G_CALLBACK (monitor_event_cb),
-			  monitor);
-
-	g_hash_table_insert (monitors,
-			     g_object_ref (file),
-			     file_monitor);
-#endif /* USE_LIBINOTIFY */
 
 	g_debug ("Added monitor for module:'%s', path:'%s', total monitors:%d",
 		 module_name,
diff --git a/tests/tracker-miner-fs/Makefile.am b/tests/tracker-miner-fs/Makefile.am
index 4d68bf6..261fb3a 100644
--- a/tests/tracker-miner-fs/Makefile.am
+++ b/tests/tracker-miner-fs/Makefile.am
@@ -25,9 +25,6 @@ INCLUDES = 									\
 	$(DBUS_CFLAGS)								\
 	$(RAPTOR_CFLAGS)
 
-if HAVE_INOTIFY
-inotify_libs = $(top_builddir)/src/libinotify/libinotify.la
-endif
 
 tracker_metadata_utils_SOURCES = 						\
 	$(top_srcdir)/src/tracker-store/tracker-events.c			\
@@ -50,7 +47,7 @@ tracker_metadata_utils_LDADD =	                                        	\
 	$(top_builddir)/src/libtracker-common/libtracker-common.la 		\
 	$(top_builddir)/src/libtracker/libtrackerclient- TRACKER_API_VERSION@.la \
 	$(top_builddir)/tests/common/libtracker-testcommon.la           	\
-	$(inotify_libs)								\
+	$(top_builddir)/src/libinotify/libinotify.la				\
 	$(DBUS_LIBS)								\
 	$(PANGO_LIBS)								\
 	$(GMODULE_LIBS)								\



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