tracker r1699 - in branches/xesam-support: . data/dbus src/libtracker src/libtracker-common src/tracker-applet src/tracker-indexer src/trackerd tests/scripts



Author: pvanhoof
Date: Tue Jun 17 14:00:24 2008
New Revision: 1699
URL: http://svn.gnome.org/viewvc/tracker?rev=1699&view=rev

Log:
2008-06-17  Philip Van Hoof  <pvanhoof gnome org>

        * svn merge -r 1687:1697 ../indexer-split



Added:
   branches/xesam-support/tests/scripts/
      - copied from r1696, /branches/indexer-split/tests/scripts/
Modified:
   branches/xesam-support/ChangeLog
   branches/xesam-support/configure.ac
   branches/xesam-support/data/dbus/tracker-indexer.xml
   branches/xesam-support/src/libtracker-common/tracker-dbus.c
   branches/xesam-support/src/libtracker-common/tracker-hal.c
   branches/xesam-support/src/libtracker-common/tracker-log.c
   branches/xesam-support/src/libtracker-common/tracker-nfs-lock.c
   branches/xesam-support/src/libtracker/tracker-files.c
   branches/xesam-support/src/libtracker/tracker-get-meta-for-folder.c
   branches/xesam-support/src/libtracker/tracker-query.c
   branches/xesam-support/src/tracker-applet/tracker-applet.c
   branches/xesam-support/src/tracker-indexer/tracker-indexer.c
   branches/xesam-support/src/tracker-indexer/tracker-indexer.h
   branches/xesam-support/src/tracker-indexer/tracker-main.c
   branches/xesam-support/src/trackerd/tracker-crawler.c
   branches/xesam-support/src/trackerd/tracker-main.c
   branches/xesam-support/src/trackerd/tracker-monitor.c
   branches/xesam-support/src/trackerd/tracker-monitor.h

Modified: branches/xesam-support/configure.ac
==============================================================================
--- branches/xesam-support/configure.ac	(original)
+++ branches/xesam-support/configure.ac	Tue Jun 17 14:00:24 2008
@@ -229,6 +229,12 @@
 
    if test "x$have_unit_tests" = "xyes" ; then
       AC_DEFINE(HAVE_UNIT_TEST, 1, [Unit test framework available in glib])
+
+      AC_PATH_PROG(sqlite_exec, sqlite3)
+      if test -z $sqlite_exec; then
+          AC_MSG_ERROR([Could not find 'sqlite3'])
+      fi
+
       glib_pkgconfig=$glib_pkgconfig_tmp 
       AC_PATH_PROG(GTESTER, [gtester], [no] )
       if test "x$GTESTER" = "xno" ; then
@@ -739,6 +745,8 @@
 	tests/libtracker-common/Makefile
 	tests/trackerd/Makefile
 	tests/trackerd/xesam/Makefile
+	tests/scripts/dummy_data_start.sh
+	tests/scripts/dummy_data_stop.sh
 	src/xdgmime/Makefile
 	po/Makefile.in
 	python/Makefile

Modified: branches/xesam-support/data/dbus/tracker-indexer.xml
==============================================================================
--- branches/xesam-support/data/dbus/tracker-indexer.xml	(original)
+++ branches/xesam-support/data/dbus/tracker-indexer.xml	Tue Jun 17 14:00:24 2008
@@ -16,16 +16,21 @@
     <method name="SetRunning">
       <arg type="b" name="should_be_running" direction="in" />
     </method>
-
-    <method name="ProcessFiles">
+    <method name="CheckFiles">
+      <arg type="as" name="files" direction="in" />
+    </method>
+    <method name="UpdateFiles">
+      <arg type="as" name="files" direction="in" />
+    </method>
+    <method name="DeleteFiles">
       <arg type="as" name="files" direction="in" />
     </method>
     
     <!-- The old signal in the daemon used to send the time taken, we
 	 can add this later
       -->
-    <signal name="Finished"/>
     <signal name="IndexUpdated"/>
+    <signal name="Finished"/>
 
   </interface>
 </node>

Modified: branches/xesam-support/src/libtracker-common/tracker-dbus.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-dbus.c	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-dbus.c	Tue Jun 17 14:00:24 2008
@@ -102,14 +102,9 @@
 	strv = g_new0 (gchar*, length + 1);
 	
 	while (i <= length) {
-		GTimeVal  t;
-		gchar    *str;
+		gchar *str;
 		
-		g_get_current_time (&t);
-		g_time_val_add (&t, 100000);
-
-		/* Get next item and wait 0.1 seconds max per try */
-		str = g_async_queue_timed_pop (queue, &t);
+		str = g_async_queue_try_pop (queue);
 
 		if (str) {
 			if (!g_utf8_validate (str, -1, NULL)) {
@@ -120,7 +115,7 @@
 
 			strv[i++] = str;
 		} else {
-			/* We don't expect this */
+			/* Queue is empty and we don't expect this */
 			break;
 		}
 	}

Modified: branches/xesam-support/src/libtracker-common/tracker-hal.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-hal.c	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-hal.c	Tue Jun 17 14:00:24 2008
@@ -195,11 +195,11 @@
 
 	if (!libhal_ctx_init (priv->context, &error)) {
 		if (dbus_error_is_set (&error)) {
-                        g_critical ("Could not initialise the HAL context, %s",
+                        g_critical ("Could not initialize the HAL context, %s",
 				    error.message);
                         dbus_error_free (&error);
                 } else {
-                        g_critical ("Could not initialise the HAL context, "
+                        g_critical ("Could not initialize the HAL context, "
 				    "no error, is hald running?");
                 }
 

Modified: branches/xesam-support/src/libtracker-common/tracker-log.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-log.c	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-log.c	Tue Jun 17 14:00:24 2008
@@ -146,6 +146,6 @@
 	g_free (log->filename);
 	g_free (log);
 
-	/* Reset the log pointer so we can re-initialise if we want */
+	/* Reset the log pointer so we can re-initialize if we want */
 	log = NULL;
 }

Modified: branches/xesam-support/src/libtracker-common/tracker-nfs-lock.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-nfs-lock.c	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-nfs-lock.c	Tue Jun 17 14:00:24 2008
@@ -79,7 +79,7 @@
 	}
 
         if (!is_initialized()) {
-                g_critical ("Could not initialise NFS lock");
+                g_critical ("Could not initialize NFS lock");
                 return FALSE;
         }
  
@@ -135,7 +135,7 @@
 	}
  
         if (!is_initialized ()) {
-                g_critical ("Could not initialise NFS lock");
+                g_critical ("Could not initialize NFS lock");
                 return;
         }
  
@@ -172,7 +172,7 @@
 					    NULL);
         }
 
