tracker r1329 - in branches/indexer-split: . src/libtracker-common src/libtracker-db src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1329 - in branches/indexer-split: . src/libtracker-common src/libtracker-db src/trackerd
- Date: Wed, 30 Apr 2008 12:54:13 +0100 (BST)
Author: mr
Date: Wed Apr 30 11:54:10 2008
New Revision: 1329
URL: http://svn.gnome.org/viewvc/tracker?rev=1329&view=rev
Log:
* src/libtracker-common/Makefile.am:
* src/libtracker-common/tracker-file-utils.[ch]: Added to handle
IO operations.
* src/libtracker-db/Makefile.am:
* src/libtracker-db/tracker-db-action.[ch]:
* src/trackerd/Makefile.am:
* src/trackerd/tracker-action.[ch]: Moved TrackerAction to
libtracker-db and renamed to TrackerDBAction.
* src/trackerd/tracker-apps.[ch]:
* src/trackerd/tracker-db-email.c:
* src/trackerd/tracker-db-sqlite.[ch]:
* src/trackerd/tracker-db.[ch]:
* src/trackerd/tracker-dbus-files.c:
* 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-email.c:
* src/trackerd/tracker-email.h:
* src/trackerd/tracker-inotify.c:
* src/trackerd/tracker-process-files.[ch]:
* src/trackerd/tracker-status.[ch]:
* src/trackerd/tracker-utils.[ch]:
* src/trackerd/trackerd.c: Moved FileInfo and WatchTypes to
libtracker-db and renamed to TrackerDBFileInfo and
TrackerDBWatch.
Added:
branches/indexer-split/src/libtracker-common/tracker-file-utils.c
branches/indexer-split/src/libtracker-common/tracker-file-utils.h
branches/indexer-split/src/libtracker-db/tracker-db-action.c
- copied, changed from r1328, /branches/indexer-split/src/trackerd/tracker-action.c
branches/indexer-split/src/libtracker-db/tracker-db-action.h
- copied, changed from r1328, /branches/indexer-split/src/trackerd/tracker-action.h
Removed:
branches/indexer-split/src/trackerd/tracker-action.c
branches/indexer-split/src/trackerd/tracker-action.h
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/libtracker-common/Makefile.am
branches/indexer-split/src/libtracker-db/Makefile.am
branches/indexer-split/src/trackerd/Makefile.am
branches/indexer-split/src/trackerd/tracker-apps.c
branches/indexer-split/src/trackerd/tracker-apps.h
branches/indexer-split/src/trackerd/tracker-db-email.c
branches/indexer-split/src/trackerd/tracker-db-sqlite.c
branches/indexer-split/src/trackerd/tracker-db-sqlite.h
branches/indexer-split/src/trackerd/tracker-db.c
branches/indexer-split/src/trackerd/tracker-db.h
branches/indexer-split/src/trackerd/tracker-dbus-files.c
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-email.c
branches/indexer-split/src/trackerd/tracker-email.h
branches/indexer-split/src/trackerd/tracker-inotify.c
branches/indexer-split/src/trackerd/tracker-process-files.c
branches/indexer-split/src/trackerd/tracker-process-files.h
branches/indexer-split/src/trackerd/tracker-status.c
branches/indexer-split/src/trackerd/tracker-status.h
branches/indexer-split/src/trackerd/tracker-utils.c
branches/indexer-split/src/trackerd/tracker-utils.h
branches/indexer-split/src/trackerd/trackerd.c
Modified: branches/indexer-split/src/libtracker-common/Makefile.am
==============================================================================
--- branches/indexer-split/src/libtracker-common/Makefile.am (original)
+++ branches/indexer-split/src/libtracker-common/Makefile.am Wed Apr 30 11:54:10 2008
@@ -17,6 +17,8 @@
tracker-configuration.h \
tracker-config.c \
tracker-config.h \
+ tracker-file-utils.c \
+ tracker-file-utils.h \
tracker-language.c \
tracker-language.h \
tracker-log.c \
@@ -24,8 +26,6 @@
tracker-os-dependant.h \
tracker-type-utils.c \
tracker-type-utils.h \
- tracker-file-utils.c \
- tracker-file-utils.h \
tracker-utils.c \
tracker-utils.h
Added: branches/indexer-split/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libtracker-common/tracker-file-utils.c Wed Apr 30 11:54:10 2008
@@ -0,0 +1,420 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * 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 _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <glib.h>
+
+#include <xdgmime/xdgmime.h>
+
+#include "tracker-log.h"
+#include "tracker-os-dependant.h"
+#include "tracker-file-utils.h"
+
+#define TEXT_SNIFF_SIZE 4096
+
+gint
+tracker_file_open (const gchar *uri,
+ gboolean readahead)
+{
+ gint fd;
+
+#if defined(__linux__)
+ fd = open (uri, O_RDONLY | O_NOATIME);
+
+ if (fd == -1) {
+ fd = open (uri, O_RDONLY);
+ }
+#else
+ fd = open (uri, O_RDONLY);
+#endif
+
+ if (fd == -1) {
+ return -1;
+ }
+
+#ifdef HAVE_POSIX_FADVISE
+ if (readahead) {
+ posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+ } else {
+ posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM);
+ }
+#endif
+
+ return fd;
+}
+
+void
+tracker_file_close (gint fd,
+ gboolean no_longer_needed)
+{
+
+#ifdef HAVE_POSIX_FADVISE
+ if (no_longer_needed) {
+ posix_fadvise (fd, 0, 0, POSIX_FADV_DONTNEED);
+ }
+#endif
+
+ close (fd);
+}
+
+gboolean
+tracker_file_unlink (const gchar *uri)
+{
+ gchar *str;
+ gboolean result;
+
+ str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+ result = g_unlink (str) == 0;
+ g_free (str);
+
+ return result;
+}
+
+guint32
+tracker_file_get_size (const gchar *uri)
+{
+ struct stat finfo;
+
+ if (g_lstat (uri, &finfo) == -1) {
+ return 0;
+ } else {
+ return (guint32) finfo.st_size;
+ }
+}
+
+static inline gboolean
+is_utf8 (const gchar *buffer,
+ gint buffer_length)
+{
+ gchar *end;
+
+ /* Code in this function modified from gnome-vfs */
+ if (g_utf8_validate ((gchar*) buffer,
+ buffer_length,
+ (const gchar**) &end)) {
+ return TRUE;
+ } else {
+ /* Check whether the string was truncated in the middle of
+ * a valid UTF8 char, or if we really have an invalid
+ * UTF8 string.
+ */
+ gunichar validated;
+ gint remaining_bytes;
+
+ remaining_bytes = buffer_length;
+ remaining_bytes -= end - ((gchar *) buffer);
+
+ if (remaining_bytes > 4) {
+ return FALSE;
+ }
+
+ validated = g_utf8_get_char_validated (end, (gsize) remaining_bytes);
+
+ if (validated == (gunichar) - 2) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+is_text_file (const gchar *uri)
+{
+ gchar buffer[TEXT_SNIFF_SIZE];
+ gint buffer_length = 0;
+ gint fd;
+ gboolean result = FALSE;
+
+ fd = tracker_file_open (uri, FALSE);
+ buffer_length = read (fd, buffer, TEXT_SNIFF_SIZE);
+
+ /* Don't allow embedded zeros in textfiles. */
+ if (buffer_length > 2 &&
+ memchr (buffer, 0, buffer_length) == NULL) {
+ if (is_utf8 (buffer, buffer_length)) {
+ result = TRUE;
+ } else {
+ GError *error = NULL;
+ gchar *tmp;
+
+ tmp = g_locale_to_utf8 (buffer,
+ buffer_length,
+ NULL,
+ NULL,
+ &error);
+ g_free (tmp);
+
+ if (error) {
+ gboolean result = FALSE;
+
+ if (error->code != G_CONVERT_ERROR_ILLEGAL_SEQUENCE &&
+ error->code != G_CONVERT_ERROR_FAILED &&
+ error->code != G_CONVERT_ERROR_NO_CONVERSION) {
+ result = TRUE;
+ }
+
+ g_error_free (error);
+ }
+ }
+ }
+
+ tracker_file_close (fd, !result);
+
+ return result;
+}
+
+gboolean
+tracker_file_is_valid (const gchar *uri)
+{
+ gchar *str;
+ gboolean is_valid = TRUE;
+
+ str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+
+ if (!str) {
+ tracker_error ("URI:'%s' could not be converted to locale format",
+ uri);
+ return FALSE;
+ }
+
+ /* g_file_test (file,G_FILE_TEST_EXISTS) uses the access ()
+ * system call and so needs locale filenames.
+ */
+ is_valid &= tracker_check_uri (uri);
+ is_valid &= g_file_test (str,
+ G_FILE_TEST_IS_REGULAR |
+ G_FILE_TEST_IS_DIR |
+ G_FILE_TEST_IS_SYMLINK);
+
+ g_free (str);
+
+ return is_valid;
+}
+
+gboolean
+tracker_file_is_directory (const gchar *uri)
+{
+ gchar *str;
+ gboolean is_directory;
+
+ str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+
+ if (!str) {
+ tracker_error ("URI:'%s' could not be converted to locale format",
+ str);
+ return FALSE;
+ }
+
+ is_directory = g_file_test (str, G_FILE_TEST_IS_DIR);
+ g_free (str);
+
+ return is_directory;
+}
+
+gboolean
+tracker_file_is_indexable (const gchar *uri)
+{
+ gchar *str;
+ struct stat finfo;
+ gboolean is_indexable;
+
+ str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+
+ if (!str) {
+ tracker_error ("URI:'%s' could not be converted to locale format",
+ str);
+ return FALSE;
+ }
+
+ g_lstat (str, &finfo);
+ g_free (str);
+
+ is_indexable = TRUE;
+ is_indexable &= !S_ISDIR (finfo.st_mode);
+ is_indexable &= S_ISREG (finfo.st_mode);
+
+ tracker_debug ("URI:'%s' %s indexable",
+ uri,
+ is_indexable ? "is" : "is not");
+
+ return is_indexable;
+}
+
+gint32
+tracker_file_get_mtime (const gchar *uri)
+{
+ struct stat finfo;
+ gchar *str;
+
+ str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+
+ if (str) {
+ if (g_lstat (str, &finfo) == -1) {
+ g_free (str);
+ return 0;
+ }
+ } else {
+ tracker_error ("URI:'%s' could not be converted to locale format",
+ uri);
+ return 0;
+ }
+
+ g_free (str);
+
+ return (gint32) finfo.st_mtime;
+}
+
+gchar *
+tracker_file_get_mime_type (const gchar *uri)
+{
+ struct stat finfo;
+ gchar *str;
+ const gchar *result;
+ gchar *mime_type;
+
+ if (!tracker_file_is_valid (uri)) {
+ tracker_log ("URI:'%s' is no longer valid",
+ uri);
+ return g_strdup ("unknown");
+ }
+
+ str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+
+ if (!str) {
+ tracker_error ("URI:'%s' could not be converted to locale format",
+ uri);
+ return g_strdup ("unknown");
+ }
+
+ g_lstat (str, &finfo);
+
+ if (S_ISLNK (finfo.st_mode) && S_ISDIR (finfo.st_mode)) {
+ g_free (str);
+ return g_strdup ("symlink");
+ }
+
+ /* Handle iso files as they can be mistaken for video files */
+ if (g_str_has_suffix (uri, ".iso")) {
+ return g_strdup ("application/x-cd-image");
+ }
+
+ result = xdg_mime_get_mime_type_for_file (uri, NULL);
+
+ if (!result || result == XDG_MIME_TYPE_UNKNOWN) {
+ if (is_text_file (str)) {
+ mime_type = g_strdup ("text/plain");
+ } else {
+ mime_type = g_strdup ("unknown");
+ }
+ } else {
+ mime_type = g_strdup (result);
+ }
+
+ g_free (str);
+
+ return mime_type;
+}
+
+gchar *
+tracker_file_get_vfs_path (const gchar *uri)
+{
+ gchar *p;
+
+ if (!uri || !strchr (uri, G_DIR_SEPARATOR)) {
+ return NULL;
+ }
+
+ p = (gchar*) uri + strlen (uri) - 1;
+
+ /* Skip trailing slash */
+ if (p != uri && *p == G_DIR_SEPARATOR) {
+ p--;
+ }
+
+ /* Search backwards to the next slash. */
+ while (p != uri && *p != G_DIR_SEPARATOR) {
+ p--;
+ }
+
+ if (p[0] != '\0') {
+ gchar *new_uri_text;
+ gint length;
+
+ length = p - uri;
+
+ if (length == 0) {
+ new_uri_text = g_strdup (G_DIR_SEPARATOR_S);
+ } else {
+ new_uri_text = g_malloc (length + 1);
+ memcpy (new_uri_text, uri, length);
+ new_uri_text[length] = '\0';
+ }
+
+ return new_uri_text;
+ } else {
+ return g_strdup (G_DIR_SEPARATOR_S);
+ }
+}
+
+gchar *
+tracker_file_get_vfs_name (const gchar *uri)
+{
+ gchar *p, *res, *tmp, *result;
+
+ if (!uri || !strchr (uri, G_DIR_SEPARATOR)) {
+ return g_strdup (" ");
+ }
+
+ tmp = g_strdup (uri);
+ p = tmp + strlen (uri) - 1;
+
+ /* Skip trailing slash */
+ if (p != tmp && *p == G_DIR_SEPARATOR) {
+ *p = '\0';
+ }
+
+ /* Search backwards to the next slash. */
+ while (p != tmp && *p != G_DIR_SEPARATOR) {
+ p--;
+ }
+
+ res = p + 1;
+
+ if (res && res[0] != '\0') {
+ result = g_strdup (res);
+ g_free (tmp);
+
+ return result;
+ }
+
+ g_free (tmp);
+
+ return g_strdup (" ");
+}
Added: branches/indexer-split/src/libtracker-common/tracker-file-utils.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/libtracker-common/tracker-file-utils.h Wed Apr 30 11:54:10 2008
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * 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 __TRACKER_FILE_UTILS_H__
+#define __TRACKER_FILE_UTILS_H__
+
+gint tracker_file_open (const gchar *uri,
+ gboolean readahead);
+void tracker_file_close (gint fd,
+ gboolean no_longer_needed);
+gboolean tracker_file_unlink (const gchar *uri);
+gboolean tracker_file_is_valid (const gchar *uri);
+gboolean tracker_file_is_directory (const gchar *uri);
+gboolean tracker_file_is_indexable (const gchar *uri);
+guint32 tracker_file_get_size (const gchar *uri);
+gint32 tracker_file_get_mtime (const gchar *uri);
+gchar * tracker_file_get_mime_type (const gchar *uri);
+gchar * tracker_file_get_vfs_path (const gchar *uri);
+gchar * tracker_file_get_vfs_name (const gchar *uri);
+
+#endif /* __TRACKER_FILE_UTILS_H__ */
Modified: branches/indexer-split/src/libtracker-db/Makefile.am
==============================================================================
--- branches/indexer-split/src/libtracker-db/Makefile.am (original)
+++ branches/indexer-split/src/libtracker-db/Makefile.am Wed Apr 30 11:54:10 2008
@@ -9,6 +9,10 @@
noinst_LTLIBRARIES = libtracker-db.la
libtracker_db_la_SOURCES = \
+ tracker-db-action.c \
+ tracker-db-action.h \
+ tracker-db-file-info.c \
+ tracker-db-file-info.h \
tracker-db-interface.c \
tracker-db-interface.h \
tracker-db-interface-sqlite.c \
Copied: branches/indexer-split/src/libtracker-db/tracker-db-action.c (from r1328, /branches/indexer-split/src/trackerd/tracker-action.c)
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-action.c (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-action.c Wed Apr 30 11:54:10 2008
@@ -1,5 +1,7 @@
-/* Tracker - indexer and metadata database engine
+/* -*- 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
* modify it under the terms of the GNU General Public
@@ -19,88 +21,88 @@
#include "config.h"
-#include "tracker-action.h"
+#include "tracker-db-action.h"
GType
-tracker_action_get_type (void)
+tracker_db_action_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
- { TRACKER_ACTION_IGNORE,
- "TRACKER_ACTION_IGNORE",
+ { TRACKER_DB_ACTION_IGNORE,
+ "TRACKER_DB_ACTION_IGNORE",
"Ignoring" },
- { TRACKER_ACTION_CHECK,
- "TRACKER_ACTION_CHECK",
+ { TRACKER_DB_ACTION_CHECK,
+ "TRACKER_DB_ACTION_CHECK",
"Checking" },
- { TRACKER_ACTION_DELETE,
- "TRACKER_ACTION_DELETE",
+ { TRACKER_DB_ACTION_DELETE,
+ "TRACKER_DB_ACTION_DELETE",
"Deleting" },
- { TRACKER_ACTION_DELETE_SELF,
- "TRACKER_ACTION_DELETE_SELF",
+ { TRACKER_DB_ACTION_DELETE_SELF,
+ "TRACKER_DB_ACTION_DELETE_SELF",
"Deleting Self" },
- { TRACKER_ACTION_CREATE,
- "TRACKER_ACTION_CREATE",
+ { TRACKER_DB_ACTION_CREATE,
+ "TRACKER_DB_ACTION_CREATE",
"Creating" },
- { TRACKER_ACTION_MOVED_FROM,
- "TRACKER_ACTION_MOVED_FROM",
+ { TRACKER_DB_ACTION_MOVED_FROM,
+ "TRACKER_DB_ACTION_MOVED_FROM",
"Moved From" },
- { TRACKER_ACTION_MOVED_TO,
- "TRACKER_ACTION_MOVED_TO",
+ { TRACKER_DB_ACTION_MOVED_TO,
+ "TRACKER_DB_ACTION_MOVED_TO",
"Moved To" },
- { TRACKER_ACTION_FILE_CHECK,
- "TRACKER_ACTION_FILE_CHECK",
+ { TRACKER_DB_ACTION_FILE_CHECK,
+ "TRACKER_DB_ACTION_FILE_CHECK",
"File Check" },
- { TRACKER_ACTION_FILE_CHANGED,
- "TRACKER_ACTION_FILE_CHANGED",
+ { TRACKER_DB_ACTION_FILE_CHANGED,
+ "TRACKER_DB_ACTION_FILE_CHANGED",
"File Changed" },
- { TRACKER_ACTION_FILE_DELETED,
- "TRACKER_ACTION_FILE_DELETED",
+ { TRACKER_DB_ACTION_FILE_DELETED,
+ "TRACKER_DB_ACTION_FILE_DELETED",
"File Deleted" },
- { TRACKER_ACTION_FILE_CREATED,
- "TRACKER_ACTION_FILE_CREATED",
+ { TRACKER_DB_ACTION_FILE_CREATED,
+ "TRACKER_DB_ACTION_FILE_CREATED",
"File Created" },
- { TRACKER_ACTION_FILE_MOVED_FROM,
- "TRACKER_ACTION_FILE_MOVED_FROM",
+ { TRACKER_DB_ACTION_FILE_MOVED_FROM,
+ "TRACKER_DB_ACTION_FILE_MOVED_FROM",
"File Moved From" },
- { TRACKER_ACTION_FILE_MOVED_TO,
- "TRACKER_ACTION_FILE_MOVED_TO",
+ { TRACKER_DB_ACTION_FILE_MOVED_TO,
+ "TRACKER_DB_ACTION_FILE_MOVED_TO",
"File Moved To" },
- { TRACKER_ACTION_WRITABLE_FILE_CLOSED,
- "TRACKER_ACTION_WRITABLE_FILE_CLOSED",
+ { TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED,
+ "TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED",
"Writable File Closed" },
- { TRACKER_ACTION_DIRECTORY_CHECK,
- "TRACKER_ACTION_DIRECTORY_CHECK",
+ { TRACKER_DB_ACTION_DIRECTORY_CHECK,
+ "TRACKER_DB_ACTION_DIRECTORY_CHECK",
"Directory Check" },
- { TRACKER_ACTION_DIRECTORY_CREATED,
- "TRACKER_ACTION_DIRECTORY_CREATED",
+ { TRACKER_DB_ACTION_DIRECTORY_CREATED,
+ "TRACKER_DB_ACTION_DIRECTORY_CREATED",
"Directory Created" },
- { TRACKER_ACTION_DIRECTORY_UNMOUNTED,
- "TRACKER_ACTION_DIRECTORY_UNMOUNTED",
+ { TRACKER_DB_ACTION_DIRECTORY_UNMOUNTED,
+ "TRACKER_DB_ACTION_DIRECTORY_UNMOUNTED",
"Directory Unmounted" },
- { TRACKER_ACTION_DIRECTORY_DELETED,
- "TRACKER_ACTION_DIRECTORY_DELETED",
+ { TRACKER_DB_ACTION_DIRECTORY_DELETED,
+ "TRACKER_DB_ACTION_DIRECTORY_DELETED",
"Directory Deleted" },
- { TRACKER_ACTION_DIRECTORY_MOVED_FROM,
- "TRACKER_ACTION_DIRECTORY_MOVED_FROM",
+ { TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM,
+ "TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM",
"Directory Moved From" },
- { TRACKER_ACTION_DIRECTORY_MOVED_TO,
- "TRACKER_ACTION_DIRECTORY_MOVED_TO",
+ { TRACKER_DB_ACTION_DIRECTORY_MOVED_TO,
+ "TRACKER_DB_ACTION_DIRECTORY_MOVED_TO",
"Directory Moved To" },
- { TRACKER_ACTION_DIRECTORY_REFRESH,
- "TRACKER_ACTION_DIRECTORY_REFRESH",
+ { TRACKER_DB_ACTION_DIRECTORY_REFRESH,
+ "TRACKER_DB_ACTION_DIRECTORY_REFRESH",
"Directory Refresh" },
- { TRACKER_ACTION_EXTRACT_METADATA,
- "TRACKER_ACTION_EXTRACT_METADATA",
+ { TRACKER_DB_ACTION_EXTRACT_METADATA,
+ "TRACKER_DB_ACTION_EXTRACT_METADATA",
"Extract Metadata" },
- { TRACKER_ACTION_FORCE_REFRESH,
- "TRACKER_ACTION_FORCE_REFRESH",
+ { TRACKER_DB_ACTION_FORCE_REFRESH,
+ "TRACKER_DB_ACTION_FORCE_REFRESH",
"Forcing Refresh" },
{ 0, NULL, NULL }
};
- etype = g_enum_register_static ("TrackerAction", values);
+ etype = g_enum_register_static ("TrackerDBAction", values);
/* Since we don't reference this enum anywhere, we do
* it here to make sure it exists when we call
@@ -119,18 +121,18 @@
}
const gchar *
-tracker_action_to_string (TrackerAction action)
+tracker_db_action_to_string (TrackerDBAction action)
{
GType type;
GEnumClass *enum_class;
GEnumValue *enum_value;
- type = tracker_action_get_type ();
+ type = tracker_db_action_get_type ();
enum_class = G_ENUM_CLASS (g_type_class_peek (type));
enum_value = g_enum_get_value (enum_class, action);
if (!enum_value) {
- enum_value = g_enum_get_value (enum_class, TRACKER_ACTION_IGNORE);
+ enum_value = g_enum_get_value (enum_class, TRACKER_DB_ACTION_IGNORE);
}
return enum_value->value_nick;
Copied: branches/indexer-split/src/libtracker-db/tracker-db-action.h (from r1328, /branches/indexer-split/src/trackerd/tracker-action.h)
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-action.h (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-action.h Wed Apr 30 11:54:10 2008
@@ -1,5 +1,7 @@
-/* Tracker - indexer and metadata database engine
+/* -*- 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
* modify it under the terms of the GNU General Public
@@ -17,40 +19,40 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __TRACKER_ACTION_H__
-#define __TRACKER_ACTION_H__
+#ifndef __TRACKER_DB_ACTION_H__
+#define __TRACKER_DB_ACTION_H__
#include <glib-object.h>
-#define TRACKER_TYPE_ACTION (tracker_action_get_type ())
+#define TRACKER_TYPE_ACTION (tracker_db_action_get_type ())
typedef enum {
- TRACKER_ACTION_IGNORE,
- TRACKER_ACTION_CHECK,
- TRACKER_ACTION_DELETE,
- TRACKER_ACTION_DELETE_SELF,
- TRACKER_ACTION_CREATE,
- TRACKER_ACTION_MOVED_FROM,
- TRACKER_ACTION_MOVED_TO,
- TRACKER_ACTION_FILE_CHECK,
- TRACKER_ACTION_FILE_CHANGED,
- TRACKER_ACTION_FILE_DELETED,
- TRACKER_ACTION_FILE_CREATED,
- TRACKER_ACTION_FILE_MOVED_FROM,
- TRACKER_ACTION_FILE_MOVED_TO,
- TRACKER_ACTION_WRITABLE_FILE_CLOSED,
- TRACKER_ACTION_DIRECTORY_CHECK,
- TRACKER_ACTION_DIRECTORY_CREATED,
- TRACKER_ACTION_DIRECTORY_UNMOUNTED,
- TRACKER_ACTION_DIRECTORY_DELETED,
- TRACKER_ACTION_DIRECTORY_MOVED_FROM,
- TRACKER_ACTION_DIRECTORY_MOVED_TO,
- TRACKER_ACTION_DIRECTORY_REFRESH,
- TRACKER_ACTION_EXTRACT_METADATA,
- TRACKER_ACTION_FORCE_REFRESH
-} TrackerAction;
+ TRACKER_DB_ACTION_IGNORE,
+ TRACKER_DB_ACTION_CHECK,
+ TRACKER_DB_ACTION_DELETE,
+ TRACKER_DB_ACTION_DELETE_SELF,
+ TRACKER_DB_ACTION_CREATE,
+ TRACKER_DB_ACTION_MOVED_FROM,
+ TRACKER_DB_ACTION_MOVED_TO,
+ TRACKER_DB_ACTION_FILE_CHECK,
+ TRACKER_DB_ACTION_FILE_CHANGED,
+ TRACKER_DB_ACTION_FILE_DELETED,
+ TRACKER_DB_ACTION_FILE_CREATED,
+ TRACKER_DB_ACTION_FILE_MOVED_FROM,
+ TRACKER_DB_ACTION_FILE_MOVED_TO,
+ TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED,
+ TRACKER_DB_ACTION_DIRECTORY_CHECK,
+ TRACKER_DB_ACTION_DIRECTORY_CREATED,
+ TRACKER_DB_ACTION_DIRECTORY_UNMOUNTED,
+ TRACKER_DB_ACTION_DIRECTORY_DELETED,
+ TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM,
+ TRACKER_DB_ACTION_DIRECTORY_MOVED_TO,
+ TRACKER_DB_ACTION_DIRECTORY_REFRESH,
+ TRACKER_DB_ACTION_EXTRACT_METADATA,
+ TRACKER_DB_ACTION_FORCE_REFRESH
+} TrackerDBAction;
-GType tracker_action_get_type (void) G_GNUC_CONST;
-const gchar *tracker_action_to_string (TrackerAction action);
+GType tracker_db_action_get_type (void) G_GNUC_CONST;
+const gchar *tracker_db_action_to_string (TrackerDBAction action);
-#endif /* __TRACKER_ACTION_H__ */
+#endif /* __TRACKER_DB_ACTION_H__ */
Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am (original)
+++ branches/indexer-split/src/trackerd/Makefile.am Wed Apr 30 11:54:10 2008
@@ -85,8 +85,6 @@
$(hal_sources) \
$(db_sources) \
trackerd.c \
- tracker-action.c \
- tracker-action.h \
tracker-apps.c \
tracker-apps.h \
tracker-db.c \
Modified: branches/indexer-split/src/trackerd/tracker-apps.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-apps.c (original)
+++ branches/indexer-split/src/trackerd/tracker-apps.c Wed Apr 30 11:54:10 2008
@@ -1,5 +1,5 @@
-/* Tracker
- * routines for applications
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2007, Marcus Rosell (mudflap75 gmail com)
*
* This library is free software; you can redistribute it and/or
@@ -84,7 +84,7 @@
}
void
-tracker_db_index_application (DBConnection *db_con, FileInfo *info)
+tracker_db_index_application (DBConnection *db_con, TrackerDBFileInfo *info)
{
/* Index application metadata from .desktop files */
Modified: branches/indexer-split/src/trackerd/tracker-apps.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-apps.h (original)
+++ branches/indexer-split/src/trackerd/tracker-apps.h Wed Apr 30 11:54:10 2008
@@ -1,5 +1,5 @@
-/* Tracker
- * routines for applications
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2007, Marcus Rosell (mudflap75 gmail com)
*
* This library is free software; you can redistribute it and/or
@@ -18,16 +18,18 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef _TRACKER_APPS_H_
-#define _TRACKER_APPS_H_
-
-#include "tracker-utils.h"
+#ifndef __TRACKER_APPS_H__
+#define __TRACKER_APPS_H__
#include "config.h"
+#include <libtracker-db/tracker-db-file-info.h>
+
+#include "tracker-utils.h"
+
#include "tracker-db-sqlite.h"
void tracker_applications_add_service_directories (void);
-void tracker_db_index_application (DBConnection *db_con, FileInfo *info);
+void tracker_db_index_application (DBConnection *db_con, TrackerDBFileInfo *info);
-#endif
+#endif
Modified: branches/indexer-split/src/trackerd/tracker-db-email.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-email.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-email.c Wed Apr 30 11:54:10 2008
@@ -496,7 +496,7 @@
return TRUE;
}
- FileInfo *info = tracker_create_file_info (mm->uri, 0,0,0);
+ TrackerDBFileInfo *info = tracker_db_file_info_new (mm->uri, 0,0,0);
info->mime = mime;
info->offset = mm->offset;
@@ -505,7 +505,7 @@
id = tracker_db_create_service (db_con->index, service, info);
- tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
if (id != 0) {
GHashTable *index_table;
@@ -677,7 +677,7 @@
MailAttachment *ma = tmp->data;
if (ma->tmp_decoded_file) {
- FileInfo *attachment_info;
+ TrackerDBFileInfo *attachment_info;
gchar *locale_path, *uri;
locale_path = g_filename_from_utf8 (ma->tmp_decoded_file, -1, NULL, NULL, NULL);
@@ -687,7 +687,7 @@
continue;
}
- attachment_info = tracker_create_file_info (ma->tmp_decoded_file, TRACKER_ACTION_CHECK, 0, WATCH_OTHER);
+ attachment_info = tracker_db_file_info_new (ma->tmp_decoded_file, TRACKER_DB_ACTION_CHECK, 0, TRACKER_DB_WATCH_OTHER);
attachment_info->is_directory = FALSE;
attachment_info->mime = g_strdup (ma->mime);
@@ -696,7 +696,7 @@
tracker_db_index_file (db_con, attachment_info, uri, attachment_service);
g_free (uri);
- tracker_dec_info_ref (attachment_info);
+ tracker_db_file_info_unref (attachment_info);
/* remove temporary and indexed attachment file */
g_unlink (locale_path);
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.c Wed Apr 30 11:54:10 2008
@@ -1,4 +1,5 @@
-/* Tracker - indexer and metadata database engine
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
*
* This library is free software; you can redistribute it and/or
@@ -1824,7 +1825,7 @@
void
-tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GHashTable *old_table, const char *file_name, FileInfo *info)
+tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GHashTable *old_table, const char *file_name, TrackerDBFileInfo *info)
{
char buffer[MAX_TEXT_BUFFER], out[MAX_COMPRESS_BUFFER];
int fd, bytes_read = 0, bytes_compressed = 0, flush;
@@ -3245,7 +3246,7 @@
}
guint32
-tracker_db_create_service (DBConnection *db_con, const char *service, FileInfo *info)
+tracker_db_create_service (DBConnection *db_con, const char *service, TrackerDBFileInfo *info)
{
TrackerDBResultSet *result_set;
int i;
@@ -3618,7 +3619,7 @@
void
-tracker_db_update_file (DBConnection *db_con, FileInfo *info)
+tracker_db_update_file (DBConnection *db_con, TrackerDBFileInfo *info)
{
char *str_file_id;
char *str_service_type_id;
@@ -4232,7 +4233,7 @@
guint32 id = tracker_db_get_file_id (db_con, moved_from_uri);
if (id == 0) {
tracker_debug ("WARNING: original file %s not found in DB", moved_from_uri);
- tracker_db_insert_pending_file (db_con, id, moved_to_uri, NULL, "unknown", 0, TRACKER_ACTION_WRITABLE_FILE_CLOSED, FALSE, TRUE, -1);
+ tracker_db_insert_pending_file (db_con, id, moved_to_uri, NULL, "unknown", 0, TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED, FALSE, TRUE, -1);
tracker_db_interface_end_transaction (db_con->db);
return;
}
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.h (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.h Wed Apr 30 11:54:10 2008
@@ -1,4 +1,5 @@
-/* Tracker - indexer and metadata database engine
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
*
* This library is free software; you can redistribute it and/or
@@ -17,19 +18,17 @@
* Boston, MA 02110-1301, USA.
*/
-
-
-#ifndef _TRACKER_SQLITE_DB_H_
-#define _TRACKER_SQLITE_DB_H_
+#ifndef __TRACKER_SQLITE_DB_H__
+#define __TRACKER_SQLITE_DB_H__
#include <glib.h>
#include <libtracker-db/tracker-db-interface.h>
+#include <libtracker-db/tracker-db-file-info.h>
#include "tracker-utils.h"
#include "tracker-service-manager.h"
-
typedef enum {
METADATA_INDEX,
METADATA_REINDEX,
@@ -37,8 +36,6 @@
METADATA_USER_REPLACE
} MetadataAction;
-
-
typedef struct DBConnection DBConnection;
struct DBConnection {
@@ -67,162 +64,285 @@
gpointer word_index;
};
-
-char ** tracker_db_get_row (char ***result, int num);
-unsigned int tracker_db_get_last_id (DBConnection *db_con);
-void tracker_db_free_result (char ***result);
-void tracker_db_log_result (char ***result);
-int tracker_get_row_count (char ***result);
-int tracker_get_field_count (char ***result);
-
-gboolean tracker_db_needs_setup (void);
-gboolean tracker_db_needs_data (void);
-gboolean tracker_db_initialize (void);
-void tracker_db_thread_init (void);
-void tracker_db_thread_end (void);
-void tracker_db_close (DBConnection *db_con);
-void tracker_db_finalize (void);
-
-DBConnection * tracker_db_connect (void);
-DBConnection * tracker_db_connect_common (void);
-DBConnection * tracker_db_connect_file_content (void);
-DBConnection * tracker_db_connect_email_content(void);
-DBConnection * tracker_db_connect_cache (void);
-DBConnection * tracker_db_connect_emails (void);
-DBConnection * tracker_db_connect_email_meta (void);
-DBConnection * tracker_db_connect_file_meta (void);
-DBConnection * tracker_db_connect_all (gboolean indexer_process);
-void tracker_db_close_all (DBConnection *db_con);
-void tracker_db_refresh_all (DBConnection *db_con);
-void tracker_db_refresh_email (DBConnection *db_con);
-
-gboolean tracker_update_db (DBConnection *db_con);
-
-char * tracker_escape_string (const char *in);
-
-void tracker_db_prepare_queries (DBConnection *db_con);
-TrackerDBResultSet * tracker_exec_proc (DBConnection *db_con, const char *procedure, ...);
-gboolean tracker_exec_proc_no_reply (DBConnection *db_con, const char *procedure, ...);
-gboolean tracker_db_exec_no_reply (DBConnection *db_con, const char *query, ...);
-void tracker_create_db (void);
-void tracker_db_load_stored_procs (DBConnection *db_con);
-void tracker_db_save_file_contents (DBConnection *db_con, GHashTable *index_table, GHashTable *old_table, const char *file_name, FileInfo *info);
-void tracker_db_clear_temp (DBConnection *db_con);
-void tracker_db_check_tables (DBConnection *db_con);
-gboolean tracker_db_start_transaction (DBConnection *db_con);
-gboolean tracker_db_end_transaction (DBConnection *db_con);
-
-void tracker_db_update_indexes_for_new_service (guint32 service_id, int service_type_id, GHashTable *table);
-void tracker_db_update_differential_index (DBConnection *db_con,GHashTable *old_table, GHashTable *new_table, const char *id, int service_type_id);
-void tracker_db_update_index_file_contents (DBConnection *blob_db_con, GHashTable *index_table);
-int tracker_db_flush_words_to_qdbm (DBConnection *db_con, int limit);
-
-void tracker_db_release_memory (void);
-
-void tracker_db_set_default_pragmas (DBConnection *db_con);
-
-void tracker_db_fsync (DBConnection *db_con, gboolean enable);
-
-
-char * tracker_get_related_metadata_names (DBConnection *db_con, const char *name);
-char * tracker_get_metadata_table (DataTypes type);
-
-TrackerDBResultSet * tracker_db_search_text (DBConnection *db_con, const char *service, const char *search_string, int offset, int limit, gboolean save_results, gboolean detailed);
-TrackerDBResultSet * tracker_db_search_files_by_text (DBConnection *db_con, const char *text, int offset, int limit, gboolean sort);
-TrackerDBResultSet * tracker_db_search_metadata (DBConnection *db_con, const char *service, const char *field, const char *text, int offset, int limit);
-TrackerDBResultSet * tracker_db_search_matching_metadata (DBConnection *db_con, const char *service, const char *id, const char *text);
-
-/* gets metadata as a single row (with multiple values delimited by semicolons) */
-TrackerDBResultSet * tracker_db_get_metadata (DBConnection *db_con, const char *service, const char *id, const char *key);
-
-/* gets metadata using a separate row for each value it has */
-char * tracker_db_get_metadata_delimited (DBConnection *db_con, const char *service, const char *id, const char *key);
-char * tracker_db_set_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, char **values, int length, gboolean do_backup);
-void tracker_db_set_single_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value, gboolean do_backup);
-
-void tracker_db_insert_embedded_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, char **values, int length, GHashTable *table);
-void tracker_db_insert_single_embedded_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value, GHashTable *table);
-
-
-void tracker_db_delete_metadata_value (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value);
-void tracker_db_delete_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, gboolean update_indexes);
-
-char * tracker_db_refresh_display_metadata (DBConnection *db_con, const char *id, const char *metadata_id, int data_type, const char *key);
-void tracker_db_refresh_all_display_metadata (DBConnection *db_con, const char *id);
-
-void tracker_db_update_keywords (DBConnection *db_con, const char *service, const char *id, const char *value);
-
-guint32 tracker_db_create_service (DBConnection *db_con, const char *service, FileInfo *info);
-
-void tracker_db_delete_file (DBConnection *db_con, guint32 file_id);
-void tracker_db_delete_directory (DBConnection *db_con, guint32 file_id, const char *uri);
-void tracker_db_update_file (DBConnection *db_con, FileInfo *info);
-void tracker_db_move_file (DBConnection *db_con, const char *moved_from_uri, const char *moved_to_uri);
-void tracker_db_move_directory (DBConnection *db_con, const char *moved_from_uri, const char *moved_to_uri);
-
-guint32 tracker_db_get_file_id (DBConnection *db_con, const char *uri);
-void tracker_db_insert_pending_file (DBConnection *db_con, guint32 file_id, const char *uri, const char *moved_to_uri, const char *mime, int counter, TrackerAction action, gboolean is_directory, gboolean is_new, int service_type_id);
-
-gboolean tracker_db_has_pending_files (DBConnection *db_con);
-gboolean tracker_db_has_pending_metadata (DBConnection *db_con);
-TrackerDBResultSet * tracker_db_get_pending_files (DBConnection *db_con);
-void tracker_db_remove_pending_files (DBConnection *db_con);
-TrackerDBResultSet * tracker_db_get_pending_metadata (DBConnection *db_con);
-void tracker_db_remove_pending_metadata (DBConnection *db_con);
-void tracker_db_insert_pending (DBConnection *db_con, const char *id, const char *action, const char *counter, const char *uri, const char *mime, gboolean is_dir, gboolean is_new, int service_type_id);
-void tracker_db_update_pending (DBConnection *db_con, const char *counter, const char *action, const char *uri);
-
-TrackerDBResultSet * tracker_db_get_files_by_service (DBConnection *db_con, const char *service, int offset, int limit);
-TrackerDBResultSet * tracker_db_get_files_by_mime (DBConnection *db_con, char **mimes, int n, int offset, int limit, gboolean vfs);
-TrackerDBResultSet * tracker_db_search_text_mime (DBConnection *db_con, const char *text, char **mime_array);
-TrackerDBResultSet * tracker_db_search_text_location (DBConnection *db_con, const char *text,const char *location);
-TrackerDBResultSet * tracker_db_search_text_mime_location (DBConnection *db_con, const char *text, char **mime_array, const char *location);
-
-TrackerDBResultSet * tracker_db_get_file_subfolders (DBConnection *db_con, const char *uri);
-
-TrackerDBResultSet * tracker_db_get_metadata_types (DBConnection *db_con, const char *class, gboolean writeable);
-
-TrackerDBResultSet * tracker_db_get_sub_watches (DBConnection *db_con, const char *dir);
-TrackerDBResultSet * tracker_db_delete_sub_watches (DBConnection *db_con, const char *dir);
-
-TrackerDBResultSet * tracker_db_get_keyword_list (DBConnection *db_con, const char *service);
-
-void tracker_db_update_index_multiple_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, char **values);
-
-void tracker_db_get_static_data (DBConnection *db_con);
-
-DBConnection * tracker_db_get_service_connection (DBConnection *db_con, const char *service);
-
-char * tracker_db_get_service_for_entity (DBConnection *db_con, const char *id);
-
-gboolean tracker_db_metadata_is_child (DBConnection *db_con, const char *child, const char *parent);
-
-GHashTable * tracker_db_get_file_contents_words (DBConnection *db_con, guint32 id, GHashTable *old_table);
-
-GHashTable * tracker_db_get_indexable_content_words (DBConnection *db_con, guint32 id, GHashTable *table, gboolean embedded_only);
-
-gboolean tracker_db_has_display_metadata (FieldDef *def);
-
-gboolean tracker_db_load_service_file (DBConnection *db_con, const char *filename, gboolean full_path);
-
-char * tracker_db_get_field_name (const char *service, const char *meta_name);
-int tracker_metadata_is_key (const char *service, const char *meta_name);
-char * tracker_db_get_display_field (FieldDef *def);
-
-void tracker_db_delete_service (DBConnection *db_con, guint32 id, const char *uri);
-
-FieldData * tracker_db_get_metadata_field (DBConnection *db_con, const char *service, const char *field_name, int field_count, gboolean is_select, gboolean is_condition);
-
-void tracker_db_start_index_transaction (DBConnection *db_con);
-void tracker_db_end_index_transaction (DBConnection *db_con);
-gboolean tracker_db_regulate_transactions (DBConnection *db_con, int interval);
-
-
-char * tracker_db_get_option_string (DBConnection *db_con, const char *option);
-void tracker_db_set_option_string (DBConnection *db_con, const char *option, const char *value);
-int tracker_db_get_option_int (DBConnection *db_con, const char *option);
-void tracker_db_set_option_int (DBConnection *db_con, const char *option, int value);
-
-gboolean tracker_db_integrity_check (DBConnection *db_con);
+gchar ** tracker_db_get_row (gchar ***result,
+ gint num);
+unsigned int tracker_db_get_last_id (DBConnection *db_con);
+void tracker_db_free_result (gchar ***result);
+void tracker_db_log_result (gchar ***result);
+gint tracker_get_row_count (gchar ***result);
+gint tracker_get_field_count (gchar ***result);
+gboolean tracker_db_needs_setup (void);
+gboolean tracker_db_needs_data (void);
+gboolean tracker_db_initialize (void);
+void tracker_db_thread_init (void);
+void tracker_db_thread_end (void);
+void tracker_db_close (DBConnection *db_con);
+void tracker_db_finalize (void);
+DBConnection * tracker_db_connect (void);
+DBConnection * tracker_db_connect_common (void);
+DBConnection * tracker_db_connect_file_content (void);
+DBConnection * tracker_db_connect_email_content (void);
+DBConnection * tracker_db_connect_cache (void);
+DBConnection * tracker_db_connect_emails (void);
+DBConnection * tracker_db_connect_email_meta (void);
+DBConnection * tracker_db_connect_file_meta (void);
+DBConnection * tracker_db_connect_all (gboolean indexer_process);
+void tracker_db_close_all (DBConnection *db_con);
+void tracker_db_refresh_all (DBConnection *db_con);
+void tracker_db_refresh_email (DBConnection *db_con);
+gboolean tracker_update_db (DBConnection *db_con);
+gchar * tracker_escape_string (const gchar *in);
+void tracker_db_prepare_queries (DBConnection *db_con);
+TrackerDBResultSet *tracker_exec_proc (DBConnection *db_con,
+ const gchar *procedure,
+ ...);
+gboolean tracker_exec_proc_no_reply (DBConnection *db_con,
+ const gchar *procedure,
+ ...);
+gboolean tracker_db_exec_no_reply (DBConnection *db_con,
+ const gchar *query,
+ ...);
+void tracker_create_db (void);
+void tracker_db_load_stored_procs (DBConnection *db_con);
+void tracker_db_save_file_contents (DBConnection *db_con,
+ GHashTable *index_table,
+ GHashTable *old_table,
+ const gchar *file_name,
+ TrackerDBFileInfo *info);
+void tracker_db_clear_temp (DBConnection *db_con);
+void tracker_db_check_tables (DBConnection *db_con);
+gboolean tracker_db_start_transaction (DBConnection *db_con);
+gboolean tracker_db_end_transaction (DBConnection *db_con);
+void tracker_db_update_indexes_for_new_service (guint32 service_id,
+ gint service_type_id,
+ GHashTable *table);
+void tracker_db_update_differential_index (DBConnection *db_con,
+ GHashTable *old_table,
+ GHashTable *new_table,
+ const gchar *id,
+ gint service_type_id);
+void tracker_db_update_index_file_contents (DBConnection *blob_db_con,
+ GHashTable *index_table);
+gint tracker_db_flush_words_to_qdbm (DBConnection *db_con,
+ gint limit);
+void tracker_db_release_memory (void);
+void tracker_db_set_default_pragmas (DBConnection *db_con);
+void tracker_db_fsync (DBConnection *db_con,
+ gboolean enable);
+gchar * tracker_get_related_metadata_names (DBConnection *db_con,
+ const gchar *name);
+gchar * tracker_get_metadata_table (DataTypes type);
+TrackerDBResultSet *tracker_db_search_text (DBConnection *db_con,
+ const gchar *service,
+ const gchar *search_string,
+ gint offset,
+ gint limit,
+ gboolean save_results,
+ gboolean detailed);
+TrackerDBResultSet *tracker_db_search_files_by_text (DBConnection *db_con,
+ const gchar *text,
+ gint offset,
+ gint limit,
+ gboolean sort);
+TrackerDBResultSet *tracker_db_search_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *field,
+ const gchar *text,
+ gint offset,
+ gint limit);
+TrackerDBResultSet *tracker_db_search_matching_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *text);
+
+/* Gets metadata as a single row (with multiple values delimited by semicolons) */
+TrackerDBResultSet *tracker_db_get_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key);
+
+/* Gets metadata using a separate row for each value it has */
+gchar * tracker_db_get_metadata_delimited (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key);
+gchar * tracker_db_set_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ gchar **values,
+ gint length,
+ gboolean do_backup);
+void tracker_db_set_single_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ const gchar *value,
+ gboolean do_backup);
+void tracker_db_insert_embedded_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ gchar **values,
+ gint length,
+ GHashTable *table);
+void tracker_db_insert_single_embedded_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ const gchar *value,
+ GHashTable *table);
+void tracker_db_delete_metadata_value (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ const gchar *value);
+void tracker_db_delete_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ gboolean update_indexes);
+gchar * tracker_db_refresh_display_metadata (DBConnection *db_con,
+ const gchar *id,
+ const gchar *metadata_id,
+ gint data_type,
+ const gchar *key);
+void tracker_db_refresh_all_display_metadata (DBConnection *db_con,
+ const gchar *id);
+void tracker_db_update_keywords (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *value);
+guint32 tracker_db_create_service (DBConnection *db_con,
+ const gchar *service,
+ TrackerDBFileInfo *info);
+void tracker_db_delete_file (DBConnection *db_con,
+ guint32 file_id);
+void tracker_db_delete_directory (DBConnection *db_con,
+ guint32 file_id,
+ const gchar *uri);
+void tracker_db_update_file (DBConnection *db_con,
+ TrackerDBFileInfo *info);
+void tracker_db_move_file (DBConnection *db_con,
+ const gchar *moved_from_uri,
+ const gchar *moved_to_uri);
+void tracker_db_move_directory (DBConnection *db_con,
+ const gchar *moved_from_uri,
+ const gchar *moved_to_uri);
+guint32 tracker_db_get_file_id (DBConnection *db_con,
+ const gchar *uri);
+void tracker_db_insert_pending_file (DBConnection *db_con,
+ guint32 file_id,
+ const gchar *uri,
+ const gchar *moved_to_uri,
+ const gchar *mime,
+ gint counter,
+ TrackerDBAction action,
+ gboolean is_directory,
+ gboolean is_new,
+ gint service_type_id);
+gboolean tracker_db_has_pending_files (DBConnection *db_con);
+gboolean tracker_db_has_pending_metadata (DBConnection *db_con);
+TrackerDBResultSet *tracker_db_get_pending_files (DBConnection *db_con);
+void tracker_db_remove_pending_files (DBConnection *db_con);
+TrackerDBResultSet *tracker_db_get_pending_metadata (DBConnection *db_con);
+void tracker_db_remove_pending_metadata (DBConnection *db_con);
+void tracker_db_insert_pending (DBConnection *db_con,
+ const gchar *id,
+ const gchar *action,
+ const gchar *counter,
+ const gchar *uri,
+ const gchar *mime,
+ gboolean is_dir,
+ gboolean is_new,
+ gint service_type_id);
+void tracker_db_update_pending (DBConnection *db_con,
+ const gchar *counter,
+ const gchar *action,
+ const gchar *uri);
+TrackerDBResultSet *tracker_db_get_files_by_service (DBConnection *db_con,
+ const gchar *service,
+ gint offset,
+ gint limit);
+TrackerDBResultSet *tracker_db_get_files_by_mime (DBConnection *db_con,
+ gchar **mimes,
+ gint n,
+ gint offset,
+ gint limit,
+ gboolean vfs);
+TrackerDBResultSet *tracker_db_search_text_mime (DBConnection *db_con,
+ const gchar *text,
+ gchar **mime_array);
+TrackerDBResultSet *tracker_db_search_text_location (DBConnection *db_con,
+ const gchar *text,
+ const gchar *location);
+TrackerDBResultSet *tracker_db_search_text_mime_location (DBConnection *db_con,
+ const gchar *text,
+ gchar **mime_array,
+ const gchar *location);
+TrackerDBResultSet *tracker_db_get_file_subfolders (DBConnection *db_con,
+ const gchar *uri);
+TrackerDBResultSet *tracker_db_get_metadata_types (DBConnection *db_con,
+ const gchar *class,
+ gboolean writeable);
+TrackerDBResultSet *tracker_db_get_sub_watches (DBConnection *db_con,
+ const gchar *dir);
+TrackerDBResultSet *tracker_db_delete_sub_watches (DBConnection *db_con,
+ const gchar *dir);
+TrackerDBResultSet *tracker_db_get_keyword_list (DBConnection *db_con,
+ const gchar *service);
+void tracker_db_update_index_multiple_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ gchar **values);
+void tracker_db_get_static_data (DBConnection *db_con);
+DBConnection * tracker_db_get_service_connection (DBConnection *db_con,
+ const gchar *service);
+gchar * tracker_db_get_service_for_entity (DBConnection *db_con,
+ const gchar *id);
+gboolean tracker_db_metadata_is_child (DBConnection *db_con,
+ const gchar *child,
+ const gchar *parent);
+GHashTable * tracker_db_get_file_contents_words (DBConnection *db_con,
+ guint32 id,
+ GHashTable *old_table);
+GHashTable * tracker_db_get_indexable_content_words (DBConnection *db_con,
+ guint32 id,
+ GHashTable *table,
+ gboolean embedded_only);
+gboolean tracker_db_has_display_metadata (FieldDef *def);
+gboolean tracker_db_load_service_file (DBConnection *db_con,
+ const gchar *filename,
+ gboolean full_path);
+gchar * tracker_db_get_field_name (const gchar *service,
+ const gchar *meta_name);
+gint tracker_metadata_is_key (const gchar *service,
+ const gchar *meta_name);
+gchar * tracker_db_get_display_field (FieldDef *def);
+void tracker_db_delete_service (DBConnection *db_con,
+ guint32 id,
+ const gchar *uri);
+FieldData * tracker_db_get_metadata_field (DBConnection *db_con,
+ const gchar *service,
+ const gchar *field_name,
+ gint field_count,
+ gboolean is_select,
+ gboolean is_condition);
+void tracker_db_start_index_transaction (DBConnection *db_con);
+void tracker_db_end_index_transaction (DBConnection *db_con);
+gboolean tracker_db_regulate_transactions (DBConnection *db_con,
+ gint interval);
+gchar * tracker_db_get_option_string (DBConnection *db_con,
+ const gchar *option);
+void tracker_db_set_option_string (DBConnection *db_con,
+ const gchar *option,
+ const gchar *value);
+gint tracker_db_get_option_int (DBConnection *db_con,
+ const gchar *option);
+void tracker_db_set_option_int (DBConnection *db_con,
+ const gchar *option,
+ gint value);
+gboolean tracker_db_integrity_check (DBConnection *db_con);
#endif
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 Wed Apr 30 11:54:10 2008
@@ -1,4 +1,5 @@
-/* Tracker - indexer and metadata database engine
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2007, Jason Kivlighn (jkivlighn gmail com)
* Copyright (C) 2007, Creative Commons (http://creativecommons.org)
@@ -139,8 +140,8 @@
}
-FileInfo *
-tracker_db_get_file_info (DBConnection *db_con, FileInfo *info)
+TrackerDBFileInfo *
+tracker_db_get_file_info (DBConnection *db_con, TrackerDBFileInfo *info)
{
TrackerDBResultSet *result_set;
gchar *path, *name;
@@ -367,11 +368,11 @@
}
-FileInfo *
+TrackerDBFileInfo *
tracker_db_get_pending_file (DBConnection *db_con, const char *uri)
{
TrackerDBResultSet *result_set;
- FileInfo *info;
+ TrackerDBFileInfo *info;
info = NULL;
result_set = tracker_exec_proc (db_con->cache, "SelectPendingByUri", uri, NULL);
@@ -391,7 +392,7 @@
8, &service_type_id,
-1);
- info = tracker_create_file_info (uri, counter, 0, 0);
+ info = tracker_db_file_info_new (uri, counter, 0, 0);
info->mime = mimetype;
info->is_directory = is_directory;
info->is_new = is_new;
@@ -405,9 +406,8 @@
return info;
}
-
static void
-make_pending_file (DBConnection *db_con, guint32 file_id, const char *uri, const char *moved_to_uri, const char *mime, int counter, TrackerAction action, gboolean is_directory, gboolean is_new, int service_type_id)
+make_pending_file (DBConnection *db_con, guint32 file_id, const char *uri, const char *moved_to_uri, const char *mime, int counter, TrackerDBAction action, gboolean is_directory, gboolean is_new, int service_type_id)
{
char *str_file_id, *str_action, *str_counter;
@@ -419,7 +419,7 @@
if (tracker->is_running) {
- gboolean move_file = (action == TRACKER_ACTION_FILE_MOVED_FROM || action == TRACKER_ACTION_DIRECTORY_MOVED_FROM);
+ gboolean move_file = (action == TRACKER_DB_ACTION_FILE_MOVED_FROM || action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM);
if (!move_file && ((counter > 0) || (g_async_queue_length (tracker->file_process_queue) > tracker->max_process_queue_size))) {
@@ -432,9 +432,9 @@
} else {
- FileInfo *info;
+ TrackerDBFileInfo *info;
- info = tracker_create_file_info (uri, action, 0, WATCH_OTHER);
+ info = tracker_db_file_info_new (uri, action, 0, TRACKER_DB_WATCH_OTHER);
info->is_directory = is_directory;
info->is_new = is_new;
@@ -445,11 +445,11 @@
info->mime = g_strdup (mime);
}
- if (action == TRACKER_ACTION_FILE_MOVED_FROM || action == TRACKER_ACTION_DIRECTORY_MOVED_FROM) {
+ if (action == TRACKER_DB_ACTION_FILE_MOVED_FROM || action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM) {
info->moved_to_uri = g_strdup (moved_to_uri);
}
- if (action != TRACKER_ACTION_EXTRACT_METADATA) {
+ if (action != TRACKER_DB_ACTION_EXTRACT_METADATA) {
g_async_queue_push (tracker->file_process_queue, info);
} else {
g_async_queue_push (tracker->file_metadata_queue, info);
@@ -466,7 +466,7 @@
/* tracker_log ("inserting pending file for %s with action %s", uri, tracker_actions[action]); */
/* signal respective thread that data is available and awake it if its asleep */
- if (action == TRACKER_ACTION_EXTRACT_METADATA) {
+ if (action == TRACKER_DB_ACTION_EXTRACT_METADATA) {
tracker_notify_meta_data_available ();
} else {
tracker_notify_file_data_available ();
@@ -479,7 +479,7 @@
void
-tracker_db_update_pending_file (DBConnection *db_con, const char *uri, int counter, TrackerAction action)
+tracker_db_update_pending_file (DBConnection *db_con, const char *uri, int counter, TrackerDBAction action)
{
char *str_counter, *str_action;
@@ -498,7 +498,7 @@
void
-tracker_db_add_to_extract_queue (DBConnection *db_con, FileInfo *info)
+tracker_db_add_to_extract_queue (DBConnection *db_con, TrackerDBFileInfo *info)
{
int i;
@@ -510,12 +510,12 @@
if (i < tracker->max_extract_queue_size) {
/* inc ref count to prevent it being deleted */
- info = tracker_inc_info_ref (info);
+ info = tracker_db_file_info_ref (info);
g_async_queue_push (tracker->file_metadata_queue, info);
} else {
- tracker_db_insert_pending_file (db_con, info->file_id, info->uri, NULL, info->mime, 0, TRACKER_ACTION_EXTRACT_METADATA, info->is_directory, info->is_new, info->service_type_id);
+ tracker_db_insert_pending_file (db_con, info->file_id, info->uri, NULL, info->mime, 0, TRACKER_DB_ACTION_EXTRACT_METADATA, info->is_directory, info->is_new, info->service_type_id);
}
tracker_notify_meta_data_available ();
@@ -581,9 +581,9 @@
static void
index_blacklist_file (char *uri)
{
- FileInfo *info;
+ TrackerDBFileInfo *info;
- info = tracker_create_file_info (uri, TRACKER_ACTION_FILE_CHECK, 0, WATCH_OTHER);
+ info = tracker_db_file_info_new (uri, TRACKER_DB_ACTION_FILE_CHECK, 0, TRACKER_DB_WATCH_OTHER);
info->is_directory = FALSE;
@@ -686,15 +686,15 @@
}
void
-tracker_db_insert_pending_file (DBConnection *db_con, guint32 file_id, const char *uri, const char *moved_to_uri, const char *mime, int counter, TrackerAction action, gboolean is_directory, gboolean is_new, int service_type_id)
+tracker_db_insert_pending_file (DBConnection *db_con, guint32 file_id, const char *uri, const char *moved_to_uri, const char *mime, int counter, TrackerDBAction action, gboolean is_directory, gboolean is_new, int service_type_id)
{
- FileInfo *info;
+ TrackerDBFileInfo *info;
g_return_if_fail (tracker_check_uri (uri));
/* check if uri changed too frequently */
- if (((action == TRACKER_ACTION_CHECK) ||
- (action == TRACKER_ACTION_FILE_CHECK) || (action == TRACKER_ACTION_WRITABLE_FILE_CLOSED)) &&
+ if (((action == TRACKER_DB_ACTION_CHECK) ||
+ (action == TRACKER_DB_ACTION_FILE_CHECK) || (action == TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED)) &&
check_uri_changed_frequently (uri)) {
return;
@@ -707,45 +707,45 @@
if (info) {
switch (action) {
- case TRACKER_ACTION_FILE_CHECK:
+ case TRACKER_DB_ACTION_FILE_CHECK:
/* update counter for any existing event in the file_scheduler */
- if ((info->action == TRACKER_ACTION_FILE_CHECK) ||
- (info->action == TRACKER_ACTION_FILE_CREATED) ||
- (info->action == TRACKER_ACTION_FILE_CHANGED)) {
+ if ((info->action == TRACKER_DB_ACTION_FILE_CHECK) ||
+ (info->action == TRACKER_DB_ACTION_FILE_CREATED) ||
+ (info->action == TRACKER_DB_ACTION_FILE_CHANGED)) {
tracker_db_update_pending_file (db_con, uri, counter, action);
}
break;
- case TRACKER_ACTION_FILE_CHANGED:
+ case TRACKER_DB_ACTION_FILE_CHANGED:
tracker_db_update_pending_file (db_con, uri, counter, action);
break;
- case TRACKER_ACTION_WRITABLE_FILE_CLOSED:
+ case TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED:
tracker_db_update_pending_file (db_con, uri, 0, action);
break;
- case TRACKER_ACTION_FILE_DELETED:
- case TRACKER_ACTION_FILE_CREATED:
- case TRACKER_ACTION_DIRECTORY_DELETED:
- case TRACKER_ACTION_DIRECTORY_CREATED:
+ case TRACKER_DB_ACTION_FILE_DELETED:
+ case TRACKER_DB_ACTION_FILE_CREATED:
+ case TRACKER_DB_ACTION_DIRECTORY_DELETED:
+ case TRACKER_DB_ACTION_DIRECTORY_CREATED:
/* overwrite any existing event in the file_scheduler */
tracker_db_update_pending_file (db_con, uri, 0, action);
break;
- case TRACKER_ACTION_EXTRACT_METADATA:
+ case TRACKER_DB_ACTION_EXTRACT_METADATA:
/* we only want to continue extracting metadata if file is not being changed/deleted in any way */
- if (info->action == TRACKER_ACTION_FILE_CHECK) {
+ if (info->action == TRACKER_DB_ACTION_FILE_CHECK) {
tracker_db_update_pending_file (db_con, uri, 0, action);
}
@@ -755,7 +755,7 @@
break;
}
- tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
} else {
make_pending_file (db_con, file_id, uri, moved_to_uri, mime, counter, action, is_directory, is_new, service_type_id);
@@ -788,7 +788,7 @@
void
-tracker_db_index_service (DBConnection *db_con, FileInfo *info, const char *service, GHashTable *meta_table, const char *attachment_uri, const char *attachment_service, gboolean get_embedded, gboolean get_full_text, gboolean get_thumbs)
+tracker_db_index_service (DBConnection *db_con, TrackerDBFileInfo *info, const char *service, GHashTable *meta_table, const char *attachment_uri, const char *attachment_service, gboolean get_embedded, gboolean get_full_text, gboolean get_thumbs)
{
char *str_file_id;
const char *uri;
@@ -1020,7 +1020,7 @@
const gchar *curr_ext;
const gchar *curr_filename;
- FileInfo *master_info;
+ TrackerDBFileInfo *master_info;
gchar *master_uri;
while ((curr_filename = g_dir_read_name (dir)) != NULL) {
@@ -1036,7 +1036,7 @@
tracker_debug ("master file, %s, about to be updated", curr_filename);
master_uri = g_build_filename (dirname, curr_filename, NULL);
- master_info = tracker_create_file_info (master_uri, TRACKER_ACTION_FILE_CHANGED, 0, 0);
+ master_info = tracker_db_file_info_new (master_uri, TRACKER_DB_ACTION_FILE_CHANGED, 0, 0);
master_info = tracker_db_get_file_info (db_con, master_info);
g_free (master_uri);
@@ -1050,7 +1050,7 @@
void
-tracker_db_index_file (DBConnection *db_con, FileInfo *info, const char *attachment_uri, const char *attachment_service)
+tracker_db_index_file (DBConnection *db_con, TrackerDBFileInfo *info, const char *attachment_uri, const char *attachment_service)
{
GHashTable *meta_table;
@@ -1237,12 +1237,12 @@
tracker_file_unlink (info->uri);
}
- tracker_dec_info_ref (info);
+ tracker_db_file_info_unref (info);
}
void
-tracker_db_index_conversation (DBConnection *db_con, FileInfo *info)
+tracker_db_index_conversation (DBConnection *db_con, TrackerDBFileInfo *info)
{
/* to do use offsets */
@@ -1250,7 +1250,7 @@
}
void
-tracker_db_index_webhistory(DBConnection *db_con, FileInfo *info)
+tracker_db_index_webhistory(DBConnection *db_con, TrackerDBFileInfo *info)
{
tracker_db_index_file (db_con, info, NULL, "WebHistory");
}
Modified: branches/indexer-split/src/trackerd/tracker-db.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.h (original)
+++ branches/indexer-split/src/trackerd/tracker-db.h Wed Apr 30 11:54:10 2008
@@ -1,4 +1,5 @@
-/* Tracker - indexer and metadata database engine
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
*
* This library is free software; you can redistribute it and/or
@@ -17,39 +18,73 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef _TRACKER_DB_H_
-#define _TRACKER_DB_H_
+#ifndef __TRACKER_DB_H__
+#define __TRACKER_DB_H__
-#include <glib.h>
+#include "config.h"
-#include "tracker-utils.h"
+#include <glib.h>
-#include "config.h"
+#include <libtracker-db/tracker-db-file-info.h>
+#include "tracker-utils.h"
#include "tracker-db-sqlite.h"
-gboolean tracker_db_is_file_up_to_date (DBConnection *db_con, const char *uri, guint32 *id);
-FileInfo * tracker_db_get_file_info (DBConnection *db_con, FileInfo *info);
-gboolean tracker_is_valid_service (DBConnection *db_con, const char *service);
-char * tracker_db_get_id (DBConnection *db_con, const char *service, const char *uri);
-GHashTable * tracker_db_save_metadata (DBConnection *db_con, GHashTable *table, GHashTable *index_table, const char *service, guint32 file_id, gboolean new_file);
-void tracker_db_save_thumbs (DBConnection *db_con, const char *small_thumb, const char *large_thumb, guint32 file_id);
-char ** tracker_db_get_files_in_folder (DBConnection *db_con, const char *folder_uri);
-FieldDef * tracker_db_get_field_def (DBConnection *db_con, const char *field_name);
-void tracker_db_free_field_def (FieldDef *def);
-gboolean tracker_metadata_is_date (DBConnection *db_con, const char *meta);
-FileInfo * tracker_db_get_pending_file (DBConnection *db_con, const char *uri);
-void tracker_db_update_pending_file (DBConnection *db_con, const char *uri, int counter, TrackerAction action);
-void tracker_db_add_to_extract_queue (DBConnection *db_con, FileInfo *info);
-gboolean tracker_db_has_pending_files (DBConnection *db_con);
-gboolean tracker_db_has_pending_metadata (DBConnection *db_con);
-
-void tracker_db_index_service (DBConnection *db_con, FileInfo *info, const char *service, GHashTable *meta_table, const char *attachment_uri, const char *attachment_service,
- gboolean get_embedded, gboolean get_full_text, gboolean get_thumbs);
-
-void tracker_db_index_file (DBConnection *db_con, FileInfo *info, const char *attachment_uri, const char *attachment_service);
-void tracker_db_index_conversation (DBConnection *db_con, FileInfo *info);
-void tracker_db_index_application (DBConnection *db_con, FileInfo *info);
-void tracker_db_index_webhistory (DBConnection *db_con, FileInfo *info);
+gboolean tracker_db_is_file_up_to_date (DBConnection *db_con,
+ const gchar *uri,
+ guint32 *id);
+TrackerDBFileInfo *tracker_db_get_file_info (DBConnection *db_con,
+ TrackerDBFileInfo *info);
+gboolean tracker_is_valid_service (DBConnection *db_con,
+ const gchar *service);
+gchar * tracker_db_get_id (DBConnection *db_con,
+ const gchar *service,
+ const gchar *uri);
+GHashTable * tracker_db_save_metadata (DBConnection *db_con,
+ GHashTable *table,
+ GHashTable *index_table,
+ const gchar *service,
+ guint32 file_id,
+ gboolean new_file);
+void tracker_db_save_thumbs (DBConnection *db_con,
+ const gchar *small_thumb,
+ const gchar *large_thumb,
+ guint32 file_id);
+gchar ** tracker_db_get_files_in_folder (DBConnection *db_con,
+ const gchar *folder_uri);
+FieldDef * tracker_db_get_field_def (DBConnection *db_con,
+ const gchar *field_name);
+void tracker_db_free_field_def (FieldDef *def);
+gboolean tracker_metadata_is_date (DBConnection *db_con,
+ const gchar *meta);
+TrackerDBFileInfo *tracker_db_get_pending_file (DBConnection *db_con,
+ const gchar *uri);
+void tracker_db_update_pending_file (DBConnection *db_con,
+ const gchar *uri,
+ gint counter,
+ TrackerDBAction action);
+void tracker_db_add_to_extract_queue (DBConnection *db_con,
+ TrackerDBFileInfo *info);
+gboolean tracker_db_has_pending_files (DBConnection *db_con);
+gboolean tracker_db_has_pending_metadata (DBConnection *db_con);
+void tracker_db_index_service (DBConnection *db_con,
+ TrackerDBFileInfo *info,
+ const gchar *service,
+ GHashTable *meta_table,
+ const gchar *attachment_uri,
+ const gchar *attachment_service,
+ gboolean get_embedded,
+ gboolean get_full_text,
+ gboolean get_thumbs);
+void tracker_db_index_file (DBConnection *db_con,
+ TrackerDBFileInfo *info,
+ const gchar *attachment_uri,
+ const gchar *attachment_service);
+void tracker_db_index_conversation (DBConnection *db_con,
+ TrackerDBFileInfo *info);
+void tracker_db_index_application (DBConnection *db_con,
+ TrackerDBFileInfo *info);
+void tracker_db_index_webhistory (DBConnection *db_con,
+ TrackerDBFileInfo *info);
#endif
Modified: branches/indexer-split/src/trackerd/tracker-dbus-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-files.c Wed Apr 30 11:54:10 2008
@@ -174,10 +174,10 @@
exists = file_id > 0;
if (!exists && auto_create) {
- FileInfo *info;
+ TrackerDBFileInfo *info;
gchar *service;
- info = tracker_create_file_info (uri, 1, 0, 0);
+ info = tracker_db_file_info_new (uri, 1, 0, 0);
if (!tracker_file_is_valid (uri)) {
info->mime = g_strdup ("unknown");
@@ -185,11 +185,11 @@
} else {
info->mime = tracker_file_get_mime_type (uri);
service = tracker_service_manager_get_service_type_for_mime (info->mime);
- info = tracker_get_file_info (info);
+ info = tracker_db_file_info_get (info);
}
tracker_db_create_service (db_con, "Files", info);
- tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
g_free (service);
}
@@ -212,7 +212,7 @@
TrackerDBusFilesPriv *priv;
guint request_id;
DBConnection *db_con;
- FileInfo *info;
+ TrackerDBFileInfo *info;
gchar *name;
gchar *path;
gchar *service;
@@ -241,7 +241,7 @@
mtime);
/* Create structure */
- info = tracker_create_file_info (uri, 1, 0, 0);
+ info = tracker_db_file_info_new (uri, 1, 0, 0);
info->mime = g_strdup (mime);
info->is_directory = is_directory;
@@ -258,7 +258,7 @@
service = tracker_service_manager_get_service_type_for_mime (mime);
file_id = tracker_db_create_service (db_con, service, info);
- tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
created = file_id != 0;
@@ -338,7 +338,7 @@
gchar *name;
gchar *path;
gboolean is_directory;
- TrackerAction action;
+ TrackerDBAction action;
request_id = tracker_dbus_get_next_request_id ();
@@ -379,9 +379,9 @@
}
if (is_directory) {
- action = TRACKER_ACTION_DIRECTORY_DELETED;
+ action = TRACKER_DB_ACTION_DIRECTORY_DELETED;
} else {
- action = TRACKER_ACTION_FILE_DELETED;
+ action = TRACKER_DB_ACTION_FILE_DELETED;
}
tracker_db_insert_pending_file (db_con,
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 Wed Apr 30 11:54:10 2008
@@ -1,5 +1,5 @@
-/* Tracker
- * routines for emails with Evolution
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2006, Laurent Aguerreche (laurent aguerreche free fr)
*
* This library is free software; you can redistribute it and/or
@@ -37,6 +37,8 @@
#include <libtracker-common/tracker-type-utils.h>
#include <libtracker-common/tracker-utils.h>
+#include <libtracker-db/tracker-db-file-info.h>
+
#include "tracker-email-utils.h"
#include "tracker-db-email.h"
#include "tracker-cache.h"
@@ -314,7 +316,7 @@
static gboolean
-evolution_file_is_interesting (FileInfo *info)
+evolution_file_is_interesting (TrackerDBFileInfo *info)
{
GSList *dir;
@@ -370,7 +372,7 @@
gboolean
-tracker_email_index_file (DBConnection *db_con, FileInfo *info)
+tracker_email_index_file (DBConnection *db_con, TrackerDBFileInfo *info)
{
gchar *file_name;
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 Wed Apr 30 11:54:10 2008
@@ -81,7 +81,7 @@
static GSList * get_dirs_to_watch (DBConnection *db_con, const gchar *dir_path, gboolean in_imap_dir);
static gboolean ignore_email (const gchar *uri);
static KMailMailProtocol find_mail_protocol (const gchar *mail_path);
-static gboolean index_mail_file_in_maildir_dir (DBConnection *db_con, const gchar *dir, FileInfo *info, MailType mail_type);
+static gboolean index_mail_file_in_maildir_dir (DBConnection *db_con, const gchar *dir, TrackerDBFileInfo *info, MailType mail_type);
//static void watch_imap_cache (DBConnection *db_con, const gchar *imap_dir_path);
//static void watch_local_maildir_dir (DBConnection *db_con, const gchar *dir_path);
@@ -159,7 +159,7 @@
static gboolean
-kmail_file_is_interesting (FileInfo *info)
+kmail_file_is_interesting (TrackerDBFileInfo *info)
{
const GSList *account;
@@ -185,7 +185,7 @@
gboolean
-tracker_email_index_file (DBConnection *db_con, FileInfo *info)
+tracker_email_index_file (DBConnection *db_con, TrackerDBFileInfo *info)
{
KMailMailProtocol mail_protocol;
@@ -703,7 +703,7 @@
static gboolean
-index_mail_file_in_maildir_dir (DBConnection *db_con, const gchar *dir, FileInfo *info, MailType mail_type)
+index_mail_file_in_maildir_dir (DBConnection *db_con, const gchar *dir, TrackerDBFileInfo *info, MailType mail_type)
{
MailStore *store;
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 Wed Apr 30 11:54:10 2008
@@ -319,7 +319,7 @@
}
static gboolean
-modest_file_is_interesting (FileInfo *info)
+modest_file_is_interesting (TrackerDBFileInfo *info)
{
g_return_val_if_fail (info, FALSE);
g_return_val_if_fail (info->uri, FALSE);
@@ -338,7 +338,7 @@
gboolean
-tracker_email_index_file (DBConnection *db_con, FileInfo *info)
+tracker_email_index_file (DBConnection *db_con, TrackerDBFileInfo *info)
{
gchar *file_name;
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 Wed Apr 30 11:54:10 2008
@@ -91,7 +91,7 @@
}
static gboolean
-thunderbird_file_is_interesting (FileInfo *info)
+thunderbird_file_is_interesting (TrackerDBFileInfo *info)
{
//Filename should be objectX.tms (Thunderbird Message Summary)
return g_str_has_suffix (info->uri, ".tms") ;
@@ -135,7 +135,7 @@
gboolean
-tracker_email_index_file (DBConnection *db_con, FileInfo *info)
+tracker_email_index_file (DBConnection *db_con, TrackerDBFileInfo *info)
{
g_return_val_if_fail (db_con, FALSE);
g_return_val_if_fail (info, FALSE);
Modified: branches/indexer-split/src/trackerd/tracker-email.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email.c Wed Apr 30 11:54:10 2008
@@ -1,5 +1,5 @@
-/* Tracker
- * routines for emails
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2006, Laurent Aguerreche (laurent aguerreche free fr)
*
* This library is free software; you can redistribute it and/or
@@ -64,7 +64,7 @@
gboolean
-tracker_email_index_file (DBConnection *db_con, FileInfo *info)
+tracker_email_index_file (DBConnection *db_con, TrackerDBFileInfo *info)
{
TrackerMailIndexFile func;
Modified: branches/indexer-split/src/trackerd/tracker-email.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email.h (original)
+++ branches/indexer-split/src/trackerd/tracker-email.h Wed Apr 30 11:54:10 2008
@@ -1,5 +1,5 @@
-/* Tracker
- * routines for emails
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2006, Laurent Aguerreche (laurent aguerreche free fr)
*
* This library is free software; you can redistribute it and/or
@@ -18,28 +18,29 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef _TRACKER_EMAIL_H_
-#define _TRACKER_EMAIL_H_
-
-#include "tracker-utils.h"
+#ifndef __TRACKER_EMAIL_H__
+#define __TRACKER_EMAIL_H__
#include "config.h"
+#include <libtracker-db/tracker-db-file-info.h>
+
+#include "tracker-utils.h"
#include "tracker-db-sqlite.h"
typedef gboolean (* TrackerMailInit) (void);
typedef void (* TrackerMailFinalize) (void);
typedef void (* TrackerMailWatchEmails) (DBConnection *db_con);
typedef gboolean (* TrackerMailIndexFile) (DBConnection *db_con,
- FileInfo *info);
+ TrackerDBFileInfo *info);
typedef const gchar * (* TrackerMailGetName) (void);
-gboolean tracker_email_init (void);
-void tracker_email_add_service_directories (DBConnection *db_con);
-void tracker_email_end_email_watching (void);
-gboolean tracker_email_file_is_interesting (FileInfo *info);
-gboolean tracker_email_index_file (DBConnection *db_con, FileInfo *info);
-const gchar * tracker_email_get_name (void);
-
+gboolean tracker_email_init (void);
+void tracker_email_add_service_directories (DBConnection *db_con);
+void tracker_email_end_email_watching (void);
+gboolean tracker_email_file_is_interesting (TrackerDBFileInfo *info);
+gboolean tracker_email_index_file (DBConnection *db_con,
+ TrackerDBFileInfo *info);
+const gchar *tracker_email_get_name (void);
#endif
Modified: branches/indexer-split/src/trackerd/tracker-inotify.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-inotify.c (original)
+++ branches/indexer-split/src/trackerd/tracker-inotify.c Wed Apr 30 11:54:10 2008
@@ -37,9 +37,10 @@
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-utils.h>
+#include <libtracker-db/tracker-db-action.h>
+
#include "tracker-watch.h"
#include "tracker-process-files.h"
-#include "tracker-action.h"
#define INOTIFY_WATCH_LIMIT "/proc/sys/fs/inotify/max_user_watches"
@@ -86,24 +87,24 @@
static gboolean
-is_delete_event (TrackerAction event_type)
+is_delete_event (TrackerDBAction event_type)
{
- return (event_type == TRACKER_ACTION_DELETE ||
- event_type == TRACKER_ACTION_DELETE_SELF ||
- event_type == TRACKER_ACTION_FILE_DELETED ||
- event_type == TRACKER_ACTION_DIRECTORY_DELETED);
+ return (event_type == TRACKER_DB_ACTION_DELETE ||
+ event_type == TRACKER_DB_ACTION_DELETE_SELF ||
+ event_type == TRACKER_DB_ACTION_FILE_DELETED ||
+ event_type == TRACKER_DB_ACTION_DIRECTORY_DELETED);
}
static void
-process_event (const char *uri, gboolean is_dir, TrackerAction action, guint32 cookie)
+process_event (const char *uri, gboolean is_dir, TrackerDBAction action, guint32 cookie)
{
- FileInfo *info;
+ TrackerDBFileInfo *info;
g_return_if_fail (uri && (uri[0] == '/'));
- info = tracker_create_file_info (uri, action, 1, WATCH_OTHER);
+ info = tracker_db_file_info_new (uri, action, 1, TRACKER_DB_WATCH_OTHER);
if (!tracker_process_files_is_file_info_valid (info)) {
return;
@@ -120,7 +121,8 @@
g_async_queue_push (tracker->file_process_queue, info);
tracker_notify_file_data_available ();
} else {
- info = tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
+ info = NULL;
}
g_free (parent);
@@ -128,20 +130,20 @@
}
/* we are not interested in create events for non-folders (we use writable file closed instead) */
- if (action == TRACKER_ACTION_DIRECTORY_CREATED) {
+ if (action == TRACKER_DB_ACTION_DIRECTORY_CREATED) {
- info->action = TRACKER_ACTION_DIRECTORY_CREATED;
+ info->action = TRACKER_DB_ACTION_DIRECTORY_CREATED;
info->is_directory = TRUE;
tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, NULL, info->mime, 0, info->action, info->is_directory, TRUE, -1);
- info = tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
return;
- } else if (action == TRACKER_ACTION_FILE_CREATED) {
+ } else if (action == TRACKER_DB_ACTION_FILE_CREATED) {
tracker_add_io_grace (info->uri);
- info = tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
return;
- } else if (action == TRACKER_ACTION_DIRECTORY_MOVED_FROM || action == TRACKER_ACTION_FILE_MOVED_FROM) {
+ } else if (action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM || action == TRACKER_DB_ACTION_FILE_MOVED_FROM) {
tracker_add_io_grace (info->uri);
info->cookie = cookie;
info->counter = 1;
@@ -153,16 +155,16 @@
);
return;
- } else if (action == TRACKER_ACTION_FILE_MOVED_TO || action == TRACKER_ACTION_DIRECTORY_MOVED_TO) {
- FileInfo *moved_to_info;
+ } else if (action == TRACKER_DB_ACTION_FILE_MOVED_TO || action == TRACKER_DB_ACTION_DIRECTORY_MOVED_TO) {
+ TrackerDBFileInfo *moved_to_info;
GSList *tmp;
moved_to_info = info;
tracker_add_io_grace (info->uri);
for (tmp = move_list; tmp; tmp = tmp->next) {
- FileInfo *moved_from_info;
+ TrackerDBFileInfo *moved_from_info;
- moved_from_info = (FileInfo *) tmp->data;
+ moved_from_info = (TrackerDBFileInfo *) tmp->data;
if (!moved_from_info) {
tracker_error ("ERROR: bad FileInfo struct found in move list. Skipping...");
@@ -177,11 +179,11 @@
tracker->request_waiting = TRUE;
if (!tracker_file_is_directory (moved_to_info->uri)) {
- tracker_db_insert_pending_file (main_thread_db_con, moved_from_info->file_id, moved_from_info->uri, moved_to_info->uri, moved_from_info->mime, 0, TRACKER_ACTION_FILE_MOVED_FROM, FALSE, TRUE, -1);
+ tracker_db_insert_pending_file (main_thread_db_con, moved_from_info->file_id, moved_from_info->uri, moved_to_info->uri, moved_from_info->mime, 0, TRACKER_DB_ACTION_FILE_MOVED_FROM, FALSE, TRUE, -1);
// tracker_db_move_file (main_thread_db_con, moved_from_info->uri, moved_to_info->uri);
} else {
- tracker_db_insert_pending_file (main_thread_db_con, moved_from_info->file_id, moved_from_info->uri, moved_to_info->uri, moved_from_info->mime, 0, TRACKER_ACTION_DIRECTORY_MOVED_FROM, TRUE, TRUE, -1);
+ tracker_db_insert_pending_file (main_thread_db_con, moved_from_info->file_id, moved_from_info->uri, moved_to_info->uri, moved_from_info->mime, 0, TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM, TRUE, TRUE, -1);
// tracker_db_move_directory (main_thread_db_con, moved_from_info->uri, moved_to_info->uri);
}
@@ -194,27 +196,27 @@
/* matching pair not found so treat as a create action */
tracker_debug ("no matching pair found for inotify move event for %s", info->uri);
if (tracker_file_is_directory (info->uri)) {
- info->action = TRACKER_ACTION_DIRECTORY_CREATED;
+ info->action = TRACKER_DB_ACTION_DIRECTORY_CREATED;
} else {
- info->action = TRACKER_ACTION_WRITABLE_FILE_CLOSED;
+ info->action = TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED;
}
tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, NULL, info->mime, 10, info->action, info->is_directory, TRUE, -1);
- info = tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
return;
- } else if (action == TRACKER_ACTION_WRITABLE_FILE_CLOSED) {
+ } else if (action == TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED) {
tracker_add_io_grace (info->uri);
tracker_info ("File %s has finished changing", info->uri);
tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, NULL, info->mime, 0, info->action, info->is_directory, TRUE, -1);
- info = tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
return;
}
tracker_log ("WARNING: not processing event %s for uri %s",
- tracker_action_to_string (info->action),
+ tracker_db_action_to_string (info->action),
info->uri);
- tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
}
@@ -232,25 +234,25 @@
}
for (tmp = move_list; tmp; tmp = tmp->next) {
- FileInfo *info;
+ TrackerDBFileInfo *info;
- info = (FileInfo *) tmp->data;
+ info = (TrackerDBFileInfo *) tmp->data;
/* make it a DELETE if we have not received a corresponding MOVED_TO event after a certain period */
- if ((info->counter < 1) && ((info->action == TRACKER_ACTION_FILE_MOVED_FROM) || (info->action == TRACKER_ACTION_DIRECTORY_MOVED_FROM))) {
+ if ((info->counter < 1) && ((info->action == TRACKER_DB_ACTION_FILE_MOVED_FROM) || (info->action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM))) {
/* make sure file no longer exists before issuing a "delete" */
if (!tracker_file_is_valid (info->uri)) {
- if (info->action == TRACKER_ACTION_DIRECTORY_MOVED_FROM) {
- process_event (info->uri, TRUE, TRACKER_ACTION_DIRECTORY_DELETED, 0);
+ if (info->action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM) {
+ process_event (info->uri, TRUE, TRACKER_DB_ACTION_DIRECTORY_DELETED, 0);
} else {
- process_event (info->uri, FALSE, TRACKER_ACTION_FILE_DELETED, 0);
+ process_event (info->uri, FALSE, TRACKER_DB_ACTION_FILE_DELETED, 0);
}
}
move_list = g_slist_remove (move_list, info);
- tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
continue;
} else {
@@ -265,57 +267,57 @@
}
-static TrackerAction
+static TrackerDBAction
get_event (guint32 event_type)
{
if (event_type & IN_DELETE) {
if (event_type & IN_ISDIR) {
- return TRACKER_ACTION_DIRECTORY_DELETED;
+ return TRACKER_DB_ACTION_DIRECTORY_DELETED;
} else {
- return TRACKER_ACTION_FILE_DELETED;
+ return TRACKER_DB_ACTION_FILE_DELETED;
}
}
if (event_type & IN_DELETE_SELF) {
if (event_type & IN_ISDIR) {
- return TRACKER_ACTION_DIRECTORY_DELETED;
+ return TRACKER_DB_ACTION_DIRECTORY_DELETED;
} else {
- return TRACKER_ACTION_FILE_DELETED;
+ return TRACKER_DB_ACTION_FILE_DELETED;
}
}
if (event_type & IN_MOVED_FROM) {
if (event_type & IN_ISDIR) {
- return TRACKER_ACTION_DIRECTORY_MOVED_FROM;
+ return TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM;
} else {
- return TRACKER_ACTION_FILE_MOVED_FROM;
+ return TRACKER_DB_ACTION_FILE_MOVED_FROM;
}
}
if (event_type & IN_MOVED_TO) {
if (event_type & IN_ISDIR) {
- return TRACKER_ACTION_DIRECTORY_MOVED_TO;
+ return TRACKER_DB_ACTION_DIRECTORY_MOVED_TO;
} else {
- return TRACKER_ACTION_FILE_MOVED_TO;
+ return TRACKER_DB_ACTION_FILE_MOVED_TO;
}
}
if (event_type & IN_CLOSE_WRITE) {
- return TRACKER_ACTION_WRITABLE_FILE_CLOSED;
+ return TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED;
}
if (event_type & IN_CREATE) {
if (event_type & IN_ISDIR) {
- return TRACKER_ACTION_DIRECTORY_CREATED;
+ return TRACKER_DB_ACTION_DIRECTORY_CREATED;
} else {
- return TRACKER_ACTION_FILE_CREATED;
+ return TRACKER_DB_ACTION_FILE_CREATED;
}
}
- return TRACKER_ACTION_IGNORE;
+ return TRACKER_DB_ACTION_IGNORE;
}
static gboolean
@@ -323,7 +325,7 @@
{
while (g_queue_get_length (inotify_queue) > 0) {
TrackerDBResultSet *result_set;
- TrackerAction action_type;
+ TrackerDBAction action_type;
char *str = NULL, *filename = NULL, *monitor_name = NULL, *str_wd;
char *file_utf8_uri = NULL, *dir_utf8_uri = NULL;
guint cookie;
@@ -342,7 +344,7 @@
action_type = get_event (event->mask);
- if (action_type == TRACKER_ACTION_IGNORE) {
+ if (action_type == TRACKER_DB_ACTION_IGNORE) {
g_free (event);
continue;
}
@@ -409,7 +411,7 @@
if (str && str[0] == '/' &&
(!tracker_process_files_should_be_ignored (str) ||
- action_type == TRACKER_ACTION_DIRECTORY_MOVED_FROM) &&
+ action_type == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM) &&
tracker_process_files_should_be_crawled (tracker, str) &&
tracker_process_files_should_be_watched (tracker->config, str)) {
process_event (str, tracker_file_is_directory (str), action_type, cookie);
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 Wed Apr 30 11:54:10 2008
@@ -298,7 +298,7 @@
g_return_if_fail (tracker->index_db);
tracker_db_insert_pending_file (tracker->index_db, 0, uri, NULL, "unknown", 0,
- TRACKER_ACTION_DIRECTORY_REFRESH, TRUE, FALSE, -1);
+ TRACKER_DB_ACTION_DIRECTORY_REFRESH, TRUE, FALSE, -1);
}
static void
@@ -317,7 +317,7 @@
if (!tracker_file_is_directory (uri)) {
tracker_db_insert_pending_file (tracker->index_db, 0, uri, NULL, "unknown", 0,
- TRACKER_ACTION_CHECK, 0, FALSE, -1);
+ TRACKER_DB_ACTION_CHECK, 0, FALSE, -1);
} else {
process_schedule_directory_check_foreach (uri, tracker);
}
@@ -390,22 +390,22 @@
}
static void
-process_action_verify (FileInfo *info)
+process_action_verify (TrackerDBFileInfo *info)
{
/* Determines whether an action applies to a file or a
* directory.
*/
- if (info->action == TRACKER_ACTION_CHECK) {
+ if (info->action == TRACKER_DB_ACTION_CHECK) {
if (info->is_directory) {
- info->action = TRACKER_ACTION_DIRECTORY_CHECK;
+ info->action = TRACKER_DB_ACTION_DIRECTORY_CHECK;
info->counter = 0;
} else {
- info->action = TRACKER_ACTION_FILE_CHECK;
+ info->action = TRACKER_DB_ACTION_FILE_CHECK;
}
} else {
- if (info->action == TRACKER_ACTION_DELETE || info->action == TRACKER_ACTION_DELETE_SELF) {
+ if (info->action == TRACKER_DB_ACTION_DELETE || info->action == TRACKER_DB_ACTION_DELETE_SELF) {
/* we are in trouble if we cant find the deleted uri in the DB - assume its a directory (worst case) */
if (info->file_id == 0) {
@@ -414,36 +414,36 @@
info->counter = 0;
if (info->is_directory) {
- info->action = TRACKER_ACTION_DIRECTORY_DELETED;
+ info->action = TRACKER_DB_ACTION_DIRECTORY_DELETED;
} else {
- info->action = TRACKER_ACTION_FILE_DELETED;
+ info->action = TRACKER_DB_ACTION_FILE_DELETED;
}
} else {
- if (info->action == TRACKER_ACTION_MOVED_FROM) {
+ if (info->action == TRACKER_DB_ACTION_MOVED_FROM) {
info->counter = 1;
if (info->is_directory) {
- info->action = TRACKER_ACTION_DIRECTORY_MOVED_FROM;
+ info->action = TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM;
} else {
- info->action = TRACKER_ACTION_FILE_MOVED_FROM;
+ info->action = TRACKER_DB_ACTION_FILE_MOVED_FROM;
}
} else {
- if (info->action == TRACKER_ACTION_CREATE) {
+ if (info->action == TRACKER_DB_ACTION_CREATE) {
if (info->is_directory) {
- info->action = TRACKER_ACTION_DIRECTORY_CREATED;
+ info->action = TRACKER_DB_ACTION_DIRECTORY_CREATED;
info->counter = 0; /* do not reschedule a created directory */
} else {
- info->action = TRACKER_ACTION_FILE_CREATED;
+ info->action = TRACKER_DB_ACTION_FILE_CREATED;
}
} else {
- if (info->action == TRACKER_ACTION_FILE_MOVED_TO) {
+ if (info->action == TRACKER_DB_ACTION_FILE_MOVED_TO) {
info->counter = 0;
if (info->is_directory) {
- info->action = TRACKER_ACTION_DIRECTORY_MOVED_TO;
+ info->action = TRACKER_DB_ACTION_DIRECTORY_MOVED_TO;
} else {
- info->action = TRACKER_ACTION_FILE_MOVED_TO;
+ info->action = TRACKER_DB_ACTION_FILE_MOVED_TO;
}
}
}
@@ -453,8 +453,8 @@
}
static void
-process_index_entity (Tracker *tracker,
- FileInfo *info)
+process_index_entity (Tracker *tracker,
+ TrackerDBFileInfo *info)
{
TrackerService *def;
gchar *service_info;
@@ -524,8 +524,8 @@
}
static void
-process_index_delete_file (Tracker *tracker,
- FileInfo *info)
+process_index_delete_file (Tracker *tracker,
+ TrackerDBFileInfo *info)
{
/* Info struct may have been deleted in transit here so check
* if still valid and intact.
@@ -545,8 +545,8 @@
}
static void
-process_index_delete_directory (Tracker *tracker,
- FileInfo *info)
+process_index_delete_directory (Tracker *tracker,
+ TrackerDBFileInfo *info)
{
/* Info struct may have been deleted in transit here so check
* if still valid and intact.
@@ -585,9 +585,9 @@
gchar *str = *p;
if (!tracker_file_is_valid (str)) {
- FileInfo *info;
+ TrackerDBFileInfo *info;
- info = tracker_create_file_info (str, 1, 0, 0);
+ info = tracker_db_file_info_new (str, 1, 0, 0);
info = tracker_db_get_file_info (tracker->index_db, info);
if (!info->is_directory) {
@@ -595,7 +595,7 @@
} else {
process_index_delete_directory (tracker, info);
}
- tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
}
}
@@ -606,11 +606,11 @@
process_queue_files_foreach (const gchar *uri,
gpointer user_data)
{
- Tracker *tracker;
- FileInfo *info;
+ Tracker *tracker;
+ TrackerDBFileInfo *info;
tracker = (Tracker*) user_data;
- info = tracker_create_file_info (uri, TRACKER_ACTION_CHECK, 0, 0);
+ info = tracker_db_file_info_new (uri, TRACKER_DB_ACTION_CHECK, 0, 0);
g_async_queue_push (tracker->file_process_queue, info);
}
@@ -1244,8 +1244,8 @@
}
static gboolean
-process_action (Tracker *tracker,
- FileInfo *info)
+process_action (Tracker *tracker,
+ TrackerDBFileInfo *info)
{
DBConnection *db_con;
gboolean need_index;
@@ -1254,22 +1254,22 @@
need_index = info->mtime > info->indextime;
switch (info->action) {
- case TRACKER_ACTION_FILE_CHECK:
+ case TRACKER_DB_ACTION_FILE_CHECK:
break;
- case TRACKER_ACTION_FILE_CHANGED:
- case TRACKER_ACTION_FILE_CREATED:
- case TRACKER_ACTION_WRITABLE_FILE_CLOSED:
+ case TRACKER_DB_ACTION_FILE_CHANGED:
+ case TRACKER_DB_ACTION_FILE_CREATED:
+ case TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED:
need_index = TRUE;
break;
- case TRACKER_ACTION_FILE_MOVED_FROM:
+ case TRACKER_DB_ACTION_FILE_MOVED_FROM:
need_index = FALSE;
tracker_log ("Starting moving file %s to %s", info->uri, info->moved_to_uri);
tracker_db_move_file (db_con, info->uri, info->moved_to_uri);
break;
- case TRACKER_ACTION_DIRECTORY_REFRESH:
+ case TRACKER_DB_ACTION_DIRECTORY_REFRESH:
if (need_index &&
tracker_process_files_should_be_watched (tracker->config, info->uri)) {
g_async_queue_push (tracker->dir_queue, g_strdup (info->uri));
@@ -1282,7 +1282,7 @@
need_index = FALSE;
break;
- case TRACKER_ACTION_DIRECTORY_CHECK:
+ case TRACKER_DB_ACTION_DIRECTORY_CHECK:
if (need_index &&
tracker_process_files_should_be_watched (tracker->config, info->uri)) {
g_async_queue_push (tracker->dir_queue, g_strdup (info->uri));
@@ -1294,12 +1294,12 @@
break;
- case TRACKER_ACTION_DIRECTORY_MOVED_FROM:
+ case TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM:
tracker_db_move_directory (db_con, info->uri, info->moved_to_uri);
need_index = FALSE;
break;
- case TRACKER_ACTION_DIRECTORY_CREATED:
+ case TRACKER_DB_ACTION_DIRECTORY_CREATED:
need_index = TRUE;
tracker_debug ("Processing created directory %s", info->uri);
@@ -1333,8 +1333,8 @@
}
static gboolean
-process_action_prechecks (Tracker *tracker,
- FileInfo *info)
+process_action_prechecks (Tracker *tracker,
+ TrackerDBFileInfo *info)
{
DBConnection *db_con;
@@ -1348,14 +1348,14 @@
db_con = tracker->index_db;
if (info->file_id == 0 &&
- info->action != TRACKER_ACTION_CREATE &&
- info->action != TRACKER_ACTION_DIRECTORY_CREATED &&
- info->action != TRACKER_ACTION_FILE_CREATED) {
+ info->action != TRACKER_DB_ACTION_CREATE &&
+ info->action != TRACKER_DB_ACTION_DIRECTORY_CREATED &&
+ info->action != TRACKER_DB_ACTION_FILE_CREATED) {
info = tracker_db_get_file_info (db_con, info);
/* Get more file info if db retrieval returned nothing */
if (info->file_id == 0) {
- info = tracker_get_file_info (info);
+ info = tracker_db_file_info_get (info);
info->is_new = TRUE;
} else {
info->is_new = FALSE;
@@ -1366,7 +1366,7 @@
tracker_debug ("Processing %s with action %s and counter %d ",
info->uri,
- tracker_action_to_string (info->action),
+ tracker_db_action_to_string (info->action),
info->counter);
/* Preprocess ambiguous actions when we need to work
@@ -1375,10 +1375,10 @@
*/
process_action_verify (info);
- if (info->action != TRACKER_ACTION_DELETE &&
- info->action != TRACKER_ACTION_DIRECTORY_DELETED &&
- info->action != TRACKER_ACTION_DIRECTORY_UNMOUNTED &&
- info->action != TRACKER_ACTION_FILE_DELETED) {
+ if (info->action != TRACKER_DB_ACTION_DELETE &&
+ info->action != TRACKER_DB_ACTION_DIRECTORY_DELETED &&
+ info->action != TRACKER_DB_ACTION_DIRECTORY_UNMOUNTED &&
+ info->action != TRACKER_DB_ACTION_FILE_DELETED) {
if (!tracker_file_is_valid (info->uri) ) {
gboolean invalid = TRUE;
@@ -1387,7 +1387,7 @@
}
if (invalid) {
- tracker_free_file_info (info);
+ tracker_db_file_info_free (info);
return TRUE;
}
}
@@ -1397,16 +1397,16 @@
* is newly created.
*/
} else {
- if (info->action == TRACKER_ACTION_FILE_DELETED) {
+ if (info->action == TRACKER_DB_ACTION_FILE_DELETED) {
process_index_delete_file (tracker, info);
- info = tracker_dec_info_ref (info);
+ info = tracker_db_file_info_unref (info);
return TRUE;
} else {
- if (info->action == TRACKER_ACTION_DIRECTORY_DELETED ||
- info->action == TRACKER_ACTION_DIRECTORY_UNMOUNTED) {
+ if (info->action == TRACKER_DB_ACTION_DIRECTORY_DELETED ||
+ info->action == TRACKER_DB_ACTION_DIRECTORY_UNMOUNTED) {
process_index_delete_file (tracker, info);
process_index_delete_directory (tracker, info);
- info = tracker_dec_info_ref (info);
+ info = tracker_db_file_info_unref (info);
return TRUE;
}
}
@@ -1414,7 +1414,7 @@
/* Get latest file info from disk */
if (info->mtime == 0) {
- info = tracker_get_file_info (info);
+ info = tracker_db_file_info_get (info);
}
return FALSE;
@@ -1575,8 +1575,8 @@
tracker->index_time_start = time (NULL);
while (TRUE) {
- FileInfo *info;
- gboolean need_index;
+ TrackerDBFileInfo *info;
+ gboolean need_index;
if (!tracker_cache_process_events (tracker->index_db, TRUE) ) {
tracker_status_set_and_signal (TRACKER_STATUS_SHUTDOWN,
@@ -1632,9 +1632,9 @@
tracker_status_set (TRACKER_STATUS_PENDING);
while (valid) {
- FileInfo *info_tmp;
- TrackerAction tmp_action;
- gchar *uri;
+ TrackerDBFileInfo *info_tmp;
+ TrackerDBAction tmp_action;
+ gchar *uri;
if (!tracker->is_running) {
g_object_unref (result_set);
@@ -1646,7 +1646,7 @@
2, &tmp_action,
-1);
- info_tmp = tracker_create_file_info (uri, tmp_action, 0, WATCH_OTHER);
+ info_tmp = tracker_db_file_info_new (uri, tmp_action, 0, TRACKER_DB_WATCH_OTHER);
g_async_queue_push (tracker->file_process_queue, info_tmp);
pushed_events = TRUE;
@@ -1710,7 +1710,7 @@
process_index_entity (tracker, info);
}
- tracker_dec_info_ref (info);
+ tracker_db_file_info_unref (info);
}
g_signal_handlers_disconnect_by_func (tracker->hal,
@@ -1977,17 +1977,17 @@
}
gboolean
-tracker_process_files_is_file_info_valid (FileInfo *info)
+tracker_process_files_is_file_info_valid (TrackerDBFileInfo *info)
{
g_return_val_if_fail (info != NULL, FALSE);
g_return_val_if_fail (info->uri != NULL, FALSE);
if (!g_utf8_validate (info->uri, -1, NULL)) {
- tracker_log ("Expected UTF-8 validation of FileInfo URI");
+ tracker_log ("Expected UTF-8 validation of TrackerDBFileInfo URI");
return FALSE;
}
- if (info->action == TRACKER_ACTION_IGNORE) {
+ if (info->action == TRACKER_DB_ACTION_IGNORE) {
return FALSE;
}
Modified: branches/indexer-split/src/trackerd/tracker-process-files.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-process-files.h (original)
+++ branches/indexer-split/src/trackerd/tracker-process-files.h Wed Apr 30 11:54:10 2008
@@ -22,6 +22,8 @@
#include <libtracker-common/tracker-config.h>
+#include <libtracker-db/tracker-db-file-info.h>
+
#include "tracker-utils.h"
/* Thread entry point */
@@ -45,6 +47,6 @@
GSList * tracker_process_files_get_files_with_prefix (Tracker *tracker,
const char *dir,
const char *prefix);
-gboolean tracker_process_files_is_file_info_valid (FileInfo *info);
+gboolean tracker_process_files_is_file_info_valid (TrackerDBFileInfo *info);
#endif /* __TRACKER_PROCESS_FILES_H__ */
Modified: branches/indexer-split/src/trackerd/tracker-status.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-status.c (original)
+++ branches/indexer-split/src/trackerd/tracker-status.c Wed Apr 30 11:54:10 2008
@@ -1,5 +1,7 @@
-/* Tracker - indexer and metadata database engine
+/* -*- 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
* modify it under the terms of the GNU General Public
Modified: branches/indexer-split/src/trackerd/tracker-status.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-status.h (original)
+++ branches/indexer-split/src/trackerd/tracker-status.h Wed Apr 30 11:54:10 2008
@@ -1,5 +1,7 @@
-/* Tracker - indexer and metadata database engine
+/* -*- 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
* modify it under the terms of the GNU General Public
Modified: branches/indexer-split/src/trackerd/tracker-utils.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-utils.c (original)
+++ branches/indexer-split/src/trackerd/tracker-utils.c Wed Apr 30 11:54:10 2008
@@ -1,4 +1,5 @@
-/* Tracker - indexer and metadata database engine
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
* Copyright (C) 2007, Michal Pryc (Michal Pryc Sun Com)
*
@@ -248,225 +249,6 @@
-FileInfo *
-tracker_create_file_info (const char *uri, TrackerAction action, int counter, WatchTypes watch)
-{
- FileInfo *info;
-
- info = g_slice_new0 (FileInfo);
-
- info->action = action;
- info->uri = g_strdup (uri);
-
- info->counter = counter;
- info->file_id = 0;
-
- info->file_type = FILE_ORDINARY;
-
- info->watch_type = watch;
- info->is_directory = FALSE;
-
- info->is_link = FALSE;
- info->link_id = 0;
- info->link_path = NULL;
- info->link_name = NULL;
-
- info->mime = NULL;
- info->file_size = 0;
- info->permissions = g_strdup ("-r--r--r--");
- info->mtime = 0;
- info->atime = 0;
- info->indextime = 0;
- info->offset = 0;
- info->aux_id = -1;
-
- info->is_hidden = FALSE;
-
- info->is_new = TRUE;
- info->service_type_id = -1;
-
- info->ref_count = 1;
- info_allocated ++;
-
- return info;
-}
-
-
-FileInfo *
-tracker_free_file_info (FileInfo *info)
-{
- if (!info) {
- return NULL;
- }
-
- if (info->uri) {
- g_free (info->uri);
- }
-
- if (info->moved_to_uri) {
- g_free (info->moved_to_uri);
- }
-
- if (info->link_path) {
- g_free (info->link_path);
- }
-
- if (info->link_name) {
- g_free (info->link_name);
- }
-
- if (info->mime) {
- g_free (info->mime);
- }
-
- if (info->permissions) {
- g_free (info->permissions);
- }
-
- g_slice_free (FileInfo, info);
-
- info_deallocated ++;
-
- return NULL;
-}
-
-
-/* ref count FileInfo instances */
-FileInfo *
-tracker_inc_info_ref (FileInfo *info)
-{
- if (info) {
- g_atomic_int_inc (&info->ref_count);
- }
-
- return info;
-}
-
-
-FileInfo *
-tracker_dec_info_ref (FileInfo *info)
-{
- if (!info) {
- return NULL;
- }
-
- if g_atomic_int_dec_and_test (&info->ref_count) {
- tracker_free_file_info (info);
- return NULL;
- }
-
- return info;
-}
-
-
-FileInfo *
-tracker_get_pending_file_info (guint32 file_id, const char *uri, const char *mime, int counter, TrackerAction action, gboolean is_directory)
-{
- FileInfo *info;
-
- info = g_slice_new0 (FileInfo);
-
- info->action = action;
- info->uri = g_strdup (uri);
-
- info->counter = counter;
- info->file_id = file_id;
-
- info->file_type = FILE_ORDINARY;
-
- info->is_directory = is_directory;
-
- info->is_link = FALSE;
- info->link_id = 0;
- info->link_path = NULL;
- info->link_name = NULL;
-
- if (mime) {
- info->mime = g_strdup (mime);
- } else {
- info->mime = NULL;
- }
-
- info->file_size = 0;
- info->permissions = g_strdup ("-r--r--r--");
- info->mtime = 0;
- info->atime = 0;
- info->indextime = 0;
- info->offset = 0;
-
- info->service_type_id = -1;
- info->is_new = TRUE;
-
- info->ref_count = 1;
- info_allocated ++;
-
- return info;
-}
-
-
-
-
-FileInfo *
-tracker_get_file_info (FileInfo *info)
-{
- struct stat finfo;
- char *str, *uri_in_locale;
-
- if (!info || !info->uri) {
- return info;
- }
-
- uri_in_locale = g_filename_from_utf8 (info->uri, -1, NULL, NULL, NULL);
-
- if (uri_in_locale) {
- if (g_lstat (uri_in_locale, &finfo) == -1) {
- g_free (uri_in_locale);
-
- return info;
- }
-
- } else {
- tracker_error ("ERROR: info->uri could not be converted to locale format");
-
- return NULL;
- }
-
- info->is_directory = S_ISDIR (finfo.st_mode);
- info->is_link = S_ISLNK (finfo.st_mode);
-
- if (info->is_link && !info->link_name) {
- str = g_file_read_link (uri_in_locale, NULL);
-
- if (str) {
- char *link_uri;
-
- link_uri = g_filename_to_utf8 (str, -1, NULL, NULL, NULL);
- info->link_name = g_path_get_basename (link_uri);
- info->link_path = g_path_get_dirname (link_uri);
- g_free (link_uri);
- g_free (str);
- }
- }
-
- g_free (uri_in_locale);
-
- if (!info->is_directory) {
- info->file_size = (guint32) finfo.st_size;
- } else {
- if (info->watch_type == WATCH_OTHER) {
- info->watch_type = WATCH_SUBFOLDER;
- }
- }
-
- g_free (info->permissions);
- info->permissions = tracker_create_permission_string (finfo);
-
- info->mtime = finfo.st_mtime;
- info->atime = finfo.st_atime;
-
- return info;
-}
-
GSList *
tracker_get_service_dirs (const char *service)
Modified: branches/indexer-split/src/trackerd/tracker-utils.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-utils.h (original)
+++ branches/indexer-split/src/trackerd/tracker-utils.h Wed Apr 30 11:54:10 2008
@@ -28,12 +28,15 @@
extern char *service_metadata_table_names[];
extern char *service_metadata_join_names[];
+#include "config.h"
+
#include <time.h>
+
#include <glib.h>
-#include "config.h"
+#include <libtracker-db/tracker-db-action.h>
+
#include "tracker-parser.h"
-#include "tracker-action.h"
#define MAX_HITS_FOR_WORD 30000
@@ -302,72 +305,6 @@
} Tracker;
-/* service type that the file represents */
-typedef enum {
- FILE_ORDINARY,
- FILE_DESKTOP,
- FILE_BOOKMARKS,
- FILE_SMARTBOOKMARKS,
- FILE_WEBHISTORY,
- FILE_EMAILS,
- FILE_CONVERSATIONS,
- FILE_CONTACTS
-} FileTypes;
-
-
-typedef enum {
- WATCH_ROOT,
- WATCH_SUBFOLDER,
- WATCH_SPECIAL_FOLDER,
- WATCH_SPECIAL_FILE,
- WATCH_NO_INDEX,
- WATCH_OTHER
-} WatchTypes;
-
-
-typedef struct {
-
- /* file name/path related info */
- char *uri;
- guint32 file_id;
-
- TrackerAction action;
- guint32 cookie;
- int counter;
- FileTypes file_type;
- WatchTypes watch_type;
-
- /* symlink info - File ID of link might not be in DB so need to store path/filename too */
- gint32 link_id;
- char *link_path;
- char *link_name;
-
- char *mime;
- int service_type_id;
- guint32 file_size;
- char *permissions;
- gint32 mtime;
- gint32 atime;
- gint32 indextime;
- gint32 offset;
-
- /* options */
- char *moved_to_uri;
-
- int aux_id;
-
- guint is_new : 1;
- guint is_directory : 1;
- guint is_link : 1;
- guint extract_embedded : 1;
- guint extract_contents : 1;
- guint extract_thumbs : 1;
- guint is_hidden : 1;
-
- /* we ref count FileInfo as it has a complex lifespan and is tossed between various threads, lists, queues and hash tables */
- int ref_count;
-
-} FileInfo;
char * tracker_get_radix_by_suffix (const char *str, const char *suffix);
@@ -384,14 +321,6 @@
char * tracker_get_service_for_uri (const char *uri);
gboolean tracker_is_service_file (const char *uri);
-FileInfo * tracker_create_file_info (const char *uri, TrackerAction action, int counter, WatchTypes watch);
-FileInfo * tracker_get_file_info (FileInfo *info);
-FileInfo * tracker_copy_file_info (FileInfo *info);
-FileInfo * tracker_inc_info_ref (FileInfo *info);
-FileInfo * tracker_dec_info_ref (FileInfo *info);
-
-FileInfo * tracker_free_file_info (FileInfo *info);
-
GSList * tracker_get_watch_root_dirs (void);
void tracker_print_object_allocations (void);
Modified: branches/indexer-split/src/trackerd/trackerd.c
==============================================================================
--- branches/indexer-split/src/trackerd/trackerd.c (original)
+++ branches/indexer-split/src/trackerd/trackerd.c Wed Apr 30 11:54:10 2008
@@ -379,7 +379,7 @@
static inline void
queue_dir (const gchar *uri)
{
- FileInfo *info = tracker_create_file_info (uri, TRACKER_ACTION_DIRECTORY_CHECK, 0, 0);
+ TrackerDBFileInfo *info = tracker_db_file_info_new (uri, TRACKER_DB_ACTION_DIRECTORY_CHECK, 0, 0);
g_async_queue_push (tracker->file_process_queue, info);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]