[tracker/libtracker-miner] Connect all signals up and make test case work



commit c3d5f32a8b1e73e935a6bf59f53e1b52a366365f
Author: Martyn Russell <martyn imendio com>
Date:   Tue Aug 4 13:16:16 2009 +0100

    Connect all signals up and make test case work

 src/libtracker-miner/Makefile.am             |    7 +-
 src/libtracker-miner/tracker-main.c          |  190 ++++
 src/libtracker-miner/tracker-miner-crawler.c |    2 +-
 src/libtracker-miner/tracker-miner-test.c    |    2 +-
 src/libtracker-miner/tracker-miner-test.h    |    9 +-
 src/libtracker-miner/tracker-processor.c     | 1472 +++++++-------------------
 src/libtracker-miner/tracker-processor.h     |   28 +-
 7 files changed, 590 insertions(+), 1120 deletions(-)
---
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index 15a56f8..bb48a12 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -21,6 +21,9 @@ libtracker_minerdir = $(libdir)/tracker-$(TRACKER_API_VERSION)
 libtracker_minerincludedir=$(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-miner/
 libtracker_miner_LTLIBRARIES = libtracker-miner.la
 
+# tracker-miner-crawler.c				
+# tracker-miner-crawler.h				
+
 libtracker_miner_la_SOURCES = 				\
 	tracker-config.c				\
 	tracker-config.h				\
@@ -33,8 +36,6 @@ libtracker_miner_la_SOURCES = 				\
 	tracker-miner-dbus.h				\
 	tracker-miner.c					\
 	tracker-miner.h					\
-	tracker-miner-crawler.c				\
-	tracker-miner-crawler.h				\
 	tracker-monitor.c				\
 	tracker-monitor.h				\
 	tracker-processor.c				\
@@ -46,7 +47,7 @@ libtracker_miner_la_SOURCES = 				\
 
 libtracker_minerinclude_HEADERS = 			\
 	tracker-miner.h 				\
-	tracker-miner-crawler.h
+	tracker-processor.h
 
 libtracker_miner_la_LDFLAGS = \
 	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
diff --git a/src/libtracker-miner/tracker-main.c b/src/libtracker-miner/tracker-main.c
index 3a29e48..7729721 100644
--- a/src/libtracker-miner/tracker-main.c
+++ b/src/libtracker-miner/tracker-main.c
@@ -18,7 +18,13 @@
  * Boston, MA  02110-1301, USA.
  */
 
+#include "config.h"
+
+#include <string.h>
 #include <stdlib.h>
+
+#include <libtracker-common/tracker-utils.h>
+
 #include "tracker-miner-test.h"
 
 static void
@@ -39,6 +45,172 @@ on_miner_start (TrackerMiner *miner)
 	return FALSE;
 }
 
+static gboolean
+check_dir_cb (TrackerProcessor *processor,
+	      GFile	       *file,
+	      gpointer          user_data)
+{
+	GSList *sl;
+	gchar *path;
+	gchar *basename;
+	gboolean should_process;
+
+	should_process = FALSE;
+	basename = NULL;
+	path = g_file_get_path (file);
+
+	if (tracker_is_empty_string (path)) {
+		goto done;
+	}
+
+	if (!g_utf8_validate (path, -1, NULL)) {
+		g_message ("Ignoring path:'%s', not valid UTF-8", path);
+		goto done;
+	}
+
+	/* Most common things to ignore */
+	if (strcmp (path, "/dev") == 0 ||
+	    strcmp (path, "/lib") == 0 ||
+	    strcmp (path, "/proc") == 0 ||
+	    strcmp (path, "/sys") == 0) {
+		goto done;
+	}
+	
+	if (g_str_has_prefix (path, g_get_tmp_dir ())) {
+		goto done;
+	}
+	
+	/* Check ignored directories in config */
+#ifdef FIX
+	for (sl = crawler->private->no_watch_directory_roots; sl; sl = sl->next) {
+		if (strcmp (sl->data, path) == 0) {
+			goto done;
+		}
+	}
+#endif
+
+	basename = g_file_get_basename (file);
+
+	if (!basename) {
+		goto done;
+	}
+	
+	/* If directory begins with ".", check it isn't one of
+	 * the top level directories to watch/crawl if it
+	 * isn't we ignore it. If it is, we don't.
+	 */
+	if (basename[0] == '.') {
+#ifdef FIX
+		for (sl = crawler->private->watch_directory_roots; sl; sl = sl->next) {
+			if (strcmp (sl->data, path) == 0) {
+				should_process = TRUE;
+				goto done;
+			}
+		}
+		
+		for (sl = crawler->private->crawl_directory_roots; sl; sl = sl->next) {
+			if (strcmp (sl->data, path) == 0) {
+				should_process = TRUE;
+				goto done;
+			}
+		}
+#endif		
+		goto done;
+	}
+	
+	/* Check module directory ignore patterns */
+#ifdef FIX
+	for (l = crawler->private->ignored_directory_patterns; l; l = l->next) {
+		if (g_pattern_match_string (l->data, basename)) {
+			goto done;
+		}
+	}
+#endif
+
+	should_process = TRUE;
+
+done:
+	g_free (path);
+	g_free (basename);
+
+	return should_process;
+}
+
+static gboolean
+check_file_cb (TrackerProcessor *processor,
+	       GFile	        *file,
+	       gpointer	         user_data)
+{
+	GList *l;
+	gchar *path;
+	gchar *basename;
+	gboolean should_process;
+
+	should_process = FALSE;
+	basename = NULL;
+	path = g_file_get_path (file);
+
+	if (tracker_is_empty_string (path)) {
+		goto done;
+	}
+
+	if (!g_utf8_validate (path, -1, NULL)) {
+		g_message ("Ignoring path:'%s', not valid UTF-8", path);
+		goto done;
+	}
+
+	/* Check basename against pattern matches */
+	basename = g_file_get_basename (file);
+
+	if (!basename || basename[0] == '.') {
+		goto done;
+	}
+
+#ifdef FIX
+	/* Check module file ignore patterns */
+	for (l = crawler->private->ignored_file_patterns; l; l = l->next) {
+		if (g_pattern_match_string (l->data, basename)) {
+			goto done;
+		}
+	}
+	
+	/* Check module file match patterns */
+	for (l = crawler->private->index_file_patterns; l; l = l->next) {
+		if (!g_pattern_match_string (l->data, basename)) {
+			goto done;
+		}
+	}
+#endif
+
+	should_process = TRUE;
+
+done:
+	g_free (path);
+	g_free (basename);
+
+	return should_process;
+}
+
+static void
+process_file_cb (TrackerProcessor *processor,
+		 GFile	          *file,
+		 gpointer          user_data)
+{
+	gchar *path;
+
+	path = g_file_get_path (file);
+	g_print ("** PROCESSING FILE:'%s'\n", path);
+	g_free (path);
+}
+
+static gboolean
+monitor_dir_cb (TrackerProcessor *processor,
+		GFile	         *file,
+		gpointer          user_data)
+{
+	return TRUE;
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -54,6 +226,24 @@ main (int argc, char *argv[])
         main_loop = g_main_loop_new (NULL, FALSE);
 
         miner = tracker_miner_test_new ("test");
+
+	g_signal_connect (TRACKER_PROCESSOR (miner), "check-file",
+			  G_CALLBACK (check_file_cb),
+			  NULL);
+	g_signal_connect (TRACKER_PROCESSOR (miner), "check-dir",
+			  G_CALLBACK (check_dir_cb),
+			  NULL);
+	g_signal_connect (TRACKER_PROCESSOR (miner), "process-file",
+			  G_CALLBACK (process_file_cb),
+			  NULL);
+	g_signal_connect (TRACKER_PROCESSOR (miner), "monitor-dir",
+			  G_CALLBACK (monitor_dir_cb),
+			  NULL);
+
+	tracker_processor_add_directory (TRACKER_PROCESSOR (miner), 
+					 g_get_home_dir (),
+					 FALSE);
+
         g_signal_connect (miner, "terminated",
                           G_CALLBACK (on_miner_terminated), main_loop);
 
diff --git a/src/libtracker-miner/tracker-miner-crawler.c b/src/libtracker-miner/tracker-miner-crawler.c
index 47f0e87..7cf85f1 100644
--- a/src/libtracker-miner/tracker-miner-crawler.c
+++ b/src/libtracker-miner/tracker-miner-crawler.c
@@ -210,7 +210,7 @@ tracker_miner_crawler_started (TrackerMiner *miner)
 	miner_crawler = TRACKER_MINER_CRAWLER (miner);
 	priv = miner_crawler->_priv;
 
-	tracker_processor_start (priv->processor);
+	/* tracker_processor_start (priv->processor); */
 }
 
 /* Public API */
