tracker r1798 - in branches/xesam-support: . data data/modules src/libtracker-common src/tracker-indexer src/tracker-indexer/modules src/trackerd tests/libtracker-common tests/libtracker-db tests/trackerd



Author: pvanhoof
Date: Fri Jun 27 13:08:56 2008
New Revision: 1798
URL: http://svn.gnome.org/viewvc/tracker?rev=1798&view=rev

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

	* svn merge -r 1776:1797 ../indexer-split



Added:
   branches/xesam-support/data/modules/
      - copied from r1797, /branches/indexer-split/data/modules/
   branches/xesam-support/src/libtracker-common/tracker-module-config.c
      - copied unchanged from r1797, /branches/indexer-split/src/libtracker-common/tracker-module-config.c
   branches/xesam-support/src/libtracker-common/tracker-module-config.h
      - copied unchanged from r1797, /branches/indexer-split/src/libtracker-common/tracker-module-config.h
   branches/xesam-support/tests/libtracker-db/union-performance.c
      - copied unchanged from r1797, /branches/indexer-split/tests/libtracker-db/union-performance.c
   branches/xesam-support/tests/trackerd/README
      - copied unchanged from r1797, /branches/indexer-split/tests/trackerd/README
Modified:
   branches/xesam-support/ChangeLog
   branches/xesam-support/configure.ac
   branches/xesam-support/data/Makefile.am
   branches/xesam-support/src/libtracker-common/Makefile.am
   branches/xesam-support/src/libtracker-common/tracker-config.c
   branches/xesam-support/src/libtracker-common/tracker-file-utils.c
   branches/xesam-support/src/libtracker-common/tracker-file-utils.h
   branches/xesam-support/src/libtracker-common/tracker-type-utils.c
   branches/xesam-support/src/libtracker-common/tracker-type-utils.h
   branches/xesam-support/src/tracker-indexer/Makefile.am
   branches/xesam-support/src/tracker-indexer/modules/evolution.c
   branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c
   branches/xesam-support/src/trackerd/tracker-crawler.c
   branches/xesam-support/src/trackerd/tracker-crawler.h
   branches/xesam-support/src/trackerd/tracker-db.c
   branches/xesam-support/src/trackerd/tracker-indexer.c
   branches/xesam-support/src/trackerd/tracker-main.c
   branches/xesam-support/src/trackerd/tracker-process.c
   branches/xesam-support/src/trackerd/tracker-process.h
   branches/xesam-support/src/trackerd/tracker-rdf-query.c
   branches/xesam-support/src/trackerd/tracker-xesam-query.c
   branches/xesam-support/tests/libtracker-common/tracker-type-utils-test.c
   branches/xesam-support/tests/libtracker-db/Makefile.am
   branches/xesam-support/tests/libtracker-db/run-test-in-tmp-dir.sh
   branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-attach.c

Modified: branches/xesam-support/configure.ac
==============================================================================
--- branches/xesam-support/configure.ac	(original)
+++ branches/xesam-support/configure.ac	Fri Jun 27 13:08:56 2008
@@ -705,6 +705,7 @@
 	docs/Makefile
 	data/Makefile
 	data/dbus/Makefile
+	data/modules/Makefile
 	data/languages/Makefile
 	data/icons/Makefile
 	data/icons/16x16/Makefile

Modified: branches/xesam-support/data/Makefile.am
==============================================================================
--- branches/xesam-support/data/Makefile.am	(original)
+++ branches/xesam-support/data/Makefile.am	Fri Jun 27 13:08:56 2008
@@ -1,4 +1,4 @@
-SUBDIRS = dbus languages icons services
+SUBDIRS = dbus modules languages icons services
 
 configdir = $(datadir)/tracker
 

Modified: branches/xesam-support/src/libtracker-common/Makefile.am
==============================================================================
--- branches/xesam-support/src/libtracker-common/Makefile.am	(original)
+++ branches/xesam-support/src/libtracker-common/Makefile.am	Fri Jun 27 13:08:56 2008
@@ -42,6 +42,8 @@
 	tracker-language.h			\
 	tracker-log.c	 			\
 	tracker-log.h				\
+	tracker-module-config.c			\
+	tracker-module-config.h			\
 	tracker-nfs-lock.c			\
 	tracker-nfs-lock.h			\
 	tracker-ontology.c			\

Modified: branches/xesam-support/src/libtracker-common/tracker-config.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-config.c	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-config.c	Fri Jun 27 13:08:56 2008
@@ -30,6 +30,7 @@
 
 #include "tracker-language.h"
 #include "tracker-config.h"
+#include "tracker-file-utils.h"
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_CONFIG, TrackerConfigPriv))
 
@@ -906,31 +907,6 @@
 	return directory;
 }
 
-static gchar *
-config_dir_validate_name (const gchar *original_path)
-{
-	gchar resolved_path[PATH_MAX + 2];
-
-	if (!original_path || original_path[0] == '\0') {
-		return NULL;
-	}
-
-	if (original_path[0] == '~') {
-		const char *home = g_get_home_dir ();
-
-		if (!home || home[0] == '\0') {
-			return NULL;
-		}
-
-		return g_build_path (G_DIR_SEPARATOR_S,
-				     home,
-				     original_path + 1,
-				     NULL);
-	}
-
-	return g_strdup (realpath (original_path, resolved_path));
-}
-
 static gboolean
 config_dir_is_child_of (const char *dir,
 			const char *dir_to_test)
@@ -1255,7 +1231,7 @@
 		/* For directories we validate any special characters,
 		 * for example '~' and '../../'
 		 */
-		validated = config_dir_validate_name (str);
+		validated = tracker_path_evaluate_name (str);
 		if (validated) {
 			list = g_slist_prepend (list, validated);
 		}
