[tracker/wip/miner-fs-refactor: 1/31] libtracker-miner: Add TrackerIndexingTree



commit bb86278f6705b5268240efa39b37b87e37f31dbc
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Jul 29 15:41:12 2011 +0200

    libtracker-miner: Add TrackerIndexingTree
    
    This object holds the parameters for the indexed directories, and
    the applying filters, so can effectively tell whether a file should
    be indexed or not.

 .../libtracker-miner/libtracker-miner-sections.txt |   26 +
 .../libtracker-miner/libtracker-miner.types        |    1 +
 src/libtracker-miner/Makefile.am                   |    5 +-
 src/libtracker-miner/tracker-indexing-tree.c       |  554 ++++++++++++++++++++
 src/libtracker-miner/tracker-indexing-tree.h       |   87 +++
 src/libtracker-miner/tracker-miner-enums.h         |   42 ++
 src/libtracker-miner/tracker-miner.h               |    3 +
 7 files changed, 717 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/libtracker-miner/libtracker-miner-sections.txt b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
index 1528c2f..83fe4b1 100644
--- a/docs/reference/libtracker-miner/libtracker-miner-sections.txt
+++ b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
@@ -197,3 +197,29 @@ TRACKER_STORAGE_CLASS
 TRACKER_IS_STORAGE_CLASS
 TRACKER_STORAGE_GET_CLASS
 </SECTION>
+
+<SECTION>
+<FILE>tracker-indexing-tree</FILE>
+<TITLE>TrackerIndexingTree</TITLE>
+TrackerIndexingTree
+TrackerIndexingTreeClass
+TrackerDirectoryFlags
+TrackerFilterType
+tracker_indexing_tree_new
+tracker_indexing_tree_add
+tracker_indexing_tree_remove
+tracker_indexing_tree_add_filter
+tracker_indexing_tree_clear_filters
+tracker_indexing_tree_file_matches_filter
+tracker_indexing_tree_file_is_indexable
+tracker_indexing_tree_parent_is_indexable
+tracker_indexing_tree_get_effective_parent
+<SUBSECTION Standard>
+TRACKER_INDEXING_TREE
+TRACKER_IS_INDEXING_TREE
+TRACKER_TYPE_INDEXING_TREE
+tracker_indexing_tree_get_type
+TRACKER_INDEXING_TREE_CLASS
+TRACKER_IS_INDEXING_TREE_CLASS
+TRACKER_INDEXING_TREE_GET_CLASS
+</SECTION>
diff --git a/docs/reference/libtracker-miner/libtracker-miner.types b/docs/reference/libtracker-miner/libtracker-miner.types
index 64a138a..b0a73b6 100644
--- a/docs/reference/libtracker-miner/libtracker-miner.types
+++ b/docs/reference/libtracker-miner/libtracker-miner.types
@@ -1,3 +1,4 @@
+tracker_indexing_tree_get_type
 tracker_miner_manager_get_type
 tracker_miner_get_type
 tracker_miner_fs_get_type
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index 34da63d..8f9a8d2 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -67,6 +67,8 @@ libtracker_miner_ TRACKER_API_VERSION@_la_SOURCES =    \
 	$(password_provider_sources)                   \
 	$(crawler_sources)			       \
 	$(miner_sources)			       \
+	tracker-indexing-tree.c                        \
+	tracker-indexing-tree.h                        \
 	tracker-network-provider.c                     \
 	tracker-password-provider.c                    \
 	tracker-thumbnailer.c                          \
@@ -77,6 +79,7 @@ libtracker_miner_ TRACKER_API_VERSION@_la_SOURCES =    \
 libtracker_minerinclude_HEADERS =                      \
 	tracker-albumart.h                             \
 	tracker-crawler.h                              \
+	tracker-indexing-tree.h                        \
 	tracker-miner.h                                \
 	tracker-miner-common.h                         \
 	tracker-miner-object.h                         \
@@ -94,7 +97,7 @@ if !ENABLE_GCOV
 # Using enable_gcov instead of have_unit_test because when doing a release
 #  we disable gcov but NOT the unit tests
 libtracker_miner_ TRACKER_API_VERSION@_la_LDFLAGS +=    \
