tracker r1583 - in branches/xesam-support: . filters/application filters/text src/libtracker-db src/tracker-indexer src/tracker-indexer/modules



Author: pvanhoof
Date: Thu Jun  5 08:05:17 2008
New Revision: 1583
URL: http://svn.gnome.org/viewvc/tracker?rev=1583&view=rev

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

	* svn merge -r 1573:1582 ../indexer-split



Modified:
   branches/xesam-support/ChangeLog
   branches/xesam-support/filters/application/csv_filter
   branches/xesam-support/filters/application/msword_filter
   branches/xesam-support/filters/application/pdf_filter
   branches/xesam-support/filters/application/tab-separated-values_filter
   branches/xesam-support/filters/application/vnd.ms-excel_filter
   branches/xesam-support/filters/application/vnd.oasis.opendocument.presentation-template_filter
   branches/xesam-support/filters/application/vnd.oasis.opendocument.presentation_filter
   branches/xesam-support/filters/application/vnd.oasis.opendocument.spreadsheet-template_filter
   branches/xesam-support/filters/application/vnd.oasis.opendocument.spreadsheet_filter
   branches/xesam-support/filters/application/vnd.oasis.opendocument.text-template_filter
   branches/xesam-support/filters/application/vnd.oasis.opendocument.text_filter
   branches/xesam-support/filters/application/vnd.stardivision.writer_filter
   branches/xesam-support/filters/application/vnd.sun.xml.calc.template_filter
   branches/xesam-support/filters/application/vnd.sun.xml.calc_filter
   branches/xesam-support/filters/application/vnd.sun.xml.draw_filter
   branches/xesam-support/filters/application/vnd.sun.xml.impress.template_filter
   branches/xesam-support/filters/application/vnd.sun.xml.impress_filter
   branches/xesam-support/filters/application/vnd.sun.xml.writer.template_filter
   branches/xesam-support/filters/application/vnd.sun.xml.writer_filter
   branches/xesam-support/filters/application/x-abiword_filter
   branches/xesam-support/filters/application/x-gnumeric_filter
   branches/xesam-support/filters/text/csv_filter
   branches/xesam-support/filters/text/djvu_filter
   branches/xesam-support/filters/text/html_filter
   branches/xesam-support/filters/text/spreadsheet_filter
   branches/xesam-support/filters/text/tab-separated-values_filter
   branches/xesam-support/filters/text/x-comma-separated-values_filter
   branches/xesam-support/filters/text/x-tex_filter
   branches/xesam-support/filters/text/xml_filter
   branches/xesam-support/src/libtracker-db/tracker-db-interface-sqlite.c
   branches/xesam-support/src/tracker-indexer/modules/files.c
   branches/xesam-support/src/tracker-indexer/tracker-indexer-module.c
   branches/xesam-support/src/tracker-indexer/tracker-indexer-module.h

Modified: branches/xesam-support/filters/application/csv_filter
==============================================================================
--- branches/xesam-support/filters/application/csv_filter	(original)
+++ branches/xesam-support/filters/application/csv_filter	Thu Jun  5 08:05:17 2008
@@ -4,7 +4,7 @@
 
 nice -n19 ssindex -i "$1" > "$tmpfile"
 
-nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/application/msword_filter
==============================================================================
--- branches/xesam-support/filters/application/msword_filter	(original)
+++ branches/xesam-support/filters/application/msword_filter	Thu Jun  5 08:05:17 2008
@@ -3,6 +3,8 @@
 tmpdir=${TMPDIR-/tmp}
 tmpdir="$tmpdir"/tmpdir.$$
 
+tmptxtfile=`mktemp`
+
 (umask 077 && mkdir "$tmpdir") || exit 1
 
 tmpfile="$tmpdir"/tmpfile.$$
@@ -15,6 +17,8 @@
 
 cd "$tmpdir"
 
-nice -n19 wvText "$tmpfile" "$2"
+nice -n19 wvText "$tmpfile" "$tmptxtfile"
 
 rm -rf "$tmpdir"
+rm "$tmptxtfile"
+

Modified: branches/xesam-support/filters/application/pdf_filter
==============================================================================
--- branches/xesam-support/filters/application/pdf_filter	(original)
+++ branches/xesam-support/filters/application/pdf_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 pdftotext -enc UTF-8 -q -nopgbrk  "$1" "$2"
+nice -n19 pdftotext -enc UTF-8 -q -nopgbrk  "$1" -