@@ -2483,7 +2459,7 @@
 	priv = GET_PRIV (config);
 
 	for (p = roots; *p; p++) {
-		validated_root = config_dir_validate_name (*p);
+		validated_root = tracker_path_evaluate_name (*p);
 		if (!validated_root) {
 			g_print ("Root '%s' is not valid to add to watch directory list\n",
 				 validated_root);
@@ -2516,7 +2492,7 @@
 	priv = GET_PRIV (config);
 
 	for (p = roots; *p; p++) {
-		validated_root = config_dir_validate_name (*p);
+		validated_root = tracker_path_evaluate_name (*p);
 		if (!validated_root) {
 			g_print ("Root '%s' is not valid to add to crawl directory list\n",
 				 validated_root);
@@ -2544,7 +2520,7 @@
 	priv = GET_PRIV (config);
 
 	for (p = roots; *p; p++) {
-		validated_root = config_dir_validate_name (*p);
+		validated_root = tracker_path_evaluate_name (*p);
 		if (!validated_root) {
 			g_print ("Root '%s' is not valid to add to no_watch directory list\n",
 				 validated_root);

Modified: branches/xesam-support/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-file-utils.c	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-file-utils.c	Fri Jun 27 13:08:56 2008
@@ -27,8 +27,10 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <limits.h>
 
 #include <glib.h>
+#include <gio/gio.h>
 
 #include <xdgmime/xdgmime.h>
 
@@ -536,3 +538,87 @@
 
 	return checked_roots;
 }
+
+gchar *
+tracker_path_evaluate_name (const gchar *uri)
+{
+	gchar        *final_path;
+	gchar       **tokens;
+	gchar       **token;
+	gchar        *start;
+	gchar        *end;
+	const gchar  *env;
+	gchar        *expanded;
+
+	if (!uri || uri[0] == '\0') {
+		return NULL;
+	}
+
+	/* First check the simple case of using tilder */
+	if (uri[0] == '~') {
+		const char *home = g_get_home_dir ();
+
+		if (!home || home[0] == '\0') {
+			return NULL;
+		}
+
+		return g_build_path (G_DIR_SEPARATOR_S,
+				     home,
+				     uri + 1,
+				     NULL);
+	}
+
+	/* Second try to find any environment variables and expand
+	 * them, like $HOME or ${FOO} 
+	 */
+	tokens = g_strsplit (uri, G_DIR_SEPARATOR_S, -1);
+
+	for (token = tokens; *token; token++) {
+		if (**token != '$') {
+			continue;
+		}
+
+		start = *token + 1;
+		
+		if (*start == '{') {
+			start++;
+			end = start + (strlen (start)) - 1;
+			*end='\0';
+		}
+		
+		env = g_getenv (start);
+		g_free (*token);
+
+		/* Don't do g_strdup (s?s1:s2) as that doesn't work
+		 * with certain gcc 2.96 versions.
+		 */
+		*token = env ? g_strdup (env) : g_strdup ("");
+	}
+
+	/* Third get the real path removing any "../" and other
+	 * symbolic links to other places, returning only the REAL
+	 * location. 
+	 */
+	if (tokens) {
+		expanded = g_strjoinv (G_DIR_SEPARATOR_S, tokens);
+		g_strfreev (tokens);
+	} else {
+		expanded = g_strdup (uri);
+	}
+
+	/* Only resolve relative paths if there is a directory
+	 * separator in the path, otherwise it is just a name.
+	 */
+	if (strchr (expanded, G_DIR_SEPARATOR)) {
+		GFile *file;
+		
+		file = g_file_new_for_commandline_arg (expanded);
+		final_path = g_file_get_path (file);
+		g_object_unref (file);
+		g_free (expanded);
+	} else {
+		final_path = expanded;
+	}
+
+	return final_path;
+}

Modified: branches/xesam-support/src/libtracker-common/tracker-file-utils.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-file-utils.h	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-file-utils.h	Fri Jun 27 13:08:56 2008
@@ -39,5 +39,6 @@
 gchar *  tracker_file_get_vfs_name           (const gchar *uri);
 void     tracker_path_remove                 (const gchar *uri);
 GSList * tracker_path_list_filter_duplicates (GSList      *roots);
+gchar *  tracker_path_evaluate_name          (const gchar *uri);
 
 #endif /* __LIBTRACKER_COMMON_FILE_UTILS_H__ */

Modified: branches/xesam-support/src/libtracker-common/tracker-type-utils.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-type-utils.c	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-type-utils.c	Fri Jun 27 13:08:56 2008
@@ -615,23 +615,55 @@
 	return strv;
 }
 
+GSList *
+tracker_string_list_to_gslist (gchar **strv, 
+			       gsize   size)
+{
+	GSList *list;
+	gint    i;
+	gint    size_used;
+
+	g_return_val_if_fail (strv != NULL, NULL);
+
+	if (size == -1) {
+		size_used = g_strv_length (strv);
+	} else {
+		size_used = size;
+	}
+
+	list = NULL;
+
+	for (i = 0; i < size; i++) {
+		if (strv[i]) {
+			list = g_slist_prepend (list, g_strdup (strv[i]));
+		} else {
+			break;
+		}
+	}
+
+	return g_slist_reverse (list);
+}
+
 gchar *
 tracker_string_list_to_string (gchar **strv, 
-			       gint    length, 
+			       gsize   size, 
 			       gchar   sep)
 {
 	GString *string;
 	gint     i;
+	gint     size_used;
 
 	g_return_val_if_fail (strv != NULL, NULL);
 
-	if (length == -1) {
-		length = g_strv_length (strv);
+	if (size == -1) {
+		size_used = g_strv_length (strv);
+	} else {
+		size_used = size;
 	}
 
 	string = g_string_new ("");
 
-	for (i = 0; i < length; i++) {
+	for (i = 0; i < size; i++) {
 		if (strv[i]) {
 			if (i > 0) {
 				g_string_append_c (string, sep);

Modified: branches/xesam-support/src/libtracker-common/tracker-type-utils.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-type-utils.h	(original)
+++ branches/xesam-support/src/libtracker-common/tracker-type-utils.h	Fri Jun 27 13:08:56 2008
@@ -36,9 +36,11 @@
 					    guint                *ret);
 gint     tracker_string_in_string_list     (const gchar          *str,
 					    gchar               **strv);
-gchar ** tracker_gslist_to_string_list     (GSList               *list);
+gchar ** tracker_gslist_to_string_list     (GSList               *list);       
+GSList * tracker_string_list_to_gslist     (gchar               **strv, 
+					    gsize                 length);
 gchar *  tracker_string_list_to_string     (gchar               **strv,
-					    gint                  length,
+					    gsize                 length,
 					    gchar                 sep);
 
 /* "true" -> "1"; "false" -> "0" */

Modified: branches/xesam-support/src/tracker-indexer/Makefile.am
==============================================================================
--- branches/xesam-support/src/tracker-indexer/Makefile.am	(original)
+++ branches/xesam-support/src/tracker-indexer/Makefile.am	Fri Jun 27 13:08:56 2008
@@ -8,10 +8,7 @@
 	-DG_LOG_DOMAIN=\"Tracker\"					\
 	-I$(top_srcdir)/src						\
 	$(DBUS_CFLAGS)							\
-	$(GMODULE_CFLAGS)						\
-	$(GTHREAD_LIBS)							\
-	$(GIO_LIBS)							\
-	$(GLIB2_CFLAGS)
+	$(GMODULE_CFLAGS)
 
 bin_PROGRAMS = tracker-indexer
 

Modified: branches/xesam-support/src/tracker-indexer/modules/evolution.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/modules/evolution.c	(original)
+++ branches/xesam-support/src/tracker-indexer/modules/evolution.c	Fri Jun 27 13:08:56 2008
@@ -24,7 +24,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <string.h>
+#include <stdlib.h>
 #include <tracker-indexer/tracker-module.h>
+#include <libtracker-common/tracker-utils.h>
 #include <libtracker-common/tracker-file-utils.h>
 #include <libtracker-common/tracker-type-utils.h>
 
@@ -75,6 +77,9 @@
         SUMMARY_TYPE_TIME_T
 };
 
+static gchar *local_dir = NULL;
+static gchar *imap_dir = NULL;
+
 static gboolean
 read_summary (FILE *summary,
               ...)
@@ -181,7 +186,7 @@
 tracker_module_get_name (void)
 {
         /* Return module name here */
-        return "Evolution";
+        return "EvolutionEmails";
 }
 
 gchar **
@@ -191,9 +196,12 @@
 
         g_mime_init (0);
 
+        local_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "local", G_DIR_SEPARATOR_S, NULL);
+        imap_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "imap", G_DIR_SEPARATOR_S, NULL);
+
         dirs = g_new0 (gchar *, 3);
-        dirs[0] = g_build_filename (g_get_home_dir (), ".evolution", "mail", "local", NULL);
-        dirs[1] = g_build_filename (g_get_home_dir (), ".evolution", "mail", "imap", NULL);
+        dirs[0] = g_strdup (local_dir);
+        dirs[1] = g_strdup (imap_dir);
 
         return dirs;
 }
@@ -202,11 +210,9 @@
 get_mail_storage_type_from_path (const gchar *path)
 {
         MailStorageType type = MAIL_STORAGE_NONE;
-        gchar *basename, *local_dir, *imap_dir;
+        gchar *basename;
 
         basename = g_path_get_basename (path);
-        local_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "local", NULL);
-        imap_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "imap", NULL);
 
         if (g_str_has_prefix (path, local_dir) &&
             strchr (basename, '.') == NULL) {
@@ -225,8 +231,6 @@
                 type = MAIL_STORAGE_NONE;
         }
 
-        g_free (local_dir);
-        g_free (imap_dir);
         g_free (basename);
 
         return type;
@@ -378,12 +382,31 @@
         g_slice_free (EvolutionFileData, data);
 }
 
+gint
+get_mbox_message_id (GMimeMessage *message)
+{
+        const gchar *header, *pos;
+        gchar *number;
+        gint id;
+
+        header = g_mime_message_get_header (message, "X-Evolution");
+        pos = strchr (header, '-');
+
+        number = g_strndup (header, pos - header);
+        id = strtoul (number, NULL, 16);
+
+        g_free (number);
+
+        return id;
+}
+
 GHashTable *
 get_metadata_for_mbox (TrackerFile *file)
 {
         EvolutionLocalData *data;
         GMimeMessage *message;
         GHashTable *metadata;
+        gchar *dir, *name;
         time_t date;
 
         data = file->data;
@@ -397,6 +420,12 @@
 					  NULL,
 					  (GDestroyNotify) g_free);
 
+        dir = tracker_string_replace (file->path, local_dir, NULL);
+        name = g_strdup_printf ("%s;uid=%d", dir, get_mbox_message_id (message));
+
+        g_hash_table_insert (metadata, METADATA_FILE_PATH, g_strdup ("email://local local"));
+        g_hash_table_insert (metadata, METADATA_FILE_NAME, name);
+
         g_mime_message_get_date (message, &date, NULL);
 	g_hash_table_insert (metadata, METADATA_EMAIL_DATE,
                              tracker_uint_to_string (date));
@@ -416,6 +445,8 @@
          * Attachments
          */
 
+        g_free (dir);
+
         return metadata;
 }
 

Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c	(original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c	Fri Jun 27 13:08:56 2008
@@ -142,8 +142,17 @@
 	id_str = tracker_guint32_to_string (id);
 	service_type_id_str = tracker_int_to_string (tracker_service_get_id (service));
 
-	dirname = g_path_get_dirname (path);
-	basename = g_path_get_basename (path);
+	dirname = g_hash_table_lookup (metadata, "File:Path");
+	basename = g_hash_table_lookup (metadata, "File:Name");
+
+	if (dirname && basename) {
+		/* Keep a copy */
+		dirname = g_strdup (dirname);
+		basename = g_strdup (basename);
+	} else {
+		dirname = g_path_get_dirname (path);
+		basename = g_path_get_basename (path);
+	}
 
 	is_dir = g_file_test (path, G_FILE_TEST_IS_DIR);
 	is_symlink = g_file_test (path, G_FILE_TEST_IS_SYMLINK);

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	Fri Jun 27 13:08:56 2008
@@ -302,9 +302,13 @@
 }
 
 TrackerCrawler *
-tracker_crawler_new (void)
+tracker_crawler_new (TrackerConfig *config)
 {
-	return g_object_new (TRACKER_TYPE_CRAWLER, NULL); 
+	g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
+
+	return g_object_new (TRACKER_TYPE_CRAWLER, 
+			     "config", config,
+			     NULL); 
 }
 
 void

Modified: branches/xesam-support/src/trackerd/tracker-crawler.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-crawler.h	(original)
+++ branches/xesam-support/src/trackerd/tracker-crawler.h	Fri Jun 27 13:08:56 2008
@@ -52,7 +52,7 @@
 };
 
 GType           tracker_crawler_get_type     (void);
-TrackerCrawler *tracker_crawler_new          (void);
+TrackerCrawler *tracker_crawler_new          (TrackerConfig  *config);
 void            tracker_crawler_set_config   (TrackerCrawler *object,
 					      TrackerConfig  *config);
 

Modified: branches/xesam-support/src/trackerd/tracker-db.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-db.c	Fri Jun 27 13:08:56 2008
@@ -43,6 +43,7 @@
 #include "tracker-query-tree.h"
 #include "tracker-monitor.h"
 #include "tracker-xesam-manager.h"
+#include "tracker-main.h"
 
 #define ZLIBBUFSIZ            8192
 

Modified: branches/xesam-support/src/trackerd/tracker-indexer.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-indexer.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-indexer.c	Fri Jun 27 13:08:56 2008
@@ -41,6 +41,7 @@
 
 #include <glib.h>
 #include <glib/gstdio.h>
+#include <gio/gio.h>
 
 #include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-config.h>
@@ -582,25 +583,66 @@
 gboolean
 tracker_indexer_has_tmp_merge_files (TrackerIndexerType type)
 {
-	GSList  *files = NULL;
-	gboolean result = FALSE;
+	GFile           *file;
+	GFileEnumerator *enumerator;
+	GFileInfo       *info;
+	GError          *error = NULL;
+	const gchar     *prefix;
+	const gchar     *data_dir;
+	gboolean         found;
+
+	data_dir = tracker_get_data_dir ();
+	file = g_file_new_for_path (data_dir);
+
+	enumerator = g_file_enumerate_children (file,
+						G_FILE_ATTRIBUTE_STANDARD_NAME ","
+						G_FILE_ATTRIBUTE_STANDARD_TYPE,
+						G_PRIORITY_DEFAULT,
+						NULL, 
+						&error);
+
+	if (error) {
+		g_warning ("Could not check for temporary indexer files in "
+			   "directory:'%s', %s",
+			   data_dir,
+			   error->message);
+		g_error_free (error);
+		g_object_unref (file);
+		return FALSE;
+	}
 
+	
 	if (type == TRACKER_INDEXER_TYPE_FILES) {
-		files = tracker_process_files_get_files_with_prefix (tracker_get_data_dir (),
-                                                                     "file-index.tmp.");
+		prefix = "file-index.tmp.";
 	} else {
-		files = tracker_process_files_get_files_with_prefix (tracker_get_data_dir (), 
-                                                                     "email-index.tmp.");
+		prefix = "email-index.tmp.";
 	}
 
-	result = files != NULL;
+	found = FALSE;
+
+	for (info = g_file_enumerator_next_file (enumerator, NULL, &error);
+	     info && !error && !found;
+	     info = g_file_enumerator_next_file (enumerator, NULL, &error)) {
+		/* Check each file has or hasn't got the prefix */
+		if (g_str_has_prefix (g_file_info_get_name (info), prefix)) {
+			found = TRUE;
+		}
+
+		g_object_unref (info);
+	}
 
-	if (result) {
-		g_slist_foreach (files, (GFunc) g_free, NULL);
-		g_slist_free (files);
+	if (error) {
+		g_warning ("Could not get file information for temporary "
+			   "indexer files in directory:'%s', %s",
+			   data_dir,
+			   error->message);
+		g_error_free (error);
 	}
+		
+	g_object_unref (enumerator);
+	g_object_unref (file);
 
-	return result;
+	return found;
 }
 
 guint8

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	Fri Jun 27 13:08:56 2008
@@ -226,45 +226,6 @@
 }
 
 static void
-reset_blacklist_file (gchar *uri)
-{
-	gchar *dirname;
-	gchar *dirname_parent;
-	gchar *basename;
-
-	dirname = g_path_get_dirname (uri);
-	if (!dirname) { 
-		return;
-	}
-
-	basename = g_path_get_basename (dirname);
-	if (!basename) {
-		return;
-	}
-
-	dirname_parent = g_path_get_dirname (dirname);
-	if (!dirname_parent) {
-		return;	
-	}
-
-	g_message ("Resetting black list file:'%s'", uri);
-
-	/* Reset mtime on parent folder of all outstanding black list
-	 * files so they get indexed when next restarted 
-	 */
-	tracker_db_exec_proc (tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA), 
-			      "UpdateFileMTime", 
-			      "0", 
-			      dirname_parent, 
-			      basename, 
-			      NULL);
-	
-	g_free (basename);
-	g_free (dirname_parent);
-	g_free (dirname);
-}
-
-static void
 log_option_list (GSList      *list,
 		 const gchar *str)
 {
@@ -677,7 +638,7 @@
 	}
 
 	/* Get files first */