-        g_message ("NFS lock initialised %s", 
+        g_message ("NFS lock initialized %s", 
 		   use_nfs_safe_locking ? "" : "(safe locking not in use)");
 }
 
@@ -193,5 +193,5 @@
 		tmp_dir = NULL;
         }
 
-        g_message ("NFS lock finalised");
+        g_message ("NFS lock finalized");
 }

Modified: branches/xesam-support/src/libtracker/tracker-files.c
==============================================================================
--- branches/xesam-support/src/libtracker/tracker-files.c	(original)
+++ branches/xesam-support/src/libtracker/tracker-files.c	Tue Jun 17 14:00:24 2008
@@ -47,7 +47,7 @@
 	client = tracker_connect (FALSE);
 
 	if (!client) {
-		g_print ("Could not initialise Tracker - exiting...\n");
+		g_print ("Could not initialize Tracker - exiting...\n");
 		return 1;
 	}
 

Modified: branches/xesam-support/src/libtracker/tracker-get-meta-for-folder.c
==============================================================================
--- branches/xesam-support/src/libtracker/tracker-get-meta-for-folder.c	(original)
+++ branches/xesam-support/src/libtracker/tracker-get-meta-for-folder.c	Tue Jun 17 14:00:24 2008
@@ -67,7 +67,7 @@
 	client =  tracker_connect (FALSE);
 
 	if (!client) {
-		g_print ("Could not initialise Tracker - exiting...\n");
+		g_print ("Could not initialize Tracker - exiting...\n");
 		return 1;
 	}
 

Modified: branches/xesam-support/src/libtracker/tracker-query.c
==============================================================================
--- branches/xesam-support/src/libtracker/tracker-query.c	(original)
+++ branches/xesam-support/src/libtracker/tracker-query.c	Tue Jun 17 14:00:24 2008
@@ -162,7 +162,7 @@
 	client =  tracker_connect (FALSE);
 
 	if (!client) {
-		g_print ("Could not initialise Tracker over dbus connection - exiting...\n");
+		g_print ("Could not initialize Tracker over dbus connection - exiting...\n");
 		return 1; 
 	}
 

Modified: branches/xesam-support/src/tracker-applet/tracker-applet.c
==============================================================================
--- branches/xesam-support/src/tracker-applet/tracker-applet.c	(original)
+++ branches/xesam-support/src/tracker-applet/tracker-applet.c	Tue Jun 17 14:00:24 2008
@@ -1675,7 +1675,7 @@
 	priv->tracker = tracker_connect (FALSE);
 
 	if (!priv->tracker) {
-		g_print ("Could not initialise Tracker\n");
+		g_print ("Could not initialize Tracker\n");
 		exit (1);
 	}
 

Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer.c	(original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer.c	Tue Jun 17 14:00:24 2008
@@ -259,43 +259,11 @@
 				  sizeof (TrackerIndexerPrivate));
 }
 
-static gboolean
-init_indexer (TrackerIndexer *indexer)
-{
-	TrackerIndexerPrivate *priv;
-	gchar *index_file;
-
-	priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
-
-	if (priv->reindex || !g_file_test (priv->db_dir, G_FILE_TEST_IS_DIR)) {
-		tracker_path_remove (priv->db_dir);
-	}
-
-	if (!g_file_test (priv->db_dir, G_FILE_TEST_EXISTS)) {
-		g_mkdir_with_parents (priv->db_dir, 00755);
-	}
-
-	index_file = g_build_filename (priv->db_dir, "file-index.db", NULL);
-
-	priv->index = tracker_index_new (index_file,
-					 tracker_config_get_max_bucket_count (priv->config));
-
-	priv->common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
-	priv->metadata = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
-	priv->contents = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_CONTENTS);
-
-	tracker_indexer_set_running (indexer, TRUE, NULL);
-
-	g_free (index_file);
-
-	return FALSE;
-}
-
 static void
 tracker_indexer_init (TrackerIndexer *indexer)
 {
 	TrackerIndexerPrivate *priv;
-	gint initial_sleep;
+	gchar *index_file;
 	GSList *m;
 
 	priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
@@ -326,8 +294,26 @@
 		}
 	}
 
-	initial_sleep = tracker_config_get_initial_sleep (priv->config);
-	g_timeout_add (initial_sleep * 1000, (GSourceFunc) init_indexer, indexer);
+	if (priv->reindex || !g_file_test (priv->db_dir, G_FILE_TEST_IS_DIR)) {
+		tracker_path_remove (priv->db_dir);
+	}
+
+	if (!g_file_test (priv->db_dir, G_FILE_TEST_EXISTS)) {
+		g_mkdir_with_parents (priv->db_dir, 00755);
+	}
+
+	index_file = g_build_filename (priv->db_dir, "file-index.db", NULL);
+
+	priv->index = tracker_index_new (index_file,
+					 tracker_config_get_max_bucket_count (priv->config));
+
+	priv->common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+	priv->metadata = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
+	priv->contents = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_CONTENTS);
+
+	tracker_indexer_set_running (indexer, TRUE, NULL);
+
+	g_free (index_file);
 }
 
 static void
@@ -668,9 +654,95 @@
 }
 
 gboolean
