tracker r1577 - in branches/indexer-split: . src/tracker-indexer src/tracker-indexer/modules
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1577 - in branches/indexer-split: . src/tracker-indexer src/tracker-indexer/modules
- Date: Wed, 4 Jun 2008 14:46:27 +0000 (UTC)
Author: carlosg
Date: Wed Jun 4 14:46:27 2008
New Revision: 1577
URL: http://svn.gnome.org/viewvc/tracker?rev=1577&view=rev
Log:
2008-06-04 Carlos Garnacho <carlos imendio com>
* src/tracker-indexer/tracker-indexer-module.[ch]
(tracker_indexer_module_get_text): New
function, returns the contained/extracted text for a file.
* src/tracker-indexer/modules/files.c (tracker_module_get_file_text)
(tracker_metadata_call_text_filter): Added, either get the text for
text/development files, or call the external filter, which returns the
contained text.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/tracker-indexer/modules/files.c
branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c
branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h
Modified: branches/indexer-split/src/tracker-indexer/modules/files.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/modules/files.c (original)
+++ branches/indexer-split/src/tracker-indexer/modules/files.c Wed Jun 4 14:46:27 2008
@@ -179,7 +179,7 @@
check_exclude_file (const gchar *path)
{
gchar *name;
- gint i;
+ guint i;
const gchar const *ignore_suffix[] = {
"~", ".o", ".la", ".lo", ".loT", ".in",
@@ -292,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/indexer-split/src/tracker-indexer/tracker-indexer-module.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c Wed Jun 4 14:46:27 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/indexer-split/src/tracker-indexer/tracker-indexer-module.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h Wed Jun 4 14:46:27 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]