tracker r2096 - in branches/indexer-split: . src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2096 - in branches/indexer-split: . src/trackerd
- Date: Mon, 18 Aug 2008 16:49:18 +0000 (UTC)
Author: mr
Date: Mon Aug 18 16:49:18 2008
New Revision: 2096
URL: http://svn.gnome.org/viewvc/tracker?rev=2096&view=rev
Log:
* src/trackerd/tracker-daemon.c: Use TrackerDaemonPrivate not Priv.
* src/trackerd/tracker-db.c: Removed commented out code.
* src/trackerd/tracker-dbus.c:
* src/trackerd/tracker-files.[ch]: Use the processor for the
org.freedesktop.Tracker.Files.{Create|Delete} interfaces so we
make use of the processor's queues and do things all one way. This
includes checking ignore lists, etc.
* src/trackerd/tracker-keywords.c: Use TrackerKeywordsPrivate not Priv.
* src/trackerd/tracker-processor.[ch]: Add public functions to
check/update/delete files. This simply makes the functions we
already have public which send files to the indexer to
check/update/delete.
* src/trackerd/tracker-search.c: Use TrackerSearchPrivate not Priv.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/trackerd/tracker-daemon.c
branches/indexer-split/src/trackerd/tracker-db.c
branches/indexer-split/src/trackerd/tracker-dbus.c
branches/indexer-split/src/trackerd/tracker-files.c
branches/indexer-split/src/trackerd/tracker-files.h
branches/indexer-split/src/trackerd/tracker-keywords.c
branches/indexer-split/src/trackerd/tracker-processor.c
branches/indexer-split/src/trackerd/tracker-processor.h
branches/indexer-split/src/trackerd/tracker-search.c
Modified: branches/indexer-split/src/trackerd/tracker-daemon.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-daemon.c (original)
+++ branches/indexer-split/src/trackerd/tracker-daemon.c Mon Aug 18 16:49:18 2008
@@ -41,13 +41,13 @@
#include "tracker-status.h"
#include "tracker-marshal.h"
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_DAEMON, TrackerDaemonPriv))
+#define TRACKER_DAEMON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_DAEMON, TrackerDaemonPrivate))
typedef struct {
TrackerConfig *config;
TrackerProcessor *processor;
DBusGProxy *indexer_proxy;
-} TrackerDaemonPriv;
+} TrackerDaemonPrivate;
enum {
DAEMON_INDEX_STATE_CHANGE,
@@ -56,19 +56,19 @@
LAST_SIGNAL
};
-static void daemon_finalize (GObject *object);
-static void indexer_pause_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data);
-static void indexer_continue_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data);
-static void indexer_paused_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data);
-static void indexer_continued_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data);
+static void tracker_daemon_finalize (GObject *object);
+static void indexer_pause_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data);
+static void indexer_continue_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data);
+static void indexer_paused_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data);
+static void indexer_continued_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data);
static guint signals[LAST_SIGNAL] = {0};
@@ -81,7 +81,7 @@
object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = daemon_finalize;
+ object_class->finalize = tracker_daemon_finalize;
signals[DAEMON_INDEX_STATE_CHANGE] =
g_signal_new ("index-state-change",
@@ -124,7 +124,7 @@
G_TYPE_INT,
G_TYPE_INT);
- g_type_class_add_private (object_class, sizeof (TrackerDaemonPriv));
+ g_type_class_add_private (object_class, sizeof (TrackerDaemonPrivate));
}
static void
@@ -133,13 +133,13 @@
}
static void
-daemon_finalize (GObject *object)
+tracker_daemon_finalize (GObject *object)
{
- TrackerDaemon *daemon;
- TrackerDaemonPriv *priv;
+ TrackerDaemon *daemon;
+ TrackerDaemonPrivate *priv;
daemon = TRACKER_DAEMON (object);
- priv = GET_PRIV (daemon);
+ priv = TRACKER_DAEMON_GET_PRIVATE (daemon);
dbus_g_proxy_disconnect_signal (priv->indexer_proxy, "Continued",
G_CALLBACK (indexer_continued_cb),
@@ -159,16 +159,16 @@
tracker_daemon_new (TrackerConfig *config,
TrackerProcessor *processor)
{
- TrackerDaemon *object;
- TrackerDaemonPriv *priv;
- DBusGProxy *proxy;
+ TrackerDaemon *object;
+ TrackerDaemonPrivate *priv;
+ DBusGProxy *proxy;
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
g_return_val_if_fail (TRACKER_IS_PROCESSOR (processor), NULL);
object = g_object_new (TRACKER_TYPE_DAEMON, NULL);
- priv = GET_PRIV (object);
+ priv = TRACKER_DAEMON_GET_PRIVATE (object);
priv->config = g_object_ref (config);
priv->processor = g_object_ref (processor);
@@ -262,13 +262,13 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDaemonPriv *priv;
- gchar *status;
- guint request_id;
+ TrackerDaemonPrivate *priv;
+ gchar *status;
+ guint request_id;
request_id = tracker_dbus_get_next_request_id ();
- priv = GET_PRIV (object);
+ priv = TRACKER_DAEMON_GET_PRIVATE (object);
tracker_dbus_request_new (request_id,
"DBus request to get daemon status");
@@ -371,9 +371,9 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDaemonPriv *priv;
- guint request_id;
- GError *actual_error = NULL;
+ TrackerDaemonPrivate *priv;
+ guint request_id;
+ GError *actual_error = NULL;
/* FIXME: Shouldn't we just make the TrackerConfig module a
* DBus object instead so values can be tweaked in real time
@@ -384,7 +384,7 @@
tracker_dbus_async_return_if_fail (option != NULL, FALSE);
- priv = GET_PRIV (object);
+ priv = TRACKER_DAEMON_GET_PRIVATE (object);
tracker_dbus_request_new (request_id,
"DBus request to set daemon boolean option, "
@@ -472,9 +472,9 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDaemonPriv *priv;
- guint request_id;
- GError *actual_error = NULL;
+ TrackerDaemonPrivate *priv;
+ guint request_id;
+ GError *actual_error = NULL;
/* FIXME: Shouldn't we just make the TrackerConfig module a
* DBus object instead so values can be tweaked in real time
@@ -485,7 +485,7 @@
tracker_dbus_async_return_if_fail (option != NULL, FALSE);
- priv = GET_PRIV (object);
+ priv = TRACKER_DAEMON_GET_PRIVATE (object);
tracker_dbus_request_new (request_id,
"DBus request to set daemon integer option, "
@@ -525,8 +525,8 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDaemonPriv *priv;
- guint request_id;
+ TrackerDaemonPrivate *priv;
+ guint request_id;
request_id = tracker_dbus_get_next_request_id ();
@@ -535,7 +535,7 @@
"reindex:%s",
reindex ? "yes" : "no");
- priv = GET_PRIV (object);
+ priv = TRACKER_DAEMON_GET_PRIVATE (object);
g_message ("Tracker daemon attempting to shutdown");
@@ -553,15 +553,15 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDaemonPriv *priv;
- guint request_id;
+ TrackerDaemonPrivate *priv;
+ guint request_id;
request_id = tracker_dbus_get_next_request_id ();
tracker_dbus_request_new (request_id,
"DBus request to daemon to signal progress/state");
- priv = GET_PRIV (object);
+ priv = TRACKER_DAEMON_GET_PRIVATE (object);
/* Signal state change */
tracker_status_signal ();
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 Mon Aug 18 16:49:18 2008
@@ -2434,11 +2434,6 @@
path = tracker_file_get_vfs_path (info->uri);
}
- /* Using GetNewUID is deprecated, use
-
- SELECT MAX(ID) from files-meta.Services followed by
- SELECT MAX(ID) from email-meta.Services instead !!! */
-
/* Get a new unique ID for the service - use mutex to prevent race conditions */
result_set = tracker_db_exec_proc (iface, "GetNewID", NULL);
@@ -2490,7 +2485,6 @@
}
str_service_type_id = tracker_int_to_string (service_type_id);
-
str_aux = tracker_int_to_string (info->aux_id);
if (service_type_id != -1) {
@@ -2515,21 +2509,6 @@
g_object_unref (result_set_proc);
}
- /*
- Undetectable error
- tracker_error ("ERROR: CreateService uri is %s/%s", path, name);
- g_free (name);
- g_free (path);
- g_free (str_aux);
- g_free (str_service_type_id);
- g_free (sid);
- g_free (str_filesize);
- g_free (str_mtime);
- g_free (str_offset);
- g_static_rec_mutex_unlock (&events_table_lock);
- return 0;
- */
-
id = tracker_db_interface_sqlite_get_last_insert_id (TRACKER_DB_INTERFACE_SQLITE (iface));
if (info->is_hidden) {
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 Mon Aug 18 16:49:18 2008
@@ -334,7 +334,7 @@
objects = g_slist_prepend (objects, object);
/* Add org.freedesktop.Tracker.Files */
- object = tracker_files_new ();
+ object = tracker_files_new (processor);
if (!object) {
g_critical ("Could not create TrackerFiles object to register");
return FALSE;
Modified: branches/indexer-split/src/trackerd/tracker-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-files.c Mon Aug 18 16:49:18 2008
@@ -39,11 +39,26 @@
#include "tracker-marshal.h"
#include "tracker-indexer-client.h"
+#define TRACKER_FILES_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_FILES, TrackerFilesPrivate))
+
+typedef struct {
+ TrackerProcessor *processor;
+} TrackerFilesPrivate;
+
+static void tracker_files_finalize (GObject *object);
+
G_DEFINE_TYPE(TrackerFiles, tracker_files, G_TYPE_OBJECT)
static void
tracker_files_class_init (TrackerFilesClass *klass)
{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = tracker_files_finalize;
+
+ g_type_class_add_private (object_class, sizeof (TrackerFilesPrivate));
}
static void
@@ -51,10 +66,33 @@
{
}
+static void
+tracker_files_finalize (GObject *object)
+{
+ TrackerFilesPrivate *priv;
+
+ priv = TRACKER_FILES_GET_PRIVATE (object);
+
+ g_object_unref (priv->processor);
+
+ G_OBJECT_CLASS (tracker_files_parent_class)->finalize (object);
+}
+
TrackerFiles *
-tracker_files_new (void)
+tracker_files_new (TrackerProcessor *processor)
{
- return g_object_new (TRACKER_TYPE_FILES, NULL);
+ TrackerFiles *object;
+ TrackerFilesPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_PROCESSOR (processor), NULL);
+
+ object = g_object_new (TRACKER_TYPE_FILES, NULL);
+
+ priv = TRACKER_FILES_GET_PRIVATE (object);
+
+ priv->processor = g_object_ref (processor);
+
+ return object;
}
/*
@@ -80,39 +118,35 @@
"DBus request to see if files exist, "
"uri:'%s' auto-create:'%d'",
uri, auto_create);
+
+ /* This API is broken. The Daemon doesn't do anything in the
+ * database except read from it.
+ */
+ if (auto_create) {
+ GError *actual_error = NULL;
+
+ tracker_dbus_request_failed (request_id,
+ &actual_error,
+ "Request to check existence of file '%s' failed, "
+ "the 'auto-create' variable can not be TRUE, "
+ "this feature is no longer supported.",
+ uri);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+
+ return;
+ }
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
file_id = tracker_db_file_get_id (iface, uri);
exists = file_id > 0;
- if (!exists && auto_create) {
- TrackerDBFileInfo *info;
- gchar *service;
-
- info = tracker_db_file_info_new (uri, 1, 0, 0);
-
- if (!tracker_file_is_valid (uri)) {
- info->mime = g_strdup ("unknown");
- /* FIXME Shouldn't it be "other"? */
- service = g_strdup ("Files");
- } else {
- info->mime = tracker_file_get_mime_type (uri);
- service = tracker_ontology_get_service_type_for_mime (info->mime);
- info = tracker_db_file_info_get (info);
- }
-
- tracker_db_service_create (iface, service, info);
- tracker_db_file_info_free (info);
- g_free (service);
- }
-
dbus_g_method_return (context, exists);
tracker_dbus_request_success (request_id);
}
-/* You should deprecate this API */
void
tracker_files_create (TrackerFiles *object,
const gchar *uri,
@@ -123,14 +157,10 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
- TrackerDBFileInfo *info;
- guint request_id;
- gchar *name;
- gchar *path;
- gchar *service;
- guint32 file_id;
- gboolean created;
+ TrackerFilesPrivate *priv;
+ GFile *file;
+ const gchar *module_name = "files";
+ guint request_id;
request_id = tracker_dbus_get_next_request_id ();
@@ -149,113 +179,27 @@
size,
mtime);
- iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
-
- /* Create structure */
- info = tracker_db_file_info_new (uri, 1, 0, 0);
-
- info->mime = g_strdup (mime);
- info->is_directory = is_directory;
- info->file_size = size;
- info->mtime = mtime;
-
- if (info->uri[0] == G_DIR_SEPARATOR) {
- name = g_path_get_basename (info->uri);
- path = g_path_get_dirname (info->uri);
- } else {
- name = tracker_file_get_vfs_name (info->uri);
- path = tracker_file_get_vfs_path (info->uri);
- }
-
- service = tracker_ontology_get_service_type_for_mime (mime);
- file_id = tracker_db_service_create (iface, service, info);
- tracker_db_file_info_free (info);
-
- created = file_id != 0;
-
- if (created) {
- gchar *file_id_str;
- gchar *mtime_str;
- gchar *size_str;
-
- tracker_dbus_request_comment (request_id,
- "File or directory has been created in database, uri:'%s'",
- uri);
-
- file_id_str = tracker_uint_to_string (file_id);
- mtime_str = tracker_int_to_string (mtime);
- size_str = tracker_int_to_string (size);
+ priv = TRACKER_FILES_GET_PRIVATE (object);
- tracker_db_metadata_set_single (iface,
- service,
- file_id_str,
- "File:Modified",
- mtime_str,
- FALSE);
- tracker_db_metadata_set_single (iface,
- service,
- file_id_str,
- "File:Size",
- size_str,
- FALSE);
- tracker_db_metadata_set_single (iface,
- service,
- file_id_str,
- "File:Name",
- name,
- FALSE);
- tracker_db_metadata_set_single (iface,
- service,
- file_id_str,
- "File:Path",
- path,
- FALSE);
- tracker_db_metadata_set_single (iface,
- service,
- file_id_str,
- "File:Format",
- mime,
- FALSE);
-
- g_free (size_str);
- g_free (mtime_str);
- g_free (file_id_str);
-
- } else {
- tracker_dbus_request_comment (request_id,
- "File/directory was already in the database, uri:'%s'",
- uri);
- }
-
- g_free (path);
- g_free (name);
- g_free (service);
+ file = g_file_new_for_path (uri);
+ tracker_processor_files_check (priv->processor, module_name, file, is_directory);
+ g_object_unref (file);
dbus_g_method_return (context);
tracker_dbus_request_success (request_id);
}
-static void
-on_indexer_deleted (DBusGProxy *proxy, GError *error, gpointer user_data)
-{
- GStrv files = user_data;
- g_strfreev (files);
-}
-
void
tracker_files_delete (TrackerFiles *object,
const gchar *uri,
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
- guint request_id;
- guint32 file_id;
- gchar *full;
- gchar *path;
- gchar *name;
- GStrv files;
+ TrackerFilesPrivate *priv;
+ GFile *file;
+ const gchar *module_name = "files";
+ guint request_id;
request_id = tracker_dbus_get_next_request_id ();
@@ -266,45 +210,16 @@
"uri:'%s'",
uri);
- iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
-
- file_id = tracker_db_file_get_id (iface, uri);
-
- if (file_id == 0) {
- tracker_dbus_request_comment (request_id,
- "File or directory was not in database to delete, uri:'%s'",
- uri);
-
- dbus_g_method_return (context);
- tracker_dbus_request_success (request_id);
- return;
- }
-
- if (uri[0] == G_DIR_SEPARATOR) {
- name = g_path_get_basename (uri);
- path = g_path_get_dirname (uri);
- full = g_strdup (uri);
- } else {
- name = tracker_file_get_vfs_name (uri);
- path = tracker_file_get_vfs_path (uri);
- full = g_build_filename (G_DIR_SEPARATOR_S, path, name, NULL);
- }
-
- files = (GStrv) g_malloc0 (sizeof (gchar*) * 1);
-
- /* full is freed as part of the GStrv in the callback */
- files[0] = full;
+ priv = TRACKER_FILES_GET_PRIVATE (object);
- org_freedesktop_Tracker_Indexer_files_delete_async (tracker_dbus_indexer_get_proxy (),
- "files",
- (const char **) files,
- on_indexer_deleted,
- files);
-
- /* When we refactor to use async DBus api implementations, we can start
- * caring about errors that happen in on_indexer_deleted and only
- * dbus_g_method_return_error or dbus_g_method_return in the callback
- * on_indexer_deleted */
+ /* Check the file exists, if not delete, this is broken, we
+ * really don't know with the API if it is a file or
+ * directory we are dealing with so we check both.
+ */
+ file = g_file_new_for_path (uri);
+ tracker_processor_files_check (priv->processor, module_name, file, TRUE);
+ tracker_processor_files_check (priv->processor, module_name, file, FALSE);
+ g_object_unref (file);
dbus_g_method_return (context);
Modified: branches/indexer-split/src/trackerd/tracker-files.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-files.h (original)
+++ branches/indexer-split/src/trackerd/tracker-files.h Mon Aug 18 16:49:18 2008
@@ -49,7 +49,7 @@
};
GType tracker_files_get_type (void);
-TrackerFiles *tracker_files_new (void);
+TrackerFiles *tracker_files_new (TrackerProcessor *processor);
void tracker_files_exist (TrackerFiles *object,
const gchar *uri,
gboolean auto_create,
Modified: branches/indexer-split/src/trackerd/tracker-keywords.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-keywords.c (original)
+++ branches/indexer-split/src/trackerd/tracker-keywords.c Mon Aug 18 16:49:18 2008
@@ -35,11 +35,11 @@
#include "tracker-marshal.h"
#include "tracker-indexer-client.h"
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_KEYWORDS, TrackerKeywordsPriv))
+#define TRACKER_KEYWORDS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_KEYWORDS, TrackerKeywordsPrivate))
typedef struct {
DBusGProxy *fd_proxy;
-} TrackerKeywordsPriv;
+} TrackerKeywordsPrivate;
enum {
KEYWORD_ADDED,
@@ -47,7 +47,7 @@
LAST_SIGNAL
};
-static void keywords_finalize (GObject *object);
+static void tracker_keywords_finalize (GObject *object);
static guint signals[LAST_SIGNAL] = {0};
@@ -60,7 +60,7 @@
object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = keywords_finalize;
+ object_class->finalize = tracker_keywords_finalize;
signals[KEYWORD_ADDED] =
g_signal_new ("keyword-added",
@@ -81,7 +81,7 @@
G_TYPE_NONE,
3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
- g_type_class_add_private (object_class, sizeof (TrackerKeywordsPriv));
+ g_type_class_add_private (object_class, sizeof (TrackerKeywordsPrivate));
}
static void
@@ -90,11 +90,11 @@
}
static void
-keywords_finalize (GObject *object)
+tracker_keywords_finalize (GObject *object)
{
- TrackerKeywordsPriv *priv;
+ TrackerKeywordsPrivate *priv;
- priv = GET_PRIV (object);
+ priv = TRACKER_KEYWORDS_GET_PRIVATE (object);
if (priv->fd_proxy) {
g_object_unref (priv->fd_proxy);
Modified: branches/indexer-split/src/trackerd/tracker-processor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-processor.c (original)
+++ branches/indexer-split/src/trackerd/tracker-processor.c Mon Aug 18 16:49:18 2008
@@ -22,9 +22,6 @@
#include <string.h>
-#include <glib.h>
-#include <gio/gio.h>
-
#include <libtracker-common/tracker-dbus.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-hal.h>
@@ -544,10 +541,10 @@
static gboolean
item_queue_handlers_cb (gpointer user_data)
{
- TrackerProcessor *processor;
- GQueue *queue;
- GStrv files;
- gchar *module_name;
+ TrackerProcessor *processor;
+ GQueue *queue;
+ GStrv files;
+ gchar *module_name;
processor = user_data;
@@ -990,25 +987,21 @@
}
static void
-monitor_item_created_cb (TrackerMonitor *monitor,
- const gchar *module_name,
- GFile *file,
- gboolean is_directory,
- gpointer user_data)
+processor_files_check (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory)
{
- TrackerProcessor *processor;
- TrackerCrawler *crawler;
- GQueue *queue;
- gboolean ignored;
- gchar *path;
-
- processor = user_data;
+ TrackerCrawler *crawler;
+ GQueue *queue;
+ gboolean ignored;
+ gchar *path;
path = g_file_get_path (file);
crawler = g_hash_table_lookup (processor->private->crawlers, module_name);
ignored = tracker_crawler_is_path_ignored (crawler, path, is_directory);
- g_debug ("%s:'%s' (created monitor event)",
+ g_debug ("%s:'%s' (create monitor event or user request)",
ignored ? "Ignored" : "Found ",
path);
@@ -1021,29 +1014,25 @@
queue = g_hash_table_lookup (processor->private->items_created_queues, module_name);
g_queue_push_tail (queue, g_object_ref (file));
- item_queue_handlers_set_up (user_data);
+ item_queue_handlers_set_up (processor);
}
static void
-monitor_item_updated_cb (TrackerMonitor *monitor,
- const gchar *module_name,
- GFile *file,
- gboolean is_directory,
- gpointer user_data)
+processor_files_update (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory)
{
- TrackerProcessor *processor;
- TrackerCrawler *crawler;
- GQueue *queue;
- gchar *path;
- gboolean ignored;
-
- processor = user_data;
+ TrackerCrawler *crawler;
+ GQueue *queue;
+ gchar *path;
+ gboolean ignored;
path = g_file_get_path (file);
crawler = g_hash_table_lookup (processor->private->crawlers, module_name);
ignored = tracker_crawler_is_path_ignored (crawler, path, is_directory);
- g_debug ("%s:'%s' (updated monitor event)",
+ g_debug ("%s:'%s' (update monitor event or user request)",
ignored ? "Ignored" : "Found ",
path);
@@ -1056,29 +1045,25 @@
queue = g_hash_table_lookup (processor->private->items_updated_queues, module_name);
g_queue_push_tail (queue, g_object_ref (file));
- item_queue_handlers_set_up (user_data);
+ item_queue_handlers_set_up (processor);
}
static void
-monitor_item_deleted_cb (TrackerMonitor *monitor,
- const gchar *module_name,
- GFile *file,
- gboolean is_directory,
- gpointer user_data)
+processor_files_delete (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory)
{
- TrackerProcessor *processor;
- TrackerCrawler *crawler;
- GQueue *queue;
- gchar *path;
- gboolean ignored;
-
- processor = user_data;
+ TrackerCrawler *crawler;
+ GQueue *queue;
+ gchar *path;
+ gboolean ignored;
path = g_file_get_path (file);
crawler = g_hash_table_lookup (processor->private->crawlers, module_name);
ignored = tracker_crawler_is_path_ignored (crawler, path, is_directory);
- g_debug ("%s:'%s' (updated monitor event)",
+ g_debug ("%s:'%s' (delete monitor event or user request)",
ignored ? "Ignored" : "Found ",
path);
@@ -1091,7 +1076,37 @@
queue = g_hash_table_lookup (processor->private->items_deleted_queues, module_name);
g_queue_push_tail (queue, g_object_ref (file));
- item_queue_handlers_set_up (user_data);
+ item_queue_handlers_set_up (processor);
+}
+
+static void
+monitor_item_created_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data)
+{
+ tracker_processor_files_check (user_data, module_name, file, is_directory);
+}
+
+static void
+monitor_item_updated_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data)
+{
+ processor_files_update (user_data, module_name, file, is_directory);
+}
+
+static void
+monitor_item_deleted_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data)
+{
+ processor_files_delete (user_data, module_name, file, is_directory);
}
static void
@@ -1376,6 +1391,45 @@
}
}
+void
+tracker_processor_files_check (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory)
+{
+ g_return_if_fail (TRACKER_IS_PROCESSOR (processor));
+ g_return_if_fail (module_name != NULL);
+ g_return_if_fail (G_IS_FILE (file));
+
+ processor_files_check (processor, module_name, file, is_directory);
+}
+
+void
+tracker_processor_files_update (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory)
+{
+ g_return_if_fail (TRACKER_IS_PROCESSOR (processor));
+ g_return_if_fail (module_name != NULL);
+ g_return_if_fail (G_IS_FILE (file));
+
+ processor_files_update (processor, module_name, file, is_directory);
+}
+
+void
+tracker_processor_files_delete (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory)
+{
+ g_return_if_fail (TRACKER_IS_PROCESSOR (processor));
+ g_return_if_fail (module_name != NULL);
+ g_return_if_fail (G_IS_FILE (file));
+
+ processor_files_delete (processor, module_name, file, is_directory);
+}
+
guint
tracker_processor_get_directories_found (TrackerProcessor *processor)
{
Modified: branches/indexer-split/src/trackerd/tracker-processor.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-processor.h (original)
+++ branches/indexer-split/src/trackerd/tracker-processor.h Mon Aug 18 16:49:18 2008
@@ -22,6 +22,7 @@
#define __TRACKERD_PROCESSOR_H__
#include <glib-object.h>
+#include <gio/gio.h>
#include <libtracker-common/tracker-config.h>
#include <libtracker-common/tracker-hal.h>
@@ -57,10 +58,24 @@
void tracker_processor_start (TrackerProcessor *processor);
void tracker_processor_stop (TrackerProcessor *processor);
+/* Required API for org.freedesktop.Tracker.Files */
+void tracker_processor_files_check (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory);
+void tracker_processor_files_update (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory);
+void tracker_processor_files_delete (TrackerProcessor *processor,
+ const gchar *module_name,
+ GFile *file,
+ gboolean is_directory);
+
+/* Statistics */
guint tracker_processor_get_directories_found (TrackerProcessor *processor);
guint tracker_processor_get_directories_ignored (TrackerProcessor *processor);
guint tracker_processor_get_directories_total (TrackerProcessor *processor);
-
guint tracker_processor_get_files_found (TrackerProcessor *processor);
guint tracker_processor_get_files_ignored (TrackerProcessor *processor);
guint tracker_processor_get_files_total (TrackerProcessor *processor);
Modified: branches/indexer-split/src/trackerd/tracker-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-search.c (original)
+++ branches/indexer-split/src/trackerd/tracker-search.c Mon Aug 18 16:49:18 2008
@@ -42,19 +42,17 @@
#include "tracker-query-tree.h"
#include "tracker-marshal.h"
-#define DEFAULT_SEARCH_MAX_HITS 1024
+#define TRACKER_SEARCH_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_SEARCH, TrackerSearchPrivate))
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_SEARCH, TrackerSearchPriv))
+#define DEFAULT_SEARCH_MAX_HITS 1024
typedef struct {
- DBusGProxy *fd_proxy;
-
TrackerConfig *config;
TrackerLanguage *language;
TrackerDBIndex *index;
-} TrackerSearchPriv;
+} TrackerSearchPrivate;
-static void search_finalize (GObject *object);
+static void tracker_search_finalize (GObject *object);
G_DEFINE_TYPE(TrackerSearch, tracker_search, G_TYPE_OBJECT)
@@ -65,9 +63,9 @@
object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = search_finalize;
+ object_class->finalize = tracker_search_finalize;
- g_type_class_add_private (object_class, sizeof (TrackerSearchPriv));
+ g_type_class_add_private (object_class, sizeof (TrackerSearchPrivate));
}
static void
@@ -76,15 +74,11 @@
}
static void
-search_finalize (GObject *object)
+tracker_search_finalize (GObject *object)
{
- TrackerSearchPriv *priv;
+ TrackerSearchPrivate *priv;
- priv = GET_PRIV (object);
-
- if (priv->fd_proxy) {
- g_object_unref (priv->fd_proxy);
- }
+ priv = TRACKER_SEARCH_GET_PRIVATE (object);
g_object_unref (priv->index);
g_object_unref (priv->language);
@@ -98,8 +92,8 @@
TrackerLanguage *language,
TrackerDBIndex *index)
{
- TrackerSearch *object;
- TrackerSearchPriv *priv;
+ TrackerSearch *object;
+ TrackerSearchPrivate *priv;
g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
g_return_val_if_fail (TRACKER_IS_LANGUAGE (language), NULL);
@@ -107,7 +101,7 @@
object = g_object_new (TRACKER_TYPE_SEARCH, NULL);
- priv = GET_PRIV (object);
+ priv = TRACKER_SEARCH_GET_PRIVATE (object);
priv->config = g_object_ref (config);
priv->language = g_object_ref (language);
@@ -434,13 +428,13 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
- TrackerSearchPriv *priv;
- TrackerQueryTree *tree;
- GArray *array;
- guint request_id;
- gint services[12];
- gint count = 0;
+ TrackerSearchPrivate *priv;
+ TrackerQueryTree *tree;
+ GError *actual_error = NULL;
+ GArray *array;
+ guint request_id;
+ gint services[12];
+ gint count = 0;
request_id = tracker_dbus_get_next_request_id ();
@@ -474,7 +468,7 @@
return;
}
- priv = GET_PRIV (object);
+ priv = TRACKER_SEARCH_GET_PRIVATE (object);
services[count++] = tracker_ontology_get_id_for_service_type (service);
@@ -519,14 +513,14 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
- TrackerSearchPriv *priv;
- TrackerDBResultSet *result_set = NULL;
- TrackerQueryTree *tree;
- GArray *hit_counts;
- guint request_id;
- guint i;
- GPtrArray *values = NULL;
+ TrackerSearchPrivate *priv;
+ TrackerDBResultSet *result_set = NULL;
+ TrackerQueryTree *tree;
+ GError *actual_error = NULL;
+ GArray *hit_counts;
+ guint request_id;
+ guint i;
+ GPtrArray *values = NULL;
request_id = tracker_dbus_get_next_request_id ();
@@ -547,7 +541,7 @@
return;
}
- priv = GET_PRIV (object);
+ priv = TRACKER_SEARCH_GET_PRIVATE (object);
tree = tracker_query_tree_new (search_text,
priv->index,
@@ -846,11 +840,11 @@
g_free (service_id);
if (result_set) {
- TrackerSearchPriv *priv;
- gchar **strv;
- gchar *text;
+ TrackerSearchPrivate *priv;
+ gchar **strv;
+ gchar *text;
- priv = GET_PRIV (object);
+ priv = TRACKER_SEARCH_GET_PRIVATE (object);
tracker_db_result_set_get (result_set, 0, &text, -1);
strv = tracker_parser_text_into_array (text,
@@ -1225,10 +1219,10 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
- TrackerSearchPriv *priv;
- guint request_id;
- gchar *value;
+ GError *actual_error = NULL;
+ TrackerSearchPrivate *priv;
+ guint request_id;
+ gchar *value;
request_id = tracker_dbus_get_next_request_id ();
@@ -1240,7 +1234,7 @@
search_text,
max_dist);
- priv = GET_PRIV (object);
+ priv = TRACKER_SEARCH_GET_PRIVATE (object);
value = tracker_db_index_get_suggestion (priv->index, search_text, max_dist);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]