-	tracker_crawler_start (tracker->crawler);
+	tracker_process_start (user_data);
 	
 	proxy = tracker_dbus_indexer_get_proxy ();
 	tracker_xesam_subscribe_index_updated (proxy);
@@ -691,7 +652,6 @@
 	GOptionContext        *context = NULL;
 	GOptionGroup          *group;
 	GError                *error = NULL;
-	GSList                *l;
 	TrackerDBManagerFlags  flags;
 
         g_type_init ();
@@ -834,15 +794,14 @@
 	tracker_db_manager_init (flags, &tracker->first_time_index);
 	tracker_db_init ();
 	tracker_xesam_manager_init ();
+	tracker_process_init ();
 
-	tracker->crawler = tracker_crawler_new ();
+	tracker->crawler = tracker_crawler_new (tracker->config);
 
 #ifdef HAVE_HAL
  	tracker->hal = tracker_hal_new ();
 	tracker_crawler_set_hal (tracker->crawler, tracker->hal);
 #endif /* HAVE_HAL */
-	
-	tracker_crawler_set_config (tracker->crawler, tracker->config);
 
 	umask (077);
 
@@ -879,7 +838,7 @@
 				   seconds);
 			g_timeout_add (seconds * 1000, 
 				       start_cb,
-				       NULL);
+				       tracker->crawler);
 		} else {
 			g_idle_add (start_cb, tracker);
 		}
@@ -899,13 +858,8 @@
 	 */
 	tracker_status_set (TRACKER_STATUS_SHUTDOWN);
 
-	/* Reset black list files */
-        l = tracker_process_files_get_temp_black_list ();
-	g_slist_foreach (l, (GFunc) reset_blacklist_file, NULL);
-	g_slist_free (l);
-
 	/* Set kill timeout */
-	g_timeout_add_full (G_PRIORITY_LOW, 10000, shutdown_timeout_cb, NULL, NULL);
+	g_timeout_add_full (G_PRIORITY_LOW, 5000, shutdown_timeout_cb, NULL, NULL);
 
 	shutdown_indexer ();
 	shutdown_databases ();
@@ -913,6 +867,7 @@
 
 	/* Shutdown major subsystems */
 	tracker_dbus_shutdown ();
+	tracker_process_shutdown ();
 	tracker_xesam_manager_shutdown ();
 	tracker_db_manager_shutdown (TRUE);
 	tracker_db_shutdown ();
@@ -948,7 +903,7 @@
 	tracker->is_running = FALSE;
 
 	/* Stop any tight loop operations */
-	tracker_crawler_stop (tracker->crawler);
+	tracker_process_stop ();
 
 	g_main_loop_quit (main_loop);
 }

Modified: branches/xesam-support/src/trackerd/tracker-process.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-process.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-process.c	Fri Jun 27 13:08:56 2008
@@ -1,5 +1,7 @@
-/* Tracker - indexer and metadata database engine
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
  * Copyright (C) 2008, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
@@ -19,1168 +21,114 @@
 
 #include "config.h"
 
-#include <string.h>
-#include <signal.h>
-
-#ifdef OS_WIN32
-#include <windows.h>
-#include <pthread.h>
-#include "mingw-compat.h"
-#endif
-
 #include <glib.h>
+#include <gio/gio.h>
 
-#include <libtracker-common/tracker-config.h>
-#include <libtracker-common/tracker-log.h>
-#include <libtracker-common/tracker-file-utils.h>
-#include <libtracker-common/tracker-hal.h>
-#include <libtracker-common/tracker-os-dependant.h>
-#include <libtracker-common/tracker-service.h>
-#include <libtracker-common/tracker-type-utils.h>
-#include <libtracker-common/tracker-utils.h>
-
-#include <libtracker-db/tracker-db-manager.h>
-
-#include "../xdgmime/xdgmime.h"
-
-#include "tracker-db.h"
-#include "tracker-dbus.h"
-#include "tracker-daemon.h"
-#include "tracker-indexer.h"
-#include "tracker-monitor.h"
-#include "tracker-status.h"
-#include "tracker-process.h"
-
-static TrackerHal     *hal;
-static TrackerConfig  *config;
-
-/* static TrackerDBInterface   *db_con; */
+#include <libtracker-common/tracker-module-config.h>
 