Modified: branches/xesam-support/filters/application/tab-separated-values_filter
==============================================================================
--- branches/xesam-support/filters/application/tab-separated-values_filter	(original)
+++ branches/xesam-support/filters/application/tab-separated-values_filter	Thu Jun  5 08:05:17 2008
@@ -4,7 +4,7 @@
 
 nice -n19 ssindex -i "$1" > "$tmpfile"
 
-nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/application/vnd.ms-excel_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.ms-excel_filter	(original)
+++ branches/xesam-support/filters/application/vnd.ms-excel_filter	Thu Jun  5 08:05:17 2008
@@ -4,7 +4,7 @@
 
 nice -n19 ssindex -i "$1" > "$tmpfile"
 
-nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/application/vnd.oasis.opendocument.presentation-template_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.oasis.opendocument.presentation-template_filter	(original)
+++ branches/xesam-support/filters/application/vnd.oasis.opendocument.presentation-template_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.oasis.opendocument.presentation_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.oasis.opendocument.presentation_filter	(original)
+++ branches/xesam-support/filters/application/vnd.oasis.opendocument.presentation_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.oasis.opendocument.spreadsheet-template_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.oasis.opendocument.spreadsheet-template_filter	(original)
+++ branches/xesam-support/filters/application/vnd.oasis.opendocument.spreadsheet-template_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.oasis.opendocument.spreadsheet_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.oasis.opendocument.spreadsheet_filter	(original)
+++ branches/xesam-support/filters/application/vnd.oasis.opendocument.spreadsheet_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.oasis.opendocument.text-template_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.oasis.opendocument.text-template_filter	(original)
+++ branches/xesam-support/filters/application/vnd.oasis.opendocument.text-template_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.oasis.opendocument.text_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.oasis.opendocument.text_filter	(original)
+++ branches/xesam-support/filters/application/vnd.oasis.opendocument.text_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.stardivision.writer_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.stardivision.writer_filter	(original)
+++ branches/xesam-support/filters/application/vnd.stardivision.writer_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.sun.xml.calc.template_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.sun.xml.calc.template_filter	(original)
+++ branches/xesam-support/filters/application/vnd.sun.xml.calc.template_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.sun.xml.calc_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.sun.xml.calc_filter	(original)
+++ branches/xesam-support/filters/application/vnd.sun.xml.calc_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.sun.xml.draw_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.sun.xml.draw_filter	(original)
+++ branches/xesam-support/filters/application/vnd.sun.xml.draw_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.sun.xml.impress.template_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.sun.xml.impress.template_filter	(original)
+++ branches/xesam-support/filters/application/vnd.sun.xml.impress.template_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.sun.xml.impress_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.sun.xml.impress_filter	(original)
+++ branches/xesam-support/filters/application/vnd.sun.xml.impress_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.sun.xml.writer.template_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.sun.xml.writer.template_filter	(original)
+++ branches/xesam-support/filters/application/vnd.sun.xml.writer.template_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/vnd.sun.xml.writer_filter
==============================================================================
--- branches/xesam-support/filters/application/vnd.sun.xml.writer_filter	(original)
+++ branches/xesam-support/filters/application/vnd.sun.xml.writer_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt

Modified: branches/xesam-support/filters/application/x-abiword_filter
==============================================================================
--- branches/xesam-support/filters/application/x-abiword_filter	(original)
+++ branches/xesam-support/filters/application/x-abiword_filter	Thu Jun  5 08:05:17 2008
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-nice -n19 xsltproc - "$1" > "$2" <<EOF
+nice -n19 xsltproc - "$1" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/application/x-gnumeric_filter
==============================================================================
--- branches/xesam-support/filters/application/x-gnumeric_filter	(original)
+++ branches/xesam-support/filters/application/x-gnumeric_filter	Thu Jun  5 08:05:17 2008
@@ -4,7 +4,7 @@
 
 nice -n19 ssindex -i "$1" > "$tmpfile"
 
-nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/text/csv_filter
==============================================================================
--- branches/xesam-support/filters/text/csv_filter	(original)
+++ branches/xesam-support/filters/text/csv_filter	Thu Jun  5 08:05:17 2008
@@ -4,7 +4,7 @@
 
 nice -n19 ssindex -i "$1" > "$tmpfile"
 
-nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/text/djvu_filter
==============================================================================
--- branches/xesam-support/filters/text/djvu_filter	(original)
+++ branches/xesam-support/filters/text/djvu_filter	Thu Jun  5 08:05:17 2008
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-nice -n19 djvused "$1" -e 'print-pure-txt' > "$2"
+nice -n19 djvused "$1" -e 'print-pure-txt'

Modified: branches/xesam-support/filters/text/html_filter
==============================================================================
--- branches/xesam-support/filters/text/html_filter	(original)
+++ branches/xesam-support/filters/text/html_filter	Thu Jun  5 08:05:17 2008
@@ -12,4 +12,4 @@
     -o ucs_conv=true \
     -T text/html \
     -dump \
-    "$1" > "$2"
+    "$1"

Modified: branches/xesam-support/filters/text/spreadsheet_filter
==============================================================================
--- branches/xesam-support/filters/text/spreadsheet_filter	(original)
+++ branches/xesam-support/filters/text/spreadsheet_filter	Thu Jun  5 08:05:17 2008
@@ -4,7 +4,7 @@
 
 nice -n19 ssindex -i "$1" > "$tmpfile"
 
-nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/text/tab-separated-values_filter
==============================================================================
--- branches/xesam-support/filters/text/tab-separated-values_filter	(original)
+++ branches/xesam-support/filters/text/tab-separated-values_filter	Thu Jun  5 08:05:17 2008
@@ -4,7 +4,7 @@
 
 nice -n19 ssindex -i "$1" > "$tmpfile"
 
-nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/text/x-comma-separated-values_filter
==============================================================================
--- branches/xesam-support/filters/text/x-comma-separated-values_filter	(original)
+++ branches/xesam-support/filters/text/x-comma-separated-values_filter	Thu Jun  5 08:05:17 2008
@@ -4,7 +4,7 @@
 
 nice -n19 ssindex -i "$1" > "$tmpfile"
 
-nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/filters/text/x-tex_filter
==============================================================================
--- branches/xesam-support/filters/text/x-tex_filter	(original)
+++ branches/xesam-support/filters/text/x-tex_filter	Thu Jun  5 08:05:17 2008
@@ -1,5 +1,5 @@
 #!/bin/sh
 UNTEX=`which untex`
-if [ -n "$UNTEX" ]; then nice -n19 $UNTEX "$1" > "$2";
-else cat "$1" > "$2";
+if [ -n "$UNTEX" ]; then nice -n19 $UNTEX "$1";
+else cat "$1";
 fi

Modified: branches/xesam-support/filters/text/xml_filter
==============================================================================
--- branches/xesam-support/filters/text/xml_filter	(original)
+++ branches/xesam-support/filters/text/xml_filter	Thu Jun  5 08:05:17 2008
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-nice -n19 xsltproc - "$1" > "$2" <<EOF
+nice -n19 xsltproc - "$1" <<EOF
 <?xml version="1.0"?>
 <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

Modified: branches/xesam-support/src/libtracker-db/tracker-db-interface-sqlite.c
==============================================================================
--- branches/xesam-support/src/libtracker-db/tracker-db-interface-sqlite.c	(original)
+++ branches/xesam-support/src/libtracker-db/tracker-db-interface-sqlite.c	Thu Jun  5 08:05:17 2008
@@ -451,16 +451,12 @@
 	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
 	stmt = get_stored_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), procedure_name);
 	stmt_args = sqlite3_bind_parameter_count (stmt);
-	n_args = 1;
 
-	while ((str = va_arg (args, gchar *)) != NULL) {
+	for (n_args = 1; n_args <= stmt_args; n_args++) {
+		str = va_arg (args, gchar *);
 		sqlite3_bind_text (stmt, n_args, str, -1, SQLITE_STATIC);
-		n_args++;
 	}
 
-	/* Just panic if the number of arguments don't match */
-	g_assert (n_args != stmt_args);
-
 	return create_result_set_from_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), stmt, error);
 }
 
@@ -478,9 +474,9 @@
 	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
 	stmt = get_stored_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), procedure_name);
 	stmt_args = sqlite3_bind_parameter_count (stmt);
-	n_args = 1;
 