-tracker_indexer_process_files (TrackerIndexer  *indexer,
-			       GStrv            files,
-			       GError         **error)
+tracker_indexer_check_files (TrackerIndexer  *indexer,
+			     GStrv            files,
+			     GError         **error)
+{
+	TrackerIndexerPrivate *priv;
+	GModule               *module;
+	guint                  request_id;
+	gint                   i;
+
+	tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), FALSE, error);
+	tracker_dbus_return_val_if_fail (files != NULL, FALSE, error);
+
+	priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+	request_id = tracker_dbus_get_next_request_id ();
+
+	tracker_dbus_request_new (request_id,
+                                  "DBus request to check %d files",
+				  g_strv_length (files));
+
+	/* Assume we're using always the files module, bail out if it's not available */
+	module = g_hash_table_lookup (priv->indexer_modules, "files");
+
+	if (!module) {
+		tracker_dbus_request_failed (request_id,
+					     error,
+					     "The files module is not loaded");
+		return FALSE;
+	}
+
+	/* Add files to the queue */
+	for (i = 0; files[i]; i++) {
+		PathInfo *info;
+
+		info = path_info_new (module, files[i]);
+		tracker_indexer_add_file (indexer, info);
+	}
+
+	tracker_dbus_request_success (request_id);
+
+	return TRUE;
+}
+
+gboolean
+tracker_indexer_update_files (TrackerIndexer  *indexer,
+			      GStrv            files,
+			      GError         **error)
+{
+	TrackerIndexerPrivate *priv;
+	GModule               *module;
+	guint                  request_id;
+	gint                   i;
+
+	tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), FALSE, error);
+	tracker_dbus_return_val_if_fail (files != NULL, FALSE, error);
+
+	priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
+	request_id = tracker_dbus_get_next_request_id ();
+
+	tracker_dbus_request_new (request_id,
+                                  "DBus request to update %d files",
+				  g_strv_length (files));
+
+	/* Assume we're using always the files module, bail out if it's not available */
+	module = g_hash_table_lookup (priv->indexer_modules, "files");
+
+	if (!module) {
+		tracker_dbus_request_failed (request_id,
+					     error,
+					     "The files module is not loaded");
+		return FALSE;
+	}
+
+	/* Add files to the queue */
+	for (i = 0; files[i]; i++) {
+		PathInfo *info;
+
+		info = path_info_new (module, files[i]);
+		tracker_indexer_add_file (indexer, info);
+	}
+
+	tracker_dbus_request_success (request_id);
+
+	return TRUE;
+}
+
+gboolean
+tracker_indexer_delete_files (TrackerIndexer  *indexer,
+			      GStrv            files,
+			      GError         **error)
 {
 	TrackerIndexerPrivate *priv;
 	GModule               *module;
@@ -684,7 +756,7 @@
 	request_id = tracker_dbus_get_next_request_id ();
 
 	tracker_dbus_request_new (request_id,
-                                  "DBus request to process %d files",
+                                  "DBus request to delete %d files",
 				  g_strv_length (files));
 
 	/* Assume we're using always the files module, bail out if it's not available */

Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer.h	(original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer.h	Tue Jun 17 14:00:24 2008
@@ -52,16 +52,22 @@
 };
 
 GType           tracker_indexer_get_type      (void) G_GNUC_CONST;
-TrackerIndexer *tracker_indexer_new           (gboolean         reindex);
-gboolean        tracker_indexer_set_running   (TrackerIndexer  *indexer,
-					       gboolean         should_be_running,
-					       GError         **error);
-gboolean        tracker_indexer_get_running   (TrackerIndexer  *indexer,
-					       gboolean        *is_running,
-					       GError         **error);
-gboolean        tracker_indexer_process_files (TrackerIndexer  *indexer,
-					       GStrv            files,
-					       GError         **error);
+TrackerIndexer *tracker_indexer_new          (gboolean         reindex);
+gboolean        tracker_indexer_set_running  (TrackerIndexer  *indexer,
+					      gboolean         should_be_running,
+					      GError         **error);
+gboolean        tracker_indexer_get_running  (TrackerIndexer  *indexer,
+					      gboolean        *is_running,
+					      GError         **error);
+gboolean        tracker_indexer_check_files  (TrackerIndexer  *indexer,
+					      GStrv            files,
+					      GError         **error);
+gboolean        tracker_indexer_update_files (TrackerIndexer  *indexer,
+					      GStrv            files,
+					      GError         **error);
+gboolean        tracker_indexer_delete_files (TrackerIndexer  *indexer,
+					      GStrv            files,
+					      GError         **error);
 
 G_END_DECLS
 

Modified: branches/xesam-support/src/tracker-indexer/tracker-main.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-main.c	(original)
+++ branches/xesam-support/src/tracker-indexer/tracker-main.c	Tue Jun 17 14:00:24 2008
@@ -106,7 +106,7 @@
 }
 
 static void
-initialise_signal_handler (void)
+initialize_signal_handler (void)
 {
 #ifndef OS_WIN32
   	struct sigaction   act;
@@ -226,9 +226,9 @@
 	g_print ("\n" ABOUT "\n" LICENSE "\n");
 	g_print ("Initializing tracker-indexer...\n");
 
-	initialise_signal_handler ();
+	initialize_signal_handler ();
 
-        /* Initialise logging */
+        /* Initialize logging */
         config = tracker_config_new ();
 
 	if (verbosity > -1) {

Modified: branches/xesam-support/src/trackerd/tracker-crawler.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-crawler.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-crawler.c	Tue Jun 17 14:00:24 2008
@@ -83,27 +83,27 @@
 	GFile          *parent;
 } EnumeratorData;
 
-static void crawler_finalize        (GObject         *object);
-static void crawler_set_property    (GObject         *object,
-				     guint            param_id,
-				     const GValue    *value,
-				     GParamSpec      *pspec);
-static void set_ignored_file_types  (TrackerCrawler  *crawler);
-
+static void crawler_finalize          (GObject         *object);
+static void crawler_set_property      (GObject         *object,
+				       guint            param_id,
+				       const GValue    *value,
+				       GParamSpec      *pspec);
+static void set_ignored_file_types    (TrackerCrawler  *crawler);
 
 #ifdef HAVE_HAL
-static void mount_point_added_cb    (TrackerHal      *hal,
-				     const gchar     *mount_point,
-				     gpointer         user_data);
-static void mount_point_removed_cb  (TrackerHal      *hal,
-				     const gchar     *mount_point,
-				     gpointer         user_data);
-
+static void mount_point_added_cb      (TrackerHal      *hal,
+				       const gchar     *mount_point,
+				       gpointer         user_data);
+static void mount_point_removed_cb    (TrackerHal      *hal,
+				       const gchar     *mount_point,
+				       gpointer         user_data);
 #endif /* HAVE_HAL */
-static void file_enumerate_next     (GFileEnumerator *enumerator,
-				     EnumeratorData  *ed);
-static void file_enumerate_children (TrackerCrawler  *crawler,
-				     GFile           *file);
+
+static void file_enumerate_next       (GFileEnumerator *enumerator,
+				       EnumeratorData  *ed);
+static void file_enumerate_children   (TrackerCrawler  *crawler,
+				       GFile           *file);
+static void file_queue_handler_set_up (TrackerCrawler  *crawler);
 
 G_DEFINE_TYPE(TrackerCrawler, tracker_crawler, G_TYPE_OBJECT)
 
@@ -240,9 +240,9 @@
 		priv->files_queue_handle_id = 0;
 	}
 