-static GAsyncQueue    *dir_queue;
-static GAsyncQueue    *file_metadata_queue;
-static GAsyncQueue    *file_process_queue;
-
-static GSList         *ignore_pattern_list;
-static GSList         *temp_black_list;
-static GSList         *crawl_directories;
-        
-static gchar         **ignore_pattern;
-
-static const gchar    *ignore_suffix[] = {
-        "~", ".o", ".la", ".lo", ".loT", ".in", 
-        ".csproj", ".m4", ".rej", ".gmo", ".orig", 
-        ".pc", ".omf", ".aux", ".tmp", ".po", 
-        ".vmdk",".vmx",".vmxf",".vmsd",".nvram", 
-        ".part", NULL
-};
-
-static const gchar    *ignore_prefix[] = { 
-        "autom4te", "conftest.", "confstat", 
-        "config.", NULL 
-};
-
-static const gchar    *ignore_name[] = { 
-        "po", "CVS", "aclocal", "Makefile", "CVS", 
-        "SCCS", "ltmain.sh","libtool", "config.status", 
-        "conftest", "confdefs.h", NULL
-};
-
-static void
-process_iter_main_context (void)
-{
-        GMainContext *context;
-
-        context = g_main_context_default ();
-
-        while (g_main_context_pending (context)) {
-                g_main_context_iteration (context, FALSE);
-        }
-}
-
-static void
-process_my_yield (void)
-{
-#ifndef OS_WIN32
-        process_iter_main_context ();
-#endif
-}
-
-static GSList *
-process_get_files (const char *dir, 
-                   gboolean    dir_only, 
-                   gboolean    skip_ignored_files, 
-                   const char *filter_prefix)
-{
-	GDir   *dirp;
-	GSList *files;
-	char   *dir_in_locale;
-
-	dir_in_locale = g_filename_from_utf8 (dir, -1, NULL, NULL, NULL);
-
-	if (!dir_in_locale) {
-		g_warning ("Could not convert directory:'%s' o UTF-8", dir);
-		g_free (dir_in_locale);
-		return NULL;
-	}
-
-	files = NULL;
-
-   	if ((dirp = g_dir_open (dir_in_locale, 0, NULL))) {
-		const gchar *name;
-
-   		while ((name = g_dir_read_name (dirp))) {
-                        gchar *filename;
-			gchar *built_filename;
-
-			filename = g_filename_to_utf8 (name, -1, NULL, NULL, NULL);
-
-			if (!filename) {
-				continue;
-			}
-
-			if (filter_prefix && !g_str_has_prefix (filename, filter_prefix)) {
-				g_free (filename);
-				continue;
-			}
-
-			if (skip_ignored_files && 
-                            tracker_process_files_should_be_ignored (filename)) {
-				g_free (filename);
-				continue;
-			}
-
-			built_filename = g_build_filename (dir, filename, NULL);
-			g_free (filename);
-
- 			if (!tracker_file_is_valid (built_filename)) {
-				g_free (built_filename);
-				continue;
-			}
-
-                        if (!tracker_process_files_should_be_crawled (built_filename)) {
-                                g_free (built_filename);
-                                continue;
-                        }
-
-			if (!dir_only || tracker_file_is_directory (built_filename)) {
-				if (tracker_process_files_should_be_watched (config, built_filename)) {
-					files = g_slist_prepend (files, built_filename);
-                                } else {
-                                        g_free (built_filename);
-                                }
-                        } else {
-                                g_free (built_filename);
-			}
-		}
-
- 		g_dir_close (dirp);
-	}
-
-	g_free (dir_in_locale);
+#include "tracker-process.h"
+#include "tracker-monitor.h"
 
-	return files;
-}
+static TrackerCrawler *crawler; 
 
 static void