-	while ((str = va_arg (args, gchar *)) != NULL) {
+	for (n_args = 1; n_args <= stmt_args; n_args++) {
+		str = va_arg (args, gchar *);
 		len = va_arg (args, gint);
 
 		if (len == -1) {
@@ -490,13 +486,8 @@
 			/* Deal with it as a blob */
 			sqlite3_bind_blob (stmt, n_args, str, len, SQLITE_STATIC);
 		}
-
-		n_args++;
 	}
 
-	/* Just panic if the number of arguments don't match */
-	g_assert (n_args != stmt_args);
-
 	return create_result_set_from_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), stmt, error);
 }
 

Modified: branches/xesam-support/src/tracker-indexer/modules/files.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/modules/files.c	(original)
+++ branches/xesam-support/src/tracker-indexer/modules/files.c	Thu Jun  5 08:05:17 2008
@@ -27,6 +27,7 @@
 #include <libtracker-common/tracker-config.h>
 #include <libtracker-common/tracker-file-utils.h>
 #include <libtracker-common/tracker-os-dependant.h>
+#include <libtracker-common/tracker-ontology.h>
 
 #define METADATA_FILE_NAME_DELIMITED "File:NameDelimited"
 #define METADATA_FILE_EXT            "File:Ext"
@@ -92,18 +93,17 @@
 }
 
 void
