tracker r1802 - in branches/indexer-split: . data/modules src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1802 - in branches/indexer-split: . data/modules src/trackerd
- Date: Mon, 30 Jun 2008 12:01:24 +0000 (UTC)
Author: mr
Date: Mon Jun 30 12:01:24 2008
New Revision: 1802
URL: http://svn.gnome.org/viewvc/tracker?rev=1802&view=rev
Log:
* data/modules/applications.module: Changed the location to
$prefix/share/applications for now, it was just $prefix/share,
there are too many files there and we need the appropriate ignore
patterns in place before we can really do this.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/data/modules/applications.module
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-main.h
branches/indexer-split/src/trackerd/tracker-process.c
branches/indexer-split/src/trackerd/tracker-process.h
Modified: branches/indexer-split/data/modules/applications.module
==============================================================================
--- branches/indexer-split/data/modules/applications.module (original)
+++ branches/indexer-split/data/modules/applications.module Mon Jun 30 12:01:24 2008
@@ -4,7 +4,7 @@
[Monitors]
Directories=
-RecurseDirectories=/usr/share;
+RecurseDirectories=/usr/share/applications;
[Ignored]
Directories=
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Mon Jun 30 12:01:24 2008
@@ -40,6 +40,7 @@
#include <libtracker-common/tracker-language.h>
#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-hal.h>
+#include <libtracker-common/tracker-module-config.h>
#include <libtracker-common/tracker-ontology.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-nfs-lock.h>
@@ -638,7 +639,7 @@
}
/* Get files first */
- tracker_process_start (user_data);
+ tracker_processor_start (user_data);
proxy = tracker_dbus_indexer_get_proxy ();
tracker_xesam_subscribe_index_updated (proxy);
@@ -653,6 +654,7 @@
GOptionGroup *group;
GError *error = NULL;
TrackerDBManagerFlags flags;
+ TrackerProcessor *processor;
g_type_init ();
@@ -794,14 +796,9 @@
tracker_db_manager_init (flags, &tracker->first_time_index);
tracker_db_init ();
tracker_xesam_manager_init ();
- tracker_process_init ();
+ tracker_module_config_init ();
- 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 */
+ processor = tracker_processor_new (tracker->config);
umask (077);
@@ -838,7 +835,7 @@
seconds);
g_timeout_add (seconds * 1000,
start_cb,
- tracker->crawler);
+ processor);
} else {
g_idle_add (start_cb, tracker);
}
@@ -867,7 +864,6 @@
/* Shutdown major subsystems */
tracker_dbus_shutdown ();
- tracker_process_shutdown ();
tracker_xesam_manager_shutdown ();
tracker_db_manager_shutdown (TRUE);
tracker_db_shutdown ();
@@ -875,13 +871,8 @@
tracker_nfs_lock_shutdown ();
tracker_log_shutdown ();
-#ifdef HAVE_HAL
- if (tracker->hal) {
- g_object_unref (tracker->hal);
- }
-#endif
- if (tracker->crawler) {
- g_object_unref (tracker->crawler);
+ if (processor) {
+ g_object_unref (processor);
}
if (tracker->language) {
@@ -892,6 +883,8 @@
g_object_unref (tracker->config);
}
+ tracker_module_config_shutdown ();
+
shutdown_locations ();
return EXIT_SUCCESS;
@@ -903,7 +896,7 @@
tracker->is_running = FALSE;
/* Stop any tight loop operations */
- tracker_process_stop ();
+/* tracker_processor_stop ();*/
g_main_loop_quit (main_loop);
}
Modified: branches/indexer-split/src/trackerd/tracker-main.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.h (original)
+++ branches/indexer-split/src/trackerd/tracker-main.h Mon Jun 30 12:01:24 2008
@@ -42,14 +42,9 @@
G_BEGIN_DECLS
typedef struct {
-#ifdef HAVE_HAL
- TrackerHal *hal;
-#endif
-
TrackerConfig *config;
TrackerLanguage *language;
- TrackerCrawler *crawler;
TrackerIndexer *file_index;
TrackerIndexer *file_update_index;
TrackerIndexer *email_index;
Modified: branches/indexer-split/src/trackerd/tracker-process.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-process.c (original)
+++ branches/indexer-split/src/trackerd/tracker-process.c Mon Jun 30 12:01:24 2008
@@ -1,6 +1,5 @@
/* -*- 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
@@ -21,15 +20,193 @@
#include "config.h"
+#include <string.h>
+
#include <glib.h>
#include <gio/gio.h>
#include <libtracker-common/tracker-module-config.h>
+#include <libtracker-common/tracker-hal.h>
#include "tracker-process.h"
+#include "tracker-crawler.h"
#include "tracker-monitor.h"
-static TrackerCrawler *crawler;
+#define TRACKER_PROCESSOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_PROCESSOR, TrackerProcessorPrivate))
+
+typedef struct TrackerProcessorPrivate TrackerProcessorPrivate;
+
+struct TrackerProcessorPrivate {
+ TrackerConfig *config;
+#ifdef HAVE_HAL
+ TrackerHal *hal;
+#endif /* HAVE_HAL */
+ TrackerCrawler *crawler;
+
+ GQueue *dir_queue;
+ GQueue *file_queue;
+ GList *modules;
+ GList *current_module;
+
+ guint idle_id;
+
+ GTimer *timer;
+
+ gboolean finished;
+};
+
+typedef struct {
+ gchar *module_name;
+ gchar *path;
+} ProcessInfo;
+
+enum {
+ FINISHED,
+ LAST_SIGNAL
+};
+
+static void tracker_processor_finalize (GObject *object);
+static void info_free (ProcessInfo *info);
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE (TrackerProcessor, tracker_processor, G_TYPE_OBJECT)
+
+static void
+tracker_processor_class_init (TrackerProcessorClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = tracker_processor_finalize;
+
+ signals [FINISHED] =
+ g_signal_new ("finished",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (TrackerProcessorClass, finished),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_type_class_add_private (object_class, sizeof (TrackerProcessorPrivate));
+}
+
+static void
+tracker_processor_init (TrackerProcessor *processor)
+{
+ TrackerProcessorPrivate *priv;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ priv->dir_queue = g_queue_new ();
+ priv->file_queue = g_queue_new ();
+
+ priv->modules = tracker_module_config_get_modules ();
+}
+
+static void
+tracker_processor_finalize (GObject *object)
+{
+ TrackerProcessorPrivate *priv;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (object);
+
+ if (priv->timer) {
+ g_timer_destroy (priv->timer);
+ }
+
+ if (priv->idle_id) {
+ g_source_remove (priv->idle_id);
+ priv->idle_id = 0;
+ }
+
+ g_list_free (priv->modules);
+
+ g_queue_foreach (priv->file_queue, (GFunc) info_free, NULL);
+ g_queue_free (priv->file_queue);
+
+ g_queue_foreach (priv->dir_queue, (GFunc) info_free, NULL);
+ g_queue_free (priv->dir_queue);
+
+ g_object_unref (priv->crawler);
+
+#ifdef HAVE_HAL
+ g_object_unref (priv->hal);
+#endif /* HAVE_HAL */
+
+ g_object_unref (priv->config);
+
+ G_OBJECT_CLASS (tracker_processor_parent_class)->finalize (object);
+}
+
+static ProcessInfo *
+info_new (const gchar *module_name,
+ const gchar *path)
+{
+ ProcessInfo *info;
+
+ info = g_slice_new (ProcessInfo);
+
+ info->module_name = g_strdup (module_name);
+ info->path = g_strdup (path);
+
+ return info;
+}
+
+static void
+info_free (ProcessInfo *info)
+{
+ g_free (info->module_name);
+ g_free (info->path);
+ g_slice_free (ProcessInfo, info);
+}
+
+static void
+add_file (TrackerProcessor *processor,
+ ProcessInfo *info)
+{
+ TrackerProcessorPrivate *priv;
+
+ g_return_if_fail (info != NULL);
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ g_queue_push_tail (priv->file_queue, info);
+}
+
+static void
+add_directory (TrackerProcessor *processor,
+ ProcessInfo *info)
+{
+ TrackerProcessorPrivate *priv;
+ gboolean ignore = FALSE;
+ gchar **ignore_dirs = NULL;
+ gint i;
+
+ g_return_if_fail (info != NULL);
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ /* ignore_dirs = tracker_processor_module_get_ignore_directories (info->module_name); */
+
+ if (ignore_dirs) {
+ for (i = 0; ignore_dirs[i]; i++) {
+ if (strcmp (info->path, ignore_dirs[i]) == 0) {
+ ignore = TRUE;
+ break;
+ }
+ }
+ }
+
+ if (!ignore) {
+ g_queue_push_tail (priv->dir_queue, info);
+ } else {
+ g_message (" Ignoring directory:'%s'", info->path);
+ info_free (info);
+ }
+
+ g_strfreev (ignore_dirs);
+}
static void
add_monitors (const gchar *name)
@@ -83,52 +260,211 @@
}
}
-void
-tracker_process_start (TrackerCrawler *crawler_to_start)
+static gboolean
+process_file (TrackerProcessor *processor,
+ ProcessInfo *info)
{
- GList *modules;
- GList *l;
+ g_message (" Processing file:'%s'", info->path);
+ return TRUE;
+}
- g_return_if_fail (TRACKER_IS_CRAWLER (crawler_to_start));
+static void
+process_directory (TrackerProcessor *processor,
+ ProcessInfo *info,
+ gboolean recurse)
+{
+ GDir *dir;
+ const gchar *name;
- crawler = g_object_ref (crawler_to_start);
- modules = tracker_module_config_get_modules ();
+ g_message (" Processing directory:'%s'", info->path);
- g_message ("Starting to process %d modules...",
- g_list_length (modules));
-
+ dir = g_dir_open (info->path, 0, NULL);
+
+ if (!dir) {
+ return;
+ }
+
+ while ((name = g_dir_read_name (dir)) != NULL) {
+ ProcessInfo *new_info;
+ gchar *path;
+
+ path = g_build_filename (info->path, name, NULL);
+
+ new_info = info_new (info->module_name, path);
+ add_file (processor, new_info);
+
+ if (recurse && g_file_test (path, G_FILE_TEST_IS_DIR)) {
+ new_info = info_new (info->module_name, path);
+ add_directory (processor, new_info);
+ }
+
+ g_free (path);
+ }
+
+ g_dir_close (dir);
+}
+
+static void
+process_module (TrackerProcessor *processor,
+ const gchar *module_name)
+{
+ TrackerProcessorPrivate *priv;
+ GSList *dirs, *l;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ g_message ("Processing module:'%s'", module_name);
+
+ dirs = tracker_module_config_get_monitor_recurse_directories (module_name);
+ if (!dirs) {
+ g_message (" No directories to iterate, doing nothing");
+ return;
+ }
+
+ for (l = dirs; l; l = l->next) {
+ ProcessInfo *info;
+
+ info = info_new (module_name, l->data);
+ add_directory (processor, info);
+ }
+}
+
+static gboolean
+process_func (gpointer data)
+{
+ TrackerProcessor *processor;
+ TrackerProcessorPrivate *priv;
+ ProcessInfo *info;
+
+ processor = TRACKER_PROCESSOR (data);
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+#if 0
+ /* Process monitors first */
for (l = modules; l; l = l->next) {
gchar *name;
name = l->data;
- g_message ("Processing module:'%s'", name);
+ g_message ("Processoring module:'%s'", name);
add_monitors (name);
add_recurse_monitors (name);
/* FIXME: Finish, start crawling? */
}
+#endif
+
+ /* Processor file */
+ info = g_queue_peek_head (priv->file_queue);
+
+ if (info) {
+ if (process_file (processor, info)) {
+ info = g_queue_pop_head (priv->file_queue);
+ info_free (info);
+ }
+
+ return TRUE;
+ }
+
+ /* Processor directory contents */
+ info = g_queue_pop_head (priv->dir_queue);
+
+ if (info) {
+ process_directory (processor, info, TRUE);
+ info_free (info);
+ return TRUE;
+ }
+
+ /* Dirs/files queues are empty, processor the next module */
+ if (!priv->current_module) {
+ priv->current_module = priv->modules;
+ } else {
+ priv->current_module = priv->current_module->next;
+ }
+
+ if (!priv->current_module) {
+ priv->finished = TRUE;
+ tracker_processor_stop (processor);
- g_list_free (modules);
+ return FALSE;
+ }
+
+ process_module (processor, priv->current_module->data);
+
+ return TRUE;
}
-void
-tracker_process_stop (void)
+TrackerProcessor *
+tracker_processor_new (TrackerConfig *config)
{
- if (crawler) {
- tracker_crawler_stop (crawler);
- }
+ TrackerProcessor *processor;
+ TrackerProcessorPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
+
+ processor = g_object_new (TRACKER_TYPE_PROCESSOR, NULL);
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ priv->config = g_object_ref (config);
+ priv->crawler = tracker_crawler_new (config);
+
+#ifdef HAVE_HAL
+ priv->hal = tracker_hal_new ();
+ tracker_crawler_set_hal (priv->crawler, priv->hal);
+#endif /* HAVE_HAL */
+
+ return processor;
}
void
-tracker_process_init (void)
+tracker_processor_start (TrackerProcessor *processor)
{
- tracker_module_config_init ();
+ TrackerProcessorPrivate *priv;
+
+ g_return_if_fail (TRACKER_IS_PROCESSOR (processor));
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ g_message ("Starting to process %d modules...",
+ g_list_length (priv->modules));
+
+ priv->finished = FALSE;
+
+ if (priv->timer) {
+ g_timer_destroy (priv->timer);
+ }
+
+ priv->timer = g_timer_new ();
+
+ priv->idle_id = g_idle_add (process_func, processor);
}
void
-tracker_process_shutdown (void)
+tracker_processor_stop (TrackerProcessor *processor)
{
- tracker_module_config_shutdown ();
+ TrackerProcessorPrivate *priv;
+
+ g_return_if_fail (TRACKER_IS_PROCESSOR (processor));
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ if (priv->crawler) {
+ tracker_crawler_stop (priv->crawler);
+ }
+
+ if (priv->idle_id) {
+ g_source_remove (priv->idle_id);
+ priv->idle_id = 0;
+ }
+
+ /* No more modules to query, we're done */
+ g_timer_stop (priv->timer);
+
+ g_message ("Processed %s %4.4f seconds",
+ priv->finished ? "finished in" : "stopped after",
+ g_timer_elapsed (priv->timer, NULL));
+
+ g_signal_emit (processor, signals[FINISHED], 0);
}
Modified: branches/indexer-split/src/trackerd/tracker-process.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-process.h (original)
+++ branches/indexer-split/src/trackerd/tracker-process.h Mon Jun 30 12:01:24 2008
@@ -1,6 +1,5 @@
/* -*- 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
@@ -19,19 +18,40 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __TRACKERD_PROCESS_H__
-#define __TRACKERD_PROCESS_H__
+#ifndef __TRACKERD_PROCESSOR_H__
+#define __TRACKERD_PROCESSOR_H__
-#include "tracker-crawler.h"
+#include <glib-object.h>
-G_BEGIN_DECLS
+#include <libtracker-common/tracker-config.h>
-void tracker_process_init (void);
-void tracker_process_shutdown (void);
+G_BEGIN_DECLS
-void tracker_process_start (TrackerCrawler *crawler);
-void tracker_process_stop (void);
+#define TRACKER_TYPE_PROCESSOR (tracker_processor_get_type())
+#define TRACKER_PROCESSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_PROCESSOR, TrackerProcessor))
+#define TRACKER_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_PROCESSOR, TrackerProcessorClass))
+#define TRACKER_IS_PROCESSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_PROCESSOR))
+#define TRACKER_IS_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_PROCESSOR))
+#define TRACKER_PROCESSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_PROCESSOR, TrackerProcessorClass))
+
+typedef struct TrackerProcessor TrackerProcessor;
+typedef struct TrackerProcessorClass TrackerProcessorClass;
+
+struct TrackerProcessor {
+ GObject parent_instance;
+};
+
+struct TrackerProcessorClass {
+ GObjectClass parent_class;
+
+ void (*finished) (TrackerProcessor *processor);
+};
+
+GType tracker_processor_get_type (void) G_GNUC_CONST;
+TrackerProcessor *tracker_processor_new (TrackerConfig *config);
+void tracker_processor_start (TrackerProcessor *processor);
+void tracker_processor_stop (TrackerProcessor *processor);
G_END_DECLS
-#endif /* __TRACKERD_PROCESS_H__ */
+#endif /* __TRACKERD_PROCESSOR_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]