-        for (str = g_async_queue_pop (priv->files);
+	for (str = g_async_queue_try_pop (priv->files);
 	     str;
-	     str = g_async_queue_pop (priv->files)) {
+	     str = g_async_queue_try_pop (priv->files)) {
 		g_free (str);
 	}
 
@@ -558,6 +558,11 @@
 	if (g_str_has_prefix (path, g_get_tmp_dir ())) {
 		return TRUE;
 	}
+	
+	if (!g_utf8_validate (path, -1, NULL)) {
+		g_message ("Ignoring path:'%s', not valid UTF-8", path);
+		return TRUE;
+	}
 
 	basename = g_path_get_basename (path);
 	ignore = TRUE;
@@ -612,7 +617,6 @@
 	return ignore;
 }
 
-
 static EnumeratorData *
 enumerator_data_new (TrackerCrawler *crawler,
 		     GFile          *parent)
@@ -767,6 +771,7 @@
 			g_free (path);
 		} else {
 			g_async_queue_push (crawler->priv->files, path);
+			file_queue_handler_set_up (crawler);
 		}
 	}	
 
@@ -781,7 +786,6 @@
 file_enumerate_next (GFileEnumerator *enumerator,
 		     EnumeratorData  *ed)
 {
-
 	g_file_enumerator_next_files_async (enumerator, 
 					    1,
 					    G_PRIORITY_DEFAULT,
@@ -834,23 +838,21 @@
 }
 
 static void
-indexer_process_files_cb (DBusGProxy *proxy, 
-			  GError     *error, 
-			  gpointer    user_data)
+indexer_check_files_cb (DBusGProxy *proxy, 
+			GError     *error, 
+			gpointer    user_data)
 {
 	GStrv files;
 	
 	files = (GStrv) user_data;
 
 	if (error) {
-		g_critical ("Could not send files to indexer to process, %s", 
+		g_critical ("Could not send files to indexer to check, %s", 
 			    error->message);
 		g_error_free (error);
 	} else {
 		g_debug ("Sent!");
 	}
-
-	//g_strfreev (files);
 }
 
 static void
@@ -874,23 +876,23 @@
 		return;
 	}
 
-	g_debug ("Processing file queue...");
+	g_debug ("File check queue being processed...");
 	files = tracker_dbus_async_queue_to_strv (crawler->priv->files,
 						  FILES_QUEUE_PROCESS_MAX);
 	
-	g_debug ("Sending %d files to indexer to process", 
+	g_debug ("File check queue processed, sending first %d to the indexer", 
 		 g_strv_length (files));
 	
-	org_freedesktop_Tracker_Indexer_process_files_async (proxy, 
-							     (const gchar **) files,
-							     indexer_process_files_cb,
-							     files);
+	org_freedesktop_Tracker_Indexer_check_files_async (proxy, 
+							   (const gchar **) files,
+							   indexer_check_files_cb,
+							   files);
 
 	g_object_unref (crawler);
 }
 
 static gboolean
-file_queue_handle_cb (gpointer user_data)
+file_queue_handler_cb (gpointer user_data)
 {
 	TrackerCrawler *crawler;
 	DBusGProxy     *proxy;
@@ -900,8 +902,9 @@
 
 	length = g_async_queue_length (crawler->priv->files);
 	if (length < 1) {
-		g_debug ("Processing file queue... nothing to do, queue empty");
-		return TRUE;
+		g_debug ("File check queue is empty... nothing to do");
+		crawler->priv->files_queue_handle_id = 0;
+		return FALSE;
 	}
 
 	/* Check we can actually talk to the indexer */
@@ -914,6 +917,19 @@
 	return TRUE;
 }
 
+static void
+file_queue_handler_set_up (TrackerCrawler *crawler)
+{
+	if (crawler->priv->files_queue_handle_id != 0) {
+		return;
+	}
+
+	crawler->priv->files_queue_handle_id = 
+		g_timeout_add (FILES_QUEUE_PROCESS_INTERVAL, 
+			       file_queue_handler_cb,
+			       crawler);
+}
+
 void
 tracker_crawler_start (TrackerCrawler *crawler)
 {
@@ -928,15 +944,6 @@
 
 	priv = crawler->priv;
 
-	/* Set up queue handler */
-	if (priv->files_queue_handle_id) {
-		g_source_remove (priv->files_queue_handle_id);	
-	}
-
-	priv->files_queue_handle_id = g_timeout_add (FILES_QUEUE_PROCESS_INTERVAL, 
-						     file_queue_handle_cb,
-						     crawler);
-
 	/* Get locations to index from config, if none are set, we use
 	 * $HOME as the default.
 	 */

Modified: branches/xesam-support/src/trackerd/tracker-main.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-main.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-main.c	Tue Jun 17 14:00:24 2008
@@ -130,61 +130,64 @@
 static gchar         *sys_tmp_dir;
 
 /* Private command line parameters */
-static gchar        **no_watch_dirs;
-static gchar        **watch_dirs;
+static gint           verbosity = -1;
+static gint           initial_sleep = -1;
+static gboolean       low_memory;
+static gchar        **monitors_to_exclude;
+static gchar        **monitors_to_include;
 static gchar        **crawl_dirs;
-static gchar         *language;
-static gboolean       disable_indexing;
+
 static gboolean       reindex;
-static gboolean       low_memory;
+static gboolean       disable_indexing;
 static gint           throttle = -1;
-static gint           verbosity = -1;
-static gint           initial_sleep = -1;
+static gchar         *language;
 
-static GOptionEntry   entries[] = {
-	{ "exclude-dir", 'e', 0, 
-	  G_OPTION_ARG_STRING_ARRAY, &no_watch_dirs, 
-	  N_("Directory to exclude from indexing"), 
-	  N_("/PATH/DIR") },
-	{ "include-dir", 'i', 0, 
-	  G_OPTION_ARG_STRING_ARRAY, &watch_dirs, 
-	  N_("Directory to include in indexing"), 
-	  N_("/PATH/DIR") },
-	{ "crawl-dir", 'c', 0, 
-	  G_OPTION_ARG_STRING_ARRAY, &crawl_dirs, 
-	  N_("Directory to crawl for indexing at start up only"), 
-	  N_("/PATH/DIR") },
-	{ "no-indexing", 'n', 0, 
-	  G_OPTION_ARG_NONE, &disable_indexing, 
-	  N_("Disable any indexing or watching taking place"), NULL },
+static GOptionEntry   entries_daemon[] = {
 	{ "verbosity", 'v', 0, 
 	  G_OPTION_ARG_INT, &verbosity, 
-	  N_("Value that controls the level of logging."
-	     "Valid values are: 0 (displays/logs only errors), "
-	     "1 (minimal), 2 (detailed), and 3 (debug)"), 
-	  N_("VALUE") },
-	{ "throttle", 't', 0, 
-	  G_OPTION_ARG_INT, &throttle, 
-	  N_("Value to use for throttling indexing. "
-	     "Value must be in range 0-99 (default 0) "
-	     "with lower values increasing indexing speed"), 
-	  N_("VALUE") },
+	  N_("Logging, 0 = errors only, "
+	     "1 = minimal, 2 = detailed and 3 = debug (default = 0)"), 
+	  NULL },
+	{ "initial-sleep", 's', 0, 
+	  G_OPTION_ARG_INT, &initial_sleep, 
+	  N_("Seconds to wait before starting any crawling or indexing (default = 45)"), 
+	  NULL },
 	{ "low-memory", 'm', 0, 
 	  G_OPTION_ARG_NONE, &low_memory, 
 	  N_("Minimizes the use of memory but may slow indexing down"), 
 	  NULL },
-	{ "language", 'l', 0, 
-	  G_OPTION_ARG_STRING, &language, 
-	  N_("Language to use for stemmer and stop words list "
-	     "(ISO 639-1 2 characters code)"), 
-	  N_("LANG")},
-	{ "reindex", 'R', 0, 
+	{ "monitors-exclude-dirs", 'e', 0, 
+	  G_OPTION_ARG_STRING_ARRAY, &monitors_to_exclude, 
+	  N_("Directories to exclude for file change monitoring (you can do -e <path> -e <path>)"), 
+	  NULL },
+	{ "monitors-include-dirs", 'i', 0, 
+	  G_OPTION_ARG_STRING_ARRAY, &monitors_to_include, 
+	  N_("Directories to include for file change monitoring (you can do -i <path> -i <path>)"), 
+	  NULL },
+	{ "crawler-include-dirs", 'c', 0, 
+	  G_OPTION_ARG_STRING_ARRAY, &crawl_dirs, 
+	  N_("Directories to crawl to index files (you can do -c <path> -c <path>)"), 
+	  NULL },
+	{ NULL }
+};
+
+static GOptionEntry   entries_indexer[] = {
+	{ "reindex", 'r', 0, 
 	  G_OPTION_ARG_NONE, &reindex, 
 	  N_("Force a re-index of all content"), 
 	  NULL },
-	{ "initial-sleep", 's', 0, 
-	  G_OPTION_ARG_INT, &initial_sleep, 
-	  N_("Time to wait before crawling the file system"), 
+	{ "disable-indexing", 'n', 0, 
+	  G_OPTION_ARG_NONE, &disable_indexing, 
+	  N_("Disable any indexing and monitoring"), NULL },
+	{ "throttle", 't', 0, 
+	  G_OPTION_ARG_INT, &throttle, 
+	  N_("Indexer throttling, 0-99 (default = 0), "
+	     "lower values increase speed"), 
+	  NULL },
+	{ "language", 'l', 0, 
+	  G_OPTION_ARG_STRING, &language, 
+	  N_("Language to use for stemmer and stop words "
+	     "(ISO 639-1 2 characters code)"), 
 	  NULL },
 	{ NULL }
 };
@@ -266,13 +269,13 @@
 {
 	GSList *l;
 
+	g_message ("%s:", str);
+
 	if (!list) {
-		g_message ("%s: NONE!", str);
+		g_message ("  DEFAULT");
 		return;
 	}
 
-	g_message ("%s:", str);
-
 	for (l = list; l; l = l->next) {
 		g_message ("  %s", (gchar*) l->data);
 	}
@@ -281,31 +284,22 @@
 static void
 sanity_check_option_values (void)
 {
-        GSList *watch_directory_roots;
-        GSList *crawl_directory_roots;
-        GSList *no_watch_directory_roots;
-        GSList *no_index_file_types;
-
-        watch_directory_roots = tracker_config_get_watch_directory_roots (tracker->config);
-        crawl_directory_roots = tracker_config_get_crawl_directory_roots (tracker->config);
-        no_watch_directory_roots = tracker_config_get_no_watch_directory_roots (tracker->config);
-
-        no_index_file_types = tracker_config_get_no_index_file_types (tracker->config);
-
 	g_message ("Tracker configuration options:");
+	g_message ("  Initial sleep  ........................  %d (seconds)", 
+		   tracker_config_get_initial_sleep (tracker->config));
 	g_message ("  Verbosity  ............................  %d", 
 		   tracker_config_get_verbosity (tracker->config));
  	g_message ("  Low memory mode  ......................  %s", 
 		   tracker_config_get_low_memory_mode (tracker->config) ? "yes" : "no");
  	g_message ("  Indexing enabled  .....................  %s", 
 		   tracker_config_get_enable_indexing (tracker->config) ? "yes" : "no");
- 	g_message ("  Watching enabled  .....................  %s", 
+ 	g_message ("  Monitoring enabled  ...................  %s", 
 		   tracker_config_get_enable_watches (tracker->config) ? "yes" : "no");
  	g_message ("  File content indexing enabled  ........  %s", 
 		   tracker_config_get_enable_content_indexing (tracker->config) ? "yes" : "no");
 	g_message ("  Thumbnailing enabled  .................  %s", 
 		   tracker_config_get_enable_thumbnails (tracker->config) ? "yes" : "no");
-	g_message ("  Email client to index .................  %s",
+	g_message ("  Email client to index  ................  %s",
 		   tracker_config_get_email_client (tracker->config));
 
 	g_message ("Tracker indexer parameters:");
@@ -315,14 +309,14 @@
 		   tracker_config_get_enable_stemmer (tracker->config) ? "yes" : "no");
 	g_message ("  Fast merges enabled  ..................  %s", 
 		   tracker_config_get_fast_merges (tracker->config) ? "yes" : "no");
-	g_message ("  Disable indexing on battery............  %s (initially = %s)", 
+	g_message ("  Disable indexing on battery  ..........  %s (initially = %s)", 
 		   tracker_config_get_disable_indexing_on_battery (tracker->config) ? "yes" : "no",
 		   tracker_config_get_disable_indexing_on_battery_init (tracker->config) ? "yes" : "no");
 
 	if (tracker_config_get_low_disk_space_limit (tracker->config) == -1) { 
-		g_message ("  Low disk space limit ..................  Disabled");
+		g_message ("  Low disk space limit  .................  Disabled");
 	} else {
-		g_message ("  Low disk space limit ..................  %d%%",
+		g_message ("  Low disk space limit  .................  %d%%",
 			   tracker_config_get_low_disk_space_limit (tracker->config));
 	}
 
@@ -330,30 +324,33 @@
 		   tracker_config_get_min_word_length (tracker->config));
 	g_message ("  Maximum index word length  ............  %d",
 		   tracker_config_get_max_word_length (tracker->config));
-	g_message ("  Maximum text to index .................  %d",
+	g_message ("  Maximum text to index  ................  %d",
 		   tracker_config_get_max_text_to_index (tracker->config));
-	g_message ("  Maximum words to index ................  %d",
+	g_message ("  Maximum words to index  ...............  %d",
 		   tracker_config_get_max_words_to_index (tracker->config));
-	g_message ("  Maximum bucket count ..................  %d",
+	g_message ("  Maximum bucket count  .................  %d",
 		   tracker_config_get_max_bucket_count (tracker->config));
-	g_message ("  Minimum bucket count ..................  %d",
+	g_message ("  Minimum bucket count  .................  %d",
 		   tracker_config_get_min_bucket_count (tracker->config));
-	g_message ("  Divisions .............................  %d",
+	g_message ("  Divisions  ............................  %d",
 		   tracker_config_get_divisions (tracker->config));
-	g_message ("  Padding ...............................  %d",
+	g_message ("  Padding  ..............................  %d",
 		   tracker_config_get_padding (tracker->config));
-	g_message ("  Optimization sweep count ..............  %d",
+	g_message ("  Optimization sweep count  .............  %d",
 		   tracker_config_get_optimization_sweep_count (tracker->config));
-	g_message ("  Thread stack size .....................  %d",
+	g_message ("  Thread stack size  ....................  %d",
 		   tracker_config_get_thread_stack_size (tracker->config));
-	g_message ("  Throttle level ........................  %d",
+	g_message ("  Throttle level  .......................  %d",
 		   tracker_config_get_throttle (tracker->config));
 
-	log_option_list (watch_directory_roots, "Watching directory roots");
-	log_option_list (crawl_directory_roots, "Crawling directory roots");
-	log_option_list (no_watch_directory_roots, "NOT watching directory roots");
-	log_option_list (no_index_file_types, "NOT indexing file types");
-
+	log_option_list (tracker_config_get_watch_directory_roots (tracker->config),
+			 "Monitor directories included");
+	log_option_list (tracker_config_get_no_watch_directory_roots (tracker->config),
+			 "Monitor directories excluded");
+	log_option_list (tracker_config_get_crawl_directory_roots (tracker->config),
+			 "Crawling directories");
+	log_option_list (tracker_config_get_no_index_file_types (tracker->config),
+			 "File types excluded from indexing");
 }
 
 static void
@@ -422,7 +419,7 @@
 }
 
 static void
-initialise_signal_handler (void)
+initialize_signal_handler (void)
 {
 #ifndef OS_WIN32
   	struct sigaction   act;
@@ -446,7 +443,7 @@
 }
 
 static void
-initialise_locations (void)
+initialize_locations (void)
 {
 	gchar *filename;
 	
@@ -472,7 +469,7 @@
 }
 
 static void
-initialise_directories (gboolean *need_index)
+initialize_directories (gboolean *need_index)
 {
 	gchar *filename;
 
@@ -516,7 +513,7 @@
 }
 
 static void
-initialise_databases (gboolean need_index)
+initialize_databases (gboolean need_index)
 {
 	Indexer  *index;
 	gchar    *final_index_name;
@@ -695,10 +692,9 @@
 main (gint argc, gchar *argv[])
 {
 	GOptionContext *context = NULL;
+	GOptionGroup   *group;
 	GError         *error = NULL;
 	GSList         *l;
-	gchar          *example;
-	gchar          *summary;
 	gboolean        need_index;
 
         g_type_init ();
@@ -721,27 +717,27 @@
 	 * usage string - Usage: COMMAND <THIS_MESSAGE> 
 	 */
 	context = g_option_context_new (_("- start the tracker daemon"));
-        example = g_strconcat ("-i ", _("DIRECTORY"), 
-			       " -i ", _("DIRECTORY"),
-			       " -e ", _("DIRECTORY"), 
-			       " -e ", _("DIRECTORY"),
-			       NULL);
 
-        /* Translators: this message will appear after the usage string 
-         * and before the list of options, showing an usage example.   
-	 */
-	summary = g_strconcat (_("To include or exclude multiple directories "
-				 "at the same time, join multiple options like:"),
-			       "\n\n\t",
-			       example, 
-			       NULL);
+	/* 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);
+
+	/* Indexer group */
+	group = g_option_group_new ("indexer", 
+				    _("Indexer Options"),
+				    _("Show indexer options"), 
+				    NULL, 
+				    NULL);
+	g_option_group_add_entries (group, entries_indexer);
+	g_option_context_add_group (context, group);
 
-        g_option_context_set_summary (context, summary);
-	g_option_context_add_main_entries (context, entries, NULL);
 	g_option_context_parse (context, &argc, &argv, &error);
 	g_option_context_free (context);
-	g_free (summary);
-	g_free (example);
 
 	if (error) {
 		g_printerr ("Invalid arguments, %s\n", error->message);
@@ -753,7 +749,7 @@
 	g_print ("\n" ABOUT "\n" LICENSE "\n");
 	g_print ("Initializing trackerd...\n");
 
-	initialise_signal_handler ();
+	initialize_signal_handler ();
 
 	/* Create struct */
 	tracker = g_new0 (Tracker, 1);
@@ -763,52 +759,57 @@
 	/* This makes sure we have all the locations like the data
 	 * dir, user data dir, etc all configured.
 	 * 
-	 * The initialise_directories() function makes sure everything
+	 * The initialize_directories() function makes sure everything
 	 * exists physically and/or is reset depending on various
 	 * options (like if we reindex, we remove the data dir).
 	 */
-	initialise_locations ();
+	initialize_locations ();
 
-        /* Initialise major subsystems */
+        /* Initialize major subsystems */
         tracker->config = tracker_config_new ();
         tracker->language = tracker_language_new (tracker->config);
 
-	/* Deal with config options with defaults, config file and
-	 * option params.
-	 */
-	if (watch_dirs) {
-                tracker_config_add_watch_directory_roots (tracker->config, watch_dirs);
+	/* Daemon command line arguments */
+	if (verbosity > -1) {
+		tracker_config_set_verbosity (tracker->config, verbosity);
 	}
 
-	if (crawl_dirs) {
-                tracker_config_add_crawl_directory_roots (tracker->config, crawl_dirs);
+	if (initial_sleep > -1) {
+		tracker_config_set_initial_sleep (tracker->config, initial_sleep);
 	}
 
-	if (no_watch_dirs) {
-                tracker_config_add_no_watch_directory_roots (tracker->config, no_watch_dirs);
+	if (low_memory) {
+		tracker_config_set_low_memory_mode (tracker->config, TRUE);
 	}
 
-	if (language) {
-		tracker_config_set_language (tracker->config, language);
+	if (monitors_to_exclude) {
+                tracker_config_add_no_watch_directory_roots (tracker->config, 
+							     monitors_to_exclude);
 	}
 
-	if (disable_indexing) {
-		tracker_config_set_enable_indexing (tracker->config, FALSE);
+	if (monitors_to_include) {
+                tracker_config_add_watch_directory_roots (tracker->config, 
+							  monitors_to_include);
 	}
 
-	if (low_memory) {
-		tracker_config_set_low_memory_mode (tracker->config, TRUE);
+	if (crawl_dirs) {
+                tracker_config_add_crawl_directory_roots (tracker->config, crawl_dirs);
+	}
+
+	/* Indexer command line arguments */
+	if (disable_indexing) {
+		tracker_config_set_enable_indexing (tracker->config, FALSE);
 	}
 
 	if (throttle != -1) {
 		tracker_config_set_throttle (tracker->config, throttle);
 	}
 
-	if (verbosity > -1) {
-		tracker_config_set_verbosity (tracker->config, verbosity);
+	if (language) {
+		tracker_config_set_language (tracker->config, language);
 	}
 
-	/* Initialise other subsystems */
+	/* Initialize other subsystems */
 	tracker_log_init (log_filename, tracker_config_get_verbosity (tracker->config));
 	g_print ("Starting log:\n  File:'%s'\n", log_filename);
 	
@@ -822,7 +823,7 @@
 
 	sanity_check_option_values ();
 
-	initialise_directories (&need_index);
+	initialize_directories (&need_index);
 
 	tracker_nfs_lock_init (tracker_config_get_nfs_locking (tracker->config));
 	tracker_ontology_init ();
@@ -844,7 +845,7 @@
 
 	tracker->readonly = check_multiple_instances ();
 
-	initialise_databases (need_index);
+	initialize_databases (need_index);
 
 	/* Set our status as running, if this is FALSE, threads stop
 	 * doing what they do and shutdown.
@@ -860,10 +861,14 @@
 
 	if (!tracker->readonly && 
 	    tracker_config_get_enable_indexing (tracker->config)) {
-		if (initial_sleep > 0) {
+		gint seconds;
+		
+		seconds = tracker_config_get_initial_sleep (tracker->config);
+		
+		if (seconds > 0) {
 			g_message ("Waiting %d seconds before starting",
-				   initial_sleep);
-			g_timeout_add (initial_sleep * 1000, 
+				   seconds);
+			g_timeout_add (seconds * 1000, 
 				       start_cb,
 				       NULL);
 		} else {

Modified: branches/xesam-support/src/trackerd/tracker-monitor.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-monitor.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-monitor.c	Tue Jun 17 14:00:24 2008
@@ -20,11 +20,14 @@
 
 #include <string.h>
 
+#include <libtracker-common/tracker-dbus.h>
 #include <libtracker-common/tracker-file-utils.h>
 
 #include "tracker-monitor.h"
+#include "tracker-dbus.h"
+#include "tracker-indexer-client.h"
 
-/* #define TESTING */
+#define TESTING 
 
 /* This is the default inotify limit - 500 to allow some monitors for
  * other applications. 
@@ -33,10 +36,17 @@
  * /proc/sys/fs/inotify/max_user_watches when there is a possiblity
  * that we don't even use inotify?
  */
-#define MAX_MONITORS (guint) ((2 ^ 13) - 500)   
+#define MAX_MONITORS                 (guint) ((2 ^ 13) - 500)   
+
+#define FILES_QUEUE_PROCESS_INTERVAL 2000
+#define FILES_QUEUE_PROCESS_MAX      5000
 
-static GHashTable    *monitors;
 static TrackerConfig *config;
+static GHashTable    *monitors;
+static GAsyncQueue   *files_created;
+static GAsyncQueue   *files_updated;
+static GAsyncQueue   *files_deleted;
+static guint          files_queue_handlers_id;
 
 gboolean 
 tracker_monitor_init (TrackerConfig *_config) 
@@ -54,12 +64,55 @@
 						  (GDestroyNotify) g_file_monitor_cancel);
 	}
 
+	if (!files_created) {
+		files_created = g_async_queue_new ();
+	}
+
+	if (!files_updated) {
+		files_updated = g_async_queue_new ();
+	}
+
+	if (!files_deleted) {
+		files_deleted = g_async_queue_new ();
+	}
+
 	return TRUE;
 }
 
 void
 tracker_monitor_shutdown (void)
 {
+	gchar *str;
+
+	if (files_queue_handlers_id) {
+		g_source_remove (files_queue_handlers_id);
+		files_queue_handlers_id = 0;
+	}
+
+        for (str = g_async_queue_try_pop (files_deleted);
+	     str;
+	     str = g_async_queue_try_pop (files_deleted)) {
+		g_free (str);
+	}
+
+	g_async_queue_unref (files_deleted);
+
+        for (str = g_async_queue_try_pop (files_updated);
+	     str;
+	     str = g_async_queue_try_pop (files_updated)) {
+		g_free (str);
+	}
+
+	g_async_queue_unref (files_updated);
+
+        for (str = g_async_queue_try_pop (files_created);
+	     str;
+	     str = g_async_queue_try_pop (files_created)) {
+		g_free (str);
+	}
+
+	g_async_queue_unref (files_created);
+
 	if (monitors) {
 		g_hash_table_unref (monitors);
 		monitors = NULL;
@@ -71,6 +124,122 @@
 	}
 }
 
+static void
+indexer_files_processed_cb (DBusGProxy *proxy, 
+			    GError     *error, 
+			    gpointer    user_data)
+{
+	GStrv files;
+	
+	files = (GStrv) user_data;
+
+	if (error) {
+		g_critical ("Could not send %d files to indexer, %s", 
+			    g_strv_length (files),
+			    error->message);
+		g_error_free (error);
+	} else {
+		g_debug ("Sent!");
+	}
+}
+
+static void
+indexer_get_running_cb (DBusGProxy *proxy, 
+			gboolean    running, 
+			GError     *error, 
+			gpointer    user_data)
+{
+	GStrv files;
+
+	if (error || !running) {
+		g_message ("%s", 
+			   error ? error->message : "Indexer exists but is not available yet, waiting...");
+
+		g_clear_error (&error);
+
+		return;
+	}
+
+	/* First do the deleted queue */
+	g_debug ("Files deleted queue being processed...");
+	files = tracker_dbus_async_queue_to_strv (files_deleted,
+						  FILES_QUEUE_PROCESS_MAX);
+	
+	if (g_strv_length (files) > 0) {
+		g_debug ("Files deleted queue processed, sending first %d to the indexer", 
+			 g_strv_length (files));
+		org_freedesktop_Tracker_Indexer_delete_files_async (proxy, 
+								    (const gchar **) files,
+								    indexer_files_processed_cb,
+								    files);
+	}
+
+	/* Second do the created queue */
+	g_debug ("Files created queue being processed...");
+	files = tracker_dbus_async_queue_to_strv (files_created,
+						  FILES_QUEUE_PROCESS_MAX);
+	if (g_strv_length (files) > 0) {
+		g_debug ("Files created queue processed, sending first %d to the indexer", 
+			 g_strv_length (files));
+		org_freedesktop_Tracker_Indexer_check_files_async (proxy, 
+								   (const gchar **) files,
+								   indexer_files_processed_cb,
+								   files);
+	}
+
+	/* Second do the created queue */
+	g_debug ("Files updated queue being processed...");
+	files = tracker_dbus_async_queue_to_strv (files_updated,
+						  FILES_QUEUE_PROCESS_MAX);
+	
+	if (g_strv_length (files) > 0) {
+		g_debug ("Files updated queue processed, sending first %d to the indexer", 
+			 g_strv_length (files));
+		org_freedesktop_Tracker_Indexer_update_files_async (proxy, 
+								    (const gchar **) files,
+								    indexer_files_processed_cb,
+								    files);
+	}
+}
+
+static gboolean
+file_queue_handlers_cb (gpointer user_data)
+{
+	DBusGProxy *proxy;
+	gint        items_to_process = 0;
+
+	items_to_process += g_async_queue_length (files_created);
+	items_to_process += g_async_queue_length (files_updated);
+	items_to_process += g_async_queue_length (files_deleted);
+
+	if (items_to_process < 1) {
+		g_debug ("All queues are empty... nothing to do");
+		files_queue_handlers_id = 0;
+		return FALSE;
+	}
+
+	/* Check we can actually talk to the indexer */
+	proxy = tracker_dbus_indexer_get_proxy ();
+	
+	org_freedesktop_Tracker_Indexer_get_running_async (proxy, 
+							   indexer_get_running_cb,
+							   NULL);
+
+	return TRUE;
+}
+
+static void
+file_queue_handlers_set_up (void)
+{
+	if (files_queue_handlers_id) {
+		return;
+	}
+
+	files_queue_handlers_id = g_timeout_add (FILES_QUEUE_PROCESS_INTERVAL, 
+						 file_queue_handlers_cb,
+						 NULL);
+}
+
 static const gchar *
 monitor_event_to_string (GFileMonitorEvent event_type)
 {
@@ -118,7 +287,31 @@
 		   str1,
 		   str2);
 		   
-	g_free (str1);
+	switch (event_type) {
+	case G_FILE_MONITOR_EVENT_CHANGED:
+	case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+	case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
+		g_async_queue_push (files_updated, str1);
+		file_queue_handlers_set_up ();
+		break;
+
+	case G_FILE_MONITOR_EVENT_DELETED:
+		g_async_queue_push (files_deleted, str1);
+		file_queue_handlers_set_up ();
+		break;
+
+	case G_FILE_MONITOR_EVENT_CREATED:
+		g_async_queue_push (files_created, str1);
+		file_queue_handlers_set_up ();
+		break;
+
+	case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
+	case G_FILE_MONITOR_EVENT_UNMOUNTED:
+		/* Do nothing */
+		g_free (str1);
+		break;
+	}
+
 	g_free (str2);
 }
 

Modified: branches/xesam-support/src/trackerd/tracker-monitor.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-monitor.h	(original)
+++ branches/xesam-support/src/trackerd/tracker-monitor.h	Tue Jun 17 14:00:24 2008
@@ -37,7 +37,6 @@
 gboolean tracker_monitor_is_watched_by_string (const gchar   *path);
 gint     tracker_monitor_get_count            (void);
 
-
 G_END_DECLS
 
 #endif /* __TRACKERD_MONITOR_H__ */



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