-tracker_metadata_get_embedded (const char *uri,
+tracker_metadata_get_embedded (const char *path,
 			       const char *mimetype,
 			       GHashTable *table)
 {
 	gboolean success;
-	gchar **argv, *output, **values;
+	gchar **argv, *output, **values, *service_type;
 	gint i;
 
-	/* FIXME: lookup the service type to check whether it possibly has metadata */
-#if 0
-	service_type = tracker_ontology_get_service_type_for_mime (mime);
-	if (!service_type ) {
+	service_type = tracker_ontology_get_service_type_for_mime (mimetype);
+
+	if (!service_type) {
 		return;
 	}
 
@@ -111,16 +111,15 @@
 		g_free (service_type);
 		return;
 	}
-#endif
 
 	/* we extract metadata out of process using pipes */
 	argv = g_new0 (gchar *, 4);
 	argv[0] = g_strdup ("tracker-extract");
-	argv[1] = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+	argv[1] = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
 	argv[2] = g_strdup (mimetype);
 
 	if (!argv[1] || !argv[2]) {
-		g_critical ("uri or mime could not be converted to locale format");
+		g_critical ("path or mime could not be converted to locale format");
 		g_strfreev (argv);
 		return;
 	}
@@ -176,6 +175,72 @@
 	g_free (output);
 }
 
+static gboolean
+check_exclude_file (const gchar *path)
+{
+	gchar *name;
+	guint i;
+
+	const gchar const *ignore_suffix[] = {
+		"~", ".o", ".la", ".lo", ".loT", ".in",
+		".csproj", ".m4", ".rej", ".gmo", ".orig",
+		".pc", ".omf", ".aux", ".tmp", ".po",
+		".vmdk",".vmx",".vmxf",".vmsd",".nvram",
+		".part"
+	};
+
+	const gchar const *ignore_prefix[] = {
+		"autom4te", "conftest.", "confstat",
+		"config."
+	};
+
+	const gchar const *ignore_name[] = {
+		"po", "CVS", "aclocal", "Makefile", "CVS",
+		"SCCS", "ltmain.sh","libtool", "config.status",
+		"conftest", "confdefs.h"
+	};
+
+	if (g_str_has_prefix (path, "/proc/") ||
+	    g_str_has_prefix (path, "/dev/") ||
+	    g_str_has_prefix (path, "/tmp/") ||
+	    g_str_has_prefix (path, g_get_tmp_dir ())) {
+		return TRUE;
+	}
+
+	name = g_path_get_basename (path);
+
+	if (name[0] == '.') {
+		g_free (name);
+		return TRUE;
+	}
+
+	for (i = 0; i < G_N_ELEMENTS (ignore_suffix); i++) {
+		if (g_str_has_suffix (name, ignore_suffix[i])) {
+			g_free (name);
+			return TRUE;
+		}
+	}
+
+	for (i = 0; i < G_N_ELEMENTS (ignore_prefix); i++) {
+		if (g_str_has_prefix (name, ignore_prefix[i])) {
+			g_free (name);
+			return TRUE;
+		}
+	}
+
+	for (i = 0; i < G_N_ELEMENTS (ignore_name); i++) {
+		if (strcmp (name, ignore_name[i]) == 0) {
+			g_free (name);
+			return TRUE;
+		}
+	}
+
+	/* FIXME: check NoIndexFileTypes in configuration */
+
+	g_free (name);
+	return FALSE;
+}
+
 GHashTable *
 tracker_module_get_file_metadata (const gchar *file)
 {
@@ -184,7 +249,9 @@
 	const gchar *ext;
 	gchar *mimetype;
 
-	/* FIXME: check exclude extensions */
+	if (check_exclude_file (file)) {
+		return NULL;
+	}
 
 	g_lstat (file, &st);
 	metadata = g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -225,3 +292,74 @@
 
 	return metadata;
 }
+
+gchar *
+tracker_metadata_call_text_filter (const gchar *path,
+				   const gchar *mime)
+{
+	gchar *str, *text_filter_file;
+	gchar *text = NULL;
+
+#ifdef OS_WIN32
+	str = g_strconcat (mime, "_filter.bat", NULL);
+#else
+	str = g_strconcat (mime, "_filter", NULL);
+#endif
+
+	text_filter_file = g_build_filename (LIBDIR,
+					     "tracker",
+					     "filters",
+					     str,
+					     NULL);
+
+	if (g_file_test (text_filter_file, G_FILE_TEST_EXISTS)) {
+		gchar **argv;
+
+		argv = g_new0 (gchar *, 3);
+		argv[0] = g_strdup (text_filter_file);
+		argv[1] = g_strdup (path);
+
+		g_message ("Extracting text for:'%s' using filter:'%s'",
+                           argv[1], argv[0]);
+
+		tracker_spawn (argv, 30, &text, NULL);
+
+		g_strfreev (argv);
+	}
+
+	g_free (text_filter_file);
+	g_free (str);
+
+	return text;
+}
+
+gchar *
+tracker_module_get_file_text (const gchar *file)
+{
+	gchar *mimetype, *service_type;
+	gchar *text = NULL;
+	GMappedFile *mapped_file;
+
+	mimetype = tracker_file_get_mime_type (file);
+	service_type = tracker_ontology_get_service_type_for_mime (mimetype);
+
+	/* No need to filter text based files - index them directly */
+	if (strcmp (service_type, "Text") == 0 ||
+            strcmp (service_type, "Development") == 0) {
+		GMappedFile *mapped_file;
+
+		mapped_file = g_mapped_file_new (file, FALSE, NULL);
+
+		if (mapped_file) {
+			text = g_strdup (g_mapped_file_get_contents (mapped_file));
+			g_mapped_file_free (mapped_file);
+		}
+	} else {
+		text = tracker_metadata_call_text_filter (file, mimetype);
+	}
+
+	g_free (mimetype);
+	g_free (service_type);
+
+	return text;
+}

Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-module.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-module.c	(original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-module.c	Thu Jun  5 08:05:17 2008
@@ -26,6 +26,7 @@
 typedef const gchar * (* TrackerIndexerModuleGetName) (void);
 typedef gchar **      (* TrackerIndexerModuleGetDirectories) (void);
 typedef GHashTable *  (* TrackerIndexerModuleGetData) (const gchar *path);
+typedef gchar *       (* TrackerIndexerModuleGetText) (const gchar *path);
 
 GModule *
 tracker_indexer_module_load (const gchar *module_name)
@@ -100,3 +101,16 @@
 
 	return NULL;
 }
+
+gchar *
+tracker_indexer_module_get_text (GModule     *module,
+				 const gchar *file)
+{
+	TrackerIndexerModuleGetText func;
+
+	if (g_module_symbol (module, "tracker_module_get_file_text", (gpointer *) &func)) {
+		return (func) (file);
+        }
+
+	return NULL;
+}

Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-module.h
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-module.h	(original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-module.h	Thu Jun  5 08:05:17 2008
@@ -34,6 +34,8 @@
 
 GHashTable *            tracker_indexer_module_get_file_metadata      (GModule     *module,
 								       const gchar *file);
+gchar *                 tracker_indexer_module_get_text               (GModule     *module,
+								       const gchar *file);
 
 G_END_DECLS
 



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