-process_get_directories (const char  *dir, 
-                         GSList     **files)
+add_monitors (const gchar *name)
 {
+	GSList *monitors;
 	GSList *l;
 
-        l = process_get_files (dir, TRUE, TRUE, NULL);
-
-        if (*files) {
-                *files = g_slist_concat (*files, l);
-        } else {
-                *files = l;
-	}
-}
-
-static void
-process_watch_directories (GSList             *dirs,
-                           TrackerDBInterface *iface)
-{
-        GSList *list;
-       
-	/* Add sub directories breadth first recursively to avoid
-         * running out of file handles.
-         */
-        list = dirs;
-        
-	while (list) {
-                GSList *files = NULL;
-                GSList *l;
-
-		for (l = list; l; l = l->next) {
-                        gchar *dir;
-
-                        if (!l->data) {
-                                continue;
-                        }
-
-                        if (!g_utf8_validate (l->data, -1, NULL)) {
-                                dir = g_filename_to_utf8 (l->data, -1, NULL,NULL,NULL);
-                                if (!dir) {
-                                        g_warning ("Could not convert directory:'%s' to UTF-8", 
-                                                   (gchar*) l->data);
-                                        continue;
-                                }
-                        } else {
-                                dir = g_strdup (l->data);
-                        }
-
-                        if (!tracker_file_is_valid (dir)) {
-                                g_free (dir);
-                                continue;
-                        }
-                        
-                        if (!tracker_file_is_directory (dir)) {
-                                g_free (dir);
-                                continue;
-                        }
-                                  
-			if (!tracker_process_files_should_be_watched (config, dir) || 
-                            !tracker_process_files_should_be_watched (config, dir)) {
-                                continue;
-                        }
-
-                        crawl_directories = g_slist_prepend (crawl_directories, dir);
-                        
-                        if (!tracker_config_get_enable_watches (config)) {
-                                continue;
-                        }
-                        
-#if 0
-                        /* Done in the crawler module now */
-                        tracker_monitor_add (dir);
-#endif
-		}
-
-                for (l = list; l; l = l->next) {
-                        process_get_directories (l->data, &files);
-                }
-
-                /* Don't free original list */
-                if (list != dirs) {
-                        g_slist_foreach (list, (GFunc) g_free, NULL);
-                        g_slist_free (list);
-                }
-
-		list = files;
-	}
-}
-
-static void
-process_schedule_directory_check_foreach (const gchar  *uri, 
-                                          TrackerDBInterface *iface)
-{
-	/* tracker_db_insert_pending_file (iface_cache, 0, uri, NULL, "unknown", 0,  */
-        /*                                 TRACKER_DB_ACTION_DIRECTORY_REFRESH, */
-        /*                                 TRUE, FALSE, -1); */
-}
-
-static void
-process_schedule_file_check_foreach (const gchar  *uri, 
-                                     TrackerDBInterface *iface)
-{
-	g_return_if_fail (uri != NULL);
-	g_return_if_fail (iface != NULL);
-
-	/* Keep mainloop responsive */
-	process_my_yield ();
-
-	if (!tracker_file_is_directory (uri)) {
-		/* tracker_db_insert_pending_file (iface_cache, 0, uri, NULL, "unknown", 0,  */
-                /*                                 TRACKER_DB_ACTION_CHECK, 0, FALSE, -1); */
-	} else {
-		process_schedule_directory_check_foreach (uri, iface);
-	}
-}
-
-static inline void
-process_directory_list (GSList       *list, 
-                        gboolean      recurse,
-                        TrackerDBInterface *iface)
-{
-	crawl_directories = NULL;
-
-	if (!list) {
-		return;
-	}
-
-        process_watch_directories (list, iface);
-
-	g_slist_foreach (list, 
-                         (GFunc) process_schedule_directory_check_foreach, 
-                         iface);
-
-	if (recurse && crawl_directories) {
-		g_slist_foreach (crawl_directories, 
-                                 (GFunc) process_schedule_directory_check_foreach, 
-                                 iface);
-	}
-
-	if (crawl_directories) {
-		g_slist_foreach (crawl_directories, (GFunc) g_free, NULL);
-		g_slist_free (crawl_directories);
-                crawl_directories = NULL;
-	}
-}
-
-static void
-process_scan_directory (const gchar  *uri,
-                        TrackerDBInterface *iface)
-{
-	GSList *files;
-
-	g_return_if_fail (iface != NULL);
-	g_return_if_fail (uri != NULL);
-	g_return_if_fail (tracker_file_is_directory (uri));
-
-	/* Keep mainloop responsive */
-	process_my_yield ();
-
-        files = process_get_files (uri, FALSE, TRUE, NULL);
-
-	g_message ("Scanning:'%s' for %d files", uri, g_slist_length (files));
-
-	g_slist_foreach (files, 
-                         (GFunc) process_schedule_file_check_foreach, 
-                         iface);
-
-	g_slist_foreach (files, 
-                         (GFunc) g_free, 
-                         NULL);
-	g_slist_free (files);
+	monitors = tracker_module_config_get_monitor_directories (name);
+	
+	for (l = monitors; l; l = l->next) {
+		GFile       *file;
+		const gchar *path;
 
-	/* Recheck directory to update its mtime if its changed whilst
-         * scanning.
-         */
-	process_schedule_directory_check_foreach (uri, iface);
+		path = l->data;
 
-	g_message ("Finished scanning");
-}
+		g_message ("  Adding specific directory monitor:'%s'", path);
 
-static void
-process_index_delete_file (TrackerDBFileInfo *info,
-                           TrackerDBInterface      *iface)
-{
-	/* Info struct may have been deleted in transit here so check
-         * if still valid and intact.
-         */
-	g_return_if_fail (tracker_db_file_info_is_valid (info));
-
-	/* If we dont have an entry in the db for the deleted file, we
-         * ignore it.
-         */
-	if (info->file_id == 0) {
-		return;
+		file = g_file_new_for_path (path);
+		tracker_monitor_add (file);
+		g_object_unref (file);
 	}
 
-	tracker_db_file_delete (iface, info->file_id);
-
-	g_message ("Deleting file:'%s'", info->uri);
-}
-
-static void
-process_index_delete_directory (TrackerDBFileInfo *info,
-                                TrackerDBInterface      *iface)
-{
-	/* Info struct may have been deleted in transit here so check
-         * if still valid and intact.
-         */
-	g_return_if_fail (tracker_db_file_info_is_valid (info));
-
-	/* If we dont have an entry in the db for the deleted
-         * directory, we ignore it.
-         */
-	if (info->file_id == 0) {
-		return;
+	if (!monitors) {
+		g_message ("  No specific monitors to set up");
 	}
-
-	tracker_db_directory_delete (iface, info->file_id, info->uri);
-
-#if 0
-        /* Done in the crawler module now */
-	tracker_monitor_remove (info->uri, TRUE);
-#endif
-
-	g_message ("Deleting directory:'%s' and subdirs", info->uri);
 }
 
 static void
-process_index_delete_directory_check (const gchar *uri,
-                                      TrackerDBInterface *iface)
-{
-	gchar **files;
-        gchar **p;
-
-	/* Check for any deletions*/
-	files = tracker_db_files_get (iface, uri);
-
-        if (!files) {
-                return;
-        }
-
-	for (p = files; *p; p++) {
-		gchar *str = *p;
-
-		if (!tracker_file_is_valid (str)) {
-                        TrackerDBFileInfo *info;
-
-			info = tracker_db_file_info_new (str, 1, 0, 0);
-			info = tracker_db_file_get_info (iface, info);
-
-			if (!info->is_directory) {
-				process_index_delete_file (info, iface);
-			} else {
-				process_index_delete_directory (info, iface);
-			}
-			tracker_db_file_info_free (info);
-		}
-	}
-
-	g_strfreev (files);
-}
-
-static inline void
-process_queue_files_foreach (const gchar *uri, 
-                             gpointer     user_data)
+add_recurse_monitors (const gchar *name)
 {
-	TrackerDBFileInfo *info;
-        
-        info = tracker_db_file_info_new (uri, TRACKER_DB_ACTION_CHECK, 0, 0);
-	g_async_queue_push (file_process_queue, info);
-}
-
-static void
-process_check_directory (const gchar *uri)
-{
-	GSList *files;
-
-	g_return_if_fail (uri != NULL);
-	g_return_if_fail (tracker_file_is_directory (uri));
-
-        files = process_get_files (uri, FALSE, TRUE, NULL);
-	g_message ("Checking:'%s' for %d files", uri, g_slist_length (files));
-
-	g_slist_foreach (files, (GFunc) process_queue_files_foreach, NULL);
-	g_slist_foreach (files, (GFunc) g_free, NULL);
-	g_slist_free (files);
-
-        process_queue_files_foreach (uri, NULL);
-}
-
-static void
-process_index_get_remote_roots (GSList **mounted_directory_roots, 
-                                GSList **removable_device_roots)
-{
-        GSList *l1 = NULL;
-        GSList *l2 = NULL;
-
-#ifdef HAVE_HAL        
-        l1 = tracker_hal_get_mounted_directory_roots (hal);
-        l2 = tracker_hal_get_removable_device_roots (hal);
-#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) {
-                GSList *l;
-                GSList *list = NULL;
-                       
-                for (l = l1; l; l = l->next) {
-                        if (g_slist_find_custom (l2, l->data, (GCompareFunc) strcmp)) {
-                                continue;
-                        } 
-                        
-                        list = g_slist_prepend (list, l->data);
-                }
-
-                *mounted_directory_roots = g_slist_reverse (list);
-        } else {
-                *mounted_directory_roots = NULL;
-        }
-
-        *removable_device_roots = g_slist_copy (l2);
-}
-
-static void
-process_index_get_roots (GSList  **included,
-                         GSList  **excluded)
-{
-        GSList *watch_directory_roots;
-        GSList *no_watch_directory_roots;
-        GSList *mounted_directory_roots;
-        GSList *removable_device_roots;
-
-        *included = NULL;
-        *excluded = NULL;
-
-        process_index_get_remote_roots (&mounted_directory_roots, 
-                                        &removable_device_roots);        
-        
-        /* Delete all stuff in the no watch dirs */
-        watch_directory_roots = 
-                tracker_config_get_watch_directory_roots (config);
-        
-        no_watch_directory_roots = 
-                tracker_config_get_no_watch_directory_roots (config);
-
-        /* Create list for enabled roots based on config */
-        *included = g_slist_concat (*included, g_slist_copy (watch_directory_roots));
-        
-        /* Create list for disabled roots based on config */
-        *excluded = g_slist_concat (*excluded, g_slist_copy (no_watch_directory_roots));
-
-        /* Add or remove roots which pertain to removable media */
-        if (tracker_config_get_index_removable_devices (config)) {
-                *included = g_slist_concat (*included, g_slist_copy (removable_device_roots));
-        } else {
-                *excluded = g_slist_concat (*excluded, g_slist_copy (removable_device_roots));
-        }
-
-        /* Add or remove roots which pertain to mounted directories */
-        if (tracker_config_get_index_mounted_directories (config)) {
-                *included = g_slist_concat (*included, g_slist_copy (mounted_directory_roots));
-        } else {
-                *excluded = g_slist_concat (*excluded, g_slist_copy (mounted_directory_roots));
-        }
-}
-
-static void
-process_index_crawl_add_directories (GSList *dirs)
-{
-	GSList *new_dirs = NULL;
-        GSList *l;
-
-	for (l = dirs; l; l = l->next) {
-		if (!l->data) {
-                        continue;
-                }
-
-                new_dirs = g_slist_prepend (new_dirs, g_strdup (l->data));
-	}
-
-	/* Add sub directories breadth first recursively to avoid
-         * running out of file handles.
-         */
-	while (new_dirs) {
-                GSList *files = NULL;
-
-		for (l = new_dirs; l; l = l->next) {
-                        if (!l->data) {
-                                continue;
-                        }
-
-			if (tracker_process_files_should_be_watched (config, l->data)) {
-				crawl_directories = g_slist_prepend (crawl_directories, g_strdup (l->data));
-			}
-		}
-
-                for (l = new_dirs; l; l = l->next) {
-                        process_get_directories (l->data, &files);
-                }
-
-		g_slist_foreach (new_dirs, (GFunc) g_free, NULL);
-		g_slist_free (new_dirs);
-
-		new_dirs = files;
-	}
-}
-
-static void
-process_index_crawl_files (TrackerDBInterface *iface)
-{
-        TrackerDBInterface *iface_cache;
-        GSList             *crawl_directory_roots;
-
-        g_message ("Starting directory crawling...");
-
-        crawl_directories = NULL;
-        crawl_directory_roots = 
-                tracker_config_get_crawl_directory_roots (config);
-        
-        if (!crawl_directory_roots) {
-                return;
-        }
-        
-        iface_cache = tracker_db_manager_get_db_interface (TRACKER_DB_CACHE);
-        tracker_db_interface_start_transaction (iface_cache);
-        
-        process_index_crawl_add_directories (crawl_directory_roots);
-
-        g_slist_foreach (crawl_directories, 
-                         (GFunc) process_schedule_directory_check_foreach, 
-                         iface);
-        
-        if (crawl_directories) {
-                g_slist_foreach (crawl_directories, (GFunc) g_free, NULL);
-                g_slist_free (crawl_directories);
-                crawl_directories = NULL;
-        }
-        
-        g_slist_foreach (crawl_directory_roots, 
-                         (GFunc) process_schedule_directory_check_foreach, 
-                         iface);
-
-        if (crawl_directories) {
-                g_slist_foreach (crawl_directories, (GFunc) g_free, NULL);
-                g_slist_free (crawl_directories);
-                crawl_directories = NULL;
-        }
-        
-        tracker_db_interface_end_transaction (iface_cache);
-}
-
-static gboolean 
-process_action (TrackerDBFileInfo *info,
-                TrackerDBInterface      *iface)
-{
-        gboolean need_index;
-
-        need_index = info->mtime > info->indextime;
-        
-        switch (info->action) {
-        case TRACKER_DB_ACTION_FILE_CHECK:
-                break;
-                
-        case TRACKER_DB_ACTION_FILE_CHANGED:
-        case TRACKER_DB_ACTION_FILE_CREATED:
-        case TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED:
-                need_index = TRUE;
-                break;
-                
-        case TRACKER_DB_ACTION_FILE_MOVED_FROM:
-                need_index = FALSE;
-                g_message ("Starting moving file:'%s' to:'%s'",
-                           info->uri, 
-                           info->moved_to_uri);
-                tracker_db_file_move (iface, info->uri, info->moved_to_uri);
-                break;
-                
-        case TRACKER_DB_ACTION_DIRECTORY_REFRESH:
-                if (need_index && 
-                    tracker_process_files_should_be_watched (config, info->uri)) {
-                        g_async_queue_push (dir_queue, g_strdup (info->uri));
-                }
-                
-                need_index = FALSE;
-                break;
-                
-        case TRACKER_DB_ACTION_DIRECTORY_CHECK:
-                if (need_index && 
-                    tracker_process_files_should_be_watched (config, info->uri)) {
-                        g_async_queue_push (dir_queue, g_strdup (info->uri));
-			
-                        if (info->indextime > 0) {
-                                process_index_delete_directory_check (info->uri, iface);
-                        }
-                }
-                
-                break;
-                
-        case TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM:
-#if 0
-                /* We should be sending this crap to the indexer */
-                tracker_db_directory_move (iface, info->uri, info->moved_to_uri); 
-#endif
-                need_index = FALSE;
-                break;
-                
-        case TRACKER_DB_ACTION_DIRECTORY_CREATED:
-                need_index = TRUE;
-                g_message ("Processing created directory %s", info->uri);
-                
-                /* Schedule a rescan for all files in folder
-                 * to avoid race conditions.
-                 */
-                if (tracker_process_files_should_be_watched (config, info->uri)) {
-                        GSList *list;
-
-                        /* Add to watch folders (including
-                         * subfolders).
-                         */
-                        list = g_slist_prepend (NULL, info->uri);
-
-                        process_watch_directories (list, iface);
-                        process_scan_directory (info->uri, iface);
-
-                        g_slist_free (list);
-                } else {
-                        g_message ("Blocked scan of directory:'%s' as its in the no watch list", 
-                                   info->uri);
-                }
-                
-                break;
-                
-        default:
-                break;
-        }
-
-        return need_index;
-}
-
-#ifdef HAVE_HAL
-
-static void
-process_mount_point_added_cb (TrackerHal   *hal,
-                              const gchar  *mount_point,
-                              TrackerDBInterface *iface)
-{
-        GSList *list;
-        
-        g_message ("** TRAWLING THROUGH NEW MOUNT POINT:'%s'", mount_point);
-        
-        list = g_slist_prepend (NULL, (gchar*) mount_point);
-        process_directory_list (list, TRUE, iface);
-        g_slist_free (list);
-}
-
-static void
-process_mount_point_removed_cb (TrackerHal  *hal,
-                                const gchar *mount_point,
-                                TrackerDBInterface *iface)
-{
-        g_message ("** CLEANING UP OLD MOUNT POINT:'%s'", mount_point);
-        
-        process_index_delete_directory_check (mount_point, iface); 
-}
-
-#endif /* HAVE_HAL */
-
-static inline gboolean
-process_is_in_path (const gchar *uri, 
-                    const gchar *path)
-{
-	gchar    *str;
-        gboolean  result;
-
-        str = g_strconcat (path, G_DIR_SEPARATOR_S, NULL);
-	result = g_str_has_prefix (uri, str);
-	g_free (str);
-
-	return result;
-}
-
-/* This is the thread entry point for the indexer to start processing
- * files and all other categories for processing.
- */
-gboolean
-tracker_process_files_init (Tracker *tracker)
-{
-        GObject *object;
-
-        g_return_val_if_fail (tracker != NULL, FALSE);
-
-        hal = g_object_ref (tracker->hal);
-        config = g_object_ref (tracker->config);
-
-        /* iface = tracker_ifacenect_all (); */
-
-	dir_queue = g_async_queue_new ();
-	file_metadata_queue = g_async_queue_new ();
-	file_process_queue = g_async_queue_new ();
-
-        /* When initially run, we set up variables */
-        if (!ignore_pattern_list) {
-                GSList *no_index_file_types;
-                
-                no_index_file_types = tracker_config_get_no_index_file_types (config);
-
-                if (no_index_file_types) {
-                        GPatternSpec  *spec;
-                        gchar        **p;
-
-                        ignore_pattern = tracker_gslist_to_string_list (no_index_file_types);
-                        
-                        for (p = ignore_pattern; *p; p++) {
-                                spec = g_pattern_spec_new (*p);
-                                ignore_pattern_list = g_slist_prepend (ignore_pattern_list, spec);
-                        }
-                        
-                        ignore_pattern_list = g_slist_reverse (ignore_pattern_list);
-                }
-        }
-
-#ifdef HAVE_HAL
-        g_signal_connect (hal, "mount-point-added", 
-                          G_CALLBACK (process_mount_point_added_cb),
-                          tracker);
-        g_signal_connect (hal, "mount-point-removed", 
-                          G_CALLBACK (process_mount_point_removed_cb),
-                          tracker);
-#endif /* HAVE_HAL */
-
-        object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
-
-        /* Signal state change */
-        g_signal_emit_by_name (object, 
-                               "index-state-change", 
-                               tracker_status_get_as_string (),
-                               tracker->first_time_index,
-                               tracker->in_merge,
-                               tracker->pause_manual,
-                               tracker_should_pause_on_battery (),
-                               tracker->pause_io,
-                               tracker_config_get_enable_indexing (config));
-
-	g_message ("Processing files...");
-
-        /* FIXME: Needs working on */
-	while (FALSE) {
-		TrackerDBFileInfo *info;
-		gboolean           need_index;
-
-                tracker_status_set_and_signal (TRACKER_STATUS_INDEXING,
-                                               tracker->first_time_index,
-                                               tracker->in_merge,
-                                               tracker->pause_manual,
-                                               tracker_should_pause_on_battery (),
-                                               tracker->pause_io,
-                                               tracker_config_get_enable_indexing (config));
-
-		info = g_async_queue_try_pop (file_process_queue);
-               
-                if (!info) {
-                        process_my_yield ();
-                        continue;
-                }
-
-		/* Check if file needs indexing */
-                need_index = process_action (info, 
-                                             tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA));
-
-                /* FIXME: Finish, maybe call the indexer with the new file */
-                if (0) {
-                        GSList *foo, *bar;
-                        process_check_directory(NULL);
-                        process_index_get_roots(&foo, &bar);
-                        process_index_crawl_files(tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA));
-                }
-
-
-		tracker_db_file_info_unref (info);
-	}
-
-        return TRUE;
-}
-
-void
-tracker_process_files_shutdown (void)
-{
-        /* FIXME: do we need this? */
-	xdg_mime_shutdown ();
-
-        /* Clean up */
-	if (file_process_queue) {
-		g_async_queue_unref (file_process_queue);
-                file_process_queue = NULL;
-	}
-
-	if (file_metadata_queue) {
-		g_async_queue_unref (file_metadata_queue);
-                file_metadata_queue = NULL;
-	}
-
-	if (dir_queue) {
-		g_async_queue_unref (dir_queue);
-                dir_queue = NULL;
-	}
-
-	/* tracker_db_close_all (iface); */
-        /* iface = NULL; */
-
-        if (config) {
-                g_object_unref (config);
-                config = NULL;
-        }
-
-#ifdef HAVE_HAL
-        g_signal_handlers_disconnect_by_func (hal, 
-                                              process_mount_point_added_cb,
-                                              NULL);
-        g_signal_handlers_disconnect_by_func (hal, 
-                                              process_mount_point_removed_cb,
-                                              NULL);
-#endif /* HAVE_HAL */
-
-        if (hal) {
-                g_object_unref (hal);
-                hal = NULL;
-        }
-
-        g_message ("Process files now finishing");
-}
-
-gboolean
-tracker_process_files_should_be_watched (TrackerConfig *config,
-                                         const gchar   *uri)
-{
-        GSList *no_watch_directory_roots;
+	GSList *monitors;
 	GSList *l;
 
-        g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
-        g_return_val_if_fail (uri != NULL, FALSE);
-
-	if (process_is_in_path (uri, g_get_tmp_dir ())) {
-		return FALSE;
-	}
-
-	if (process_is_in_path (uri, "/proc")) {
-		return FALSE;
-	}
-
-	if (process_is_in_path (uri, "/dev")) {
-		return FALSE;
-	}
+	monitors = tracker_module_config_get_monitor_recurse_directories (name);
+	
+	for (l = monitors; l; l = l->next) {
+		GFile       *file;
+		const gchar *path;
 
-	if (process_is_in_path (uri, "/tmp")) {
-		return FALSE;
-	}
+		path = l->data;
 
-        no_watch_directory_roots = tracker_config_get_no_watch_directory_roots (config);
+		g_message ("  Adding recurse directory monitor:'%s' (FIXME: Not finished)", path);
 
-	for (l = no_watch_directory_roots; l; l = l->next) {
-                if (!l->data) {
-                        continue;
-                }
-
-		/* Check if equal or a prefix with an appended '/' */
-		if (strcmp (uri, l->data) == 0) {
-			g_message ("Blocking watch of:'%s' (already being watched)", uri);
-			return FALSE;
-		}
-
-		if (process_is_in_path (uri, l->data)) {
-			g_message ("Blocking watch of:'%s' (already a watch in parent path)", uri);
-			return FALSE;
-		}
+		file = g_file_new_for_path (path);
+		tracker_monitor_add (file);
+		g_object_unref (file);
 	}
 
-	return TRUE;
-}
-
-gboolean
-tracker_process_files_should_be_crawled (const gchar *uri)
-{
-        GSList   *crawl_directory_roots;
-        GSList   *mounted_directory_roots = NULL;
-        GSList   *removable_device_roots = NULL;
-	GSList   *l;
-        gboolean  index_mounted_directories;
-        gboolean  index_removable_devices;
-        gboolean  should_be_crawled = TRUE;
-
-        g_return_val_if_fail (uri != NULL, FALSE);
-        g_return_val_if_fail (uri[0] == G_DIR_SEPARATOR, FALSE);
-
-        index_mounted_directories = tracker_config_get_index_mounted_directories (config);
-        index_removable_devices = tracker_config_get_index_removable_devices (config);
-        
-        if (!index_mounted_directories || !index_removable_devices) {
-                process_index_get_remote_roots (&mounted_directory_roots, 
-                                                &removable_device_roots);        
-        }
-
-        l = tracker_config_get_crawl_directory_roots (config);
-
-        crawl_directory_roots = g_slist_copy (l);
-
-        if (!index_mounted_directories) {
-                crawl_directory_roots = g_slist_concat (crawl_directory_roots, 
-                                                        mounted_directory_roots);
-        }
-
-        if (!index_removable_devices) {
-                crawl_directory_roots = g_slist_concat (crawl_directory_roots, 
-                                                        removable_device_roots);
-        }
-
-	for (l = crawl_directory_roots; l && should_be_crawled; l = l->next) {
-		/* Check if equal or a prefix with an appended '/' */
-		if (strcmp (uri, l->data) == 0) {
-			should_be_crawled = FALSE;
-		}
-
-		if (process_is_in_path (uri, l->data)) {
-			should_be_crawled = FALSE;
-		}
+	if (!monitors) {
+		g_message ("  No recurse monitors to set up");
 	}
-
-        g_slist_free (crawl_directory_roots);
-
-        g_message ("Indexer %s:'%s'", 
-                   should_be_crawled ? "crawling" : "blocking",
-                   uri);
-
-	return should_be_crawled;
 }
 
-gboolean
-tracker_process_files_should_be_ignored (const char *uri)
+void
+tracker_process_start (TrackerCrawler *crawler_to_start)
 {
-	GSList       *l;
-	gchar        *name = NULL;
-	const gchar **p;
-        gboolean      should_be_ignored = TRUE;
+	GList *modules;
+	GList *l;
 
-	if (tracker_is_empty_string (uri)) {
-		goto done;
-	}
-
-	name = g_path_get_basename (uri);
+	g_return_if_fail (TRACKER_IS_CRAWLER (crawler_to_start));
 
-	if (!name || name[0] == '.') {
-		goto done;
-	}
-
-	if (process_is_in_path (uri, g_get_tmp_dir ())) {
-		goto done;
-	}
-
-	if (process_is_in_path (uri, "/proc")) {
-		goto done;
-	}
-
-	if (process_is_in_path (uri, "/dev")) {
-		goto done;
-	}
-
-	if (process_is_in_path (uri, "/tmp")) {
-		goto done;
-	}
-
-	/* Test suffixes */
-	for (p = ignore_suffix; *p; p++) {
-		if (g_str_has_suffix (name, *p)) {
-                        goto done;
-		}
-	}
-
-	/* Test prefixes */
-	for (p = ignore_prefix; *p; p++) {
-		if (g_str_has_prefix (name, *p)) {
-                        goto done;
-		}
-	}
-
-	/* Test exact names */
-	for (p = ignore_name; *p; p++) {
-		if (strcmp (name, *p) == 0) {
-                        goto done;
-		}
-	}
+	crawler = g_object_ref (crawler_to_start);
+	modules = tracker_module_config_get_modules ();
 
-	/* Test ignore types */
-	if (ignore_pattern_list) {
-                for (l = ignore_pattern_list; l; l = l->next) {
-                        if (g_pattern_match_string (l->data, name)) {
-                                goto done;
-                        }
-                }
-	}
+        g_message ("Starting to process %d modules...",
+		   g_list_length (modules));
 	
-	/* Test tmp black list */
-	for (l = temp_black_list; l; l = l->next) {
-		if (!l->data) {
-                        continue;
-                }
-
-		if (strcmp (uri, l->data) == 0) {
-                        goto done;
-		}
-	}
-
-        should_be_ignored = FALSE;
-
-done:
-	g_free (name);
+	for (l = modules; l; l = l->next) {
+		gchar *name;
 
-	return should_be_ignored;
-}
-
-GSList *
-tracker_process_files_get_temp_black_list (void)
-{
-        GSList *l;
+		name = l->data;
+		g_message ("Processing module:'%s'", name);
 
-        l = g_slist_copy (temp_black_list);
-        
-        return temp_black_list;
-}
+		add_monitors (name);
+		add_recurse_monitors (name);
 
-void
-tracker_process_files_set_temp_black_list (GSList *black_list)
-{
-        g_slist_foreach (temp_black_list, 
-                         (GFunc) g_free,
-                         NULL);
-        g_slist_free (temp_black_list);
-        
-        temp_black_list = black_list;
-}
+		/* FIXME: Finish, start crawling? */
+	}	
 
-void
-tracker_process_files_append_temp_black_list (const gchar *str)
-{
-        g_return_if_fail (str != NULL);
 
-        temp_black_list = g_slist_append (temp_black_list, g_strdup (str));
+	g_list_free (modules);
 }
 
 void
-tracker_process_files_get_all_dirs (const char  *dir, 
-                                    GSList     **files)
+tracker_process_stop (void)
 {
-	GSList *l;
-
-        l = process_get_files (dir, TRUE, FALSE, NULL);
-
-        if (*files) {
-                *files = g_slist_concat (*files, l);
-        } else {
-                *files = l;
+	if (crawler) {
+		tracker_crawler_stop (crawler);
 	}
 }
 
-GSList *
-tracker_process_files_get_files_with_prefix (const char *dir, 
-                                             const char *prefix)
-{
-	return process_get_files (dir, FALSE, FALSE, prefix);
-}
-
-gint
-tracker_process_files_metadata_queue_length (void)
-{
-        return g_async_queue_length (file_metadata_queue);
-}
-
 void
-tracker_process_files_metadata_queue_push (TrackerDBFileInfo *info)
+tracker_process_init (void)
 {
-        g_return_if_fail (info != NULL);
-
-        g_async_queue_push (file_metadata_queue, info);
-}
-
-gint
-tracker_process_files_process_queue_length (void)
-{
-        return g_async_queue_length (file_process_queue);
+        tracker_module_config_init ();
 }
 
 void
-tracker_process_files_process_queue_push (TrackerDBFileInfo *info)
+tracker_process_shutdown (void)
 {
-        g_return_if_fail (info != NULL);
-
-        g_async_queue_push (file_process_queue, info);
+        tracker_module_config_shutdown ();
 }
-

Modified: branches/xesam-support/src/trackerd/tracker-process.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-process.h	(original)
+++ branches/xesam-support/src/trackerd/tracker-process.h	Fri Jun 27 13:08:56 2008
@@ -19,45 +19,19 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#ifndef __TRACKERD_PROCESS_FILES_H__
-#define __TRACKERD_PROCESS_FILES_H__
+#ifndef __TRACKERD_PROCESS_H__
+#define __TRACKERD_PROCESS_H__
 
-#include <libtracker-common/tracker-config.h>
-
-#include <libtracker-db/tracker-db-file-info.h>
-
-#include "tracker-utils.h"
-#include "tracker-main.h"
+#include "tracker-crawler.h"
 
 G_BEGIN_DECLS
 
-gboolean tracker_process_files_init                    (Tracker            *tracker);
-void     tracker_process_files_shutdown                (void);
+void tracker_process_init     (void);
+void tracker_process_shutdown (void);
 
-gboolean tracker_process_files_should_be_watched       (TrackerConfig      *config,
-							const gchar        *uri);
-gboolean tracker_process_files_should_be_crawled       (const gchar        *uri);
-gboolean tracker_process_files_should_be_ignored       (const char         *uri);
-
-/* Black list API */
-GSList  *tracker_process_files_get_temp_black_list     (void);
-void     tracker_process_files_set_temp_black_list     (GSList             *black_list);
-void     tracker_process_files_append_temp_black_list  (const gchar        *str);
-
-/* File/Directory API */
-void     tracker_process_files_get_all_dirs            (const char         *dir,
-							GSList            **files);
-GSList * tracker_process_files_get_files_with_prefix   (const char         *dir,
-							const char         *prefix);
-
-/* Metadata Queue API */
-gint     tracker_process_files_metadata_queue_length   (void);
-void     tracker_process_files_metadata_queue_push     (TrackerDBFileInfo  *info);
-
-/* Files Queue API */
-gint     tracker_process_files_process_queue_length    (void);
-void     tracker_process_files_process_queue_push      (TrackerDBFileInfo *info);
+void tracker_process_start (TrackerCrawler *crawler);
+void tracker_process_stop (void);
 
 G_END_DECLS
 
-#endif /* __TRACKERD_PROCESS_FILES_H__ */
+#endif /* __TRACKERD_PROCESS_H__ */

Modified: branches/xesam-support/src/trackerd/tracker-rdf-query.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-rdf-query.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-rdf-query.c	Fri Jun 27 13:08:56 2008
@@ -1099,7 +1099,7 @@
 	       GError		   *error,
 	       gpointer		   user_data)
 {
-	g_critical ("in rdf query parse: %s", error->message);
+	g_message ("in rdf query parse: %s", error->message);
 }
 
 

Modified: branches/xesam-support/src/trackerd/tracker-xesam-query.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-query.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-query.c	Fri Jun 27 13:08:56 2008
@@ -1372,7 +1372,7 @@
 	       GError		   *error,
 	       gpointer		   user_data)
 {
-	g_critical ("Failed to parse RDF query, %s", error->message);
+	g_message ("Failed to parse RDF query, %s", error->message);
 }
 
 void

Modified: branches/xesam-support/tests/libtracker-common/tracker-type-utils-test.c
==============================================================================
--- branches/xesam-support/tests/libtracker-common/tracker-type-utils-test.c	(original)
+++ branches/xesam-support/tests/libtracker-common/tracker-type-utils-test.c	Fri Jun 27 13:08:56 2008
@@ -2,6 +2,7 @@
 #include <glib/gtestutils.h>
 
 #include <time.h>
+#include <string.h>
 
 #include <libtracker-common/tracker-type-utils.h>
 #include <tracker-test-helpers.h>
@@ -104,8 +105,8 @@
         input = mktime (original);
 
         result = tracker_date_to_string (input);
-        // Maybe this test fails in a different time zone!
-        g_assert (tracker_test_helpers_cmpstr_equal (result, "2008-06-16T23:53:10+0300"));
+        g_print ("%s", result);
+        g_assert (result != NULL && strncmp (result, "2008-06-16T23:53:10", 19) == 0);
 }
 
 

