tracker r1631 - in branches/indexer-split: . data/dbus src/tracker-indexer src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1631 - in branches/indexer-split: . data/dbus src/tracker-indexer src/trackerd
- Date: Tue, 10 Jun 2008 16:33:27 +0000 (UTC)
Author: mr
Date: Tue Jun 10 16:33:26 2008
New Revision: 1631
URL: http://svn.gnome.org/viewvc/tracker?rev=1631&view=rev
Log:
* configure.ac: Bumped the version dependency of GLib to 2.16 for
the new GIO API and remove the old backend code checks.
* data/dbus/tracker-indexer.xml: Added a "ProcessFiles" API call
and updated the "GetRunning" to return the state as a function
parameter.
* src/trackerd/Makefile.am:
* src/trackerd/tracker-crawler.[ch]:
* src/trackerd/tracker-monitor.[ch]:
* src/trackerd/tracker-email-evolution.c:
* src/trackerd/tracker-email-kmail.c:
* src/trackerd/tracker-email-modest.c:
* src/trackerd/tracker-email-thunderbird.c:
* src/trackerd/tracker-process-files.c: Added to handle directory
monitoring and for crawling the file system. The crawler module
now contacts the indexer and sends files it finds across DBus.
* src/trackerd/tracker-db.c: Use tracker_monitor_() instead of
tracker_watcher_().
* src/trackerd/tracker-main.c: Initialise the TrackerCrawler
object so it crawls $HOME for now for testing.
Added:
branches/indexer-split/src/trackerd/tracker-crawler.c
branches/indexer-split/src/trackerd/tracker-crawler.h
branches/indexer-split/src/trackerd/tracker-monitor.c
branches/indexer-split/src/trackerd/tracker-monitor.h
- copied, changed from r1616, /branches/indexer-split/src/trackerd/tracker-watcher.h
Removed:
branches/indexer-split/src/trackerd/tracker-watcher-fam.c
branches/indexer-split/src/trackerd/tracker-watcher-inotify.c
branches/indexer-split/src/trackerd/tracker-watcher-poll.c
branches/indexer-split/src/trackerd/tracker-watcher-win.c
branches/indexer-split/src/trackerd/tracker-watcher.h
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/configure.ac
branches/indexer-split/data/dbus/tracker-indexer.xml
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.h
branches/indexer-split/src/trackerd/Makefile.am
branches/indexer-split/src/trackerd/tracker-db.c
branches/indexer-split/src/trackerd/tracker-dbus.c
branches/indexer-split/src/trackerd/tracker-dbus.h
branches/indexer-split/src/trackerd/tracker-email-evolution.c
branches/indexer-split/src/trackerd/tracker-email-kmail.c
branches/indexer-split/src/trackerd/tracker-email-modest.c
branches/indexer-split/src/trackerd/tracker-email-thunderbird.c
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-process-files.c
Modified: branches/indexer-split/configure.ac
==============================================================================
--- branches/indexer-split/configure.ac (original)
+++ branches/indexer-split/configure.ac Tue Jun 10 16:33:26 2008
@@ -25,7 +25,7 @@
AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([You must have zlib.h and zlib installed])])
-dnl can posix_fadvise be used
+# Can posix_fadvise be used
AC_CHECK_DECLS(posix_fadvise, [], [], [
#define _XOPEN_SOURCE 600
#include <fcntl.h>])
@@ -34,9 +34,9 @@
AC_CHECK_FUNCS([posix_fadvise])
AC_CHECK_FUNCS([getline])
-dnl Library Checks
+# Library Checks
DBUS_REQUIRED=0.60
-GLIB_REQUIRED=2.14.0
+GLIB_REQUIRED=2.16.0
PANGO_REQUIRED=1.0.0
GMIME_REQUIRED=2.1.0
@@ -59,7 +59,11 @@
AC_SUBST(GMODULE_CFLAGS)
AC_SUBST(GMODULE_LIBS)
-#Check for pango
+PKG_CHECK_MODULES(GIO, [ gio-2.0 >= $GLIB_REQUIRED ])
+AC_SUBST(GIO_CFLAGS)
+AC_SUBST(GIO_LIBS)
+
+# Check for pango
PKG_CHECK_MODULES(PANGO, [ pango >= $PANGO_REQUIRED ])
AC_SUBST(PANGO_CFLAGS)
AC_SUBST(PANGO_LIBS)
@@ -166,7 +170,7 @@
AS_HELP_STRING([--disable-warnings], [disable GCC warnings]),,
[enable_warnings=yes])
-dnl Only use -Wall if we have gcc
+# Only use -Wall if we have gcc
if test "x$GCC" = "xyes"; then
if test "x$enable_warnings" = "xyes"; then
CFLAGS="\
@@ -230,7 +234,7 @@
##################################################################
-# check for libxml2
+# Check for libxml2
##################################################################
LIBXML2_REQUIRED=0.6
@@ -253,7 +257,7 @@
AM_CONDITIONAL(HAVE_LIBXML2, test "x$have_libxml2" = "xyes")
##################################################################
-# check for HAL
+# Check for HAL
##################################################################
AC_ARG_ENABLE(hal, AS_HELP_STRING([--disable-hal],[Disable HAL support for ac power detection]),,[enable_hal=yes])
@@ -374,131 +378,6 @@
AC_SUBST(SQLITE3_CFLAGS)
AC_SUBST(SQLITE3_LIBS)
-###############################################################################
-# Check for file monitor backends
-###############################################################################
-
-FAM_LIBS=
-inotify_support=no
-inotify_linux=no
-inotify_header=none
-fam_support=no
-fam_type=none
-
-AM_CONDITIONAL(HAVE_INOTIFY, false)
-AM_CONDITIONAL(HAVE_INOTIFY_LINUX, false)
-AM_CONDITIONAL(HAVE_FAM, false)
-
-AC_ARG_ENABLE(file-monitoring,
- AS_HELP_STRING(
- [--enable-file-monitoring=ARG],
- [enables one of the (inotify, fam, polling, auto) file monitoring backends]),,
- enable_file_monitoring=auto)
-
-
-AC_CHECK_HEADERS([sys/inotify.h],
- [
- inotify_support=yes
- inotify_linux=no
- ])
-
-AC_CHECK_HEADERS([linux/inotify.h],
- [
- inotify_linux=yes
- inotify_support=yes
- ])
-
-AC_CHECK_LIB(fam, FAMOpen,
- [AC_CHECK_HEADERS(fam.h,
- [
- fam_support=yes
- fam_type=fam
- ],[fam_support=no])],
- [fam_support=no])
-
-PKG_CHECK_MODULES(GAMIN,
- gamin,
- [
- fam_support=yes
- fam_type=gamin
- ],
- [
- fam_support=no
- ])
-
-if test "x$enable_file_monitoring" = "xauto"; then
- if test "$inotify_support" = "yes"; then
- primary_backend="inotify"
- if test "$inotify_linux" = "yes"; then
- inotify_header="linux/inotify.h"
- else
- inotify_header="sys/inotify.h"
- fi
-
- elif test "$fam_support" = "yes"; then
- if test "$fam_type" = "gamin"; then
- primary_backend="gamin"
- else
- primary_backend="fam"
- fi
- else
- if test "$native_win32" = "yes"; then
- primary_backend="win32"
- else
- primary_backend="polling only"
- fi
- fi
-elif test "x$enable_file_monitoring" = "xinotify"; then
- if test "$inotify_support" = "no"; then
- AC_MSG_ERROR([***inotify requested but not found - exiting!])
- else
- primary_backend="inotify"
- if test "$inotify_linux" = "yes"; then
- inotify_header="linux/inotify.h"
- else
- inotify_header="sys/inotify.h"
- fi
- fi
-elif test "x$enable_file_monitoring" = "xfam"; then
- if test "$fam_support" = "no"; then
- AC_MSG_ERROR([***fam requested but not found - exiting!])
- else
- if test "$fam_type" = "gamin"; then
- primary_backend="gamin"
- else
- primary_backend="fam"
- fi
- fi
-else
- if test "$native_win32" = "yes"; then
- primary_backend="win32"
- else
- primary_backend="polling only"
- fi
-fi
-
-if test "$primary_backend" = "inotify"; then
- AC_DEFINE(HAVE_INOTIFY, [], [Define if we have inotify])
- AM_CONDITIONAL(HAVE_INOTIFY, true)
- if test "$inotify_linux" = "yes"; then
- AC_DEFINE(HAVE_INOTIFY_LINUX, [],
- [
- Define if we have inotify and header is linux/inotify.h
- ])
- AM_CONDITIONAL(HAVE_INOTIFY_LINUX, true)
- fi
-elif test "$primary_backend" = "gamin"; then
- AC_DEFINE(HAVE_FAM, [], [Define if we have FAM])
- AM_CONDITIONAL(HAVE_FAM, true)
- FAM_LIBS="-lgamin-1"
- AC_SUBST(FAM_LIBS)
-elif test "$primary_backend" = "fam"; then
- AC_DEFINE(HAVE_FAM, [], [Define if we have FAM])
- AM_CONDITIONAL(HAVE_FAM, true)
- FAM_LIBS="-lfam"
- AC_SUBST(FAM_LIBS)
-fi
-
##################################################################
# Enable building libtracker-gtk?
@@ -527,10 +406,10 @@
AM_CONDITIONAL(ENABLE_LIBTRACKERGTK, test "$enable_libtrackergtk" = "yes")
-
##################################################################
# Enable building tracker-applet notification icon?
##################################################################
+
LIBNOTIFY_GTK2_REQUIRED=2.10
LIBNOTIFY_GLIB_REQUIRED=2.10
LIBNOTIFY_REQUIRED=0.4.3
@@ -557,12 +436,10 @@
AM_CONDITIONAL(ENABLE_TRACKERAPPLET, test "$enable_trackerapplet" = "yes")
-
##################################################################
# Enable UNAC support?
##################################################################
-
AC_ARG_ENABLE([unac], AS_HELP_STRING([--disable-unac], [Disable unac accent stripper support]),,[enable_unac=yes])
if test "x$enable_unac" != "xno" ; then
@@ -581,11 +458,8 @@
fi
AM_CONDITIONAL(ENABLE_UNAC, test "$enable_unac" = "yes")
-
-
-
##################################################################
-# check for GNOME/GTK dependencies to build tracker search tool (Gnome client)
+# Check for GNOME/GTK dependencies to build tracker search tool (Gnome client)
##################################################################
GTK_REQUIRED=2.8.0
@@ -672,7 +546,7 @@
AM_CONDITIONAL(ENABLE_PREFERENCES, test "$enable_preferences" = "yes")
##################################################################
-# check for poppler's glib bingings
+# Check for poppler's glib bingings
##################################################################
POPPLER_GLIB_REQUIRED=0.4.5
@@ -695,7 +569,7 @@
test "$have_poppler" = "yes" && AC_DEFINE(HAVE_POPPLER, [], [Define if we have poppler])
##################################################################
-# check for libexif
+# Check for libexif
##################################################################
LIBEXIF_REQUIRED=0.6
@@ -714,7 +588,7 @@
test "$have_libexif" = "yes" && AC_DEFINE(HAVE_LIBEXIF, [], [Define if we have libexif])
##################################################################
-# check for libgsf
+# Check for libgsf
##################################################################
LIBGSF_REQUIRED=1.13
@@ -753,10 +627,8 @@
[ AC_DEFINE(HAVE_IOPRIO,[],[Define ioprio support]) have_ioprio=yes ])
AC_MSG_RESULT([$have_ioprio])
-#####################################################
-
##################################################################
-# check for exempi
+# Check for exempi
##################################################################
EXEMPI_REQUIRED=1.99.2
@@ -841,7 +713,7 @@
enable unac accent stripper: $enable_unac
- support for file monitoring: $primary_backend
+ support for file monitoring: gio
support for ioprio: $have_ioprio
support for HAL: $have_hal
Modified: branches/indexer-split/data/dbus/tracker-indexer.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-indexer.xml (original)
+++ branches/indexer-split/data/dbus/tracker-indexer.xml Tue Jun 10 16:33:26 2008
@@ -10,9 +10,15 @@
<node name="/">
<interface name="org.freedesktop.Tracker.Indexer">
- <method name="GetRunning"/>
+ <method name="GetRunning">
+ <arg type="b" name="is_running" direction="out" />
+ </method>
<method name="SetRunning">
- <arg type="b" name="running" direction="in" />
+ <arg type="b" name="should_be_running" direction="in" />
+ </method>
+
+ <method name="ProcessFiles">
+ <arg type="as" name="files" direction="in" />
</method>
<!-- The old signal in the daemon used to send the time taken, we
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c Tue Jun 10 16:33:26 2008
@@ -48,6 +48,7 @@
#include <glib/gstdio.h>
#include <libtracker-common/tracker-config.h>
+#include <libtracker-common/tracker-dbus.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-language.h>
#include <libtracker-common/tracker-parser.h>
@@ -182,7 +183,9 @@
switch (prop_id) {
case PROP_RUNNING:
- tracker_indexer_set_running (indexer, g_value_get_boolean (value));
+ tracker_indexer_set_running (indexer,
+ g_value_get_boolean (value),
+ NULL);
break;
case PROP_REINDEX:
priv->reindex = g_value_get_boolean (value);
@@ -281,7 +284,7 @@
priv->metadata = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_METADATA);
priv->contents = tracker_db_manager_get_db_interface (TRACKER_DB_FILE_CONTENTS);
- tracker_indexer_set_running (indexer, TRUE);
+ tracker_indexer_set_running (indexer, TRUE, NULL);
g_free (index_file);
@@ -600,21 +603,29 @@
NULL);
}
-void
-tracker_indexer_set_running (TrackerIndexer *indexer,
- gboolean running)
+gboolean
+tracker_indexer_set_running (TrackerIndexer *indexer,
+ gboolean should_be_running,
+ GError **error)
{
TrackerIndexerPrivate *priv;
- gboolean changed = FALSE;
+ guint request_id;
+ gboolean changed = FALSE;
+
+ request_id = tracker_dbus_get_next_request_id ();
- g_return_if_fail (TRACKER_IS_INDEXER (indexer));
+ tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), FALSE, error);
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
- if (running && priv->idle_id == 0) {
+ tracker_dbus_request_new (request_id,
+ "DBus request to %s indexer",
+ should_be_running ? "start" : "stop");
+
+ if (should_be_running && priv->idle_id == 0) {
priv->idle_id = g_idle_add ((GSourceFunc) indexing_func, indexer);
changed = TRUE;
- } else if (!running && priv->idle_id != 0) {
+ } else if (!should_be_running && priv->idle_id != 0) {
g_source_remove (priv->idle_id);
priv->idle_id = 0;
changed = TRUE;
@@ -623,16 +634,57 @@
if (changed) {
g_object_notify (G_OBJECT (indexer), "running");
}
+
+ tracker_dbus_request_success (request_id);
+
+ return TRUE;
}
gboolean
-tracker_indexer_get_running (TrackerIndexer *indexer)
+tracker_indexer_get_running (TrackerIndexer *indexer,
+ gboolean *is_running,
+ GError **error)
{
TrackerIndexerPrivate *priv;
+ guint request_id;
- g_return_val_if_fail (TRACKER_IS_INDEXER (indexer), FALSE);
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), FALSE, error);
+ tracker_dbus_return_val_if_fail (is_running != NULL, FALSE, error);
priv = TRACKER_INDEXER_GET_PRIVATE (indexer);
- return (priv->idle_id != 0);
+ tracker_dbus_request_new (request_id,
+ "DBus request to get running status");
+
+ *is_running = priv->idle_id != 0;
+
+ tracker_dbus_request_success (request_id);
+
+ return TRUE;
+}
+
+gboolean
+tracker_indexer_process_files (TrackerIndexer *indexer,
+ GStrv files,
+ GError **error)
+{
+ /* TrackerIndexerPrivate *priv; */
+ guint request_id;
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_return_val_if_fail (TRACKER_IS_INDEXER (indexer), FALSE, error);
+ tracker_dbus_return_val_if_fail (files != NULL, FALSE, error);
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to process %d files",
+ g_strv_length (files));
+
+ /* Do work */
+
+ tracker_dbus_request_success (request_id);
+
+ return TRUE;
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.h Tue Jun 10 16:33:26 2008
@@ -22,14 +22,14 @@
#ifndef __TRACKER_INDEXER_H__
#define __TRACKER_INDEXER_H__
+#include <glib-object.h>
+
#define TRACKER_INDEXER_SERVICE "org.freedesktop.Tracker.Indexer"
#define TRACKER_INDEXER_PATH "/org/freedesktop/Tracker/Indexer"
#define TRACKER_INDEXER_INTERFACE "org.freedesktop.Tracker.Indexer"
G_BEGIN_DECLS
-#include <glib-object.h>
-
#define TRACKER_TYPE_INDEXER (tracker_indexer_get_type())
#define TRACKER_INDEXER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_INDEXER, TrackerIndexer))
#define TRACKER_INDEXER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_INDEXER, TrackerIndexerClass))
@@ -47,15 +47,21 @@
struct TrackerIndexerClass {
GObjectClass parent_class;
- void (*finished) (TrackerIndexer *indexer);
+ void (*finished) (TrackerIndexer *indexer);
void (*index_updated) (TrackerIndexer *indexer);
};
-GType tracker_indexer_get_type (void) G_GNUC_CONST;
-TrackerIndexer *tracker_indexer_new (gboolean reindex);
-void tracker_indexer_set_running (TrackerIndexer *indexer,
- gboolean running);
-gboolean tracker_indexer_get_running (TrackerIndexer *indexer);
+GType tracker_indexer_get_type (void) G_GNUC_CONST;
+TrackerIndexer *tracker_indexer_new (gboolean reindex);
+gboolean tracker_indexer_set_running (TrackerIndexer *indexer,
+ gboolean should_be_running,
+ GError **error);
+gboolean tracker_indexer_get_running (TrackerIndexer *indexer,
+ gboolean *is_running,
+ GError **error);
+gboolean tracker_indexer_process_files (TrackerIndexer *indexer,
+ GStrv files,
+ GError **error);
G_END_DECLS
Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am (original)
+++ branches/indexer-split/src/trackerd/Makefile.am Tue Jun 10 16:33:26 2008
@@ -12,6 +12,7 @@
$(QDBM_CFLAGS) \
$(DBUS_CFLAGS) \
$(PANGO_CFLAGS) \
+ $(GIO_CFLAGS) \
$(GMODULE_CFLAGS) \
$(GTHREAD_CFLAGS) \
$(GLIB2_CFLAGS)
@@ -47,30 +48,13 @@
#
-# Use either inotify, fam, win32 or poll API to know about file
-# changes and in that order.
-#
-if HAVE_INOTIFY
-watcher_sources = tracker-watcher-inotify.c linux-inotify-syscalls.h
-else # HAVE_INOTIFY
-if HAVE_FAM
-watcher_sources = tracker-watcher-fam.c
-else # HAVE_FAM
-if OS_WIN32
-watcher_sources = tracker-watcher-win.c
-else # OS_WIN32
-watcher_sources = tracker-watcher-poll.c
-endif # OS_WIN32
-endif # HAVE_FAM
-endif # HAVE_INOTIFY
-
-#
# Daemon sources
#
bin_PROGRAMS = trackerd
trackerd_SOURCES = \
- $(watcher_sources) \
+ tracker-crawler.c \
+ tracker-crawler.h \
tracker-daemon.c \
tracker-daemon.h \
tracker-db.c \
@@ -97,6 +81,8 @@
tracker-marshal-main.c \
tracker-metadata.c \
tracker-metadata.h \
+ tracker-monitor.c \
+ tracker-monitor.h \
tracker-query-tree.c \
tracker-query-tree.h \
tracker-rdf-query.c \
@@ -107,7 +93,6 @@
tracker-status.h \
tracker-utils.c \
tracker-utils.h \
- tracker-watcher.h \
tracker-xesam.c \
tracker-xesam.h \
tracker-xesam-ontology.c \
@@ -136,6 +121,7 @@
$(QDBM_LIBS) \
$(DBUS_LIBS) \
$(PANGO_LIBS) \
+ $(GIO_LIBS) \
$(GMODULE_LIBS) \
$(GTHREAD_LIBS) \
$(GLIB2_LIBS) \
Added: branches/indexer-split/src/trackerd/tracker-crawler.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-crawler.c Tue Jun 10 16:33:26 2008
@@ -0,0 +1,740 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gio/gio.h>
+
+#include <libtracker-common/tracker-utils.h>
+
+#include "tracker-crawler.h"
+#include "tracker-dbus.h"
+#include "tracker-indexer-client.h"
+
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_CRAWLER, TrackerCrawlerPriv))
+
+#define FILES_QUEUE_PROCESS_INTERVAL 2000
+#define FILES_QUEUE_PROCESS_MAX 5000
+
+struct _TrackerCrawlerPriv {
+ TrackerConfig *config;
+#ifdef HAVE_HAL
+ TrackerHal *hal;
+#endif
+
+ GTimer *timer;
+
+ GAsyncQueue *files;
+ guint files_queue_handle_id;
+
+ GSList *ignored_patterns;
+
+ GHashTable *ignored_names;
+ GHashTable *temp_black_list;
+
+ gchar **ignored_suffixes;
+ gchar **ignored_prefixes;
+
+ guint dirs_in_progress;
+ guint files_found;
+ guint files_ignored;
+};
+
+enum {
+ PROP_0,
+ PROP_CONFIG,
+#ifdef HAVE_HAL
+ PROP_HAL
+#endif
+};
+
+static void crawler_finalize (GObject *object);
+static void crawler_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+#ifdef HAVE_HAL
+static void mount_point_added_cb (TrackerHal *hal,
+ const gchar *mount_point,
+ gpointer user_data);
+static void mount_point_removed_cb (TrackerHal *hal,
+ const gchar *mount_point,
+ gpointer user_data);
+#endif /* HAVE_HAL */
+
+static void crawl_directory (TrackerCrawler *crawler,
+ const gchar *path);
+static void crawl_directory_known_to_exist (TrackerCrawler *crawler,
+ GFile *file);
+
+G_DEFINE_TYPE(TrackerCrawler, tracker_crawler, G_TYPE_OBJECT)
+
+static void
+tracker_crawler_class_init (TrackerCrawlerClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = crawler_finalize;
+ object_class->set_property = crawler_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_CONFIG,
+ g_param_spec_object ("config",
+ "Config",
+ "TrackerConfig object",
+ tracker_config_get_type (),
+ G_PARAM_WRITABLE));
+
+#ifdef HAVE_HAL
+ g_object_class_install_property (object_class,
+ PROP_HAL,
+ g_param_spec_object ("hal",
+ "HAL",
+ "HAL",
+ tracker_hal_get_type (),
+ G_PARAM_WRITABLE));
+#endif /* HAVE_HAL */
+
+ g_type_class_add_private (object_class, sizeof (TrackerCrawlerPriv));
+}
+
+static void
+tracker_crawler_init (TrackerCrawler *object)
+{
+ TrackerCrawlerPriv *priv;
+ GPtrArray *ptr_array;
+ GSList *ignored_file_types;
+
+ object->priv = GET_PRIV (object);
+
+ priv = object->priv;
+
+ /* Create async queue for handling file pushes to the indexer */
+ priv->files = g_async_queue_new ();
+
+ /* File types as configured to ignore, using pattern matching */
+ ignored_file_types = tracker_config_get_no_index_file_types (priv->config);
+
+ if (ignored_file_types) {
+ GPatternSpec *spec;
+ GSList *patterns = NULL;
+ GSList *l;
+
+ for (l = ignored_file_types; l; l = l->next) {
+ spec = g_pattern_spec_new (l->data);
+ patterns = g_slist_prepend (patterns, spec);
+ }
+
+ priv->ignored_patterns = g_slist_reverse (patterns);
+ }
+
+ /* Whole file names to ignore */
+ priv->ignored_names = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ NULL);
+ g_hash_table_insert (priv->ignored_names, "po", GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->ignored_names, "CVS", GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->ignored_names, "Makefile", GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->ignored_names, "SCCS", GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->ignored_names, "ltmain.sh", GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->ignored_names, "libtool", GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->ignored_names, "config.status", GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->ignored_names, "conftest", GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->ignored_names, "confdefs.h", GINT_TO_POINTER (1));
+
+ /* Temporary black list */
+ priv->temp_black_list = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ NULL);
+
+ /* Suffixes to ignore */
+ ptr_array = g_ptr_array_new ();
+ g_ptr_array_add (ptr_array, g_strdup ("~"));
+ g_ptr_array_add (ptr_array, g_strdup (".o"));
+ g_ptr_array_add (ptr_array, g_strdup (".la"));
+ g_ptr_array_add (ptr_array, g_strdup (".lo"));
+ g_ptr_array_add (ptr_array, g_strdup (".loT"));
+ g_ptr_array_add (ptr_array, g_strdup (".in"));
+ g_ptr_array_add (ptr_array, g_strdup (".csproj"));
+ g_ptr_array_add (ptr_array, g_strdup (".m4"));
+ g_ptr_array_add (ptr_array, g_strdup (".rej"));
+ g_ptr_array_add (ptr_array, g_strdup (".gmo"));
+ g_ptr_array_add (ptr_array, g_strdup (".orig"));
+ g_ptr_array_add (ptr_array, g_strdup (".pc"));
+ g_ptr_array_add (ptr_array, g_strdup (".omf"));
+ g_ptr_array_add (ptr_array, g_strdup (".aux"));
+ g_ptr_array_add (ptr_array, g_strdup (".tmp"));
+ g_ptr_array_add (ptr_array, g_strdup (".po"));
+ g_ptr_array_add (ptr_array, g_strdup (".vmdk"));
+ g_ptr_array_add (ptr_array, g_strdup (".vmx"));
+ g_ptr_array_add (ptr_array, g_strdup (".vmxf"));
+ g_ptr_array_add (ptr_array, g_strdup (".vmsd"));
+ g_ptr_array_add (ptr_array, g_strdup (".nvram"));
+ g_ptr_array_add (ptr_array, g_strdup (".part"));
+ g_ptr_array_add (ptr_array, NULL);
+ priv->ignored_suffixes = (gchar **) g_ptr_array_free (ptr_array, FALSE);
+
+ /* Prefixes to ignore */
+ ptr_array = g_ptr_array_new ();
+ g_ptr_array_add (ptr_array, g_strdup ("autom4te"));
+ g_ptr_array_add (ptr_array, g_strdup ("conftest."));
+ g_ptr_array_add (ptr_array, g_strdup ("confstat"));
+ g_ptr_array_add (ptr_array, g_strdup ("config."));
+ g_ptr_array_add (ptr_array, NULL);
+ priv->ignored_prefixes = (gchar **) g_ptr_array_free (ptr_array, FALSE);
+}
+
+static void
+crawler_finalize (GObject *object)
+{
+ TrackerCrawlerPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ g_strfreev (priv->ignored_prefixes);
+ g_strfreev (priv->ignored_suffixes);
+
+ g_hash_table_unref (priv->temp_black_list);
+ g_hash_table_unref (priv->ignored_names);
+
+ g_slist_foreach (priv->ignored_patterns,
+ (GFunc) g_pattern_spec_free,
+ NULL);
+ g_slist_free (priv->ignored_patterns);
+
+ if (priv->files_queue_handle_id) {
+ g_source_remove (priv->files_queue_handle_id);
+ priv->files_queue_handle_id = 0;
+ }
+
+ g_async_queue_unref (priv->files);
+
+ if (priv->timer) {
+ g_timer_destroy (priv->timer);
+ }
+
+#ifdef HAVE_HAL
+ if (priv->hal) {
+ g_signal_handlers_disconnect_by_func (priv->hal,
+ mount_point_added_cb,
+ object);
+ g_signal_handlers_disconnect_by_func (priv->hal,
+ mount_point_removed_cb,
+ object);
+
+ g_object_unref (priv->hal);
+ }
+#endif /* HAVE_HAL */
+
+ if (priv->config) {
+ g_object_unref (priv->config);
+ }
+
+ G_OBJECT_CLASS (tracker_crawler_parent_class)->finalize (object);
+}
+
+static void
+crawler_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TrackerCrawlerPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_CONFIG:
+ tracker_crawler_set_config (TRACKER_CRAWLER (object),
+ g_value_get_object (value));
+ break;
+
+#ifdef HAVE_HAL
+ case PROP_HAL:
+ tracker_crawler_set_hal (TRACKER_CRAWLER (object),
+ g_value_get_object (value));
+ break;
+#endif /* HAVE_HAL */
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
+}
+
+TrackerCrawler *
+tracker_crawler_new (void)
+{
+ return g_object_new (TRACKER_TYPE_CRAWLER, NULL);
+}
+
+void
+tracker_crawler_set_config (TrackerCrawler *object,
+ TrackerConfig *config)
+{
+ TrackerCrawlerPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_CRAWLER (object));
+ g_return_if_fail (TRACKER_IS_CONFIG (config));
+
+ priv = GET_PRIV (object);
+
+ if (config) {
+ g_object_ref (config);
+ }
+
+ if (priv->config) {
+ g_object_unref (priv->config);
+ }
+
+ priv->config = config;
+
+ g_object_notify (G_OBJECT (object), "config");
+}
+
+#ifdef HAVE_HAL
+
+void
+tracker_crawler_set_hal (TrackerCrawler *object,
+ TrackerHal *hal)
+{
+ TrackerCrawlerPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_CRAWLER (object));
+ g_return_if_fail (TRACKER_IS_HAL (hal));
+
+ priv = GET_PRIV (object);
+
+ if (hal) {
+ g_signal_connect (hal, "mount-point-added",
+ G_CALLBACK (mount_point_added_cb),
+ object);
+ g_signal_connect (hal, "mount-point-removed",
+ G_CALLBACK (mount_point_removed_cb),
+ object);
+ g_object_ref (hal);
+ }
+
+ if (priv->hal) {
+ g_signal_handlers_disconnect_by_func (hal,
+ mount_point_added_cb,
+ object);
+ g_signal_handlers_disconnect_by_func (hal,
+ mount_point_removed_cb,
+ object);
+ g_object_unref (priv->hal);
+ }
+
+ priv->hal = hal;
+
+ g_object_notify (G_OBJECT (object), "hal");
+}
+
+#endif /* HAVE_HAL */
+
+/*
+ * Functions
+ */
+
+#ifdef HAVE_HAL
+
+static void
+mount_point_added_cb (TrackerHal *hal,
+ const gchar *mount_point,
+ gpointer user_data)
+{
+ 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
+mount_point_removed_cb (TrackerHal *hal,
+ const gchar *mount_point,
+ gpointer user_data)
+{
+ g_message ("** CLEANING UP OLD MOUNT POINT:'%s'", mount_point);
+
+ /* process_index_delete_directory_check (mount_point, iface); */
+}
+
+#endif /* HAVE_HAL */
+
+static void
+get_remote_roots (TrackerCrawler *crawler,
+ GSList **mounted_directory_roots,
+ GSList **removable_device_roots)
+{
+ GSList *l1 = NULL;
+ GSList *l2 = NULL;
+
+#ifdef HAVE_HAL
+ l1 = tracker_hal_get_mounted_directory_roots (crawler->priv->hal);
+ l2 = tracker_hal_get_removable_device_roots (crawler->priv->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 gboolean
+path_should_be_ignored (TrackerCrawler *crawler,
+ const gchar *path)
+{
+ GSList *l;
+ gchar *basename;
+ gchar **p;
+ gboolean ignore;
+
+ if (tracker_is_empty_string (path)) {
+ return TRUE;
+ }
+
+ /* Most common things to ignore */
+ if (g_str_has_prefix (path, "/proc/") ||
+ g_str_has_prefix (path, "/dev/") ||
+ g_str_has_prefix (path, "/tmp/")) {
+ /* FIXME: What about /boot, /sys, /sbin, /bin ? */
+ return TRUE;
+ }
+
+ if (g_str_has_prefix (path, g_get_tmp_dir ())) {
+ return TRUE;
+ }
+
+ basename = g_path_get_basename (path);
+ ignore = TRUE;
+
+ if (!basename || basename[0] == '.') {
+ goto done;
+ }
+
+ /* Test exact basenames */
+ if (g_hash_table_lookup (crawler->priv->ignored_names,
+ basename)) {
+ goto done;
+ }
+
+ /* Test temporary black list */
+ if (g_hash_table_lookup (crawler->priv->temp_black_list,
+ basename)) {
+ goto done;
+ }
+
+ /* Test suffixes */
+ for (p = crawler->priv->ignored_suffixes; *p; p++) {
+ if (g_str_has_suffix (basename, *p)) {
+ goto done;
+ }
+ }
+
+ /* Test prefixes */
+ for (p = crawler->priv->ignored_prefixes; *p; p++) {
+ if (g_str_has_prefix (basename, *p)) {
+ goto done;
+ }
+ }
+
+ /* Test ignore types */
+ for (l = crawler->priv->ignored_patterns; l; l = l->next) {
+ if (g_pattern_match_string (l->data, basename)) {
+ goto done;
+ }
+ }
+
+ ignore = FALSE;
+
+done:
+ g_free (basename);
+
+ return ignore;
+}
+
+static void
+dirs_crawling_increment (TrackerCrawler *crawler)
+{
+ TrackerCrawlerPriv *priv;
+
+ priv = crawler->priv;
+
+ if (priv->dirs_in_progress == 0) {
+ g_message ("Starting to crawl file system...");
+
+ if (!priv->timer) {
+ priv->timer = g_timer_new ();
+ } else {
+ g_timer_reset (priv->timer);
+ }
+
+ priv->files_found = 0;
+ priv->files_ignored = 0;
+ }
+
+ priv->dirs_in_progress++;
+}
+
+static void
+dirs_crawling_decrement (TrackerCrawler *crawler)
+{
+ TrackerCrawlerPriv *priv;
+
+ priv = crawler->priv;
+
+ priv->dirs_in_progress--;
+
+ if (priv->dirs_in_progress == 0) {
+ g_timer_stop (priv->timer);
+
+ g_message ("Finished crawling files in %4.4f seconds, %d found, %d ignored",
+ g_timer_elapsed (priv->timer, NULL),
+ priv->files_found,
+ priv->files_ignored);
+ }
+}
+
+static void
+crawl_directory_cb (GObject *file,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ TrackerCrawler *crawler;
+ GFileEnumerator *enumerator;
+ GFileInfo *info;
+ GFile *parent, *child;
+ gchar *relative_path;
+
+ crawler = TRACKER_CRAWLER (user_data);
+ parent = G_FILE (file);
+ enumerator = g_file_enumerate_children_finish (parent, res, NULL);
+
+ if (!enumerator) {
+ dirs_crawling_decrement (crawler);
+ return;
+ }
+
+ for (info = g_file_enumerator_next_file (enumerator, NULL, NULL);
+ info;
+ info = g_file_enumerator_next_file (enumerator, NULL, NULL)) {
+ child = g_file_get_child (parent, g_file_info_get_name (info));
+ relative_path = g_file_get_path (child);
+
+ if (path_should_be_ignored (crawler, relative_path)) {
+ crawler->priv->files_ignored++;
+ g_debug ("Ignored:'%s' (%d)",
+ relative_path,
+ crawler->priv->dirs_in_progress);
+ g_free (relative_path);
+ } else {
+ crawler->priv->files_found++;
+ g_debug ("Found :'%s' (%d)",
+ relative_path,
+ crawler->priv->dirs_in_progress);
+
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ crawl_directory_known_to_exist (crawler, child);
+ g_free (relative_path);
+ } else {
+ g_async_queue_push (crawler->priv->files,
+ relative_path);
+ }
+ }
+
+ g_object_unref (child);
+ }
+
+ g_file_enumerator_close (enumerator, NULL, NULL);
+
+ dirs_crawling_decrement (crawler);
+}
+
+static void
+crawl_directory_known_to_exist (TrackerCrawler *crawler,
+ GFile *file)
+{
+ dirs_crawling_increment (crawler);
+
+ g_file_enumerate_children_async (file,
+ "*",
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ crawl_directory_cb,
+ crawler);
+}
+
+static void
+crawl_directory (TrackerCrawler *crawler,
+ const gchar *path)
+{
+ GFile *file;
+ gboolean exists;
+
+ file = g_file_new_for_path (path);
+ exists = g_file_query_exists (file, NULL);
+
+ if (exists) {
+ g_message ("Searching directory:'%s'", path);
+ crawl_directory_known_to_exist (crawler, file);
+ } else {
+ g_message ("Searching directory:'%s' failed, does not exist", path);
+ }
+
+ g_object_unref (file);
+}
+
+static gboolean
+file_queue_handle_cb (gpointer user_data)
+{
+ TrackerCrawler *crawler;
+ DBusGProxy *proxy;
+ GPtrArray *ptr_array;
+ GError *error;
+ gchar ** files;
+ gboolean running;
+ gint length;
+ gint items;
+
+ crawler = user_data;
+
+ length = g_async_queue_length (crawler->priv->files);
+ if (length < 1) {
+ g_debug ("Processing file queue... nothing to do, queue empty");
+ return TRUE;
+ }
+
+ /* Check we can actually talk to the indexer */
+ proxy = tracker_dbus_indexer_get_proxy ();
+ error = NULL;
+
+ g_debug ("Checking indexer is running");
+ org_freedesktop_Tracker_Indexer_get_running (proxy,
+ &running,
+ &error);
+ if (error || !running) {
+ g_critical ("Couldn't process files, %s",
+ error ? error->message : "indexer not running");
+ g_clear_error (&error);
+ return TRUE;
+ }
+
+ g_debug ("Processing file queue...");
+ ptr_array = g_ptr_array_new ();
+
+ /* Throttle files we send over to the indexer */
+ items = MIN (FILES_QUEUE_PROCESS_MAX, length);
+ g_debug ("Processing %d/%d items in the queue",
+ items,
+ length);
+
+ while (items > 0) {
+ GTimeVal t;
+ gchar *filename;
+
+ g_get_current_time (&t);
+ g_time_val_add (&t, 100000);
+
+ /* Get next filename and wait 0.1 seconds max per try */
+ filename = g_async_queue_timed_pop (crawler->priv->files, &t);
+ if (filename) {
+ g_ptr_array_add (ptr_array, filename);
+ items--;
+ }
+ }
+
+ files = (gchar **) g_ptr_array_free (ptr_array, FALSE);
+
+ g_debug ("Sending %d files to indexer to process",
+ g_strv_length (files));
+
+ org_freedesktop_Tracker_Indexer_process_files (proxy,
+ (const gchar **) files,
+ &error);
+
+ if (error) {
+ g_critical ("Could not send %d files to indexer to process, %s",
+ g_strv_length (files),
+ error->message);
+ g_clear_error (&error);
+ } else {
+ g_debug ("Sent!");
+ }
+
+ g_strfreev (files);
+
+ return TRUE;
+}
+
+void
+tracker_crawler_start (TrackerCrawler *crawler)
+{
+ TrackerCrawlerPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_CRAWLER (crawler));
+
+ priv = crawler->priv;
+
+ if (priv->files_queue_handle_id) {
+ g_source_remove (priv->files_queue_handle_id);
+ }
+
+ priv->files_queue_handle_id = g_timeout_add (FILES_QUEUE_PROCESS_INTERVAL,
+ file_queue_handle_cb,
+ crawler);
+
+ if (0) {
+ get_remote_roots (crawler, NULL, NULL);
+ }
+
+ /* crawl_directory (crawler, "/home/martyn/Documents"); */
+ crawl_directory (crawler, g_get_home_dir ());
+}
+
Added: branches/indexer-split/src/trackerd/tracker-crawler.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-crawler.h Tue Jun 10 16:33:26 2008
@@ -0,0 +1,68 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+
+#ifndef __TRACKERD_CRAWLER_H__
+#define __TRACKERD_CRAWLER_H__
+
+#include <glib-object.h>
+
+#include <libtracker-common/tracker-config.h>
+
+#ifdef HAVE_HAL
+#include <libtracker-common/tracker-hal.h>
+#endif /* HAVE_HAL */
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_CRAWLER (tracker_crawler_get_type ())
+#define TRACKER_CRAWLER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TRACKER_TYPE_CRAWLER, TrackerCrawler))
+#define TRACKER_CRAWLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TYPE_CRAWLER, TrackerCrawlerClass))
+#define TRACKER_IS_CRAWLER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TRACKER_TYPE_CRAWLER))
+#define TRACKER_IS_CRAWLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_CRAWLER))
+#define TRACKER_CRAWLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_CRAWLER, TrackerCrawlerClass))
+
+typedef struct _TrackerCrawler TrackerCrawler;
+typedef struct _TrackerCrawlerClass TrackerCrawlerClass;
+typedef struct _TrackerCrawlerPriv TrackerCrawlerPriv;
+
+struct _TrackerCrawler {
+ GObject parent;
+ TrackerCrawlerPriv *priv;
+};
+
+struct _TrackerCrawlerClass {
+ GObjectClass parent;
+};
+
+GType tracker_crawler_get_type (void);
+TrackerCrawler *tracker_crawler_new (void);
+void tracker_crawler_set_config (TrackerCrawler *object,
+ TrackerConfig *config);
+
+#ifdef HAVE_HAL
+void tracker_crawler_set_hal (TrackerCrawler *object,
+ TrackerHal *hal);
+#endif /* HAVE_HAL */
+
+void tracker_crawler_start (TrackerCrawler *crawler);
+
+G_END_DECLS
+
+#endif /* __TRACKERD_CRAWLER_H__ */
Modified: branches/indexer-split/src/trackerd/tracker-db.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db.c Tue Jun 10 16:33:26 2008
@@ -40,7 +40,7 @@
#include "tracker-db.h"
#include "tracker-process-files.h"
#include "tracker-query-tree.h"
-#include "tracker-watcher.h"
+#include "tracker-monitor.h"
#include "tracker-xesam-manager.h"
#define ZLIBBUFSIZ 8192
@@ -556,12 +556,12 @@
const gchar *moved_to_uri)
{
/* Stop watching old dir, start watching new dir */
- tracker_watcher_remove_dir (moved_from_uri, TRUE, iface);
+ tracker_monitor_remove (moved_from_uri, TRUE, iface);
tracker_db_file_move (iface, moved_from_uri, moved_to_uri);
directory_move_files (iface, moved_from_uri, moved_to_uri);
- tracker_watcher_add_dir (moved_to_uri, iface);
+ tracker_monitor_add (moved_to_uri, iface);
}
static gint
Modified: branches/indexer-split/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.c Tue Jun 10 16:33:26 2008
@@ -41,7 +41,6 @@
#include "tracker-xesam-glue.h"
#include "tracker-indexer-client.h"
#include "tracker-utils.h"
-#include "tracker-watcher.h"
static DBusGConnection *connection;
static DBusGProxy *proxy;
@@ -312,14 +311,14 @@
return NULL;
}
-DBusGProxy *
-tracker_dbus_start_indexer (void)
+void
+tracker_dbus_indexer_start (void)
{
GError *error = NULL;
if (!connection) {
g_critical ("DBus support must be initialized before starting the indexer!");
- return NULL;
+ return;
}
if (!proxy_for_indexer) {
@@ -331,7 +330,7 @@
if (!proxy_for_indexer) {
g_critical ("Couldn't create a DBusGProxy to the indexer service");
- return NULL;
+ return;
}
}
@@ -343,6 +342,35 @@
g_warning ("Couldn't start indexer, %s",
error->message);
}
+}
+
+DBusGProxy *
+tracker_dbus_indexer_get_proxy (void)
+{
+ GError *error = NULL;
+
+ if (!connection) {
+ g_critical ("DBus support must be initialized before starting the indexer!");
+ return NULL;
+ }
+
+ if (!proxy_for_indexer) {
+ /* Get proxy for Service / Path / Interface of the indexer */
+ proxy_for_indexer = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.Tracker.Indexer",
+ "/org/freedesktop/Tracker/Indexer",
+ "org.freedesktop.Tracker.Indexer");
+
+ if (!proxy_for_indexer) {
+ g_critical ("Couldn't create a DBusGProxy to the indexer service");
+ return NULL;
+ }
+ }
+
+ if (error) {
+ g_warning ("Couldn't start indexer, %s",
+ error->message);
+ }
return proxy_for_indexer;
}
Modified: branches/indexer-split/src/trackerd/tracker-dbus.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.h (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.h Tue Jun 10 16:33:26 2008
@@ -33,11 +33,12 @@
G_BEGIN_DECLS
-gboolean tracker_dbus_init (TrackerConfig *config);
-void tracker_dbus_shutdown (void);
-gboolean tracker_dbus_register_objects (Tracker *tracker);
-GObject *tracker_dbus_get_object (GType type);
-DBusGProxy *tracker_dbus_start_indexer (void);
+gboolean tracker_dbus_init (TrackerConfig *config);
+void tracker_dbus_shutdown (void);
+gboolean tracker_dbus_register_objects (Tracker *tracker);
+GObject *tracker_dbus_get_object (GType type);
+void tracker_dbus_indexer_start (void);
+DBusGProxy *tracker_dbus_indexer_get_proxy (void);
G_END_DECLS
Modified: branches/indexer-split/src/trackerd/tracker-email-evolution.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-evolution.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-evolution.c Tue Jun 10 16:33:26 2008
@@ -43,7 +43,6 @@
#include "tracker-email-plugin.h"
#include "tracker-dbus.h"
#include "tracker-daemon.h"
-#include "tracker-watcher.h"
#include "tracker-status.h"
#include "tracker-utils.h"
#include "tracker-main.h"
Modified: branches/indexer-split/src/trackerd/tracker-email-kmail.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-kmail.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-kmail.c Tue Jun 10 16:33:26 2008
@@ -34,8 +34,8 @@
#include "tracker-email-utils.h"
#include "tracker-db-email.h"
#include "tracker-main.h"
+#include "tracker-monitor.h"
#include "tracker-process-files.h"
-#include "tracker-watcher.h"
typedef struct {
gchar *imap_path;
@@ -663,7 +663,7 @@
(( in_imap_dir && dir_name[0] == '.' && g_str_has_suffix (dir_name, ".directory")) ||
!in_imap_dir )
) {
- if (!tracker_watcher_is_dir_watched (dir_path, iface)) {
+ if (!tracker_monitor_is_watched (dir_path, iface)) {
/* if we are in a maildir directory, we will only index emails in directory "cur" */
gchar *dir_cur = g_build_filename (dir_path, "cur", NULL);
Modified: branches/indexer-split/src/trackerd/tracker-email-modest.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-modest.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-modest.c Tue Jun 10 16:33:26 2008
@@ -40,8 +40,6 @@
#include "tracker-dbus.h"
#include "tracker-daemon.h"
#include "tracker-status.h"
-#include "tracker-watcher.h"
-
#define MODEST_HOME ".modest"
#define MODEST_HOME_CACHE_MAIL MODEST_HOME G_DIR_SEPARATOR_S "cache" G_DIR_SEPARATOR_S "mail"
Modified: branches/indexer-split/src/trackerd/tracker-email-thunderbird.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-thunderbird.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-thunderbird.c Tue Jun 10 16:33:26 2008
@@ -27,7 +27,6 @@
#include "tracker-email-plugin.h"
#include "tracker-db-email.h"
-#include "tracker-watcher.h"
#include "tracker-main.h"
typedef enum
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 Tue Jun 10 16:33:26 2008
@@ -46,11 +46,12 @@
#include <libtracker-db/tracker-db-manager.h>
#include "tracker-email.h"
+#include "tracker-crawler.h"
#include "tracker-dbus.h"
#include "tracker-indexer.h"
+#include "tracker-monitor.h"
#include "tracker-process-files.h"
#include "tracker-status.h"
-#include "tracker-watcher.h"
#include "tracker-xesam-manager.h"
#ifdef OS_WIN32
@@ -158,8 +159,8 @@
N_("Disable any indexing or watching taking place"), NULL },
{ "verbosity", 'v', 0,
G_OPTION_ARG_INT, &verbosity,
- N_("Value that controls the level of logging. "
- "Valid values are 0 (displays/logs only errors), "
+ N_("Value that controls the level of logging."
+ "Valid values are: 0 (displays/logs only errors), "
"1 (minimal), 2 (detailed), and 3 (debug)"),
N_("VALUE") },
{ "throttle", 't', 0,
@@ -679,6 +680,7 @@
GOptionContext *context = NULL;
GError *error = NULL;
GSList *l;
+ TrackerCrawler *crawler;
gchar *example;
gchar *summary;
gboolean need_index;
@@ -804,7 +806,7 @@
sanity_check_option_values ();
- if (!tracker_watcher_init ()) {
+ if (!tracker_monitor_init ()) {
return EXIT_FAILURE;
}
@@ -817,10 +819,14 @@
tracker_xesam_manager_init ();
tracker_email_start_email_watching (tracker_config_get_email_client (tracker->config));
+ crawler = tracker_crawler_new ();
+
#ifdef HAVE_HAL
tracker->hal = tracker_hal_new ();
+ tracker_crawler_set_hal (crawler, tracker->hal);
#endif /* HAVE_HAL */
-
+
+ tracker_crawler_set_config (crawler, tracker->config);
umask (077);
@@ -858,22 +864,20 @@
}
}
+ /* Get files first */
+ tracker_crawler_start (crawler);
+
if (tracker->is_running) {
DBusGProxy *proxy;
- g_message ("Indexing enabled, starting...");
- proxy = tracker_dbus_start_indexer ();
- tracker_xesam_subscribe_indexer_updated (proxy);
- }
#if 0
- thread = g_thread_create_full ((GThreadFunc) tracker_process_files,
- tracker,
- (gulong) tracker_config_get_thread_stack_size (tracker->config),
- TRUE,
- FALSE,
- G_THREAD_PRIORITY_NORMAL,
- NULL);
+ g_message ("Indexing enabled, starting...");
+ tracker_dbus_indexer_start ();
#endif
+
+ proxy = tracker_dbus_indexer_get_proxy ();
+ tracker_xesam_subscribe_indexer_updated (proxy);
+ }
} else {
g_message ("Indexing disabled, not starting");
}
@@ -888,6 +892,10 @@
g_message ("Shutting down...\n");
+ if (crawler) {
+ g_object_unref (crawler);
+ }
+
/*
* Shutdown the daemon
*/
@@ -913,7 +921,7 @@
tracker_db_shutdown ();
tracker_db_manager_shutdown ();
tracker_ontology_shutdown ();
- tracker_watcher_shutdown ();
+ tracker_monitor_shutdown ();
tracker_nfs_lock_shutdown ();
tracker_log_shutdown ();
Added: branches/indexer-split/src/trackerd/tracker-monitor.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-monitor.c Tue Jun 10 16:33:26 2008
@@ -0,0 +1,114 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+
+#include "tracker-monitor.h"
+
+#if 0
+static void
+get_monitor_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;
+
+ 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));
+ }
+}
+
+#endif
+
+gboolean
+tracker_monitor_init (void)
+{
+ return TRUE;
+}
+
+void
+tracker_monitor_shutdown (void)
+{
+}
+
+gboolean
+tracker_monitor_add (const gchar *uri,
+ TrackerDBInterface *iface)
+{
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+
+ return FALSE;
+}
+
+gboolean
+tracker_monitor_remove (const gchar *uri,
+ gboolean delete_subdirs,
+ TrackerDBInterface *iface)
+{
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ return FALSE;
+}
+
+gboolean
+tracker_monitor_is_watched (const gchar *uri,
+ TrackerDBInterface *iface)
+{
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ return FALSE;
+}
+
+gint
+tracker_monitor_get_count (void)
+{
+ return 0;
+}
+
Copied: branches/indexer-split/src/trackerd/tracker-monitor.h (from r1616, /branches/indexer-split/src/trackerd/tracker-watcher.h)
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-watcher.h (original)
+++ branches/indexer-split/src/trackerd/tracker-monitor.h Tue Jun 10 16:33:26 2008
@@ -19,24 +19,24 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __TRACKERD_WATCHER_H__
-#define __TRACKERD_WATCHER_H__
+#ifndef __TRACKERD_MONITOR_H__
+#define __TRACKERD_MONITOR_H__
#include "tracker-db.h"
G_BEGIN_DECLS
-gboolean tracker_watcher_init (void);
-void tracker_watcher_shutdown (void);
-gboolean tracker_watcher_add_dir (const gchar *dir,
- TrackerDBInterface *iface);
-void tracker_watcher_remove_dir (const gchar *dir,
- gboolean delete_subdirs,
- TrackerDBInterface *iface);
-gboolean tracker_watcher_is_dir_watched (const gchar *dir,
- TrackerDBInterface *iface);
-gint tracker_watcher_get_dir_count (void);
+gboolean tracker_monitor_init (void);
+void tracker_monitor_shutdown (void);
+gboolean tracker_monitor_add (const gchar *uri,
+ TrackerDBInterface *iface);
+gboolean tracker_monitor_remove (const gchar *uri,
+ gboolean delete_subdirs,
+ TrackerDBInterface *iface);
+gboolean tracker_monitor_is_watched (const gchar *uri,
+ TrackerDBInterface *iface);
+gint tracker_monitor_get_count (void);
G_END_DECLS
-#endif /* __TRACKERD_WATCHER_H__ */
+#endif /* __TRACKERD_MONITOR_H__ */
Modified: branches/indexer-split/src/trackerd/tracker-process-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-process-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-process-files.c Tue Jun 10 16:33:26 2008
@@ -48,7 +48,7 @@
#include "tracker-daemon.h"
#include "tracker-email.h"
#include "tracker-indexer.h"
-#include "tracker-watcher.h"
+#include "tracker-monitor.h"
#include "tracker-status.h"
#include "tracker-process-files.h"
@@ -251,7 +251,7 @@
continue;
}
- if (!tracker_watcher_add_dir (dir, iface)) {
+ if (!tracker_monitor_add (dir, iface)) {
g_warning ("Watch failed for:'%s'", dir);
}
}
@@ -400,7 +400,7 @@
tracker_db_directory_delete (iface, info->file_id, info->uri);
- tracker_watcher_remove_dir (info->uri, TRUE, iface);
+ tracker_monitor_remove (info->uri, TRUE, iface);
g_message ("Deleting directory:'%s' and subdirs", info->uri);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]