diff --git a/src/libtracker-miner/tracker-miner-test.c b/src/libtracker-miner/tracker-miner-test.c
index a2571d8..bcc457a 100644
--- a/src/libtracker-miner/tracker-miner-test.c
+++ b/src/libtracker-miner/tracker-miner-test.c
@@ -20,7 +20,7 @@
 
 #include "tracker-miner-test.h"
 
-G_DEFINE_TYPE (TrackerMinerTest, tracker_miner_test, TRACKER_TYPE_MINER_CRAWLER)
+G_DEFINE_TYPE (TrackerMinerTest, tracker_miner_test, TRACKER_TYPE_PROCESSOR)
 
 static void
 tracker_miner_test_class_init (TrackerMinerTestClass *klass)
diff --git a/src/libtracker-miner/tracker-miner-test.h b/src/libtracker-miner/tracker-miner-test.h
index 8f55dfa..d000ef3 100644
--- a/src/libtracker-miner/tracker-miner-test.h
+++ b/src/libtracker-miner/tracker-miner-test.h
@@ -1,7 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
- * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
- * Copyright (C) 2008, Nokia
+ * Copyright (C) 2009, Nokia
 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
@@ -22,7 +21,7 @@
 #ifndef __TRACKER_MINER_TEST_H__
 #define __TRACKER_MINER_TEST_H__
 
-#include <libtracker-miner/tracker-miner-crawler.h>
+#include <libtracker-miner/tracker-processor.h>
 
 G_BEGIN_DECLS
 
@@ -37,11 +36,11 @@ typedef struct TrackerMinerTest TrackerMinerTest;
 typedef struct TrackerMinerTestClass TrackerMinerTestClass;
 
 struct TrackerMinerTest {
-        TrackerMinerCrawler parent_instance;
+        TrackerProcessor parent_instance;
 };
 
 struct TrackerMinerTestClass {
-        TrackerMinerCrawlerClass parent_class;
+        TrackerProcessorClass parent_class;
 };
 
 GType          tracker_miner_test_get_type (void) G_GNUC_CONST;
diff --git a/src/libtracker-miner/tracker-processor.c b/src/libtracker-miner/tracker-processor.c
index 20e970f..86145b2 100644
--- a/src/libtracker-miner/tracker-processor.c
+++ b/src/libtracker-miner/tracker-processor.c
@@ -33,43 +33,31 @@
 #include "tracker-crawler.h"
 #include "tracker-dbus.h"
 #include "tracker-monitor.h"
+#include "tracker-marshal.h"
 #include "tracker-processor.h"
-#include "tracker-status.h"
 
 #define TRACKER_PROCESSOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_PROCESSOR, TrackerProcessorPrivate))
 