Modified: branches/xesam-support/tests/libtracker-db/Makefile.am
==============================================================================
--- branches/xesam-support/tests/libtracker-db/Makefile.am	(original)
+++ branches/xesam-support/tests/libtracker-db/Makefile.am	Fri Jun 27 13:08:56 2008
@@ -2,7 +2,10 @@
 
 noinst_PROGRAMS = $(TEST_PROGS)
 
-TEST_PROGS += tracker-db-manager-unattach tracker-db-manager-attach tracker-db-manager-custom
+TEST_PROGS += tracker-db-manager-unattach \
+	tracker-db-manager-attach         \
+	tracker-db-manager-custom         \
+	union-performance
 
 INCLUDES = 				\
 	-g 				\
@@ -17,6 +20,19 @@
 	$(GLIB2_CFLAGS)
 
 
+union_performance_SOURCES = union-performance.c
+
+union_performance_LDADD =                                              \
+	$(top_builddir)/src/libtracker-db/libtracker-db.la              \
+	$(top_builddir)/src/libtracker-common/libtracker-common.la      \
+	$(top_builddir)/tests/common/libtracker-testcommon.la           \
+	$(top_builddir)/src/xdgmime/libxdgmime.la                       \
+	$(SQLITE3_LIBS)                                                 \
+	$(QDBM_LIBS)                                                    \
+	$(GMODULE_LIBS)                                                 \
+	$(GTHREAD_LIBS)                                                 \
+	$(GLIB2_LIBS)                                                   \
+	-lz
 
 tracker_db_manager_attach_SOURCES = 		\
 	tracker-db-manager-test-attach.c 	\