-	-export-symbols-regex '^tracker_(miner|thumbnailer|crawler|storage|password_provider|network_provider)_.*'
+	-export-symbols-regex '^tracker_(miner|thumbnailer|crawler|storage|password_provider|network_provider|indexing_tree)_.*'
 endif
 
 libtracker_miner_ TRACKER_API_VERSION@_la_LIBADD =     \
diff --git a/src/libtracker-miner/tracker-indexing-tree.c b/src/libtracker-miner/tracker-indexing-tree.c
new file mode 100644
index 0000000..240cdbb
--- /dev/null
+++ b/src/libtracker-miner/tracker-indexing-tree.c
@@ -0,0 +1,554 @@
+/*
+ * Copyright (C) 2011, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Carlos Garnacho  <carlos lanedo com>
+ */
+
+#include "tracker-indexing-tree.h"
+
+G_DEFINE_TYPE (TrackerIndexingTree, tracker_indexing_tree, G_TYPE_OBJECT)
+
+typedef struct _TrackerIndexingTreePrivate TrackerIndexingTreePrivate;
+typedef struct _NodeData NodeData;
+typedef struct _PatternData PatternData;
+typedef struct _FindNodeData FindNodeData;
+
+struct _NodeData
+{
+	GFile *file;
+	guint flags : 7;
+	guint shallow : 1;
+};
+
+struct _PatternData
+{
+	GPatternSpec *pattern;
+	TrackerFilterType type;
+};
+
+struct _FindNodeData
+{
+	GEqualFunc func;
+	GNode *node;
+	GFile *file;
+};
+
+struct _TrackerIndexingTreePrivate
+{
+	GNode *config_tree;
+	GList *filter_patterns;
+};
+
+static NodeData *
+node_data_new (GFile *file,
+	       guint  flags)
+{
+	NodeData *data;
+
+	data = g_slice_new (NodeData);
+	data->file = g_object_ref (file);
+	data->flags = flags;
+	data->shallow = FALSE;
+
+	return data;
+}
+
+static void
+node_data_free (NodeData *data)
+{
+	g_object_unref (data->file);
+	g_slice_free (NodeData, data);
+}
+
+static PatternData *
+pattern_data_new (const gchar *glob_string,
+		  guint        type)
+{
+	PatternData *data;
+
+	data = g_slice_new (PatternData);
+	data->pattern = g_pattern_spec_new (glob_string);
+	data->type = type;
+
+	return data;
+}
+
+static void
+pattern_data_free (PatternData *data)
+{
+	g_pattern_spec_free (data->pattern);
+	g_slice_free (PatternData, data);
+}
+
+static void
+tracker_indexing_tree_finalize (GObject *object)
+{
+	TrackerIndexingTreePrivate *priv;
+	TrackerIndexingTree *tree;
+
+	tree = TRACKER_INDEXING_TREE (object);
+	priv = tree->priv;
+
+	g_list_foreach (priv->filter_patterns, (GFunc) pattern_data_free, NULL);
+	g_list_free (priv->filter_patterns);
+
+	g_node_traverse (priv->config_tree,
+			 G_IN_ORDER,
+			 G_TRAVERSE_ALL,
+			 -1,
+			 (GNodeTraverseFunc) node_data_free,
+			 NULL);
+	g_node_destroy (priv->config_tree);
+
+	G_OBJECT_CLASS (tracker_indexing_tree_parent_class)->finalize (object);
+}
+
+static void
+tracker_indexing_tree_class_init (TrackerIndexingTreeClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = tracker_indexing_tree_finalize;
+
+	g_type_class_add_private (object_class,
+				  sizeof (TrackerIndexingTreePrivate));
+}
+
+static void
+tracker_indexing_tree_init (TrackerIndexingTree *tree)
+{
+	TrackerIndexingTreePrivate *priv;
+	NodeData *data;
+	GFile *root;
+
+	priv = tree->priv = G_TYPE_INSTANCE_GET_PRIVATE (tree,
+							 TRACKER_TYPE_INDEXING_TREE,
+							 TrackerIndexingTreePrivate);
+	/* Add a shallow root node */
+	root = g_file_new_for_uri ("file:///");
+	data = node_data_new (root, 0);
+	data->shallow = TRUE;
+
+	priv->config_tree = g_node_new (data);
+	g_object_unref (root);
+}
+
+/**
+ * tracker_indexing_tree_new:
+ *
+ * Returns a newly created #TrackerIndexingTree
+ *
+ * Returns: a newly allocated #TrackerIndexingTree
+ **/
+TrackerIndexingTree *
+tracker_indexing_tree_new (void)
+{
+	return g_object_new (TRACKER_TYPE_INDEXING_TREE, NULL);
+}
+
+static gboolean
+find_node_foreach (GNode    *node,
+                   gpointer  user_data)
+{
+	FindNodeData *data = user_data;
+	NodeData *node_data = node->data;
+
+	if ((data->func) (data->file, node_data->file)) {
+		data->node = node;
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static GNode *
+find_directory_node (GNode      *node,
+                     GFile      *file,
+                     GEqualFunc  func)
+{
+	FindNodeData data;
+
+	data.file = file;
+	data.node = NULL;
+	data.func = func;
+
+	g_node_traverse (node,
+	                 G_POST_ORDER,
+	                 G_TRAVERSE_ALL,
+	                 -1,
+	                 find_node_foreach,
+	                 &data);
+
+	return data.node;
+}
+
+static void
+check_reparent_node (GNode    *node,
+                     gpointer  user_data)
+{
+	GNode *new_node = user_data;
+	NodeData *new_node_data, *node_data;
+
+	new_node_data = new_node->data;
+	node_data = node->data;
+
+	if (g_file_has_prefix (node_data->file,
+	                       new_node_data->file)) {
+		g_node_unlink (node);
+		g_node_append (new_node, node);
+	}
+}
+
+/**
+ * tracker_indexing_tree_add:
+ * @tree: a #TrackerIndexingTree
+ * @directory: #GFile pointing to a directory
+ * @flags: Configuration flags for the directory
+ *
+ * Adds a directory to the indexing tree with the
+ * given configuration flags.
+ **/
+void
+tracker_indexing_tree_add (TrackerIndexingTree   *tree,
+                           GFile                 *directory,
+                           TrackerDirectoryFlags  flags)
+{
+	TrackerIndexingTreePrivate *priv;
+	GNode *parent, *node;
+	NodeData *data;
+
+	g_return_if_fail (TRACKER_IS_INDEXING_TREE (tree));
+	g_return_if_fail (G_IS_FILE (directory));
+
+	priv = tree->priv;
+	node = find_directory_node (priv->config_tree, directory,
+				    (GEqualFunc) g_file_equal);
+
+	if (node) {
+		/* Node already existed */
+		data = node->data;
+		data->shallow = FALSE;
+		return;
+	}
+
+	/* Find out the parent */
+	parent = find_directory_node (priv->config_tree, directory,
+	                              (GEqualFunc) g_file_has_prefix);
+
+	/* Create node, move children of parent that
+	 * could be children of this new node now.
+	 */
+	data = node_data_new (directory, flags);
+	node = g_node_new (data);
+
+	g_node_children_foreach (parent, G_TRAVERSE_ALL,
+	                         check_reparent_node, node);
+
+	/* Add the new node underneath the parent */
+	g_node_append_data (parent, directory);
+}
+
+/**
+ * tracker_indexing_tree_remove:
+ * @tree: a #TrackerIndexingTree
+ * @directory: #GFile pointing to a directory
+ *
+ * Removes @directory from the indexing tree, note that
+ * only directories previously added with tracker_indexing_tree_add()
+ * can be effectively removed.
+ **/
+void
+tracker_indexing_tree_remove (TrackerIndexingTree *tree,
+                              GFile               *directory)
+{
+	TrackerIndexingTreePrivate *priv;
+	GNode *node, *parent;
+	NodeData *data;
+
+	g_return_if_fail (TRACKER_IS_INDEXING_TREE (tree));
+	g_return_if_fail (G_IS_FILE (directory));
+
+	priv = tree->priv;
+	node = find_directory_node (priv->config_tree, directory,
+	                            (GEqualFunc) g_file_equal);
+	if (!node) {
+		return;
+	}
+
+	if (!node->parent) {
+		/* Node is the config tree
+		 * root, mark as shallow again
+		 */
+		data = node->data;
+		data->shallow = TRUE;
+		return;
+	}
+
+	parent = node->parent;
+	g_node_unlink (node);
+
+	/* Move children to parent */
+	g_node_children_foreach (node, G_TRAVERSE_ALL,
+				 check_reparent_node, parent);
+
+	node_data_free (node->data);
+	g_node_destroy (node);
+}
+
+/**
+ * tracker_indexing_tree_add_filter:
+ * @tree: a #TrackerIndexingTree
+ * @filter: filter type
+ * @glob_string: glob-style string for the filter
+ *
+ * Adds a new filter for basenames.
+ **/
+void
+tracker_indexing_tree_add_filter (TrackerIndexingTree *tree,
+                                  TrackerFilterType    filter,
+				  const gchar         *glob_string)
+{
+	TrackerIndexingTreePrivate *priv;
+	PatternData *data;
+
+	g_return_if_fail (TRACKER_IS_INDEXING_TREE (tree));
+	g_return_if_fail (glob_string != NULL);
+
+	priv = tree->priv;
+
+	data = pattern_data_new (glob_string, filter);
+	priv->filter_patterns = g_list_prepend (priv->filter_patterns, data);
+}
+
+/**
+ * tracker_indexing_tree_clear_filters:
+ * @tree: a #TrackerIndexingTree
+ * @type: filter type to clear
+ *
+ * Clears all filters of a given type.
+ **/
+void
+tracker_indexing_tree_clear_filters (TrackerIndexingTree *tree,
+				     TrackerFilterType    type)
+{
+	TrackerIndexingTreePrivate *priv;
+	GList *filters;
+
+	g_return_if_fail (TRACKER_IS_INDEXING_TREE (tree));
+
+	priv = tree->priv;
+	filters = priv->filter_patterns;
+
+	while (filters) {
+		PatternData *data = filters->data;
+		GList *cur = filters;
+
+		filters = filters->next;
+
+		if (data->type == type) {
+			pattern_data_free (data);
+			priv->filter_patterns = g_list_remove (priv->filter_patterns,
+							       cur);
+		}
+	}
+}
+
+/**
+ * tracker_indexing_tree_file_matches_filter:
+ * @tree: a #TrackerIndexingTree
+ * @type: filter type
+ * @file: a #GFile
+ *
+ * Returns %TRUE if @file matches any filter of the given filter type.
+ *
+ * Returns: %TRUE if @file is filtered
+ **/
+gboolean
+tracker_indexing_tree_file_matches_filter (TrackerIndexingTree *tree,
+					   TrackerFilterType    type,
+					   GFile               *file)
+{
+	TrackerIndexingTreePrivate *priv;
+	GList *filters;
+	gchar *basename;
+
+	g_return_val_if_fail (TRACKER_IS_INDEXING_TREE (tree), FALSE);
+	g_return_val_if_fail (G_IS_FILE (file), FALSE);
+
+	priv = tree->priv;
+	filters = priv->filter_patterns;
+	basename = g_file_get_basename (file);
+
+	while (filters) {
+		PatternData *data = filters->data;
+
+		if (data->type == type &&
+		    g_pattern_match_string (data->pattern, basename)) {
+			g_free (basename);
+			return TRUE;
+		}
+	}
+
+	g_free (basename);
+	return FALSE;
+}
+
+static gboolean
+parent_or_equals (GFile *file1,
+                  GFile *file2)
+{
+	return (file1 == file2 ||
+	        g_file_equal (file1, file2) ||
+	        g_file_has_prefix (file1, file2));
+}
+
+/**
+ * tracker_indexing_tree_file_is_indexable:
+ * @tree: a #TrackerIndexingTree
+ * @file: a #GFile
+ *
+ * returns %TRUE if @file should be indexed according to the
+ * parameters given through tracker_indexing_tree_add() and
+ * tracker_indexing_tree_add_filter()
+ *
+ * Returns: %TRUE if @file should be indexed.
+ **/
+gboolean
+tracker_indexing_tree_file_is_indexable (TrackerIndexingTree *tree,
+					 GFile               *file)
+{
+	TrackerIndexingTreePrivate *priv;
+	TrackerFilterType filter;
+	GFileType file_type;
+	NodeData *data;
+	GNode *parent;
+
+	g_return_val_if_fail (TRACKER_IS_INDEXING_TREE (tree), FALSE);
+	g_return_val_if_fail (G_IS_FILE (file), FALSE);
+
+	priv = tree->priv;
+
+	file_type = g_file_query_file_type (file,
+					    G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+					    NULL);
+
+	filter = (file_type == G_FILE_TYPE_DIRECTORY) ?
+		TRACKER_FILTER_DIRECTORY : TRACKER_FILTER_FILE;
+
+	if (tracker_indexing_tree_file_matches_filter (tree, filter, file)) {
+		return FALSE;
+	}
+
+	parent = find_directory_node (priv->config_tree, file,
+	                              (GEqualFunc) parent_or_equals);
+	if (!parent) {
+		return FALSE;
+	}
+
+	data = parent->data;
+
+	if (!data->shallow &&
+	    (data->flags & TRACKER_DIRECTORY_FLAG_RECURSE ||
+	     g_file_has_parent (file, data->file))) {
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+/**
+ * tracker_indexing_tree_parent_is_indexable:
+ * @tree: a #TrackerIndexingTree
+ * @parent: parent directory
+ * @children: children within @parent
+ * @n_children: number of children
+ *
+ * returns %TRUE if @parent should be indexed based on its contents.
+ *
+ * Returns: %TRUE if @parent should be indexed.
+ **/
+gboolean
+tracker_indexing_tree_parent_is_indexable (TrackerIndexingTree  *tree,
+					   GFile                *parent,
+					   GFile               **children,
+					   gint                  n_children)
+{
+	gint i = 0;
+
+	if (!tracker_indexing_tree_file_is_indexable (tree, parent)) {
+		return FALSE;
+	}
+
+	while (i < n_children &&
+	       children[i] != NULL) {
+		if (tracker_indexing_tree_file_matches_filter (tree,
+							       TRACKER_FILTER_PARENT_DIRECTORY,
+							       children[i])) {
+			return FALSE;
+		}
+	}
+
+	return TRUE;
+}
+
+/**
+ * tracker_indexing_tree_get_effective_parent:
+ * @tree: a #TrackerIndexingtree
+ * @file: a #GFile
+ * @directory_flags: (out): return location for the applying #TrackerDirectoryFlags
+ *
+ * Returns the #GFile that was previously added through tracker_indexing_tree_add()
+ * and would equal or contain @file, or %NULL if none applies.
+ *
+ * If the return value is non-%NULL, @directory_flags would contain the
+ * #TrackerDirectoryFlags applying to @file.
+ *
+ * Returns: (transfer none): the effective parent in @tree, or %NULL
+ **/
+GFile *
+tracker_indexing_tree_get_effective_parent (TrackerIndexingTree   *tree,
+                                            GFile                 *file,
+                                            TrackerDirectoryFlags *directory_flags)
+{
+	TrackerIndexingTreePrivate *priv;
+	NodeData *data;
+	GNode *parent;
+
+	g_return_val_if_fail (TRACKER_IS_INDEXING_TREE (tree), NULL);
+	g_return_val_if_fail (G_IS_FILE (file), NULL);
+
+	priv = tree->priv;
+	parent = find_directory_node (priv->config_tree, file,
+	                              (GEqualFunc) parent_or_equals);
+	if (!parent) {
+		return NULL;
+	}
+
+	data = parent->data;
+
+	if (!data->shallow &&
+	    g_file_has_prefix (file, data->file)) {
+		if (directory_flags) {
+			*directory_flags = data->flags;
+		}
+
+		return data->file;
+	}
+
+	return NULL;
+}
diff --git a/src/libtracker-miner/tracker-indexing-tree.h b/src/libtracker-miner/tracker-indexing-tree.h
new file mode 100644
index 0000000..f0e2b1f
--- /dev/null
+++ b/src/libtracker-miner/tracker-indexing-tree.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2011, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Carlos Garnacho  <carlos lanedo com>
+ */
+
+#ifndef __TRACKER_INDEXING_TREE_H__
+#define __TRACKER_INDEXING_TREE_H__
+
+#if !defined (__LIBTRACKER_MINER_H_INSIDE__) && !defined (TRACKER_COMPILATION)
+#error "Only <libtracker-miner/tracker-miner.h> can be included directly."
+#endif
+
+#include <gio/gio.h>
+#include "tracker-miner-enums.h"
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_INDEXING_TREE         (tracker_indexing_tree_get_type())
+#define TRACKER_INDEXING_TREE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_INDEXING_TREE, TrackerIndexingTree))
+#define TRACKER_INDEXING_TREE_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c),    TRACKER_TYPE_INDEXING_TREE, TrackerIndexingTreeClass))
+#define TRACKER_IS_INDEXING_TREE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_INDEXING_TREE))
+#define TRACKER_IS_INDEXING_TREE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c),    TRACKER_TYPE_INDEXING_TREE))
+#define TRACKER_INDEXING_TREE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),  TRACKER_TYPE_INDEXING_TREE, TrackerIndexingTreeClass))
+
+typedef struct _TrackerIndexingTree TrackerIndexingTree;
+typedef struct _TrackerIndexingTreeClass TrackerIndexingTreeClass;
+
+struct _TrackerIndexingTree
+{
+	GObject parent_instance;
+	gpointer priv;
+};
+
+struct _TrackerIndexingTreeClass
+{
+	GObjectClass parent_class;
+};
+
+GType                 tracker_indexing_tree_get_type (void) G_GNUC_CONST;
+
+TrackerIndexingTree * tracker_indexing_tree_new      (void);
+
+void      tracker_indexing_tree_add                  (TrackerIndexingTree   *tree,
+						      GFile                 *directory,
+						      TrackerDirectoryFlags  flags);
+void      tracker_indexing_tree_remove               (TrackerIndexingTree   *tree,
+						      GFile                 *directory);
+
+void      tracker_indexing_tree_add_filter           (TrackerIndexingTree  *tree,
+						      TrackerFilterType     type,
+						      const gchar          *glob_string);
+void      tracker_indexing_tree_clear_filters        (TrackerIndexingTree  *tree,
+						      TrackerFilterType     type);
+gboolean  tracker_indexing_tree_file_matches_filter  (TrackerIndexingTree  *tree,
+						      TrackerFilterType     type,
+						      GFile                *file);
+
+gboolean  tracker_indexing_tree_file_is_indexable    (TrackerIndexingTree  *tree,
+						      GFile                *file);
+gboolean  tracker_indexing_tree_parent_is_indexable  (TrackerIndexingTree  *tree,
+						      GFile                *parent,
+						      GFile               **children,
+						      gint                  n_children);
+
+GFile *   tracker_indexing_tree_get_effective_parent (TrackerIndexingTree   *tree,
+                                                      GFile                 *file,
+                                                      TrackerDirectoryFlags *directory_flags);
+
+G_END_DECLS
+
+#endif /* __TRACKER_INDEXING_TREE_H__ */
diff --git a/src/libtracker-miner/tracker-miner-enums.h b/src/libtracker-miner/tracker-miner-enums.h
new file mode 100644
index 0000000..0d37c04
--- /dev/null
+++ b/src/libtracker-miner/tracker-miner-enums.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2011, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Carlos Garnacho  <carlos lanedo com>
+ */
+
+#ifndef __TRACKER_MINER_ENUMS_H__
+#define __TRACKER_MINER_ENUMS_H__
+
+G_BEGIN_DECLS
+
+typedef enum {
+	TRACKER_DIRECTORY_FLAG_NONE        = 0,
+	TRACKER_DIRECTORY_FLAG_RECURSE     = 1 << 1,
+	TRACKER_DIRECTORY_FLAG_CHECK_MTIME = 1 << 2,
+	TRACKER_DIRECTORY_FLAG_MONITOR     = 1 << 3,
+} TrackerDirectoryFlags;
+
+typedef enum {
+	TRACKER_FILTER_FILE,
+	TRACKER_FILTER_DIRECTORY,
+	TRACKER_FILTER_PARENT_DIRECTORY
+} TrackerFilterType;
+
+G_END_DECLS
+
+#endif /* __TRACKER_MINER_ENUMS_H__ */
diff --git a/src/libtracker-miner/tracker-miner.h b/src/libtracker-miner/tracker-miner.h
index 59775c0..93a13d7 100644
--- a/src/libtracker-miner/tracker-miner.h
+++ b/src/libtracker-miner/tracker-miner.h
@@ -32,6 +32,9 @@
 #include <libtracker-miner/tracker-miner-fs.h>
 #include <libtracker-miner/tracker-miner-web.h>
 #include <libtracker-miner/tracker-miner-manager.h>
+#include <libtracker-miner/tracker-miner-enums.h>
+#include <libtracker-miner/tracker-indexing-tree.h>
+
 
 #undef __LIBTRACKER_MINER_H_INSIDE__
 



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