-typedef enum {
-	SENT_TYPE_NONE,
-	SENT_TYPE_CREATED,
-	SENT_TYPE_UPDATED,
-	SENT_TYPE_DELETED,
-	SENT_TYPE_MOVED
-} SentType;
-
 struct TrackerProcessorPrivate {
 	TrackerStorage *hal;
 	TrackerMonitor *monitor;
-
-	/* Crawlers */
 	TrackerCrawler *crawler;
 
 	/* File queues for indexer */
 	guint		item_queues_handler_id;
 
-	GQueue         *items_created_queue;
-	GQueue         *items_updated_queue;
-	GQueue         *items_deleted_queue;
-	GQueue         *items_moved_queue;
-
-	SentType	sent_type;
-	GStrv		sent_items;
+	GQueue         *items_created;
+	GQueue         *items_updated;
+	GQueue         *items_deleted;
+	GQueue         *items_moved;
 
-	/* Status */
+	GArray         *dirs;
 	GList          *devices;
 	GList          *current_device;
 
 	GTimer	       *timer;
 
+	/* Status */
 	gboolean        been_started;
 	gboolean	interrupted;
 
@@ -90,79 +78,114 @@ struct TrackerProcessorPrivate {
 	guint		files_ignored;
 };
 
+typedef struct {
+	gchar    *path;
+	gboolean  recurse;
+} DirData;
+
 enum {
+	CHECK_FILE,
+	CHECK_DIR,
+	PROCESS_FILE,
+	MONITOR_DIR,
 	FINISHED,
 	LAST_SIGNAL
 };
 
-static void tracker_processor_finalize        (GObject          *object);
-static void process_device_next               (TrackerProcessor *processor);
-static void process_devices_stop              (TrackerProcessor *processor);
-static void process_check_completely_finished (TrackerProcessor *processor);
-static void process_next                      (TrackerProcessor *processor);
-#if 0
-static void indexer_started_cb                (TrackerIndexer   *indexer,
-					       gpointer          user_data);
-static void indexer_finished_cb               (TrackerIndexer   *indexer,
-					       gdouble           seconds_elapsed,
-					       guint             items_processed,
-					       guint             items_indexed,
-					       gboolean          interrupted,
-					       gpointer          user_data);
-#endif
-static void monitor_item_created_cb           (TrackerMonitor   *monitor,
-					       GFile            *file,
-					       gboolean          is_directory,
-					       gpointer          user_data);
-static void monitor_item_updated_cb           (TrackerMonitor   *monitor,
-					       GFile            *file,
-					       gboolean          is_directory,
-					       gpointer          user_data);
-static void monitor_item_deleted_cb           (TrackerMonitor   *monitor,
-					       GFile            *file,
-					       gboolean          is_directory,
-					       gpointer          user_data);
-static void monitor_item_moved_cb             (TrackerMonitor   *monitor,
-					       GFile            *file,
-					       GFile            *other_file,
-					       gboolean          is_directory,
-					       gboolean          is_source_monitored,
-					       gpointer          user_data);
-static gboolean crawler_process_file_cb           (TrackerCrawler   *crawler,
-					       GFile            *file,
-					       gpointer          user_data);
-static gboolean crawler_process_directory_cb      (TrackerCrawler   *crawler,
-					       GFile            *file,
-					       gpointer          user_data);
-static void crawler_finished_cb               (TrackerCrawler   *crawler,
-					       guint             directories_found,
-					       guint             directories_ignored,
-					       guint             files_found,
-					       guint             files_ignored,
-					       gpointer          user_data);
-#ifdef HAVE_HAL
-static void mount_point_added_cb              (TrackerStorage   *hal,
-                                               const gchar      *volume_uuid,
-                                               const gchar      *mount_point,
-                                               gpointer          user_data);
-static void mount_point_removed_cb            (TrackerStorage   *hal,
-                                               const gchar      *volume_uuid,
-                                               const gchar      *mount_point,
-                                               gpointer          user_data);
-#endif /* HAVE_HAL */
+static void     processor_finalize           (GObject          *object);
+static gboolean processor_defaults           (TrackerProcessor *processor,
+					      GFile            *file);
+static void     processor_started            (TrackerMiner     *miner);
+static void     monitor_item_created_cb      (TrackerMonitor   *monitor,
+					      GFile            *file,
+					      gboolean          is_directory,
+					      gpointer          user_data);
+static void     monitor_item_updated_cb      (TrackerMonitor   *monitor,
+					      GFile            *file,
+					      gboolean          is_directory,
+					      gpointer          user_data);
+static void     monitor_item_deleted_cb      (TrackerMonitor   *monitor,
+					      GFile            *file,
+					      gboolean          is_directory,
+					      gpointer          user_data);
+static void     monitor_item_moved_cb        (TrackerMonitor   *monitor,
+					      GFile            *file,
+					      GFile            *other_file,
+					      gboolean          is_directory,
+					      gboolean          is_source_monitored,
+					      gpointer          user_data);
+static gboolean crawler_process_file_cb      (TrackerCrawler   *crawler,
+					      GFile            *file,
+					      gpointer          user_data);
+static gboolean crawler_process_directory_cb (TrackerCrawler   *crawler,
+					      GFile            *file,
+					      gpointer          user_data);
+static void     crawler_finished_cb          (TrackerCrawler   *crawler,
+					      guint             directories_found,
+					      guint             directories_ignored,
+					      guint             files_found,
+					      guint             files_ignored,
+					      gpointer          user_data);
 
 static guint signals[LAST_SIGNAL] = { 0, };
 
-G_DEFINE_TYPE (TrackerProcessor, tracker_processor, G_TYPE_OBJECT)
-/* G_DEFINE_ABSTRACT_TYPE (TrackerMinerCrawler, tracker_miner_crawler, TRACKER_TYPE_MINER) */
+G_DEFINE_ABSTRACT_TYPE (TrackerProcessor, tracker_processor, TRACKER_TYPE_MINER)
 
 static void
-tracker_processor_class_init (TrackerProcessorClass *class)
+tracker_processor_class_init (TrackerProcessorClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (class);
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        TrackerProcessorClass *processor_class = TRACKER_PROCESSOR_CLASS (klass);
+        TrackerMinerClass *miner_class = TRACKER_MINER_CLASS (klass);
 
-	object_class->finalize = tracker_processor_finalize;
+	object_class->finalize = processor_finalize;
 
+	if (0) {
+	processor_class->check_file   = processor_defaults;
+	processor_class->check_dir    = processor_defaults;
+	processor_class->monitor_dir  = processor_defaults;
+	}
+
+        miner_class->started = processor_started;
+	/*
+        miner_class->stopped = miner_crawler_stopped;
+        miner_class->paused  = miner_crawler_paused;
+        miner_class->resumed = miner_crawler_resumed;
+	*/
+	
+
+	signals[CHECK_FILE] =
+		g_signal_new ("check-file",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (TrackerProcessorClass, check_file),
+			      NULL, NULL,
+			      tracker_marshal_BOOLEAN__OBJECT,
+			      G_TYPE_BOOLEAN, 1, G_TYPE_FILE);
+	signals[CHECK_DIR] =
+		g_signal_new ("check-dir",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (TrackerProcessorClass, check_dir),
+			      NULL, NULL,
+			      tracker_marshal_BOOLEAN__OBJECT,
+			      G_TYPE_BOOLEAN, 1, G_TYPE_FILE);
+	signals[PROCESS_FILE] =
+		g_signal_new ("process-file",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (TrackerProcessorClass, process_file),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__OBJECT,
+			      G_TYPE_NONE, 1, G_TYPE_FILE);
+	signals[MONITOR_DIR] =
+		g_signal_new ("monitor-dir",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (TrackerProcessorClass, monitor_dir),
+			      NULL, NULL,
+			      tracker_marshal_BOOLEAN__OBJECT,
+			      G_TYPE_BOOLEAN, 1, G_TYPE_FILE);
 	signals[FINISHED] =
 		g_signal_new ("finished",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -188,14 +211,48 @@ tracker_processor_init (TrackerProcessor *object)
 	 * a hash table to look up.
 	 */
 
-	priv->items_created_queue = g_queue_new ();
-	priv->items_updated_queue = g_queue_new ();
-	priv->items_deleted_queue = g_queue_new ();
-	priv->items_moved_queue = g_queue_new ();
+	priv->items_created = g_queue_new ();
+	priv->items_updated = g_queue_new ();
+	priv->items_deleted = g_queue_new ();
+	priv->items_moved = g_queue_new ();
+
+	priv->dirs = g_array_new (FALSE, TRUE, sizeof (DirData));
+
+	/* Set up the crawlers now we have config and hal */
+	priv->crawler = tracker_crawler_new ();
+
+	g_signal_connect (priv->crawler, "process-file",
+			  G_CALLBACK (crawler_process_file_cb),
+			  object);
+	g_signal_connect (priv->crawler, "process-directory",
+			  G_CALLBACK (crawler_process_directory_cb),
+			  object);
+	g_signal_connect (priv->crawler, "finished",
+			  G_CALLBACK (crawler_finished_cb),
+			  object);
+
+	/* Set up the monitor */
+	priv->monitor = tracker_monitor_new ();
+
+	g_message ("Disabling monitor events until we have crawled the file system");
+	tracker_monitor_set_enabled (priv->monitor, FALSE);
+
+	g_signal_connect (priv->monitor, "item-created",
+			  G_CALLBACK (monitor_item_created_cb),
+			  object);
+	g_signal_connect (priv->monitor, "item-updated",
+			  G_CALLBACK (monitor_item_updated_cb),
+			  object);
+	g_signal_connect (priv->monitor, "item-deleted",
+			  G_CALLBACK (monitor_item_deleted_cb),
+			  object);
+	g_signal_connect (priv->monitor, "item-moved",
+			  G_CALLBACK (monitor_item_moved_cb),
+			  object);
 }
 
 static void
-tracker_processor_finalize (GObject *object)
+processor_finalize (GObject *object)
 {
 	TrackerProcessorPrivate *priv;
 
@@ -210,18 +267,6 @@ tracker_processor_finalize (GObject *object)
 		priv->item_queues_handler_id = 0;
 	}
 
-	g_queue_foreach (priv->items_moved_queue, (GFunc) g_object_unref, NULL);
-	g_queue_free (priv->items_moved_queue);
-
-	g_queue_foreach (priv->items_deleted_queue, (GFunc) g_object_unref, NULL);
-	g_queue_free (priv->items_deleted_queue);
-
-	g_queue_foreach (priv->items_updated_queue, (GFunc) g_object_unref, NULL);
-	g_queue_free (priv->items_updated_queue);
-
-	g_queue_foreach (priv->items_created_queue, (GFunc) g_object_unref, NULL);
-	g_queue_free (priv->items_created_queue);
-
 	if (priv->crawler) {
 		guint lsignals;
 
@@ -250,325 +295,155 @@ tracker_processor_finalize (GObject *object)
 		g_object_unref (priv->crawler);
 	}
 
-#if 0
-	g_signal_handlers_disconnect_by_func (priv->indexer,
-					      G_CALLBACK (indexer_started_cb),
-					      NULL);
-	g_signal_handlers_disconnect_by_func (priv->indexer,
-					      G_CALLBACK (indexer_finished_cb),
-					      NULL);
-#endif
-
-	g_signal_handlers_disconnect_by_func (priv->monitor,
-					      G_CALLBACK (monitor_item_deleted_cb),
-					      object);
-	g_signal_handlers_disconnect_by_func (priv->monitor,
-					      G_CALLBACK (monitor_item_updated_cb),
-					      object);
-	g_signal_handlers_disconnect_by_func (priv->monitor,
-					      G_CALLBACK (monitor_item_created_cb),
-					      object);
-	g_signal_handlers_disconnect_by_func (priv->monitor,
-					      G_CALLBACK (monitor_item_moved_cb),
-					      object);
-	g_object_unref (priv->monitor);
-
-#ifdef HAVE_HAL
-	if (priv->devices) {
-		g_list_foreach (priv->devices, (GFunc) g_free, NULL);
-		g_list_free (priv->devices);
-	}
-
-	if (priv->hal) {
-		g_signal_handlers_disconnect_by_func (priv->hal,
-		                                      mount_point_added_cb,
-		                                      object);
-		g_signal_handlers_disconnect_by_func (priv->hal,
-		                                      mount_point_removed_cb,
-		                                      object);
-
-		g_object_unref (priv->hal);
+	if (priv->monitor) {
+		g_signal_handlers_disconnect_by_func (priv->monitor,
+						      G_CALLBACK (monitor_item_deleted_cb),
+						      object);
+		g_signal_handlers_disconnect_by_func (priv->monitor,
+						      G_CALLBACK (monitor_item_updated_cb),
+						      object);
+		g_signal_handlers_disconnect_by_func (priv->monitor,
+						      G_CALLBACK (monitor_item_created_cb),
+						      object);
+		g_signal_handlers_disconnect_by_func (priv->monitor,
+						      G_CALLBACK (monitor_item_moved_cb),
+						      object);
+		g_object_unref (priv->monitor);
 	}
-#endif /* HAVE_HAL */
-
-	G_OBJECT_CLASS (tracker_processor_parent_class)->finalize (object);
-}
-
-
-static void
-get_remote_roots (TrackerProcessor  *processor,
-		  GList	           **mounted_directory_roots,
-		  GList	           **removable_device_roots)
-{
-	GList *l1;
-	GList *l2;
 
-#ifdef HAVE_HAL
-	l1 = tracker_storage_get_mounted_directory_roots (processor->private->hal);
-	l2 = tracker_storage_get_removable_device_roots (processor->private->hal);
-#else  /* HAVE_HAL */
-	l1 = NULL;
-	l2 = NULL;
-#endif /* HAVE_HAL */
-
-	/* The options to index removable media and the index mounted
-	 * directories are both mutually exclusive even though
-	 * removable media is mounted on a directory.
-	 *
-	 * Since we get ALL mounted directories from HAL, we need to
-	 * remove those which are removable device roots.
-	 */
-	if (l2) {
-		GList *l;
-		GList *list = NULL;
+	if (priv->dirs) {
+		gint i;
 
-		for (l = l1; l; l = l->next) {
-			if (g_list_find_custom (l2, l->data, (GCompareFunc) g_strcmp0)) {
-				continue;
-			}
+		for (i = 0; i < priv->dirs->len; i++) {
+			DirData dd;
 
-			list = g_list_prepend (list, l->data);
+			dd = g_array_index (priv->dirs, DirData, i);
+			g_free (dd.path);
 		}
 
-		*mounted_directory_roots = g_list_reverse (list);
-	} else {
-		*mounted_directory_roots = NULL;
+		g_array_free (priv->dirs, TRUE);
 	}
 
-	*removable_device_roots = g_list_copy (l2);
-}
+	g_queue_foreach (priv->items_moved, (GFunc) g_object_unref, NULL);
+	g_queue_free (priv->items_moved);
 
-static gboolean
-path_should_be_ignored_for_media (TrackerProcessor *processor,
-				  const gchar	   *path)
-{
-	GList	 *roots = NULL;
-	GList	 *mounted_directory_roots = NULL;
-	GList	 *removable_device_roots = NULL;
-	GList	 *l;
-	gboolean  ignore_mounted_directories;
-	gboolean  ignore_removable_devices;
-	gboolean  ignore = FALSE;
+	g_queue_foreach (priv->items_deleted, (GFunc) g_object_unref, NULL);
+	g_queue_free (priv->items_deleted);
 
-#ifdef FIX
-	ignore_mounted_directories =
-		!tracker_config_get_index_mounted_directories (processor->private->config);
-	ignore_removable_devices =
-		!tracker_config_get_index_removable_devices (processor->private->config);
-#endif
+	g_queue_foreach (priv->items_updated, (GFunc) g_object_unref, NULL);
+	g_queue_free (priv->items_updated);
 
-	if (ignore_mounted_directories || ignore_removable_devices) {
-		get_remote_roots (processor,
-				  &mounted_directory_roots,
-				  &removable_device_roots);
-	}
-
-	if (ignore_mounted_directories) {
-		roots = g_list_concat (roots, mounted_directory_roots);
-	}
-
-	if (ignore_removable_devices) {
-		roots = g_list_concat (roots, removable_device_roots);
-	}
-
-	for (l = roots; l && !ignore; l = l->next) {
-		/* If path matches a mounted or removable device by
-		 * prefix then we should ignore it since we don't
-		 * crawl those by choice in the config.
-		 */
-		if (strcmp (path, l->data) == 0) {
-			ignore = TRUE;
-		}
+	g_queue_foreach (priv->items_created, (GFunc) g_object_unref, NULL);
+	g_queue_free (priv->items_created);
 
-		/* FIXME: Should we add a DIR_SEPARATOR on the end of
-		 * these before comparing them?
-		 */
-		if (g_str_has_prefix (path, l->data)) {
-			ignore = TRUE;
-		}
+#ifdef HAVE_HAL
+	if (priv->devices) {
+		g_list_foreach (priv->devices, (GFunc) g_free, NULL);
+		g_list_free (priv->devices);
 	}
+#endif /* HAVE_HAL */
 
-	g_list_free (roots);
-
-	return ignore;
+	G_OBJECT_CLASS (tracker_processor_parent_class)->finalize (object);
 }
 
-static void
-item_queue_processed_cb (TrackerProcessor *processor)
+static gboolean 
+processor_defaults (TrackerProcessor *processor,
+		    GFile            *file)
 {
-	g_strfreev (processor->private->sent_items);
-
-	/* Reset for next batch to be sent */
-	processor->private->sent_items = NULL;
-	processor->private->sent_type = SENT_TYPE_NONE;
+	return TRUE;
 }
 
-static gboolean
-item_queue_handlers_cb (gpointer user_data)
+static void
+processor_started (TrackerMiner *miner)
 {
 	TrackerProcessor *processor;
-	TrackerStatus     status;
-	GQueue		 *queue;
-	GStrv		  files;
-	gboolean          should_repeat = FALSE;
-	GTimeVal          time_now;
-	static GTimeVal   time_last = { 0, 0 };
+	gint i;
 
-	processor = user_data;
-
-	status = tracker_status_get ();
+	processor = TRACKER_PROCESSOR (miner);
 
-	/* Don't spam */
-	g_get_current_time (&time_now);
-
-	should_repeat = (time_now.tv_sec - time_last.tv_sec) >= 10;
-	if (should_repeat) {
-		time_last = time_now;
-	}
+	processor->private->been_started = TRUE;
 
-	switch (status) {
-	case TRACKER_STATUS_PAUSED:
-		/* This way we don't send anything to the indexer from
-		 * monitor events but we still queue them ready to
-		 * send when we are unpaused.  
-		 */
-		if (should_repeat) {
-			g_message ("We are paused, sending nothing to the "
-				   "indexer until we are unpaused");
-		}
+	processor->private->interrupted = FALSE;
 
-	case TRACKER_STATUS_PENDING:
-	case TRACKER_STATUS_WATCHING:
-		/* Wait until we have finished crawling before
-		 * sending anything.
-		 */
-		return TRUE;
+	processor->private->finished_files = FALSE;
+	processor->private->finished_devices = FALSE;
+	processor->private->finished_sending = FALSE;
+	processor->private->finished_indexer = FALSE;
 
-	default:
-		break;
+	/* Go through dirs and crawl */
+	if (!processor->private->dirs) {
+		g_message ("No directories set up for processor to handle, doing nothing");
+		return;
 	}
 
-	/* This is here so we don't try to send something if we are
-	 * still waiting for a response from the last send.
-	 */
-	if (processor->private->sent_type != SENT_TYPE_NONE) {
-		if (should_repeat) {
-			g_message ("Still waiting for response from indexer, "
-				   "not sending more files yet");
-		}
+	for (i = 0; i < processor->private->dirs->len; i++) {
+		DirData dd;
+		
+		dd = g_array_index (processor->private->dirs, DirData, i);
 
-		return TRUE;
+		tracker_crawler_start (processor->private->crawler, 
+				       dd.path, 
+				       dd.recurse);
 	}
 
-	/* Process the deleted items first */
-	queue = processor->private->items_deleted_queue;
-
-	if (queue) {
-		files = tracker_dbus_queue_gfile_to_strv (queue, -1);
-
-		g_message ("Queue for deleted items processed, sending %d to the indexer",
-			   g_strv_length (files));
 
-		processor->private->finished_indexer = FALSE;
+#if 0
+	process_next (processor);
+#endif
+}
 
-		processor->private->sent_type = SENT_TYPE_DELETED;
-		processor->private->sent_items = files;
+static gboolean
+item_queue_handlers_cb (gpointer user_data)
+{
+	TrackerProcessor *processor;
+	GFile *file;
 
-		item_queue_processed_cb (processor);
+	processor = user_data;
 
+	/* Deleted items first */
+	file = g_queue_pop_head (processor->private->items_deleted);
+	if (file) {
+		g_signal_emit (processor, signals[PROCESS_FILE], 0, file);
+		g_object_unref (file);
+	
 		return TRUE;
 	}
 
-	/* Process the created items next */
-	queue = processor->private->items_created_queue;
-
-	if (queue) {
-		/* Now we try to send items to the indexer */
-		tracker_status_set_and_signal (TRACKER_STATUS_INDEXING);
-
-		files = tracker_dbus_queue_gfile_to_strv (queue, -1);
-
-		g_message ("Queue for created items processed, sending %d to the indexer",
-			   g_strv_length (files));
-
-		processor->private->finished_indexer = FALSE;
-
-		processor->private->sent_type = SENT_TYPE_CREATED;
-		processor->private->sent_items = files;
-
-		item_queue_processed_cb (processor);
-
+	/* Created items next */
+	file = g_queue_pop_head (processor->private->items_created);
+	if (file) {
+		g_signal_emit (processor, signals[PROCESS_FILE], 0, file);
+		g_object_unref (file);
+	
 		return TRUE;
 	}
 
-	/* Process the updated items next */
-	queue = processor->private->items_updated_queue;
-
-	if (queue) {
-		/* Now we try to send items to the indexer */
-		tracker_status_set_and_signal (TRACKER_STATUS_INDEXING);
-
-		files = tracker_dbus_queue_gfile_to_strv (queue, -1);
-
-		g_message ("Queue for updated items processed, sending %d to the indexer",
-			   g_strv_length (files));
-
-		processor->private->finished_indexer = FALSE;
-
-		processor->private->sent_type = SENT_TYPE_UPDATED;
-		processor->private->sent_items = files;
-
-		item_queue_processed_cb (processor);
-
+	/* Updated items next */
+	file = g_queue_pop_head (processor->private->items_updated);
+	if (file) {
+		g_signal_emit (processor, signals[PROCESS_FILE], 0, file);
+		g_object_unref (file);
+	
 		return TRUE;
 	}
 
-	/* Process the moved items last */
-	queue = processor->private->items_moved_queue;
-
-	if (queue) {
-		const gchar *source;
-		const gchar *target;
-
-		/* Now we try to send items to the indexer */
-		tracker_status_set_and_signal (TRACKER_STATUS_INDEXING);
-
-		files = tracker_dbus_queue_gfile_to_strv (queue, 2);
-
-		if (files) {
-			source = files[0];
-			target = files[1];
-		} else {
-			source = NULL;
-			target = NULL;
-		}
-
-		g_message ("Queue for moved items processed, sending %d to the indexer",
-			   g_strv_length (files));
-
-		processor->private->finished_indexer = FALSE;
-
-		processor->private->sent_type = SENT_TYPE_MOVED;
-		processor->private->sent_items = files;
-
-		item_queue_processed_cb (processor);
-
+	/* Moved items next */
+	file = g_queue_pop_head (processor->private->items_moved);
+	if (file) {
+		g_signal_emit (processor, signals[PROCESS_FILE], 0, file);
+		g_object_unref (file);
+	
 		return TRUE;
 	}
 
 	processor->private->item_queues_handler_id = 0;
 
-	processor->private->finished_sending = TRUE;
-	process_check_completely_finished (processor);
-
 	return FALSE;
 }
 
 static void
 item_queue_handlers_set_up (TrackerProcessor *processor)
 {
-	processor->private->finished_sending = FALSE;
-
 	if (processor->private->item_queues_handler_id != 0) {
 		return;
 	}
@@ -578,484 +453,35 @@ item_queue_handlers_set_up (TrackerProcessor *processor)
 			    processor);
 }
 
-static gboolean
-is_path_on_ignore_list (GSList	    *ignore_list,
-			const gchar *path)
-{
-	GSList *l;
-
-	if (!ignore_list || !path) {
-		return FALSE;
-	}
-
-	for (l = ignore_list; l; l = l->next) {
-		if (strcmp (path, l->data) == 0) {
-			return TRUE;
-		}
-	}
-
-	return FALSE;
-}
-
-static void
-process_files_add_legacy_options (TrackerProcessor *processor)
-{
-	GSList	       *no_watch_roots;
-	GSList	       *watch_roots;
-	GSList	       *crawl_roots;
-	GSList	       *l;
-	guint		watch_root_count;
-	guint		crawl_root_count;
-
-#ifdef FIX
-	tracker_crawler_use_module_paths (processor->private->crawler, TRUE);
-	tracker_crawler_special_paths_clear (processor->private->crawler);
-
-	no_watch_roots = tracker_config_get_no_watch_directory_roots (processor->private->config);
-	watch_roots = tracker_config_get_watch_directory_roots (processor->private->config);
-	crawl_roots = tracker_config_get_crawl_directory_roots (processor->private->config);
-#else
-	no_watch_roots = NULL;
-	watch_roots = g_slist_append (NULL, g_get_home_dir ());
-	crawl_roots = NULL;
-#endif
-
-	watch_root_count = 0;
-	crawl_root_count = 0;
-
-	/* This module get special treatment to make sure legacy
-	 * options are supported.
-	 */
-
-	/* Print ignored locations */
-	g_message ("  User ignored crawls & monitors:");
-	for (l = no_watch_roots; l; l = l->next) {
-		g_message ("    %s", (gchar*) l->data);
-	}
-
-	if (g_slist_length (no_watch_roots) == 0) {
-		g_message ("    NONE");
-	}
-
-	/* Add monitors, from WatchDirectoryRoots config key */
-	g_message ("  User monitors being added:");
-	for (l = watch_roots; l; l = l->next) {
-		GFile *file;
-
-		if (is_path_on_ignore_list (no_watch_roots, l->data)) {
-			continue;
-		}
-
-		g_message ("    %s", (gchar*) l->data);
-
-		file = g_file_new_for_path (l->data);
-		tracker_monitor_add (processor->private->monitor, file);
-		g_object_unref (file);
-
-		watch_root_count++;
-	}
-
-	if (g_slist_length (watch_roots) == 0) {
-		g_message ("    NONE");
-	}
-
-	/* Add crawls, from WatchDirectoryRoots and
-	 * CrawlDirectoryRoots config keys.
-	 */
-	g_message ("  User crawls being added:");
-
-	for (l = watch_roots; l; l = l->next) {
-		if (is_path_on_ignore_list (no_watch_roots, l->data)) {
-			continue;
-		}
-
-		g_message ("    %s", (gchar*) l->data);
-#ifdef FIX
-		tracker_crawler_special_paths_add (processor->private->crawler, l->data);
-#endif
-	}
-
-	for (l = crawl_roots; l; l = l->next) {
-		if (is_path_on_ignore_list (no_watch_roots, l->data)) {
-			continue;
-		}
-
-		g_message ("    %s", (gchar*) l->data);
-#ifdef FIX
-		tracker_crawler_special_paths_add (processor->private->crawler, l->data);
-#endif
-		crawl_root_count++;
-	}
-
-	if (g_slist_length (watch_roots) == 0 &&
-	    g_slist_length (crawl_roots) == 0) {
-		g_message ("    NONE");
-	}
-}
-
-static void
-process_device (TrackerProcessor *processor,
-		const gchar	 *device_root)
-{
-	GFile          *file;
-
-	g_message ("Processing device with root:'%s'", device_root);
-
-	/* Here we set up legacy .cfg options like watch roots */
-	tracker_status_set_and_signal (TRACKER_STATUS_WATCHING);
-
-	/* Gets all files and directories */
-	tracker_status_set_and_signal (TRACKER_STATUS_PENDING);
-
-#ifdef FIX
-	tracker_crawler_use_module_paths (processor->private->crawler, FALSE);
-	tracker_crawler_special_paths_clear (processor->private->crawler);
-#endif
-
-	if (path_should_be_ignored_for_media (processor, device_root)) {
-		g_message ("  Ignored due to config");
-		process_device_next (processor);
-		return;
-	}
-
-	file = g_file_new_for_path (device_root);
-	tracker_monitor_add (processor->private->monitor, file);
-	g_object_unref (file);
-	
-#ifdef FIX
-	tracker_crawler_special_paths_add (processor->private->crawler, device_root);
-#endif
-
-	if (!tracker_crawler_start (processor->private->crawler, device_root, TRUE)) {
-		process_device_next (processor);
-	}
-}
-
-static void
-process_device_next (TrackerProcessor *processor)
-{
-	if (tracker_status_get_is_readonly ()) {
-		/* Block any request to process
-		 * files if indexing is not enabled
-		 */
-		return;
-	}
-
-	/* Don't recursively iterate the devices */
-	if (!processor->private->current_device) {
-		if (!processor->private->finished_devices) {
-			processor->private->current_device = processor->private->devices;
-		}
-	} else {
-		GList *l;
-
-		l = processor->private->current_device;
-		
-		/* Now free that device so we don't recrawl it */
-		if (l) {
-			g_free (l->data);
-			
-			processor->private->current_device = 
-			processor->private->devices = 
-				g_list_delete_link (processor->private->devices, l);
-		}
-	}
-
-	/* If we have no further devices to iterate */
-	if (!processor->private->current_device) {
-		process_devices_stop (processor);
-		process_next (processor);
-		return;
-	}
-
-	process_device (processor, processor->private->current_device->data);
-}
-
 static void
-process_files_start (TrackerProcessor *processor)
-{
-	g_message ("Processor has started iterating files");
-
-	if (processor->private->timer) {
-		g_timer_destroy (processor->private->timer);
-	}
-
-	processor->private->timer = g_timer_new ();
-
-	processor->private->finished_files = FALSE;
-
-	processor->private->directories_found = 0;
-	processor->private->directories_ignored = 0;
-	processor->private->files_found = 0;
-	processor->private->files_ignored = 0;
-
-	g_message ("Processing files");
-
-	/* Here we set up legacy .cfg options like watch roots */
-	tracker_status_set_and_signal (TRACKER_STATUS_WATCHING);
-
-	process_files_add_legacy_options (processor);
-
-	/* Gets all files and directories */
-	tracker_status_set_and_signal (TRACKER_STATUS_PENDING);
-
-	tracker_crawler_start (processor->private->crawler, g_get_home_dir (), FALSE);
-}
-
-static void
-process_files_stop (TrackerProcessor *processor)
-{
-	if (processor->private->finished_files) {
-		return;
-	}
-
-	g_message ("--------------------------------------------------");
-	g_message ("Processor has %s iterating files",
-		   processor->private->interrupted ? "been stopped while" : "finished");
-
-	processor->private->finished_files = TRUE;
-
-	if (processor->private->interrupted) {
-		if (processor->private->crawler) {
-			tracker_crawler_stop (processor->private->crawler);
-		}
-
-		if (processor->private->timer) {
-			g_timer_destroy (processor->private->timer);
-			processor->private->timer = NULL;
-		}
-	} else {
-		gdouble elapsed;
-	
-		if (processor->private->timer) {
-			g_timer_stop (processor->private->timer);
-			elapsed = g_timer_elapsed (processor->private->timer, NULL);
-		} else {
-			elapsed = 0;
-		}
-		
-		g_message ("FS time taken : %4.4f seconds",
-			   elapsed);
-		g_message ("FS directories: %d (%d ignored)",
-			   processor->private->directories_found,
-			   processor->private->directories_ignored);
-		g_message ("FS files      : %d (%d ignored)",
-			   processor->private->files_found,
-			   processor->private->files_ignored);
-	}
-
-	g_message ("--------------------------------------------------\n");
-}
-
-static void
-process_devices_start (TrackerProcessor *processor)
-{
-	g_message ("Processor has started iterating %d devices", 
-		   g_list_length (processor->private->devices));
-
-	if (processor->private->timer) {
-		g_timer_destroy (processor->private->timer);
-	}
-
-	processor->private->timer = g_timer_new ();
-
-	processor->private->finished_devices = FALSE;
-
-	processor->private->directories_found = 0;
-	processor->private->directories_ignored = 0;
-	processor->private->files_found = 0;
-	processor->private->files_ignored = 0;
-
-	process_device_next (processor);
-}
-
-static void
-process_devices_stop (TrackerProcessor *processor)
-{
-	if (processor->private->finished_devices) {
-		return;
-	}
-
-	g_message ("--------------------------------------------------");
-	g_message ("Processor has %s iterating devices",
-		   processor->private->interrupted ? "been stopped while" : "finished");
-
-	processor->private->finished_devices = TRUE;
-
-	if (processor->private->interrupted) {
-		if (processor->private->crawler) {
-			tracker_crawler_stop (processor->private->crawler);
-		}
-
-		if (processor->private->timer) {
-			g_timer_destroy (processor->private->timer);
-			processor->private->timer = NULL;
-		}
-	} else {
-		gdouble elapsed;
-	
-		if (processor->private->timer) {
-			g_timer_stop (processor->private->timer);
-			elapsed = g_timer_elapsed (processor->private->timer, NULL);
-		} else {
-			elapsed = 0;
-		}
-		
-		g_message ("Device time taken : %4.4f seconds",
-			   elapsed);
-		g_message ("Device directories: %d (%d ignored)",
-			   processor->private->directories_found,
-			   processor->private->directories_ignored);
-		g_message ("Device files      : %d (%d ignored)",
-			   processor->private->files_found,
-			   processor->private->files_ignored);
-	}
-	
-	g_message ("--------------------------------------------------\n");
-}
-
-static void
-process_continue (TrackerProcessor *processor)
-{
-	if (!processor->private->finished_files) {
-		return;
-	}
-
-	if (!processor->private->finished_devices) {
-		process_device_next (processor);
-		return;
-	}
-
-	/* Nothing to do */
-}
-
-static void
-process_next (TrackerProcessor *processor)
-{
-	if (!processor->private->finished_files) {
-		process_files_start (processor);
-		return;
-	}
-
-	if (!processor->private->finished_devices) {
-		process_devices_start (processor);
-		return;
-	}
-
-	/* Only do this the first time, otherwise the results are
-	 * likely to be inaccurate. Devices can be added or removed so
-	 * we can't assume stats are correct.
-	 */
-	if (tracker_status_get_is_initial_check ()) {
-		g_message ("--------------------------------------------------");
-		g_message ("Total directories : %d (%d ignored)",
-			   processor->private->total_directories_found,
-			   processor->private->total_directories_ignored);
-		g_message ("Total files       : %d (%d ignored)",
-			   processor->private->total_files_found,
-			   processor->private->total_files_ignored);
-		g_message ("Total monitors    : %d",
-			   tracker_monitor_get_count (processor->private->monitor));
-		g_message ("--------------------------------------------------\n");
-	}
-
-	/* Now we have finished crawling, we enable monitor events */
-	g_message ("Enabling monitor events");
-	tracker_monitor_set_enabled (processor->private->monitor, TRUE);
-
-	/* Now we set the state to IDLE, the reason we do this, is it
-	 * allows us to either return to an idle state if there was
-	 * nothing to do, OR it allows us to start handling the
-	 * queues of files we just crawled. The queue handler won't
-	 * send files to the indexer while we are PENDING or WATCHING.
-	 */
-	tracker_status_set_and_signal (TRACKER_STATUS_IDLE);	
-}
-
-static void
-process_finish (TrackerProcessor *processor)
-{
-	/* TODO: Optimize DBs
-	tracker_status_set_and_signal (TRACKER_STATUS_OPTIMIZING);
-	tracker_db_manager_optimize ();
-	 */
-	
-	/* All done */
-	tracker_status_set_and_signal (TRACKER_STATUS_IDLE);
-
-	/* Set our internal state */
-	tracker_status_set_is_initial_check (FALSE);
-	
-	g_signal_emit (processor, signals[FINISHED], 0);
-}
-
-static void
-process_check_completely_finished (TrackerProcessor *processor)
-{
-	if (!processor->private->finished_sending ||
-	    !processor->private->finished_indexer) {
-		return;
-	}
-	
-	process_finish (processor);
-}
-
-#if 0
-static void
-indexer_started_cb (TrackerIndexer *indexer,
-		    gpointer	 user_data)
-{
-	TrackerProcessor *processor;
-
-	processor = user_data;
-
-	processor->private->finished_indexer = FALSE;
-}
-
-static void
-indexer_finished_cb (TrackerIndexer *indexer,
-		     gdouble	  seconds_elapsed,
-		     guint        items_processed,
-		     guint	  items_indexed,
-		     gboolean	  interrupted,
-		     gpointer	  user_data)
+monitor_item_created_cb (TrackerMonitor *monitor,
+			 GFile		*file,
+			 gboolean	 is_directory,
+			 gpointer	 user_data)
 {
 	TrackerProcessor *processor;
+	gboolean should_process = TRUE;
+	gchar *path;
 
 	processor = user_data;
 
-	/* Save indexer's state */
-	processor->private->finished_indexer = TRUE;
-	process_check_completely_finished (processor);
-}
-#endif
-
-static void
-processor_files_check (TrackerProcessor *processor,
-		       GFile		*file,
-		       gboolean		 is_directory)
-{
-	gboolean	ignored;
-	gchar	       *path;
+	g_signal_emit (processor, signals[CHECK_FILE], 0, file, &should_process);
 
 	path = g_file_get_path (file);
-#ifdef FIX
-	ignored = tracker_crawler_is_path_ignored (processor->private->crawler, path, is_directory);
-#endif
 
 	g_debug ("%s:'%s' (%s) (create monitor event or user request)",
-		 ignored ? "Ignored" : "Found ",
+		 should_process ? "Found " : "Ignored",
 		 path,
 		 is_directory ? "DIR" : "FILE");
 
-	if (!ignored) {
+	if (should_process) {
 		if (is_directory) {
 #ifdef FIX
 			tracker_crawler_add_unexpected_path (processor->private->crawler, path);
 #endif
 		}
 
-		g_queue_push_tail (processor->private->items_created_queue, 
+		g_queue_push_tail (processor->private->items_created, 
 				   g_object_ref (file));
 		
 		item_queue_handlers_set_up (processor);
@@ -1065,24 +491,26 @@ processor_files_check (TrackerProcessor *processor,
 }
 
 static void
-processor_files_update (TrackerProcessor *processor,
-			GFile		 *file,
-			gboolean	  is_directory)
+monitor_item_updated_cb (TrackerMonitor *monitor,
+			 GFile		*file,
+			 gboolean	 is_directory,
+			 gpointer	 user_data)
 {
-	gchar	       *path;
-	gboolean	ignored;
+	TrackerProcessor *processor;
+	gchar *path;
+	gboolean should_process = TRUE;
+
+	g_signal_emit (processor, signals[CHECK_FILE], 0, file, &should_process);
 
 	path = g_file_get_path (file);
-#ifdef FIX
-	ignored = tracker_crawler_is_path_ignored (processor->private->crawler, path, is_directory);
-#endif
-	g_debug ("%s:'%s' (%s) (update monitor event or user request)",
-		 ignored ? "Ignored" : "Found ",
+
+ 	g_debug ("%s:'%s' (%s) (update monitor event or user request)",
+		 should_process ? "Found " : "Ignored",
 		 path,
 		 is_directory ? "DIR" : "FILE");
 
-	if (!ignored) {
-		g_queue_push_tail (processor->private->items_updated_queue, 
+	if (should_process) {
+		g_queue_push_tail (processor->private->items_updated, 
 				   g_object_ref (file));
 		
 		item_queue_handlers_set_up (processor);
@@ -1092,118 +520,37 @@ processor_files_update (TrackerProcessor *processor,
 }
 
 static void
-processor_files_delete (TrackerProcessor *processor,
-			GFile		 *file,
-			gboolean	  is_directory)
+monitor_item_deleted_cb (TrackerMonitor *monitor,
+			 GFile		*file,
+			 gboolean	 is_directory,
+			 gpointer	 user_data)
 {
-	gchar	       *path;
-	gboolean	ignored;
-
-	path = g_file_get_path (file);
-#ifdef FIX
-	ignored = tracker_crawler_is_path_ignored (processor->private->crawler, path, is_directory);
-#endif
-	g_debug ("%s:'%s' (%s) (delete monitor event or user request)",
-		 ignored ? "Ignored" : "Found ",
-		 path,
-		 is_directory ? "DIR" : "FILE");
-
-	if (!ignored) {
-		g_queue_push_tail (processor->private->items_deleted_queue, 
-				   g_object_ref (file));
-		
-		item_queue_handlers_set_up (processor);
-	}
+	TrackerProcessor *processor;
+	gchar *path;
+	gboolean should_process = TRUE;
 
-	g_free (path);
-}
+	processor = user_data;
 
-static void
-processor_files_move (TrackerProcessor *processor,
-		      GFile	       *file,
-		      GFile	       *other_file,
-		      gboolean		is_directory)
-{
-	gchar	       *path;
-	gchar	       *other_path;
-	gboolean	path_ignored;
-	gboolean	other_path_ignored;
+	g_signal_emit (processor, signals[CHECK_FILE], 0, file, &should_process);
 
 	path = g_file_get_path (file);
-	other_path = g_file_get_path (other_file);
 
-#ifdef FIX
-	path_ignored = tracker_crawler_is_path_ignored (processor->private->crawler, path, is_directory);
-	other_path_ignored = tracker_crawler_is_path_ignored (processor->private->crawler, other_path, is_directory);
-#endif
-
-	g_debug ("%s:'%s'->'%s':%s (%s) (move monitor event or user request)",
-		 path_ignored ? "Ignored" : "Found ",
+	g_debug ("%s:'%s' (%s) (delete monitor event or user request)",
+		 should_process ? "Found " : "Ignored",
 		 path,
-		 other_path,
-		 other_path_ignored ? "Ignored" : " Found",
 		 is_directory ? "DIR" : "FILE");
 
-	if (path_ignored && other_path_ignored) {
-		/* Do nothing */
-	} else if (path_ignored) {
-		/* Check new file */
-		if (!is_directory) {
-			g_queue_push_tail (processor->private->items_created_queue, 
-					   g_object_ref (other_file));
-
-			item_queue_handlers_set_up (processor);
-		}
-
-		/* If this is a directory we need to crawl it */
-#ifdef FIX
-		tracker_crawler_add_unexpected_path (processor->private->crawler, other_path);
-#endif
-	} else if (other_path_ignored) {
-		/* Delete old file */
-		g_queue_push_tail (processor->private->items_deleted_queue, g_object_ref (file));
-
-		item_queue_handlers_set_up (processor);
-	} else {
-		/* Move old file to new file */
-		g_queue_push_tail (processor->private->items_moved_queue, g_object_ref (file));
-		g_queue_push_tail (processor->private->items_moved_queue, g_object_ref (other_file));
-
+	if (should_process) {
+		g_queue_push_tail (processor->private->items_deleted, 
+				   g_object_ref (file));
+		
 		item_queue_handlers_set_up (processor);
 	}
 
-	g_free (other_path);
 	g_free (path);
 }
 
 static void
-monitor_item_created_cb (TrackerMonitor *monitor,
-			 GFile		*file,
-			 gboolean	 is_directory,
-			 gpointer	 user_data)
-{
-	processor_files_check (user_data, file, is_directory);
-}
-
-static void
-monitor_item_updated_cb (TrackerMonitor *monitor,
-			 GFile		*file,
-			 gboolean	 is_directory,
-			 gpointer	 user_data)
-{
-	processor_files_update (user_data, file, is_directory);
-}
-
-static void
-monitor_item_deleted_cb (TrackerMonitor *monitor,
-			 GFile		*file,
-			 gboolean	 is_directory,
-			 gpointer	 user_data)
-{
-	processor_files_delete (user_data, file, is_directory);
-}
-
-static void
 monitor_item_moved_cb (TrackerMonitor *monitor,
 		       GFile	      *file,
 		       GFile	      *other_file,
@@ -1211,11 +558,12 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
 		       gboolean        is_source_monitored,
 		       gpointer        user_data)
 {
-	if (!is_source_monitored) {
-		TrackerProcessor *processor;
-		gchar            *path;
+	TrackerProcessor *processor;
 
-		processor = user_data;
+	processor = user_data;
+
+	if (!is_source_monitored) {
+		gchar *path;
 
 		/* If the source is not monitored, we need to crawl it. */
 		path = g_file_get_path (other_file);
@@ -1224,7 +572,54 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
 #endif
 		g_free (path);
 	} else {
-		processor_files_move (user_data, file, other_file, is_directory);
+		gchar *path;
+		gchar *other_path;
+		gboolean should_process;
+		gboolean should_process_other;
+		
+		path = g_file_get_path (file);
+		other_path = g_file_get_path (other_file);
+
+		g_signal_emit (processor, signals[CHECK_FILE], 0, file, &should_process);
+		g_signal_emit (processor, signals[CHECK_FILE], 0, other_file, &should_process_other);
+		
+		g_debug ("%s:'%s'->'%s':%s (%s) (move monitor event or user request)",
+			 should_process ? "Found " : "Ignored",
+			 path,
+			 other_path,
+			 should_process_other ? "Found " : "Ignored",
+			 is_directory ? "DIR" : "FILE");
+		
+		if (!should_process && !should_process_other) {
+			/* Do nothing */
+		} else if (!should_process) {
+			/* Check new file */
+			if (!is_directory) {
+				g_queue_push_tail (processor->private->items_created, 
+						   g_object_ref (other_file));
+				
+				item_queue_handlers_set_up (processor);
+			}
+			
+			/* If this is a directory we need to crawl it */
+#ifdef FIX
+			tracker_crawler_add_unexpected_path (processor->private->crawler, other_path);
+#endif
+		} else if (!should_process_other) {
+			/* Delete old file */
+			g_queue_push_tail (processor->private->items_deleted, g_object_ref (file));
+			
+			item_queue_handlers_set_up (processor);
+		} else {
+			/* Move old file to new file */
+			g_queue_push_tail (processor->private->items_moved, g_object_ref (file));
+			g_queue_push_tail (processor->private->items_moved, g_object_ref (other_file));
+			
+			item_queue_handlers_set_up (processor);
+		}
+		
+		g_free (other_path);
+		g_free (path);
 	}
 }
 
@@ -1234,16 +629,20 @@ crawler_process_file_cb (TrackerCrawler *crawler,
 			 gpointer	 user_data)
 {
 	TrackerProcessor *processor;
+	gboolean should_process = TRUE;
 
 	processor = user_data;
 
-	/* Add files in queue to our queues to send to the indexer */
-	g_queue_push_tail (processor->private->items_created_queue, 
-			   g_object_ref (file));
+	g_signal_emit (processor, signals[CHECK_FILE], 0, file, &should_process);
 
-	item_queue_handlers_set_up (processor);
+	if (should_process) {
+		/* Add files in queue to our queues to send to the indexer */
+		g_queue_push_tail (processor->private->items_created, 
+				   g_object_ref (file));
+		item_queue_handlers_set_up (processor);
+	}
 
-	return TRUE;
+	return should_process;
 }
 
 static gboolean
@@ -1252,28 +651,29 @@ crawler_process_directory_cb (TrackerCrawler *crawler,
 			      gpointer	      user_data)
 {
 	TrackerProcessor *processor;
-	gboolean	  add_monitor;
+	gboolean should_process = TRUE;
+	gboolean add_monitor = TRUE;
 
 	processor = user_data;
 
-	/* FIXME: Get ignored directories from .cfg? We know that
-	 * normally these would have monitors because these
-	 * directories are those crawled based on the module config.
-	 */
-	add_monitor = TRUE;
+	g_signal_emit (processor, signals[CHECK_DIR], 0, file, &should_process);
+	
+	if (should_process) {
+		/* FIXME: Do we add directories to the queue? */
+		g_queue_push_tail (processor->private->items_created, 
+				   g_object_ref (file));
+		
+		item_queue_handlers_set_up (processor);
+	}
+
+	g_signal_emit (processor, signals[MONITOR_DIR], 0, file, &add_monitor);
 
 	/* Should we add? */
 	if (add_monitor) {
 		tracker_monitor_add (processor->private->monitor, file);
 	}
 
-	/* Add files in queue to our queues to send to the indexer */
-	g_queue_push_tail (processor->private->items_created_queue, 
-			   g_object_ref (file));
-
-	item_queue_handlers_set_up (processor);
-
-	return TRUE;
+	return should_process;
 }
 
 static void
@@ -1300,104 +700,9 @@ crawler_finished_cb (TrackerCrawler *crawler,
 	processor->private->total_files_ignored += files_ignored;
 
 	/* Proceed to next thing to process */
-	process_continue (processor);
+	/* process_continue (processor); */
 }
 
-#ifdef HAVE_HAL
-
-static gchar *
-normalize_mount_point (const gchar *mount_point)
-{
-	if (g_str_has_suffix (mount_point, G_DIR_SEPARATOR_S)) {
-		return g_strdup (mount_point);
-	} else {
-		return g_strconcat (mount_point, G_DIR_SEPARATOR_S, NULL);
-	}
-}
-
-static void
-mount_point_added_cb (TrackerStorage *hal,
-		      const gchar    *udi,
-		      const gchar     *mount_point,
-		      gpointer         user_data)
-{
-	TrackerProcessor        *processor;
-	TrackerProcessorPrivate *priv;
-	TrackerStatus	         status;
-	gchar                   *mp;
-
-	processor = user_data;
-
-	priv = processor->private;
-
-	status = tracker_status_get ();
-	mp = normalize_mount_point (mount_point);
-
-	/* Add removable device to list of known devices to iterate */
-	if (!g_list_find_custom (priv->devices, mp, (GCompareFunc) g_strcmp0)) {
-		priv->devices = g_list_append (priv->devices, mp);
-	}
-
-	/* Reset finished devices flag */
-	processor->private->finished_devices = FALSE;
-
-	/* If we are idle/not doing anything, start up the processor
-	 * again so we handle the new location.
-	 */
-	if (status == TRACKER_STATUS_INDEXING ||
-	    status == TRACKER_STATUS_OPTIMIZING ||
-	    status == TRACKER_STATUS_IDLE) {
-		/* If we are indexing then we must have already
-		 * crawled all locations so we need to start up the
-		 * processor again for the removable media once more.
-		 */
-		process_next (processor);
-	}
-}
-
-static void
-mount_point_removed_cb (TrackerStorage *hal,
-			const gchar    *udi,
-			const gchar    *mount_point,
-			gpointer        user_data)
-{
-	TrackerProcessor        *processor;
-	TrackerProcessorPrivate *priv;
-	GFile		        *file;
-	GList                   *l;
-	gchar                   *mp;
-
-	processor = user_data;
-
-	priv = processor->private;
-	mp = normalize_mount_point (mount_point);
-
-	/* Remove directory from list of iterated_removable_media, so
-	 * we don't traverse it.
-	 */
-	l = g_list_find_custom (priv->devices, mp, (GCompareFunc) g_strcmp0);
-
-	/* Make sure we don't remove the current device we are
-	 * processing, this is because we do this same clean up later
-	 * in process_device_next() 
-	 */
-	if (l && l != priv->current_device) {
-		g_free (l->data);
-		priv->devices = g_list_delete_link (priv->devices, l);
-	}
-
-	/* Remove the monitor, the volumes are updated somewhere else
-	 * in main. 
-	 */
-	file = g_file_new_for_path (mount_point);
-	tracker_monitor_remove_recursively (priv->monitor, file);
-	g_object_unref (file);
-
-	g_free (mp);
-}
-
-#endif /* HAVE_HAL */
-
 TrackerProcessor *
 tracker_processor_new (TrackerStorage *storage)
 {
@@ -1408,10 +713,10 @@ tracker_processor_new (TrackerStorage *storage)
 	g_return_val_if_fail (TRACKER_IS_STORAGE (storage), NULL);
 #endif /* HAVE_HAL */
 
-	tracker_status_init (NULL, tracker_power_new ());
+	/* tracker_status_init (NULL, tracker_power_new ()); */
 	tracker_module_config_init ();
 
-	tracker_status_set_and_signal (TRACKER_STATUS_INITIALIZING);
+	/* tracker_status_set_and_signal (TRACKER_STATUS_INITIALIZING); */
 
 	processor = g_object_new (TRACKER_TYPE_PROCESSOR, NULL);
 	priv = processor->private;
@@ -1422,45 +727,8 @@ tracker_processor_new (TrackerStorage *storage)
 
 	priv->devices = tracker_storage_get_removable_device_roots (priv->hal);
 
-	g_signal_connect (priv->hal, "mount-point-added",
-		          G_CALLBACK (mount_point_added_cb),
-		          processor);
-	g_signal_connect (priv->hal, "mount-point-removed",
-		          G_CALLBACK (mount_point_removed_cb),
-		          processor);
 #endif /* HAVE_HAL */
 
-	/* Set up the crawlers now we have config and hal */
-	priv->crawler = tracker_crawler_new ();
-
-	g_signal_connect (priv->crawler, "process-file",
-			  G_CALLBACK (crawler_process_file_cb),
-			  processor);
-	g_signal_connect (priv->crawler, "process-directory",
-			  G_CALLBACK (crawler_process_directory_cb),
-			  processor);
-	g_signal_connect (priv->crawler, "finished",
-			  G_CALLBACK (crawler_finished_cb),
-			  processor);
-
-	/* Set up the monitor */
-	priv->monitor = tracker_monitor_new ();
-
-	g_message ("Disabling monitor events until we have crawled the file system");
-	tracker_monitor_set_enabled (priv->monitor, FALSE);
-
-	g_signal_connect (priv->monitor, "item-created",
-			  G_CALLBACK (monitor_item_created_cb),
-			  processor);
-	g_signal_connect (priv->monitor, "item-updated",
-			  G_CALLBACK (monitor_item_updated_cb),
-			  processor);
-	g_signal_connect (priv->monitor, "item-deleted",
-			  G_CALLBACK (monitor_item_deleted_cb),
-			  processor);
-	g_signal_connect (priv->monitor, "item-moved",
-			  G_CALLBACK (monitor_item_moved_cb),
-			  processor);
 
 #if 0
 	/* Set up the indexer and signalling to know when we are
@@ -1478,26 +746,10 @@ tracker_processor_new (TrackerStorage *storage)
 	return processor;
 }
 
-void
-tracker_processor_start (TrackerProcessor *processor)
-{
-	g_return_if_fail (TRACKER_IS_PROCESSOR (processor));
-
-	processor->private->been_started = TRUE;
-
-	processor->private->interrupted = FALSE;
-
-	processor->private->finished_files = FALSE;
-	processor->private->finished_devices = FALSE;
-	processor->private->finished_sending = FALSE;
-	processor->private->finished_indexer = FALSE;
-
-	process_next (processor);
-}
-
 void 
 tracker_processor_stop (TrackerProcessor *processor)
 {
+#if 0
 	g_return_if_fail (TRACKER_IS_PROCESSOR (processor));
 
 	if (!processor->private->been_started) {
@@ -1512,5 +764,21 @@ tracker_processor_stop (TrackerProcessor *processor)
 	/* Queues? */
 
 	process_finish (processor);
+#endif
 }
 
+void
+tracker_processor_add_directory (TrackerProcessor *processor,
+				 const gchar      *path,
+				 gboolean          recurse)
+{
+	DirData dd;
+
+	g_return_if_fail (TRACKER_IS_PROCESSOR (processor));
+	g_return_if_fail (path != NULL);
+
+	dd.path = g_strdup (path);
+	dd.recurse = recurse;
+
+	g_array_append_val (processor->private->dirs, dd);
+}
diff --git a/src/libtracker-miner/tracker-processor.h b/src/libtracker-miner/tracker-processor.h
index 8f30aa9..fd3a6db 100644
--- a/src/libtracker-miner/tracker-processor.h
+++ b/src/libtracker-miner/tracker-processor.h
@@ -26,7 +26,7 @@
 
 #include <libtracker-common/tracker-storage.h>
 
-#include "tracker-config.h"
+#include "tracker-miner.h"
 
 G_BEGIN_DECLS
 
@@ -42,21 +42,33 @@ typedef struct TrackerProcessorClass   TrackerProcessorClass;
 typedef struct TrackerProcessorPrivate TrackerProcessorPrivate;
 
 struct TrackerProcessor {
-	GObject			 parent;
+	TrackerMiner parent_instance;
 	TrackerProcessorPrivate *private;
 };
 
 struct TrackerProcessorClass {
-	GObjectClass		 parent;
+	TrackerMinerClass parent_class;
 
-	void (*finished) (TrackerProcessor *processor);
+	gboolean (* check_file)   (TrackerProcessor *processor,
+				   GFile            *file);
+	gboolean (* check_dir)    (TrackerProcessor *processor,
+				   GFile            *file);
+	void     (* process_file) (TrackerProcessor *processor,
+				   GFile            *file);
+	gboolean (* monitor_dir)  (TrackerProcessor *processor,
+				   GFile            *file);
+
+	void     (* finished)     (TrackerProcessor *processor);
 };
 
-GType		  tracker_processor_get_type		    (void) G_GNUC_CONST;
+GType		  tracker_processor_get_type	  (void) G_GNUC_CONST;
+
+TrackerProcessor *tracker_processor_new           (TrackerStorage   *storage);
 
-TrackerProcessor *tracker_processor_new			    (TrackerStorage   *storage);
-void		  tracker_processor_start		    (TrackerProcessor *processor);
-void		  tracker_processor_stop		    (TrackerProcessor *processor);
+void              tracker_processor_stop          (TrackerProcessor *processor);
+void              tracker_processor_add_directory (TrackerProcessor *processor,
+						   const gchar      *path,
+						   gboolean          recurse);
 
 G_END_DECLS
 



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