Modified: branches/xesam-support/tests/libtracker-db/run-test-in-tmp-dir.sh
==============================================================================
--- branches/xesam-support/tests/libtracker-db/run-test-in-tmp-dir.sh	(original)
+++ branches/xesam-support/tests/libtracker-db/run-test-in-tmp-dir.sh	Fri Jun 27 13:08:56 2008
@@ -8,4 +8,8 @@
 
 make test 2> /dev/null
 
+#./tracker-db-manager-unattach
+#./tracker-db-manager-attach
+#./tracker-db-manager-custom
+
 . ../scripts/xdg_dirs.unsource

Modified: branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-attach.c
==============================================================================
--- branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-attach.c	(original)
+++ branches/xesam-support/tests/libtracker-db/tracker-db-manager-test-attach.c	Fri Jun 27 13:08:56 2008
@@ -1,10 +1,62 @@
 #include <glib.h>
 #include <glib/gtestutils.h>
 
-
 #include <libtracker-db/tracker-db-manager.h>
 #include "tracker-db-manager-common.h"
 
+
+typedef enum {
+        NO_INIT,
+        INIT_NO_REINDEX,
+        INIT_REINDEX
+} Status;
+
+static gboolean db_manager_status = NO_INIT;
+
+void 
+ensure_db_manager_is_reindex (gboolean must_reindex)
+{
+        gint first;
+
+        if (db_manager_status == NO_INIT) {
+                if (must_reindex) {
+                        tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL |TRACKER_DB_MANAGER_FORCE_REINDEX,
+                                                 &first);
+                        db_manager_status = INIT_REINDEX;
+                } else {
+                        tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL,
+                                                 &first);
+                        db_manager_status = INIT_NO_REINDEX;
+                }
+                return;
+        }
+
+        if (db_manager_status == INIT_NO_REINDEX && !must_reindex) {
+                // tracker_db_manager is already correctly initialised
+                return;
+        }
+
+        if (db_manager_status == INIT_REINDEX && must_reindex) {
+                // tracker_db_manager is already correctly initialised
+                return ;
+        }
+
+        tracker_db_manager_shutdown (must_reindex);
+        if (must_reindex) {
+                tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL |TRACKER_DB_MANAGER_FORCE_REINDEX,
+                                         &first);
+                db_manager_status = INIT_REINDEX;
+        } else {
+                tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL,
+                                         &first);
+                db_manager_status = INIT_NO_REINDEX;
+        }
+}
+
+
+
+
+
 void
 test_assert_tables_in_db (TrackerDB db, gchar *query) 
 {
@@ -12,72 +64,99 @@
 }
 
 static void
-test_creation_common_db () {
-/*
-  Options              Volumes           ServiceLinks      
-  BackupServices       BackupMetaData    KeywordImages
-  VFolders             MetaDataTypes     MetaDataChildren
-  MetaDataGroup        MetadataOptions   ServiceTypes
-  ServiceTileMetadata  ServiceTabular    Metadata ServiceTypeOptions
-  FileMimes            FileMimePrefixes
-*/
+test_always_same_iface_no_reindex () 
+{
+        TrackerDBInterface *common, *xesam;
+        
+        ensure_db_manager_is_reindex (FALSE);
+ 
+        common = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+        xesam = tracker_db_manager_get_db_interface (TRACKER_DB_XESAM);
+
+        /* The pointer must be the same */
+        g_assert (common == xesam);
+        
 
+}
+
+static void
+test_creation_common_db_no_reindex () 
+{
+        ensure_db_manager_is_reindex (FALSE);
         test_assert_tables_in_db (TRACKER_DB_COMMON, "SELECT * FROM MetaDataTypes");
 }
 
+
+static void
+test_creation_xesam_db_no_reindex_multiple_interfaces () 
+{
+        TrackerDBInterface *iface;
+
+        ensure_db_manager_is_reindex (FALSE);
+
+        iface = tracker_db_manager_get_db_interfaces (2, 
+        											  TRACKER_DB_XESAM, 
+        											  TRACKER_DB_COMMON);
+
+        test_assert_query_run_on_iface (iface, "SELECT * FROM XesamServiceTypes");
+}
+
+
 static void
-test_creation_xesam_db () 
+test_creation_xesam_db_no_reindex () 
 {
-/*
-   XesamMetaDataTypes   XesamServiceTypes      XesamServiceMapping   XesamMetaDataMapping
-   XesamServiceChildren XesamMetaDataChildren  XesamServiceLookup    XesamMetaDataLookup
-*/
-        test_assert_tables_in_db (TRACKER_DB_XESAM, "SELECT * FROM xesam.XesamServiceTypes");
+        ensure_db_manager_is_reindex (FALSE);
+        test_assert_tables_in_db (TRACKER_DB_XESAM, "SELECT * FROM XesamServiceTypes");
 }
 
 static void
-test_creation_file_meta_db ()
+test_creation_file_meta_db_no_reindex ()
 {
+        ensure_db_manager_is_reindex (FALSE);
         test_assert_tables_in_db (TRACKER_DB_COMMON, "SELECT * FROM 'file-meta'.ServiceMetaData");
 }
 
 static void
-test_creation_file_contents_db ()
+test_creation_file_contents_db_no_reindex ()
 {
+        ensure_db_manager_is_reindex (FALSE);
         test_assert_tables_in_db (TRACKER_DB_FILE_CONTENTS, "SELECT * FROM 'file-contents'.ServiceContents");
 }
 
+
 int
 main (int argc, char **argv) {
 
         int result;
-        gint first_time;
 
 	g_type_init ();
         g_thread_init (NULL);
 	g_test_init (&argc, &argv, NULL);
 
-        /* Init */
-        tracker_db_manager_init (TRACKER_DB_MANAGER_ATTACH_ALL | TRACKER_DB_MANAGER_FORCE_REINDEX, 
-                                 &first_time);
 
+        // Tests with attach and no-reindex
+        g_test_add_func ("/libtrakcer-db/tracker-db-manager/attach/no-reindex/equal_iface",
+                         test_always_same_iface_no_reindex);
+
+        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/no-reindex/common_db_tables",
+                        test_creation_common_db_no_reindex);
+
+        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/no-reindex/xesam_db_tables",
+                         test_creation_xesam_db_no_reindex);
+
+        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/no-reindex/xesam_db_tables/multiple_interfaces",
+                         test_creation_xesam_db_no_reindex_multiple_interfaces);
 
-        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/common_db_tables",
-                        test_creation_common_db);
+        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/no-reindex/file_meta_db_tables",
+                         test_creation_file_meta_db_no_reindex);
 
-        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/xesam_db_tables",
-                         test_creation_xesam_db);
+        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/no-reindex/file_contents_db_tables",
+                         test_creation_file_contents_db_no_reindex);
 
-        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/file_meta_db_tables",
-                         test_creation_file_meta_db);
 
-        g_test_add_func ("/libtracker-db/tracker-db-manager/attach/file_contents_db_tables",
-                         test_creation_file_contents_db);
-               
         result = g_test_run ();
         
         /* End */
-        tracker_db_manager_shutdown (TRUE);
 
         return result;
 }



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