tracker r1476 - in branches/xesam-support: . po src/libtracker-common src/libtracker-db src/libtracker-gtk src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1476 - in branches/xesam-support: . po src/libtracker-common src/libtracker-db src/libtracker-gtk src/trackerd
- Date: Fri, 23 May 2008 18:14:31 +0000 (UTC)
Author: pvanhoof
Date: Fri May 23 18:14:30 2008
New Revision: 1476
URL: http://svn.gnome.org/viewvc/tracker?rev=1476&view=rev
Log:
2008-05-23 Philip Van Hoof <pvanhoof gnome org>
* Merged xesam-support with indexer-split
svn merge -r 1463:1475 ../indexer-split
Added:
branches/xesam-support/src/trackerd/tracker-field-data.c
- copied unchanged from r1475, /branches/indexer-split/src/trackerd/tracker-field-data.c
branches/xesam-support/src/trackerd/tracker-field-data.h
- copied unchanged from r1475, /branches/indexer-split/src/trackerd/tracker-field-data.h
Modified:
branches/xesam-support/ChangeLog
branches/xesam-support/po/POTFILES.in
branches/xesam-support/src/libtracker-common/tracker-nfs-lock.c
branches/xesam-support/src/libtracker-common/tracker-nfs-lock.h
branches/xesam-support/src/libtracker-db/Makefile.am
branches/xesam-support/src/libtracker-gtk/tracker-tag-bar.c
branches/xesam-support/src/trackerd/Makefile.am
branches/xesam-support/src/trackerd/tracker-cache.c
branches/xesam-support/src/trackerd/tracker-db-manager.c
branches/xesam-support/src/trackerd/tracker-db-sqlite.c
branches/xesam-support/src/trackerd/tracker-db-sqlite.h
branches/xesam-support/src/trackerd/tracker-db.c
branches/xesam-support/src/trackerd/tracker-dbus-files.c
branches/xesam-support/src/trackerd/tracker-dbus-metadata.c
branches/xesam-support/src/trackerd/tracker-email-utils.c
branches/xesam-support/src/trackerd/tracker-field.c
branches/xesam-support/src/trackerd/tracker-field.h
branches/xesam-support/src/trackerd/tracker-hal.c
branches/xesam-support/src/trackerd/tracker-indexer.c
branches/xesam-support/src/trackerd/tracker-inotify.c
branches/xesam-support/src/trackerd/tracker-main.c
branches/xesam-support/src/trackerd/tracker-main.h
branches/xesam-support/src/trackerd/tracker-metadata.c
branches/xesam-support/src/trackerd/tracker-ontology.c
branches/xesam-support/src/trackerd/tracker-ontology.h
branches/xesam-support/src/trackerd/tracker-parser.c
branches/xesam-support/src/trackerd/tracker-rdf-query.c
branches/xesam-support/src/trackerd/tracker-utils.c
branches/xesam-support/src/trackerd/tracker-xesam-query.c
branches/xesam-support/src/trackerd/tracker-xesam.c
branches/xesam-support/src/trackerd/tracker-xesam.h
Modified: branches/xesam-support/po/POTFILES.in
==============================================================================
--- branches/xesam-support/po/POTFILES.in (original)
+++ branches/xesam-support/po/POTFILES.in Fri May 23 18:14:30 2008
@@ -11,10 +11,11 @@
src/libtracker/tracker-stats.c
src/libtracker/tracker-status.c
src/libtracker/tracker-tag.c
-src/trackerd/trackerd.c
-src/tracker-applet/tracker-applet.desktop.in.in
src/tracker-applet/tracker-applet.c
+src/tracker-applet/tracker-applet.desktop.in.in
src/tracker-applet/tracker-applet-prefs.glade
+src/trackerd/tracker-main.c
+src/tracker-indexer/main.c
src/tracker-indexer/tracker-indexer.c
src/tracker-preferences/tracker-preferences.c
src/tracker-preferences/tracker-preferences.desktop.in.in
Modified: branches/xesam-support/src/libtracker-common/tracker-nfs-lock.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-nfs-lock.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-nfs-lock.c Fri May 23 18:14:30 2008
@@ -28,18 +28,18 @@
#include "tracker-nfs-lock.h"
#include "tracker-log.h"
-static gchar *lock_file = NULL;
-static gchar *tmp_filepath = NULL;
+static gchar *lock_filename;
+static gchar *tmp_dir;
-static gboolean use_nfs_safe_locking = FALSE;
+static gboolean use_nfs_safe_locking;
/* Get no of links to a file - used for safe NFS atomic file locking */
static gint
-get_nlinks (const gchar *name)
+get_nlinks (const gchar *filename)
{
struct stat st;
- if (g_stat (name, &st) == 0) {
+ if (g_stat (filename, &st) == 0) {
return st.st_nlink;
} else {
return -1;
@@ -47,11 +47,11 @@
}
static gint
-get_mtime (const gchar *name)
+get_mtime (const gchar *filename)
{
struct stat st;
- if (g_stat (name, &st) == 0) {
+ if (g_stat (filename, &st) == 0) {
return st.st_mtime;
} else {
return -1;
@@ -61,7 +61,7 @@
static gboolean
is_initialized (void)
{
- return lock_file != NULL && tmp_filepath != NULL;
+ return lock_filename != NULL || tmp_dir != NULL;
}
/* Serialises db access via a lock file for safe use on (lock broken)
@@ -70,8 +70,8 @@
gboolean
tracker_nfs_lock_obtain (void)
{
+ gchar *filename;
gint attempt;
- gchar *tmp_file;
gint fd;
if (!use_nfs_safe_locking) {
@@ -83,22 +83,22 @@
return FALSE;
}
- tmp_file = g_strdup_printf ("%s_%d.lock",
- tmp_filepath,
+ filename = g_strdup_printf ("%s_%d.lock",
+ tmp_dir,
(guint32) getpid ());
for (attempt = 0; attempt < 10000; ++attempt) {
/* Delete existing lock file if older than 5 mins */
- if (g_file_test (lock_file, G_FILE_TEST_EXISTS)
- && ( time((time_t *) NULL) - get_mtime (lock_file)) > 300) {
- g_unlink (lock_file);
+ if (g_file_test (lock_filename, G_FILE_TEST_EXISTS) &&
+ time ((time_t *) - get_mtime (lock_filename)) > 300) {
+ g_unlink (lock_filename);
}
- fd = g_open (lock_file, O_CREAT|O_EXCL, 0644);
+ fd = g_open (lock_filename, O_CREAT | O_EXCL, 0644);
if (fd >= 0) {
/* Create host specific file and link to lock file */
- if (link (lock_file, tmp_file) == -1) {
+ if (link (lock_filename, filename) == -1) {
goto error;
}
@@ -106,9 +106,9 @@
* if file locked. If greater than 2 then we
* have a race condition.
*/
- if (get_nlinks (lock_file) == 2) {
+ if (get_nlinks (lock_filename) == 2) {
close (fd);
- g_free (tmp_file);
+ g_free (filename);
return TRUE;
} else {
@@ -120,7 +120,7 @@
error:
g_critical ("Could not get NFS lock state");
- g_free (tmp_file);
+ g_free (filename);
return FALSE;
}
@@ -128,7 +128,7 @@
void
tracker_nfs_lock_release (void)
{
- gchar *tmp_file;
+ gchar *filename;
if (!use_nfs_safe_locking) {
return;
@@ -139,16 +139,18 @@
return;
}
- tmp_file = g_strdup_printf ("%s_%d.lock", tmp_filepath, (guint32) getpid ());
+ filename = g_strdup_printf ("%s_%d.lock",
+ tmp_dir,
+ (guint32) getpid ());
+
+ g_unlink (filename);
+ g_unlink (lock_filename);
- g_unlink (tmp_file);
- g_unlink (lock_file);
-
- g_free (tmp_file);
+ g_free (filename);
}
void
-tracker_nfs_lock_init (const gchar *root_dir, gboolean nfs)
+tracker_nfs_lock_init (gboolean nfs)
{
if (is_initialized ()) {
return;
@@ -156,12 +158,18 @@
use_nfs_safe_locking = nfs;
- if (lock_file == NULL) {
- lock_file = g_build_filename (root_dir, "tracker.lock", NULL);
+ if (lock_filename == NULL) {
+ lock_filename = g_build_filename (g_get_user_data_dir (),
+ "tracker",
+ "tracker.lock",
+ NULL);
}
- if (tmp_filepath == NULL) {
- tmp_filepath = g_build_filename (root_dir, g_get_host_name (), NULL);
+ if (tmp_dir == NULL) {
+ tmp_dir = g_build_filename (g_get_user_data_dir (),
+ "tracker",
+ g_get_host_name (),
+ NULL);
}
g_message ("NFS lock initialised %s",
@@ -175,12 +183,14 @@
return;
}
- if (lock_file) {
- g_free (lock_file);
+ if (lock_filename) {
+ g_free (lock_filename);
+ lock_filename = NULL;
}
- if (tmp_filepath) {
- g_free (tmp_filepath);
+ if (tmp_dir) {
+ g_free (tmp_dir);
+ tmp_dir = NULL;
}
g_message ("NFS lock finalised");
Modified: branches/xesam-support/src/libtracker-common/tracker-nfs-lock.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-nfs-lock.h (original)
+++ branches/xesam-support/src/libtracker-common/tracker-nfs-lock.h Fri May 23 18:14:30 2008
@@ -26,7 +26,7 @@
G_BEGIN_DECLS
-void tracker_nfs_lock_init (const gchar *root_dir, gboolean nfs);
+void tracker_nfs_lock_init (gboolean nfs);
void tracker_nfs_lock_shutdown (void);
gboolean tracker_nfs_lock_obtain (void);
void tracker_nfs_lock_release (void);
Modified: branches/xesam-support/src/libtracker-db/Makefile.am
==============================================================================
--- branches/xesam-support/src/libtracker-db/Makefile.am (original)
+++ branches/xesam-support/src/libtracker-db/Makefile.am Fri May 23 18:14:30 2008
@@ -1,9 +1,6 @@
INCLUDES = \
-g \
$(GLIB2_CFLAGS) \
- $(GMIME_CFLAGS) \
- $(SQLITE3_CFLAGS) \
- $(QDBM_CFLAGS) \
-DG_LOG_DOMAIN=\"Tracker\" \
-I$(top_srcdir)/src
Modified: branches/xesam-support/src/libtracker-gtk/tracker-tag-bar.c
==============================================================================
--- branches/xesam-support/src/libtracker-gtk/tracker-tag-bar.c (original)
+++ branches/xesam-support/src/libtracker-gtk/tracker-tag-bar.c Fri May 23 18:14:30 2008
@@ -60,7 +60,7 @@
};
/* CALLBACKS */
-void
+static void
_keywords_reply (char **array, GError *error, TrackerTagBar *bar)
{
TrackerTagBarPrivate *priv;
Modified: branches/xesam-support/src/trackerd/Makefile.am
==============================================================================
--- branches/xesam-support/src/trackerd/Makefile.am (original)
+++ branches/xesam-support/src/trackerd/Makefile.am Fri May 23 18:14:30 2008
@@ -104,6 +104,8 @@
tracker-email-utils.h \
tracker-field.c \
tracker-field.h \
+ tracker-field-data.c \
+ tracker-field-data.h \
tracker-indexer.c \
tracker-indexer.h \
tracker-index-stage.c \
@@ -129,7 +131,6 @@
tracker-service.h \
tracker-ioprio.c \
tracker-ioprio.h \
- tracker-os-dependant.h \
tracker-watch.h \
tracker-status.c \
tracker-status.h \
@@ -167,14 +168,10 @@
$(trackerd_win_libs)
tracker-marshal.h: tracker-marshal.list
- ($(GLIB_GENMARSHAL) --prefix=tracker_marshal tracker-marshal.list --header) > xgen-gmh \
- && (cmp -s xgen-gmh tracker-marshal.h || cp xgen-gmh tracker-marshal.h) \
- && rm -f xgen-gmh xgen-gmh~
+ $(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --header > $@
tracker-marshal.c: tracker-marshal.list
- ($(GLIB_GENMARSHAL) --prefix=tracker_marshal tracker-marshal.list --body) > xgen-gmc \
- && cp xgen-gmc tracker-marshal.c \
- && rm -f xgen-gmc xgen-gmc~
+ $(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --body > $@
tracker-marshal-main.c: tracker-marshal.c tracker-marshal.h
Modified: branches/xesam-support/src/trackerd/tracker-cache.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-cache.c (original)
+++ branches/xesam-support/src/trackerd/tracker-cache.c Fri May 23 18:14:30 2008
@@ -32,6 +32,7 @@
#include "tracker-dbus.h"
#include "tracker-dbus-daemon.h"
#include "tracker-cache.h"
+#include "tracker-main.h"
#include "tracker-status.h"
#define USE_SLICE
@@ -58,23 +59,26 @@
gint i;
for (i = 1; i < 1000; i++) {
- temp_file_name = g_strdup_printf ("%s%d", name, i);
+ gchar *filename;
+ gboolean exists;
- char *tmp = g_build_filename (tracker->data_dir, temp_file_name, NULL);
+ temp_file_name = g_strdup_printf ("%s%d", name, i);
+ filename = g_build_filename (tracker_get_data_dir (),
+ temp_file_name,
+ NULL);
+
+ exists = g_file_test (filename, G_FILE_TEST_EXISTS);
+ g_free (filename);
- if (g_file_test (tmp , G_FILE_TEST_EXISTS)) {
+ if (exists) {
g_free (temp_file_name);
- g_free (tmp);
continue;
}
- g_free (tmp);
-
break;
}
indexer = tracker_indexer_open (temp_file_name, FALSE);
-
g_free (temp_file_name);
return indexer;
@@ -450,8 +454,6 @@
if (tracker->grace_period > 1) {
g_message ("Pausing indexer while client requests/disk I/O take place");
- tracker->request_waiting = FALSE;
-
if (db_con) {
tracker_db_end_index_transaction (db_con);
stopped_trans = TRUE;
Modified: branches/xesam-support/src/trackerd/tracker-db-manager.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-manager.c (original)
+++ branches/xesam-support/src/trackerd/tracker-db-manager.c Fri May 23 18:14:30 2008
@@ -173,13 +173,17 @@
void
tracker_db_manager_init (const gchar *data_dir,
const gchar *user_data_dir,
- const gchar *sys_tmp_root_dir)
+ const gchar *sys_tmp_dir)
{
+ g_return_if_fail (data_dir != NULL);
+ g_return_if_fail (user_data_dir != NULL);
+ g_return_if_fail (sys_tmp_dir != NULL);
+
if (!initialized) {
configure_directories ();
configure_database_description (data_dir,
user_data_dir,
- sys_tmp_root_dir);
+ sys_tmp_dir);
initialized = TRUE;
}
}
Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.c Fri May 23 18:14:30 2008
@@ -42,6 +42,7 @@
#include "tracker-indexer.h"
#include "tracker-cache.h"
#include "tracker-metadata.h"
+#include "tracker-main.h"
#include "tracker-utils.h"
#include "tracker-watch.h"
#include "tracker-ontology.h"
@@ -566,7 +567,7 @@
gchar *service_file, *str_id;
gchar **groups, **keys;
gchar **group, **key;
- const TrackerField *def;
+ TrackerField *def;
gint id;
gchar *DataTypeArray[11] = {"Keyword", "Indexable", "CLOB",
"String", "Integer", "Double",
@@ -588,7 +589,6 @@
groups = g_key_file_get_groups (key_file, NULL);
for (group = groups; *group; group++) {
-
def = tracker_ontology_get_field_def (*group);
if (!def) {
@@ -1550,7 +1550,7 @@
tracker_db_needs_setup (void)
{
return (!tracker_db_manager_file_exists (TRACKER_DB_FILE_META) ||
- !file_exists (tracker->data_dir, TRACKER_INDEXER_FILE_INDEX_DB_FILENAME) ||
+ !file_exists (tracker_get_data_dir (), TRACKER_INDEXER_FILE_INDEX_DB_FILENAME) ||
!tracker_db_manager_file_exists (TRACKER_DB_FILE_CONTENTS));
}
@@ -2141,7 +2141,7 @@
TrackerDBResultSet *
tracker_db_search_metadata (DBConnection *db_con, const char *service, const char *field, const char *text, int offset, int limit)
{
- const TrackerField *def;
+ TrackerField *def;
TrackerDBResultSet *result_set;
g_return_val_if_fail ((service && field && text), NULL);
@@ -2192,7 +2192,7 @@
tracker_db_get_metadata (DBConnection *db_con, const char *service, const char *id, const char *key)
{
TrackerDBResultSet *result_set;
- const TrackerField *def;
+ TrackerField *def;
g_return_val_if_fail (id, NULL);
@@ -2268,7 +2268,11 @@
static void
-update_metadata_index (const char *id, const char *service, const TrackerField *def, const char *old_value, const char *new_value)
+update_metadata_index (const char *id,
+ const char *service,
+ TrackerField *def,
+ const char *old_value,
+ const char *new_value)
{
GHashTable *old_table, *new_table;
gint sid;
@@ -2437,10 +2441,16 @@
}
void
-tracker_db_insert_embedded_metadata (DBConnection *db_con, const gchar *service, const gchar *id, const gchar *key, gchar **values, gint length, GHashTable *table)
+tracker_db_insert_embedded_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ gchar **values,
+ gint length,
+ GHashTable *table)
{
- gint key_field = 0;
- const TrackerField *def;
+ TrackerField *def;
+ gint key_field = 0;
if (!service || !id || !key || !values || !values[0]) {
return;
@@ -2733,13 +2743,13 @@
gchar *
tracker_db_set_metadata (DBConnection *db_con, const char *service, const gchar *id, const gchar *key, gchar **values, gint length, gboolean do_backup)
{
- const TrackerField *def;
- gchar *old_value = NULL, *new_value = NULL;
- gboolean update_index;
- gint key_field = 0;
- gint i;
- GString *str = NULL;
- gchar *res_service;
+ TrackerField *def;
+ gchar *old_value = NULL, *new_value = NULL;
+ gboolean update_index;
+ gint key_field = 0;
+ gint i;
+ GString *str = NULL;
+ gchar *res_service;
g_return_val_if_fail (id && values && key && service, NULL);
@@ -3060,9 +3070,9 @@
tracker_db_delete_metadata_value (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value)
{
- char *old_value = NULL, *new_value = NULL, *mvalue;
- const TrackerField *def;
- gboolean update_index;
+ char *old_value = NULL, *new_value = NULL, *mvalue;
+ TrackerField *def;
+ gboolean update_index;
g_return_if_fail (id && key && service && db_con);
@@ -3202,8 +3212,8 @@
tracker_db_delete_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, gboolean update_indexes)
{
char *old_value = NULL;
- const TrackerField *def;
- gboolean update_index;
+ TrackerField *def;
+ gboolean update_index;
g_return_if_fail (id && key && service && db_con);
@@ -5069,54 +5079,72 @@
return TRUE;
}
-
-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)
+TrackerFieldData *
+tracker_db_get_metadata_field (DBConnection *db_con,
+ const gchar *service,
+ const gchar *field_name,
+ gint field_count,
+ gboolean is_select,
+ gboolean is_condition)
{
- FieldData *field_data = NULL;
- const TrackerField *def;
-
- field_data = g_new0 (FieldData, 1);
-
- field_data->is_select = is_select;
- field_data->is_condition = is_condition;
- field_data->field_name = g_strdup (field_name);
+ TrackerFieldData *field_data = NULL;
+ TrackerField *def;
def = tracker_ontology_get_field_def (field_name);
if (def) {
-
- field_data->table_name = tracker_get_metadata_table (tracker_field_get_data_type (def));
- field_data->alias = g_strdup_printf ("M%d", field_count);
- field_data->data_type = tracker_field_get_data_type (def);
- field_data->id_field = g_strdup (tracker_field_get_id (def));
- field_data->multiple_values = tracker_field_get_multiple_values (def);
+ gchar *alias;
+ gchar *table_name;
+ gchar *this_field_name;
+ gchar *where_field;
+
+ field_data = g_object_new (TRACKER_TYPE_FIELD_DATA,
+ "is-select", is_select,
+ "is-condition", is_condition,
+ "field-name", field_name,
+ NULL);
+
+ alias = g_strdup_printf ("M%d", field_count);
+ table_name = tracker_get_metadata_table (tracker_field_get_data_type (def));
+
+ tracker_field_data_set_alias (field_data, alias);
+ tracker_field_data_set_table_name (field_data, table_name);
+ tracker_field_data_set_id_field (field_data, tracker_field_get_id (def));
+ tracker_field_data_set_data_type (field_data, tracker_field_get_data_type (def));
+ tracker_field_data_set_multiple_values (field_data, tracker_field_get_multiple_values (def));
- char *my_field = tracker_db_get_field_name (service, field_name);
+ this_field_name = tracker_db_get_field_name (service, field_name);
- if (my_field) {
- field_data->select_field = g_strdup_printf (" S.%s ", my_field);
- g_free (my_field);
- field_data->needs_join = FALSE;
+ if (this_field_name) {
+ gchar *str;
+
+ str = g_strdup_printf (" S.%s ", this_field_name);
+ tracker_field_data_set_select_field (field_data, str);
+ tracker_field_data_set_needs_join (field_data, FALSE);
+ g_free (str);
+ g_free (this_field_name);
} else {
- char *disp_field = tracker_ontology_get_display_field (def);
- field_data->select_field = g_strdup_printf ("M%d.%s", field_count, disp_field);
- g_free (disp_field);
- field_data->needs_join = TRUE;
+ gchar *str;
+ gchar *display_field;
+
+ display_field = tracker_ontology_get_display_field (def);
+ str = g_strdup_printf ("M%d.%s", field_count, display_field);
+ tracker_field_data_set_select_field (field_data, str);
+ tracker_field_data_set_needs_join (field_data, TRUE);
+ g_free (str);
+ g_free (display_field);
}
if (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_DOUBLE) {
- field_data->where_field = g_strdup_printf ("M%d.MetaDataDisplay", field_count);
+ where_field = g_strdup_printf ("M%d.MetaDataDisplay", field_count);
} else {
- field_data->where_field = g_strdup_printf ("M%d.MetaDataValue", field_count);
+ where_field = g_strdup_printf ("M%d.MetaDataValue", field_count);
}
- } else {
- g_free (field_data);
- return NULL;
+ tracker_field_data_set_where_field (field_data, where_field);
+ g_free (where_field);
}
-
return field_data;
}
@@ -5245,35 +5273,3 @@
return FALSE;
}
-
-void
-tracker_free_metadata_field (FieldData *field_data)
-{
- g_return_if_fail (field_data);
-
- if (field_data->alias) {
- g_free (field_data->alias);
- }
-
- if (field_data->where_field) {
- g_free (field_data->where_field);
- }
-
- if (field_data->field_name) {
- g_free (field_data->field_name);
- }
-
- if (field_data->select_field) {
- g_free (field_data->select_field);
- }
-
- if (field_data->table_name) {
- g_free (field_data->table_name);
- }
-
- if (field_data->id_field) {
- g_free (field_data->id_field);
- }
-
- g_free (field_data);
-}
Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.h (original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.h Fri May 23 18:14:30 2008
@@ -26,6 +26,7 @@
#include <libtracker-db/tracker-db-interface.h>
#include <libtracker-db/tracker-db-file-info.h>
+#include "tracker-field-data.h"
#include "tracker-ontology.h"
#include "tracker-indexer.h"
#include "tracker-utils.h"
@@ -310,7 +311,7 @@
void tracker_db_delete_service (DBConnection *db_con,
guint32 id,
const gchar *uri);
-FieldData * tracker_db_get_metadata_field (DBConnection *db_con,
+TrackerFieldData * tracker_db_get_metadata_field (DBConnection *db_con,
const gchar *service,
const gchar *field_name,
gint field_count,
Modified: branches/xesam-support/src/trackerd/tracker-db.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db.c (original)
+++ branches/xesam-support/src/trackerd/tracker-db.c Fri May 23 18:14:30 2008
@@ -53,7 +53,8 @@
GHashTable *table;
} DatabaseAction;
-GQueue *file_change_queue;
+static GQueue *file_change_queue;
+static gboolean black_list_timer_active;
static void
free_metadata_list (GSList *list)
@@ -362,7 +363,7 @@
gboolean
tracker_metadata_is_date (DBConnection *db_con, const char *meta)
{
- const TrackerField *def;
+ TrackerField *def;
def = tracker_ontology_get_field_def (meta);
@@ -670,7 +671,7 @@
tracker_process_files_set_temp_black_list (NULL);
- tracker->black_list_timer_active = FALSE;
+ black_list_timer_active = FALSE;
return FALSE;
@@ -724,9 +725,11 @@
tracker_process_files_append_temp_black_list (change->uri);
- if (!tracker->black_list_timer_active) {
- tracker->black_list_timer_active = TRUE;
- g_timeout_add_seconds (BLACK_LIST_SECONDS, (GSourceFunc) index_black_list, NULL);
+ if (!black_list_timer_active) {
+ black_list_timer_active = TRUE;
+ g_timeout_add_seconds (BLACK_LIST_SECONDS,
+ (GSourceFunc) index_black_list,
+ NULL);
}
g_queue_remove_all (file_change_queue, change);
@@ -956,7 +959,7 @@
tracker_db_save_file_contents (db_con, index_table, old_table, file_as_text, info);
/* clear up if text contents are in a temp file */
- if (g_str_has_prefix (file_as_text, tracker->sys_tmp_root_dir)) {
+ if (g_str_has_prefix (file_as_text, tracker_get_sys_tmp_dir ())) {
g_unlink (file_as_text);
}
Modified: branches/xesam-support/src/trackerd/tracker-dbus-files.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-dbus-files.c (original)
+++ branches/xesam-support/src/trackerd/tracker-dbus-files.c Fri May 23 18:14:30 2008
@@ -875,7 +875,7 @@
TrackerDBResultSet *result_set;
guint request_id;
DBConnection *db_con;
- const TrackerField *defs[255];
+ TrackerField *defs[255];
guint i;
gchar *uri_filtered;
guint32 file_id;
Modified: branches/xesam-support/src/trackerd/tracker-dbus-metadata.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-dbus-metadata.c (original)
+++ branches/xesam-support/src/trackerd/tracker-dbus-metadata.c Fri May 23 18:14:30 2008
@@ -30,6 +30,7 @@
#include "tracker-dbus.h"
#include "tracker-dbus-metadata.h"
#include "tracker-db.h"
+#include "tracker-field-data.h"
#include "tracker-marshal.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_DBUS_METADATA, TrackerDBusMetadataPriv))
@@ -217,16 +218,16 @@
sql_join = g_string_new (" FROM Services S ");
for (i = 0; i < g_strv_length (keys); i++) {
- FieldData *field;
+ TrackerFieldData *field_data;
- field = tracker_db_get_metadata_field (db_con,
- service_result,
- keys[i],
- i,
- TRUE,
- FALSE);
-
- if (!field) {
+ field_data = tracker_db_get_metadata_field (db_con,
+ service_result,
+ keys[i],
+ i,
+ TRUE,
+ FALSE);
+
+ if (!field_data) {
g_string_free (sql_join, TRUE);
g_string_free (sql, TRUE);
g_free (service_result);
@@ -240,22 +241,24 @@
}
if (i == 0) {
- g_string_append_printf (sql, " %s", field->select_field);
+ g_string_append_printf (sql, " %s",
+ tracker_field_data_get_select_field (field_data));
} else {
- g_string_append_printf (sql, ", %s", field->select_field);
+ g_string_append_printf (sql, ", %s",
+ tracker_field_data_get_select_field (field_data));
}
- if (field->needs_join) {
+ if (tracker_field_data_get_needs_join (field_data)) {
g_string_append_printf (sql_join,
"\n LEFT OUTER JOIN %s %s ON (S.ID = %s.ServiceID and %s.MetaDataID = %s) ",
- field->table_name,
- field->alias,
- field->alias,
- field->alias,
- field->id_field);
+ tracker_field_data_get_table_name (field_data),
+ tracker_field_data_get_alias (field_data),
+ tracker_field_data_get_alias (field_data),
+ tracker_field_data_get_alias (field_data),
+ tracker_field_data_get_id_field (field_data));
}
- tracker_free_metadata_field (field);
+ g_object_unref (field_data);
}
g_string_append (sql, sql_join->str);
Modified: branches/xesam-support/src/trackerd/tracker-email-utils.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-email-utils.c (original)
+++ branches/xesam-support/src/trackerd/tracker-email-utils.c Fri May 23 18:14:30 2008
@@ -787,16 +787,21 @@
gchar *
email_make_tmp_name_for_mail_attachment (const gchar *filename)
{
+ gchar *email_attachments_dir;
gchar *str_uint, *tmp_filename, *tmp_name;
g_return_val_if_fail (filename, NULL);
- g_return_val_if_fail (tracker->email_attachments_dir, NULL);
+
+ email_attachments_dir = g_build_filename (tracker_get_sys_tmp_dir (),
+ "Attachments",
+ NULL);
str_uint = tracker_uint_to_string (g_random_int ());
tmp_filename = g_strconcat (str_uint, "-", filename, NULL);
g_free (str_uint);
- tmp_name = g_build_filename (tracker->email_attachments_dir, tmp_filename, NULL);
+ tmp_name = g_build_filename (email_attachments_dir, tmp_filename, NULL);
g_free (tmp_filename);
+ g_free (email_attachments_dir);
return tmp_name;
}
@@ -1074,7 +1079,7 @@
return;
} else {
- /* Decodes email attachment and stores it in tracker->email_attachements_dir
+ /* Decodes email attachment and stores it in email_attachments_dir
to index it latter.
*/
Modified: branches/xesam-support/src/trackerd/tracker-field.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-field.c (original)
+++ branches/xesam-support/src/trackerd/tracker-field.c Fri May 23 18:14:30 2008
@@ -31,7 +31,6 @@
typedef struct _TrackerFieldPriv TrackerFieldPriv;
struct _TrackerFieldPriv {
-
gchar *id;
gchar *name;
@@ -49,13 +48,13 @@
static void field_finalize (GObject *object);
static void field_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
static void field_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
enum {
PROP_0,
@@ -79,8 +78,6 @@
if (etype == 0) {
static const GEnumValue values[] = {
-
-
{ TRACKER_FIELD_TYPE_KEYWORD,
"TRACKER_FIELD_TYPE_KEYWORD",
"keyword" },
@@ -230,7 +227,7 @@
g_free (priv->id);
g_free (priv->name);
- if ( priv->field_name) {
+ if (priv->field_name) {
g_free (priv->field_name);
}
@@ -292,14 +289,10 @@
static void
field_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- TrackerFieldPriv *priv;
-
- priv = GET_PRIV (object);
-
switch (param_id) {
case PROP_ID:
tracker_field_set_id (TRACKER_FIELD (object),
@@ -323,27 +316,27 @@
break;
case PROP_EMBEDDED:
tracker_field_set_embedded (TRACKER_FIELD (object),
- g_value_get_boolean (value));
+ g_value_get_boolean (value));
break;
case PROP_MULTIPLE_VALUES:
tracker_field_set_multiple_values (TRACKER_FIELD (object),
- g_value_get_boolean (value));
+ g_value_get_boolean (value));
break;
case PROP_DELIMITED:
tracker_field_set_delimited (TRACKER_FIELD (object),
- g_value_get_boolean (value));
+ g_value_get_boolean (value));
break;
case PROP_FILTERED:
tracker_field_set_filtered (TRACKER_FIELD (object),
- g_value_get_boolean (value));
+ g_value_get_boolean (value));
break;
case PROP_STORE_METADATA:
tracker_field_set_store_metadata (TRACKER_FIELD (object),
- g_value_get_boolean (value));
+ g_value_get_boolean (value));
break;
case PROP_CHILD_IDS:
tracker_field_set_child_ids (TRACKER_FIELD (object),
- g_value_get_pointer (value));
+ g_value_get_pointer (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -353,8 +346,8 @@
static gboolean
field_int_validate (TrackerField *field,
- const gchar *property,
- gint value)
+ const gchar *property,
+ gint value)
{
#ifdef G_DISABLE_CHECKS
GParamSpec *spec;
@@ -386,7 +379,7 @@
}
const gchar *
-tracker_field_get_id (const TrackerField *field)
+tracker_field_get_id (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -398,7 +391,7 @@
}
const gchar *
-tracker_field_get_name (const TrackerField *field)
+tracker_field_get_name (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -410,7 +403,7 @@
}
TrackerFieldType
-tracker_field_get_data_type (const TrackerField *field)
+tracker_field_get_data_type (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -422,7 +415,7 @@
}
const gchar *
-tracker_field_get_field_name (const TrackerField *field)
+tracker_field_get_field_name (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -434,7 +427,7 @@
}
gint
-tracker_field_get_weight (const TrackerField *field)
+tracker_field_get_weight (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -447,7 +440,7 @@
gboolean
-tracker_field_get_embedded (const TrackerField *field)
+tracker_field_get_embedded (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -460,7 +453,7 @@
gboolean
-tracker_field_get_multiple_values (const TrackerField *field)
+tracker_field_get_multiple_values (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -472,7 +465,7 @@
}
gboolean
-tracker_field_get_delimited (const TrackerField *field)
+tracker_field_get_delimited (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -484,7 +477,7 @@
}
gboolean
-tracker_field_get_filtered (const TrackerField *field)
+tracker_field_get_filtered (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -496,7 +489,7 @@
}
gboolean
-tracker_field_get_store_metadata (const TrackerField *field)
+tracker_field_get_store_metadata (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -509,7 +502,7 @@
const GSList *
-tracker_field_get_child_ids (const TrackerField *field)
+tracker_field_get_child_ids (TrackerField *field)
{
TrackerFieldPriv *priv;
@@ -523,7 +516,7 @@
void
tracker_field_set_id (TrackerField *field,
- const gchar *value)
+ const gchar *value)
{
TrackerFieldPriv *priv;
@@ -544,7 +537,7 @@
void
tracker_field_set_name (TrackerField *field,
- const gchar *value)
+ const gchar *value)
{
TrackerFieldPriv *priv;
@@ -564,8 +557,8 @@
}
void
-tracker_field_set_data_type (TrackerField *field,
- TrackerFieldType value)
+tracker_field_set_data_type (TrackerField *field,
+ TrackerFieldType value)
{
TrackerFieldPriv *priv;
@@ -600,7 +593,7 @@
void
tracker_field_set_weight (TrackerField *field,
- gint value)
+ gint value)
{
TrackerFieldPriv *priv;
g_return_if_fail (TRACKER_IS_FIELD (field));
@@ -613,12 +606,11 @@
priv->weight = value;
g_object_notify (G_OBJECT (field), "weight");
-
}
void
tracker_field_set_embedded (TrackerField *field,
- gboolean value)
+ gboolean value)
{
TrackerFieldPriv *priv;
@@ -630,10 +622,9 @@
g_object_notify (G_OBJECT (field), "embedded");
}
-
void
tracker_field_set_multiple_values (TrackerField *field,
- gboolean value)
+ gboolean value)
{
TrackerFieldPriv *priv;
@@ -647,7 +638,7 @@
void
tracker_field_set_delimited (TrackerField *field,
- gboolean value)
+ gboolean value)
{
TrackerFieldPriv *priv;
@@ -661,7 +652,7 @@
void
tracker_field_set_filtered (TrackerField *field,
- gboolean value)
+ gboolean value)
{
TrackerFieldPriv *priv;
@@ -675,7 +666,7 @@
void
tracker_field_set_store_metadata (TrackerField *field,
- gboolean value)
+ gboolean value)
{
TrackerFieldPriv *priv;
@@ -689,7 +680,7 @@
void
tracker_field_set_child_ids (TrackerField *field,
- const GSList *value)
+ const GSList *value)
{
TrackerFieldPriv *priv;
@@ -721,7 +712,7 @@
void
tracker_field_append_child_id (TrackerField *field,
- const gchar *value)
+ const gchar *value)
{
TrackerFieldPriv *priv;
Modified: branches/xesam-support/src/trackerd/tracker-field.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-field.h (original)
+++ branches/xesam-support/src/trackerd/tracker-field.h Fri May 23 18:14:30 2008
@@ -65,42 +65,42 @@
TrackerField * tracker_field_new (void);
-const gchar * tracker_field_get_id (const TrackerField *field);
-const gchar * tracker_field_get_name (const TrackerField *field);
-TrackerFieldType tracker_field_get_data_type (const TrackerField *field);
-const gchar * tracker_field_get_field_name (const TrackerField *field);
-gint tracker_field_get_weight (const TrackerField *service);
-gboolean tracker_field_get_embedded (const TrackerField *field);
-gboolean tracker_field_get_multiple_values (const TrackerField *field);
-gboolean tracker_field_get_delimited (const TrackerField *field);
-gboolean tracker_field_get_filtered (const TrackerField *field);
-gboolean tracker_field_get_store_metadata (const TrackerField *field);
-const GSList * tracker_field_get_child_ids (const TrackerField *field);
-void tracker_field_set_id (TrackerField *field,
- const gchar *value);
-
-void tracker_field_set_name (TrackerField *field,
- const gchar *value);
-void tracker_field_set_data_type (TrackerField *field,
- TrackerFieldType value);
-void tracker_field_set_field_name (TrackerField *field,
- const gchar *value);
-void tracker_field_set_weight (TrackerField *field,
- gint value);
-void tracker_field_set_embedded (TrackerField *field,
- gboolean value);
-void tracker_field_set_multiple_values (TrackerField *field,
- gboolean value);
-void tracker_field_set_delimited (TrackerField *field,
- gboolean value);
-void tracker_field_set_filtered (TrackerField *field,
- gboolean value);
-void tracker_field_set_store_metadata (TrackerField *field,
- gboolean value);
-void tracker_field_set_child_ids (TrackerField *field,
- const GSList *value);
-void tracker_field_append_child_id (TrackerField *field,
- const gchar *id);
+const gchar * tracker_field_get_id (TrackerField *field);
+const gchar * tracker_field_get_name (TrackerField *field);
+TrackerFieldType tracker_field_get_data_type (TrackerField *field);
+const gchar * tracker_field_get_field_name (TrackerField *field);
+gint tracker_field_get_weight (TrackerField *service);
+gboolean tracker_field_get_embedded (TrackerField *field);
+gboolean tracker_field_get_multiple_values (TrackerField *field);
+gboolean tracker_field_get_delimited (TrackerField *field);
+gboolean tracker_field_get_filtered (TrackerField *field);
+gboolean tracker_field_get_store_metadata (TrackerField *field);
+const GSList * tracker_field_get_child_ids (TrackerField *field);
+
+void tracker_field_set_id (TrackerField *field,
+ const gchar *value);
+void tracker_field_set_name (TrackerField *field,
+ const gchar *value);
+void tracker_field_set_data_type (TrackerField *field,
+ TrackerFieldType value);
+void tracker_field_set_field_name (TrackerField *field,
+ const gchar *value);
+void tracker_field_set_weight (TrackerField *field,
+ gint value);
+void tracker_field_set_embedded (TrackerField *field,
+ gboolean value);
+void tracker_field_set_multiple_values (TrackerField *field,
+ gboolean value);
+void tracker_field_set_delimited (TrackerField *field,
+ gboolean value);
+void tracker_field_set_filtered (TrackerField *field,
+ gboolean value);
+void tracker_field_set_store_metadata (TrackerField *field,
+ gboolean value);
+void tracker_field_set_child_ids (TrackerField *field,
+ const GSList *value);
+void tracker_field_append_child_id (TrackerField *field,
+ const gchar *id);
G_END_DECLS
Modified: branches/xesam-support/src/trackerd/tracker-hal.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-hal.c (original)
+++ branches/xesam-support/src/trackerd/tracker-hal.c Fri May 23 18:14:30 2008
@@ -231,14 +231,24 @@
priv = GET_PRIV (object);
- g_hash_table_destroy (priv->removable_devices);
- g_hash_table_destroy (priv->mounted_devices);
- g_hash_table_destroy (priv->all_devices);
+ if (priv->removable_devices) {
+ g_hash_table_unref (priv->removable_devices);
+ }
+
+ if (priv->mounted_devices) {
+ g_hash_table_unref (priv->mounted_devices);
+ }
+
+ if (priv->all_devices) {
+ g_hash_table_unref (priv->all_devices);
+ }
g_free (priv->battery_udi);
- libhal_ctx_set_user_data (priv->context, NULL);
- libhal_ctx_free (priv->context);
+ if (priv->context) {
+ libhal_ctx_set_user_data (priv->context, NULL);
+ libhal_ctx_free (priv->context);
+ }
(G_OBJECT_CLASS (tracker_hal_parent_class)->finalize) (object);
}
Modified: branches/xesam-support/src/trackerd/tracker-indexer.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-indexer.c (original)
+++ branches/xesam-support/src/trackerd/tracker-indexer.c Fri May 23 18:14:30 2008
@@ -61,6 +61,7 @@
#include "tracker-hal.h"
#include "tracker-process-files.h"
#include "tracker-query-tree.h"
+#include "tracker-main.h"
#include "tracker-ontology.h"
#include "tracker-status.h"
#include "tracker-db-manager.h"
@@ -144,10 +145,13 @@
gboolean
tracker_indexer_repair (const char *name)
{
- gboolean result = TRUE;
- char *index_name = g_build_filename (tracker->data_dir, name, NULL);
+ gchar *index_name;
+ gboolean result = TRUE;
- result = dprepair (index_name);
+ index_name = g_build_filename (tracker_get_data_dir (),
+ name,
+ NULL);
+ result = dprepair (index_name);
g_free (index_name);
return result;
@@ -189,11 +193,7 @@
static inline char *
get_index_file (const char *name)
{
- char *word_dir;
-
- word_dir = g_build_filename (tracker->data_dir, name, NULL);
-
- return word_dir;
+ return g_build_filename (tracker_get_data_dir (), name, NULL);
}
Indexer *
@@ -264,8 +264,11 @@
if (remove_file) {
+ gchar *dbname;
- char *dbname = g_build_filename (tracker->data_dir, indexer->name, NULL);
+ dbname = g_build_filename (tracker_get_data_dir (),
+ indexer->name,
+ NULL);
g_return_if_fail (indexer);
@@ -492,9 +495,13 @@
if (type == INDEX_TYPE_FILES) {
- files = tracker_process_files_get_files_with_prefix (tracker, tracker->data_dir, "file-index.tmp.");
+ files = tracker_process_files_get_files_with_prefix (tracker,
+ tracker_get_data_dir (),
+ "file-index.tmp.");
} else {
- files = tracker_process_files_get_files_with_prefix (tracker, tracker->data_dir, "email-index.tmp.");
+ files = tracker_process_files_get_files_with_prefix (tracker,
+ tracker_get_data_dir (),
+ "email-index.tmp.");
}
result = (files != NULL);
@@ -513,19 +520,26 @@
gboolean
tracker_indexer_has_merge_files (IndexType type)
{
- GSList *files = NULL;
- gboolean result = FALSE;
- char *final;
+ GSList *files = NULL;
+ gboolean result = FALSE;
+ gchar *final;
+ const gchar *data_dir;
+
+ data_dir = tracker_get_data_dir ();
if (type == INDEX_TYPE_FILES) {
- files = tracker_process_files_get_files_with_prefix (tracker, tracker->data_dir, "file-index.tmp.");
- final = g_build_filename(tracker->data_dir, "file-index-final", NULL);
+ files = tracker_process_files_get_files_with_prefix (tracker,
+ data_dir,
+ "file-index.tmp.");
+ final = g_build_filename (data_dir, "file-index-final", NULL);
} else {
- files = tracker_process_files_get_files_with_prefix (tracker, tracker->data_dir, "email-index.tmp.");
- final = g_build_filename (tracker->data_dir, "email-index-final", NULL);
+ files = tracker_process_files_get_files_with_prefix (tracker,
+ data_dir,
+ "email-index.tmp.");
+ final = g_build_filename (data_dir, "email-index-final", NULL);
}
- result = (files != NULL);
+ result = files != NULL;
if (!result) {
result = g_file_test (final, G_FILE_TEST_EXISTS);
@@ -582,68 +596,59 @@
void
tracker_indexer_merge_indexes (IndexType type)
{
- GObject *object;
- GSList *lst;
- Indexer *final_index;
- GSList *file_list = NULL, *index_list = NULL;
- const char *prefix;
- gint i = 0, index_count, interval = 5000;
- gboolean final_exists;
+ GObject *object;
+ GSList *lst;
+ Indexer *final_index;
+ GSList *file_list = NULL, *index_list = NULL;
+ const gchar *prefix;
+ const gchar *data_dir;
+ gint i = 0, index_count, interval = 5000;
+ gboolean final_exists;
+ gchar *tmp;
if (tracker->shutdown) {
return;
}
+ data_dir = tracker_get_data_dir ();
object = tracker_dbus_get_object (TRACKER_TYPE_DBUS_DAEMON);
if (type == INDEX_TYPE_FILES) {
-
g_return_if_fail (tracker->file_index);
prefix = "file-index.tmp.";
-
index_list = g_slist_prepend (index_list, tracker->file_index);
- char *tmp = g_build_filename (tracker->data_dir, "file-index-final", NULL);
-
+ tmp = g_build_filename (data_dir, "file-index-final", NULL);
final_exists = g_file_test (tmp, G_FILE_TEST_EXISTS);
-
g_free (tmp);
-
} else {
- prefix = "email-index.tmp.";
-
g_return_if_fail (tracker->email_index);
-
- index_list = g_slist_prepend (index_list, tracker->email_index);
- char *tmp = g_build_filename (tracker->data_dir, "email-index-final", NULL);
+ prefix = "email-index.tmp.";
+ index_list = g_slist_prepend (index_list, tracker->email_index);
+ tmp = g_build_filename (data_dir, "email-index-final", NULL);
final_exists = g_file_test (tmp, G_FILE_TEST_EXISTS);
-
g_free (tmp);
}
- file_list = tracker_process_files_get_files_with_prefix (tracker, tracker->data_dir, prefix);
+ file_list = tracker_process_files_get_files_with_prefix (tracker, data_dir, prefix);
if (!file_list || !file_list->data) {
-
g_slist_free (index_list);
-
return;
-
} else {
GSList *file;
for (file = file_list; file; file = file->next) {
-
if (file->data) {
- char *name = g_path_get_basename (file->data);
- if (name) {
+ gchar *name = g_path_get_basename (file->data);
+ if (name) {
if (g_file_test (file->data, G_FILE_TEST_EXISTS)) {
-
Indexer *tmp_index = tracker_indexer_open (name, FALSE);
+
if (tmp_index) {
index_list = g_slist_prepend (index_list, tmp_index);
}
@@ -661,9 +666,7 @@
index_count = g_slist_length (index_list);
if (index_count < 2) {
-
g_slist_free (index_list);
-
return;
}
@@ -682,16 +685,12 @@
tracker->merge_count);
if (index_count == 2 && !final_exists) {
-
Indexer *index1 = index_list->data ;
Indexer *index2 = index_list->next->data ;
if (tracker_indexer_size (index1) * 3 < tracker_indexer_size (index2)) {
-
tracker_indexer_apply_changes (index2, index1, FALSE);
-
g_slist_free (index_list);
-
goto end_of_merging;
}
}
@@ -726,7 +725,6 @@
dpiterinit (index->word_index);
while ((str = dpiternext (index->word_index, NULL))) {
-
gchar buffer[MAX_HIT_BUFFER];
gint offset;
gint sz = sizeof (WordDetails);
@@ -1396,9 +1394,12 @@
{
gchar *filename;
const gchar *filename_const;
- gboolean too_big;
+ const gchar *data_dir;
+ gboolean too_big;
+
+ data_dir = tracker_get_data_dir ();
- filename = g_build_filename (tracker->data_dir, TRACKER_INDEXER_FILE_INDEX_DB_FILENAME, NULL);
+ filename = g_build_filename (data_dir, TRACKER_INDEXER_FILE_INDEX_DB_FILENAME, NULL);
too_big = tracker_file_get_size (filename) > MAX_INDEX_FILE_SIZE;
g_free (filename);
@@ -1407,7 +1408,7 @@
return TRUE;
}
- filename = g_build_filename (tracker->data_dir, TRACKER_INDEXER_EMAIL_INDEX_DB_FILENAME, NULL);
+ filename = g_build_filename (data_dir, TRACKER_INDEXER_EMAIL_INDEX_DB_FILENAME, NULL);
too_big = tracker_file_get_size (filename) > MAX_INDEX_FILE_SIZE;
g_free (filename);
Modified: branches/xesam-support/src/trackerd/tracker-inotify.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-inotify.c (original)
+++ branches/xesam-support/src/trackerd/tracker-inotify.c Fri May 23 18:14:30 2008
@@ -179,7 +179,6 @@
moved_to_info->uri);
tracker->grace_period = 2;
- 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_DB_ACTION_FILE_MOVED_FROM, FALSE, TRUE, -1);
Modified: branches/xesam-support/src/trackerd/tracker-main.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-main.c (original)
+++ branches/xesam-support/src/trackerd/tracker-main.c Fri May 23 18:14:30 2008
@@ -131,6 +131,10 @@
static GMainLoop *main_loop;
static gchar *log_filename;
+static gchar *data_dir;
+static gchar *user_data_dir;
+static gchar *sys_tmp_dir;
+
/* Private command line parameters */
static gchar **no_watch_dirs;
static gchar **watch_dirs;
@@ -194,28 +198,33 @@
static gchar *
get_lock_file (void)
{
- gchar *lock_file, *str;
+ gchar *lock_filename;
+ gchar *filename;
- str = g_strconcat (g_get_user_name (), "_tracker_lock", NULL);
+ filename = g_strconcat (g_get_user_name (), "_tracker_lock", NULL);
/* check if setup for NFS usage (and enable atomic NFS safe locking) */
if (tracker_config_get_nfs_locking (tracker->config)) {
/* Place lock file in tmp dir to allow multiple
* sessions on NFS
*/
- lock_file = g_build_filename (tracker->sys_tmp_root_dir, str, NULL);
-
+ lock_filename = g_build_filename (sys_tmp_dir,
+ filename,
+ NULL);
} else {
/* Place lock file in home dir to prevent multiple
* sessions on NFS (as standard locking might be
* broken on NFS)
*/
- lock_file = g_build_filename (tracker->root_dir, str, NULL);
+ lock_filename = g_build_filename (g_get_user_data_dir (),
+ "tracker",
+ filename,
+ NULL);
}
- g_free (str);
+ g_free (filename);
- return lock_file;
+ return lock_filename;
}
static void
@@ -466,23 +475,27 @@
static void
initialise_locations (void)
{
- gchar *str;
+ gchar *filename;
/* Public locations */
- str = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), getpid ());
- tracker->sys_tmp_root_dir = g_build_filename (g_get_tmp_dir (), str, NULL);
- g_free (str);
-
- tracker->root_dir = g_build_filename (g_get_user_data_dir (), "tracker", NULL);
- tracker->data_dir = g_build_filename (g_get_user_cache_dir (), "tracker", NULL);
- tracker->config_dir = g_strdup (g_get_user_config_dir ());
- tracker->user_data_dir = g_build_filename (tracker->root_dir, "data", NULL);
- tracker->xesam_dir = g_build_filename (g_get_home_dir (), ".xesam", NULL);
+ user_data_dir = g_build_filename (g_get_user_data_dir (),
+ "tracker",
+ "data",
+ NULL);
+
+ data_dir = g_build_filename (g_get_user_cache_dir (),
+ "tracker",
+ NULL);
- tracker->email_attachments_dir = g_build_filename (tracker->sys_tmp_root_dir, "Attachments", NULL);
+ filename = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), getpid ());
+ sys_tmp_dir = g_build_filename (g_get_tmp_dir (), filename, NULL);
+ g_free (filename);
/* Private locations */
- log_filename = g_build_filename (tracker->root_dir, "tracker.log", NULL);
+ log_filename = g_build_filename (g_get_user_data_dir (),
+ "tracker",
+ "tracker.log",
+ NULL);
}
static void
@@ -493,8 +506,8 @@
*need_index = FALSE;
/* Remove an existing one */
- if (g_file_test (tracker->sys_tmp_root_dir, G_FILE_TEST_EXISTS)) {
- tracker_dir_remove (tracker->sys_tmp_root_dir);
+ if (g_file_test (sys_tmp_dir, G_FILE_TEST_EXISTS)) {
+ tracker_dir_remove (sys_tmp_dir);
}
/* Remove old tracker dirs */
@@ -508,20 +521,22 @@
/* Remove database if we are reindexing */
if (reindex || tracker_db_needs_setup ()) {
- tracker_dir_remove (tracker->data_dir);
+ tracker_dir_remove (data_dir);
*need_index = TRUE;
}
/* Create other directories we need */
- if (!g_file_test (tracker->user_data_dir, G_FILE_TEST_EXISTS)) {
- g_mkdir_with_parents (tracker->user_data_dir, 00755);
+ if (!g_file_test (user_data_dir, G_FILE_TEST_EXISTS)) {
+ g_mkdir_with_parents (user_data_dir, 00755);
}
- if (!g_file_test (tracker->data_dir, G_FILE_TEST_EXISTS)) {
- g_mkdir_with_parents (tracker->data_dir, 00755);
+ if (!g_file_test (data_dir, G_FILE_TEST_EXISTS)) {
+ g_mkdir_with_parents (data_dir, 00755);
}
- g_mkdir_with_parents (tracker->email_attachments_dir, 00700);
+ filename = g_build_filename (sys_tmp_dir, "Attachments", NULL);
+ g_mkdir_with_parents (filename, 00700);
+ g_free (filename);
/* Remove existing log files */
tracker_file_unlink (log_filename);
@@ -593,15 +608,13 @@
/* Move final file to index file if present and no files left
* to merge.
*/
- final_index_name = g_build_filename (tracker->data_dir,
- "file-index-final",
- NULL);
+ final_index_name = g_build_filename (data_dir, "file-index-final", NULL);
if (g_file_test (final_index_name, G_FILE_TEST_EXISTS) &&
!tracker_indexer_has_tmp_merge_files (INDEX_TYPE_FILES)) {
gchar *file_index_name;
- file_index_name = g_build_filename (tracker->data_dir,
+ file_index_name = g_build_filename (data_dir,
TRACKER_INDEXER_FILE_INDEX_DB_FILENAME,
NULL);
@@ -614,7 +627,7 @@
g_free (final_index_name);
- final_index_name = g_build_filename (tracker->data_dir,
+ final_index_name = g_build_filename (data_dir,
"email-index-final",
NULL);
@@ -622,7 +635,7 @@
!tracker_indexer_has_tmp_merge_files (INDEX_TYPE_EMAILS)) {
gchar *file_index_name;
- file_index_name = g_build_filename (tracker->data_dir,
+ file_index_name = g_build_filename (data_dir,
TRACKER_INDEXER_EMAIL_INDEX_DB_FILENAME,
NULL);
@@ -768,13 +781,9 @@
shutdown_locations (void)
{
/* Public locations */
- g_free (tracker->data_dir);
- g_free (tracker->config_dir);
- g_free (tracker->root_dir);
- g_free (tracker->user_data_dir);
- g_free (tracker->sys_tmp_root_dir);
- g_free (tracker->email_attachments_dir);
- g_free (tracker->xesam_dir);
+ g_free (data_dir);
+ g_free (user_data_dir);
+ g_free (sys_tmp_dir);
/* Private locations */
g_free (log_filename);
@@ -785,13 +794,13 @@
{
/* If we are reindexing, just remove the databases */
if (tracker->reindex) {
- tracker_dir_remove (tracker->data_dir);
- g_mkdir_with_parents (tracker->data_dir, 00755);
+ tracker_dir_remove (data_dir);
+ g_mkdir_with_parents (data_dir, 00755);
}
/* Remove sys tmp directory */
- if (tracker->sys_tmp_root_dir) {
- tracker_dir_remove (tracker->sys_tmp_root_dir);
+ if (sys_tmp_dir) {
+ tracker_dir_remove (sys_tmp_dir);
}
}
@@ -934,17 +943,12 @@
sanity_check_option_values ();
- tracker_nfs_lock_init (tracker->root_dir,
- tracker_config_get_nfs_locking (tracker->config));
+ tracker_nfs_lock_init (tracker_config_get_nfs_locking (tracker->config));
tracker_db_init ();
- tracker_db_manager_init (tracker->data_dir,
- tracker->user_data_dir,
- tracker->sys_tmp_root_dir);
+ tracker_db_manager_init (data_dir, user_data_dir, sys_tmp_dir);
tracker_xesam_init ();
tracker_cache_init ();
-
tracker_ontology_init ();
-
tracker_email_init (tracker->config);
#ifdef HAVE_HAL
@@ -1036,11 +1040,6 @@
shutdown_directories ();
/* Shutdown major subsystems */
- if (tracker->hal) {
- g_object_unref (tracker->hal);
- tracker->hal = NULL;
- }
-
tracker_email_shutdown ();
tracker_dbus_shutdown ();
tracker_ontology_shutdown ();
@@ -1051,6 +1050,10 @@
tracker_nfs_lock_shutdown ();
tracker_log_shutdown ();
+ if (tracker->hal) {
+ g_object_unref (tracker->hal);
+ }
+
if (tracker->language) {
g_object_unref (tracker->language);
}
@@ -1069,3 +1072,15 @@
{
g_main_loop_quit (main_loop);
}
+
+const gchar *
+tracker_get_data_dir (void)
+{
+ return data_dir;
+}
+
+const gchar *
+tracker_get_sys_tmp_dir (void)
+{
+ return sys_tmp_dir;
+}
Modified: branches/xesam-support/src/trackerd/tracker-main.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-main.h (original)
+++ branches/xesam-support/src/trackerd/tracker-main.h Fri May 23 18:14:30 2008
@@ -58,16 +58,6 @@
/* Config options */
guint32 watch_limit;
- gpointer xesam_db;
-
- /* Data directories */
- gchar *data_dir;
- gchar *config_dir;
- gchar *root_dir;
- gchar *user_data_dir;
- gchar *sys_tmp_root_dir;
- gchar *email_attachments_dir;
- gchar *xesam_dir;
/* Performance and memory usage options */
gint max_process_queue_size;
@@ -94,15 +84,11 @@
gint mbox_processed;
gint grace_period;
- gboolean request_waiting;
/* Email config options */
gint email_service_min;
gint email_service_max;
- /* Queue for recorad file changes */
- gboolean black_list_timer_active;
-
/* Progress info for merges */
gboolean in_merge;
gint merge_count;
@@ -124,7 +110,10 @@
GCond *metadata_signal_cond;
} Tracker;
-void tracker_shutdown (void);
+void tracker_shutdown (void);
+
+const gchar *tracker_get_data_dir (void);
+const gchar *tracker_get_sys_tmp_dir (void);
G_END_DECLS
Modified: branches/xesam-support/src/trackerd/tracker-metadata.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-metadata.c (original)
+++ branches/xesam-support/src/trackerd/tracker-metadata.c Fri May 23 18:14:30 2008
@@ -75,7 +75,9 @@
char *temp_file_name;
int fd;
- temp_file_name = g_build_filename (tracker->sys_tmp_root_dir, "tmp_text_file_XXXXXX", NULL);
+ temp_file_name = g_build_filename (tracker_get_sys_tmp_dir (),
+ "tmp_text_file_XXXXXX",
+ NULL);
fd = g_mkstemp (temp_file_name);
Modified: branches/xesam-support/src/trackerd/tracker-ontology.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-ontology.c (original)
+++ branches/xesam-support/src/trackerd/tracker-ontology.c Fri May 23 18:14:30 2008
@@ -571,8 +571,8 @@
}
gchar *
-tracker_ontology_get_field_column_in_services (const TrackerField *field,
- const gchar *service_type)
+tracker_ontology_get_field_column_in_services (TrackerField *field,
+ const gchar *service_type)
{
const gchar *field_name;
const gchar *meta_name = tracker_field_get_name (field);
@@ -606,7 +606,7 @@
}
gchar *
-tracker_ontology_get_display_field (const TrackerField *field)
+tracker_ontology_get_display_field (TrackerField *field)
{
TrackerFieldType type;
@@ -624,7 +624,7 @@
gboolean
tracker_ontology_field_is_child_of (const gchar *child, const gchar *parent) {
- const TrackerField *def_child, *def_parent;
+ TrackerField *def_child, *def_parent;
def_child = tracker_ontology_get_field_def (child);
@@ -655,7 +655,7 @@
}
-const TrackerField *
+TrackerField *
tracker_ontology_get_field_def (const gchar *name)
{
return ontology_hash_lookup_by_str (metadata_table, name);
@@ -664,7 +664,7 @@
const gchar *
tracker_ontology_get_field_id (const gchar *name)
{
- const TrackerField *field;
+ TrackerField *field;
field = tracker_ontology_get_field_def (name);
Modified: branches/xesam-support/src/trackerd/tracker-ontology.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-ontology.h (original)
+++ branches/xesam-support/src/trackerd/tracker-ontology.h Fri May 23 18:14:30 2008
@@ -29,52 +29,46 @@
G_BEGIN_DECLS
-void tracker_ontology_init (void);
-void tracker_ontology_shutdown (void);
-void tracker_ontology_add_service_type (TrackerService *service,
- GSList *mimes,
- GSList *mime_prefixes);
-TrackerService * tracker_ontology_get_service_type_by_name (const gchar *service_str);
-gchar * tracker_ontology_get_service_type_by_id (gint id);
-gchar * tracker_ontology_get_service_type_for_mime (const gchar *mime);
-gint tracker_ontology_get_id_for_service_type (const gchar *service_str);
-gchar * tracker_ontology_get_parent_service (const gchar *service_str);
-gchar * tracker_ontology_get_parent_service_by_id (gint id);
-gint tracker_ontology_get_parent_id_for_service_id (gint id);
-TrackerDBType tracker_ontology_get_db_for_service_type (const gchar *service_str);
-gboolean tracker_ontology_service_type_has_embedded (const gchar *service_str);
-gboolean tracker_ontology_is_valid_service_type (const gchar *service_str);
-gboolean tracker_ontology_service_type_has_metadata (const gchar *service_str);
-gboolean tracker_ontology_service_type_has_thumbnails (const gchar *service_str);
-gboolean tracker_ontology_service_type_has_text (const gchar *service_str);
-gint tracker_ontology_metadata_key_in_service (const gchar *service_str,
- const gchar *meta_name);
-gboolean tracker_ontology_show_service_directories (const gchar *service_str);
-gboolean tracker_ontology_show_service_files (const gchar *service_str);
-
-
+void tracker_ontology_init (void);
+void tracker_ontology_shutdown (void);
+void tracker_ontology_add_service_type (TrackerService *service,
+ GSList *mimes,
+ GSList *mime_prefixes);
+TrackerService *tracker_ontology_get_service_type_by_name (const gchar *service_str);
+gchar * tracker_ontology_get_service_type_by_id (gint id);
+gchar * tracker_ontology_get_service_type_for_mime (const gchar *mime);
+gint tracker_ontology_get_id_for_service_type (const gchar *service_str);
+gchar * tracker_ontology_get_parent_service (const gchar *service_str);
+gchar * tracker_ontology_get_parent_service_by_id (gint id);
+gint tracker_ontology_get_parent_id_for_service_id (gint id);
+TrackerDBType tracker_ontology_get_db_for_service_type (const gchar *service_str);
+gboolean tracker_ontology_service_type_has_embedded (const gchar *service_str);
+gboolean tracker_ontology_is_valid_service_type (const gchar *service_str);
+gboolean tracker_ontology_service_type_has_metadata (const gchar *service_str);
+gboolean tracker_ontology_service_type_has_thumbnails (const gchar *service_str);
+gboolean tracker_ontology_service_type_has_text (const gchar *service_str);
+gint tracker_ontology_metadata_key_in_service (const gchar *service_str,
+ const gchar *meta_name);
+gboolean tracker_ontology_show_service_directories (const gchar *service_str);
+gboolean tracker_ontology_show_service_files (const gchar *service_str);
/* Service directories */
-GSList * tracker_ontology_get_dirs_for_service_type (const gchar *service);
-void tracker_ontology_add_dir_to_service_type (const gchar *service,
- const gchar *path);
-void tracker_ontology_remove_dir_to_service_type (const gchar *service,
- const gchar *path);
-gchar * tracker_ontology_get_service_type_for_dir (const gchar *path);
-
-
-
+GSList * tracker_ontology_get_dirs_for_service_type (const gchar *service);
+void tracker_ontology_add_dir_to_service_type (const gchar *service,
+ const gchar *path);
+void tracker_ontology_remove_dir_to_service_type (const gchar *service,
+ const gchar *path);
+gchar * tracker_ontology_get_service_type_for_dir (const gchar *path);
/* Field handling */
-void tracker_ontology_add_field (TrackerField *field);
-gchar * tracker_ontology_get_field_column_in_services (const TrackerField *field,
- const gchar *service_type);
-gchar * tracker_ontology_get_display_field (const TrackerField *field);
-gboolean tracker_ontology_field_is_child_of (const gchar *child,
- const gchar *parent);
-const TrackerField *tracker_ontology_get_field_def (const gchar *name);
-const gchar * tracker_ontology_get_field_id (const gchar *name);
-
+void tracker_ontology_add_field (TrackerField *field);
+gchar * tracker_ontology_get_field_column_in_services (TrackerField *field,
+ const gchar *service_type);
+gchar * tracker_ontology_get_display_field (TrackerField *field);
+gboolean tracker_ontology_field_is_child_of (const gchar *child,
+ const gchar *parent);
+TrackerField * tracker_ontology_get_field_def (const gchar *name);
+const gchar * tracker_ontology_get_field_id (const gchar *name);
G_END_DECLS
Modified: branches/xesam-support/src/trackerd/tracker-parser.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-parser.c (original)
+++ branches/xesam-support/src/trackerd/tracker-parser.c Fri May 23 18:14:30 2008
@@ -110,21 +110,18 @@
gint length,
guint32 *len)
{
- *len = length;
-
#ifdef HAVE_UNAC
- if (tracker->strip_accents) {
- gchar *s = NULL;
+ gchar *s = NULL;
- if (unac_string ("UTF-8", str, length, &s, &*len) != 0) {
- tracker_warning ("UNAC failed to strip accents");
- }
-
- return s;
+ if (unac_string ("UTF-8", str, length, &s, &*len) != 0) {
+ g_warning ("UNAC failed to strip accents");
}
-#endif
+ return s;
+#else
+ *len = length;
return NULL;
+#endif
}
static gboolean
Modified: branches/xesam-support/src/trackerd/tracker-rdf-query.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-rdf-query.c (original)
+++ branches/xesam-support/src/trackerd/tracker-rdf-query.c Fri May 23 18:14:30 2008
@@ -336,60 +336,63 @@
-static FieldData *
-add_metadata_field (ParserData *data, const char *field_name, gboolean is_select, gboolean is_condition)
+static TrackerFieldData *
+add_metadata_field (ParserData *data,
+ const gchar *field_name,
+ gboolean is_select,
+ gboolean is_condition)
{
- gboolean field_exists;
- FieldData *field_data;
- const GSList *tmp;
+ TrackerFieldData *field_data;
+ gboolean field_exists;
+ GSList *l;
field_exists = FALSE;
field_data = NULL;
- // check if field is already in list
- for (tmp = data->fields; tmp; tmp = tmp->next) {
- FieldData *tmp_field;
+ /* Check if field is already in list */
+ for (l = data->fields; l; l = l->next) {
+ const gchar *this_field_name;
+
+ this_field_name = tracker_field_data_get_field_name (l->data);
+ if (!this_field_name) {
+ continue;
+ }
+
+ if (strcasecmp (this_field_name, field_name) == 0) {
+ field_data = l->data;
+ field_exists = TRUE;
+
+ if (is_condition) {
+ tracker_field_data_set_is_condition (field_data, TRUE);
+ }
+
+ if (is_select) {
+ if (!tracker_field_data_get_is_select (field_data)) {
+ tracker_field_data_set_is_select (field_data, TRUE);
+ g_string_append_printf (data->sql_select, ", %s",
+ tracker_field_data_get_select_field (field_data));
+ }
+ }
- tmp_field = tmp->data;
-
- if (tmp_field && tmp_field->field_name) {
- if (strcasecmp (tmp_field->field_name, field_name) == 0) {
-
- field_data = tmp_field;
-
- field_exists = TRUE;
-
- if (is_condition) {
- field_data->is_condition = TRUE;
- }
-
- if (is_select) {
- if (!field_data->is_select) {
-
- field_data->is_select = TRUE;
- g_string_append_printf (data->sql_select, ", %s", field_data->select_field);
- }
-
- }
-
- break;
-
- }
+ break;
}
}
-
if (!field_exists) {
-
- field_data = tracker_db_get_metadata_field (data->db_con, data->service, field_name, g_slist_length (data->fields), is_select, is_condition);
+ field_data = tracker_db_get_metadata_field (data->db_con,
+ data->service,
+ field_name,
+ g_slist_length (data->fields),
+ is_select,
+ is_condition);
if (field_data) {
data->fields = g_slist_prepend (data->fields, field_data);
if (is_select) {
- g_string_append_printf (data->sql_select, ", %s", field_data->select_field);
+ g_string_append_printf (data->sql_select, ", %s",
+ tracker_field_data_get_select_field (field_data));
}
-
- }
+ }
}
return field_data;
@@ -666,12 +669,17 @@
static gboolean
build_sql (ParserData *data)
{
- ParseState state;
- char *avalue, *value, *sub;
- FieldData *field_data;
- GString *str;
-
- g_return_val_if_fail (data->current_field && data->current_operator != OP_NONE && data->current_value, FALSE);
+ TrackerFieldData *field_data;
+ ParseState state;
+ gchar *avalue, *value, *sub;
+ const gchar *where_field;
+ GString *str;
+ gchar **s;
+
+ g_return_val_if_fail (data->current_field &&
+ data->current_operator != OP_NONE &&
+ data->current_value,
+ FALSE);
str = g_string_new ("");
@@ -679,7 +687,9 @@
state = peek_state (data);
- avalue = get_value (data->current_value, (state != STATE_END_DATE && state != STATE_END_INTEGER && state != STATE_END_FLOAT));
+ avalue = get_value (data->current_value, (state != STATE_END_DATE &&
+ state != STATE_END_INTEGER &&
+ state != STATE_END_FLOAT));
field_data = add_metadata_field (data, data->current_field, FALSE, TRUE);
@@ -690,9 +700,9 @@
return FALSE;
}
- if (field_data->data_type == TRACKER_FIELD_TYPE_DATE) {
- char *bvalue;
- int cvalue;
+ if (tracker_field_data_get_data_type (field_data) == TRACKER_FIELD_TYPE_DATE) {
+ gchar *bvalue;
+ gint cvalue;
bvalue = tracker_date_format (avalue);
g_debug (bvalue);
@@ -716,102 +726,112 @@
}
}
- char **s;
+ where_field = tracker_field_data_get_where_field (field_data);
switch (data->current_operator) {
+ case OP_EQUALS:
+ sub = strchr (data->current_value, '*');
+ if (sub) {
+ g_string_append_printf (str, " (%s glob '%s') ",
+ where_field,
+ data->current_value);
+ } else {
+ TrackerFieldType data_type;
+
+ data_type = tracker_field_data_get_data_type (field_data);
+
+ if (data_type == TRACKER_FIELD_TYPE_DATE ||
+ data_type == TRACKER_FIELD_TYPE_INTEGER ||
+ data_type == TRACKER_FIELD_TYPE_DOUBLE) {
+ g_string_append_printf (str, " (%s = %s) ",
+ where_field,
+ value);
+ } else {
+ g_string_append_printf (str, " (%s = '%s') ",
+ where_field,
+ value);
+ }
+ }
+ break;
+
+ case OP_GREATER:
+ g_string_append_printf (str, " (%s > %s) ",
+ where_field,
+ value);
+ break;
+
+ case OP_GREATER_EQUAL:
+ g_string_append_printf (str, " (%s >= %s) ",
+ where_field,
+ value);
+ break;
+
+ case OP_LESS:
+ g_string_append_printf (str, " (%s < %s) ",
+ where_field,
+ value);
+ break;
+
+ case OP_LESS_EQUAL:
+ g_string_append_printf (str, " (%s <= %s) ",
+ where_field,
+ value);
+ break;
+
+ case OP_CONTAINS:
+ sub = strchr (data->current_value, '*');
+
+ if (sub) {
+ g_string_append_printf (str, " (%s like '%%%s%%') ",
+ where_field,
+ data->current_value);
+ } else {
+ g_string_append_printf (str, " (%s like '%%%s%%') ",
+ where_field,
+ data->current_value);
+ }
+ break;
+
+ case OP_STARTS:
+ sub = strchr (data->current_value, '*');
+
+ if (sub) {
+ g_string_append_printf (str, " (%s like '%s') ",
+ where_field,
+ data->current_value);
+ } else {
+ g_string_append_printf (str, " (%s like '%s%%') ",
+ where_field,
+ data->current_value);
+ }
+ break;
+
+ case OP_REGEX:
+ g_string_append_printf (str, " (%s REGEXP '%s') ",
+ where_field,
+ data->current_value);
+ break;
- case OP_EQUALS:
-
- sub = strchr (data->current_value, '*');
- if (sub) {
- g_string_append_printf (str, " (%s glob '%s') ", field_data->where_field, data->current_value);
- } else {
- if (field_data->data_type == TRACKER_FIELD_TYPE_DATE
- || field_data->data_type == TRACKER_FIELD_TYPE_INTEGER
- || field_data->data_type == TRACKER_FIELD_TYPE_DOUBLE) {
- g_string_append_printf (str, " (%s = %s) ", field_data->where_field, value);
- } else {
- g_string_append_printf (str, " (%s = '%s') ", field_data->where_field, value);
- }
- }
-
- break;
-
- case OP_GREATER:
-
- g_string_append_printf (str, " (%s > %s) ", field_data->where_field, value);
-
- break;
-
- case OP_GREATER_EQUAL:
-
- g_string_append_printf (str, " (%s >= %s) ", field_data->where_field, value);
-
- break;
-
- case OP_LESS:
-
- g_string_append_printf (str, " (%s < %s) ", field_data->where_field, value);
-
- break;
-
- case OP_LESS_EQUAL:
-
- g_string_append_printf (str, " (%s <= %s) ", field_data->where_field, value);
-
- break;
-
- case OP_CONTAINS:
-
- sub = strchr (data->current_value, '*');
-
- if (sub) {
- g_string_append_printf (str, " (%s like '%s%s%s') ", field_data->where_field, "%", data->current_value, "%");
- } else {
- g_string_append_printf (str, " (%s like '%s%s%s') ", field_data->where_field, "%", data->current_value, "%");
- }
-
- break;
-
- case OP_STARTS:
-
- sub = strchr (data->current_value, '*');
-
- if (sub) {
- g_string_append_printf (str, " (%s like '%s') ", field_data->where_field, data->current_value);
- } else {
- g_string_append_printf (str, " (%s like '%s%s') ", field_data->where_field, data->current_value, "%");
- }
-
- break;
-
- case OP_REGEX:
-
- g_string_append_printf (str, " (%s REGEXP '%s') ", field_data->where_field, data->current_value);
-
- break;
-
- case OP_SET:
-
- s = g_strsplit (data->current_value, ",", 0);
-
- if (s && s[0]) {
-
- g_string_append_printf (str, " (%s in ('%s'", field_data->where_field, s[0]);
-
- char **p;
- for (p = s+1; *p; p++) {
- g_string_append_printf (str, ",'%s'", *p);
- }
- g_string_append_printf (str, ") ) " );
-
- }
-
- break;
-
- default:
+ case OP_SET:
+ s = g_strsplit (data->current_value, ",", 0);
+
+ if (s && s[0]) {
+ gchar **p;
- break;
+ g_string_append_printf (str, " (%s in ('%s'",
+ where_field,
+ s[0]);
+
+ for (p = s + 1; *p; p++) {
+ g_string_append_printf (str, ",'%s'", *p);
+ }
+
+ g_string_append_printf (str, ") ) " );
+ }
+ break;
+
+ default:
+ break;
}
data->sql_where = g_string_append (data->sql_where, str->str);
@@ -829,7 +849,6 @@
return TRUE;
}
-
static void
end_element_handler (GMarkupParseContext *context,
const gchar *element_name,
@@ -1079,13 +1098,13 @@
int i;
for (i = 0; i < field_count; i++) {
- FieldData *field_data;
+ TrackerFieldData *field_data;
field_data = add_metadata_field (&data, fields[i], TRUE, FALSE);
if (!field_data) {
g_critical ("RDF Query failed: field %s not found", fields[i]);
- g_slist_foreach (data.fields, (GFunc) tracker_free_metadata_field, NULL);
+ g_slist_foreach (data.fields, (GFunc) g_object_unref, NULL);
g_slist_free (data.fields);
g_string_free (data.sql_select, TRUE);
return NULL;
@@ -1195,7 +1214,7 @@
g_string_free (data.sql_order, TRUE);
}
- g_slist_foreach (data.fields, (GFunc) tracker_free_metadata_field, NULL);
+ g_slist_foreach (data.fields, (GFunc) g_object_unref, NULL);
g_slist_free (data.fields);
g_slist_free (data.stack);
Modified: branches/xesam-support/src/trackerd/tracker-utils.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-utils.c (original)
+++ branches/xesam-support/src/trackerd/tracker-utils.c Fri May 23 18:14:30 2008
@@ -29,6 +29,7 @@
#include "tracker-utils.h"
#include "tracker-main.h"
#include "tracker-process-files.h"
+#include "tracker-xesam.h"
extern Tracker *tracker;
@@ -130,7 +131,7 @@
void
tracker_add_io_grace (const gchar *uri)
{
- if (g_str_has_prefix (uri, tracker->xesam_dir)) {
+ if (tracker_xesam_is_uri_in_xesam_dir (uri)) {
return;
}
@@ -143,8 +144,9 @@
gboolean
tracker_is_low_diskspace (void)
{
- struct statvfs st;
- gint low_disk_space_limit;
+ struct statvfs st;
+ const gchar *data_dir;
+ gint low_disk_space_limit;
low_disk_space_limit = tracker_config_get_low_disk_space_limit (tracker->config);
@@ -152,12 +154,16 @@
return FALSE;
}
- if (statvfs (tracker->data_dir, &st) == -1) {
+ data_dir = tracker_get_data_dir ();
+
+ if (statvfs (data_dir, &st) == -1) {
static gboolean reported = 0;
- if (! reported) {
+
+ if (!reported) {
reported = 1;
- g_critical ("Could not statvfs %s", tracker->data_dir);
+ g_critical ("Could not statvfs %s", data_dir);
}
+
return FALSE;
}
Modified: branches/xesam-support/src/trackerd/tracker-xesam-query.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-query.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-query.c Fri May 23 18:14:30 2008
@@ -26,6 +26,7 @@
#include <libtracker-common/tracker-utils.h>
#include "tracker-xesam-query.h"
+#include "tracker-field-data.h"
/* XESAM Query Condition
@@ -188,34 +189,49 @@
static gboolean
is_operator (ParseState state)
{
- return state == STATE_EQUALS || state == STATE_GREATER_THAN || state == STATE_LESS_THAN ||
- state == STATE_CONTAINS || state == STATE_IN_SET || STATE_LESS_OR_EQUAL ||
- STATE_GREATER_OR_EQUAL || state == STATE_STARTS_WITH || state == STATE_REGEX;
+ return
+ state == STATE_EQUALS ||
+ state == STATE_GREATER_THAN ||
+ state == STATE_LESS_THAN ||
+ state == STATE_CONTAINS ||
+ state == STATE_IN_SET ||
+ state == STATE_LESS_OR_EQUAL ||
+ state == STATE_GREATER_OR_EQUAL ||
+ state == STATE_STARTS_WITH ||
+ state == STATE_REGEX;
}
-
static gboolean
is_end_operator (ParseState state)
{
- return state == STATE_END_EQUALS || state == STATE_END_GREATER_THAN || state == STATE_END_LESS_THAN ||
- state == STATE_END_CONTAINS || state == STATE_END_IN_SET || STATE_END_LESS_OR_EQUAL ||
- STATE_END_GREATER_OR_EQUAL || state == STATE_END_STARTS_WITH || state == STATE_END_REGEX;
-
+ return
+ state == STATE_END_EQUALS ||
+ state == STATE_END_GREATER_THAN ||
+ state == STATE_END_LESS_THAN ||
+ state == STATE_END_CONTAINS ||
+ state == STATE_END_IN_SET ||
+ state == STATE_END_LESS_OR_EQUAL ||
+ state == STATE_END_GREATER_OR_EQUAL ||
+ state == STATE_END_STARTS_WITH ||
+ state == STATE_END_REGEX;
}
-
static gboolean
is_logic (ParseState state)
{
- return state == STATE_AND || state == STATE_OR;
+ return
+ state == STATE_AND ||
+ state == STATE_OR;
}
static gboolean
is_end_logic (ParseState state)
{
- return state == STATE_END_AND || state == STATE_END_OR;
+ return
+ state == STATE_END_AND ||
+ state == STATE_END_OR;
}
@@ -338,19 +354,24 @@
static GList *
-add_metadata_field (ParserData *data, const char *xesam_name, gboolean is_select, gboolean is_condition)
+add_metadata_field (ParserData *data,
+ const char *xesam_name,
+ gboolean is_select,
+ gboolean is_condition)
{
- gboolean field_exists;
- FieldData *field_data;
- const GSList *tmp;
- GList *reply=NULL;
TrackerDBResultSet *result_set;
- gboolean valid = TRUE;
+ TrackerFieldData *field_data;
+ gboolean field_exists;
+ const GSList *l;
+ GList *reply;
+ gboolean valid;
+ reply = NULL;
field_exists = FALSE;
field_data = NULL;
+ valid = TRUE;
- // Do the xesam mapping
+ /* Do the xesam mapping */
result_set = tracker_get_xesam_metadata_names (data->db_con, xesam_name);
if (!result_set) {
@@ -362,54 +383,41 @@
tracker_db_result_set_get (result_set, 0, &field_name, -1);
- // check if field is already in list
- for (tmp = data->fields; tmp; tmp = tmp->next) {
- FieldData *tmp_field;
+ /* Check if field is already in list */
+ for (l = data->fields; l; l = l->next) {
+ const gchar *this_field_name;
- tmp_field = tmp->data;
+ this_field_name = tracker_field_data_get_field_name (l->data);
- if (tmp_field && tmp_field->field_name) {
- if (strcasecmp (tmp_field->field_name, field_name) == 0) {
-
- field_data = tmp_field;
-
- field_exists = TRUE;
-
- if (is_condition) {
- field_data->is_condition = TRUE;
- }
-
- if (is_select) {
- if (!field_data->is_select) {
-
- field_data->is_select = TRUE;
- //g_string_append_printf (data->sql_select, ", %s", field_data->select_field);
- }
-
- }
-
- break;
-
- }
+ if (!this_field_name) {
+ continue;
+ }
+
+ if (strcasecmp (this_field_name, field_name) != 0) {
+ continue;
}
+
+ field_exists = TRUE;
+
+ tracker_field_data_set_is_condition (l->data, is_condition);
+ tracker_field_data_set_is_select (l->data, is_select);
+
+ break;
}
-
-
if (!field_exists) {
-
- field_data = tracker_db_get_metadata_field (data->db_con, data->service, field_name, g_slist_length (data->fields), is_select, is_condition);
+ field_data = tracker_db_get_metadata_field (data->db_con,
+ data->service,
+ field_name,
+ g_slist_length (data->fields),
+ is_select,
+ is_condition);
if (field_data) {
data->fields = g_slist_prepend (data->fields, field_data);
- if (is_select) {
- // g_string_append_printf (data->sql_select, ", %s", field_data->select_field);
- }
-
}
}
- reply = g_list_append(reply, field_data);
-
+ reply = g_list_append (reply, field_data);
valid = tracker_db_result_set_iter_next (result_set);
g_free (field_name);
}
@@ -419,11 +427,11 @@
static void
-start_element_handler (GMarkupParseContext *context,
- const gchar *element_name,
+start_element_handler (GMarkupParseContext *context,
+ const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
- gpointer user_data,
+ gpointer user_data,
GError **error)
{
ParserData *data;
@@ -791,20 +799,27 @@
static gboolean
build_sql (ParserData *data)
{
- ParseState state;
- char *avalue, *value, *sub;
+ ParseState state;
+ gchar *avalue, *value, *sub;
GList *field_data = NULL;
GList *field_data_list = NULL;
GString *str;
- int i=0;
+ gint i = 0;
- g_return_val_if_fail (data->current_field && data->current_operator != OP_NONE && data->current_value, FALSE);
+ g_return_val_if_fail (data->current_field &&
+ data->current_operator != OP_NONE &&
+ data->current_value,
+ FALSE);
data->statement_count++;
state = peek_state (data);
- avalue = get_value (data->current_value, (state != STATE_END_DATE && state != STATE_END_INTEGER && state != STATE_END_FLOAT && state != STATE_END_BOOLEAN));
+ avalue = get_value (data->current_value,
+ (state != STATE_END_DATE &&
+ state != STATE_END_INTEGER &&
+ state != STATE_END_FLOAT &&
+ state != STATE_END_BOOLEAN));
field_data_list = add_metadata_field (data, data->current_field, FALSE, TRUE);
@@ -820,16 +835,19 @@
field_data = g_list_first (field_data_list);
while (field_data) {
+ const gchar *where_field;
+ gchar **s;
+
i++;
str = g_string_new ("");
if (i>1) {
g_string_append (str, " OR ");
}
-
- if (((FieldData *)field_data->data)->data_type == TRACKER_FIELD_TYPE_DATE) {
- char *bvalue;
- int cvalue;
+
+ if (tracker_field_data_get_data_type (field_data->data) == TRACKER_FIELD_TYPE_DATE) {
+ gchar *bvalue;
+ gint cvalue;
bvalue = tracker_date_format (avalue);
g_debug (bvalue);
@@ -837,13 +855,17 @@
g_debug ("%d", cvalue);
value = tracker_int_to_string (cvalue);
g_free (bvalue);
- } else if (state == STATE_END_BOOLEAN) { /* FIXME We do a state check here, because TRACKER_FIELD_TYPE_BOOLEAN is not in db */
+ } else if (state == STATE_END_BOOLEAN) {
+ /* FIXME We do a state check here, because
+ * TRACKER_FIELD_TYPE_BOOLEAN is not in db.
+ */
if (!strcmp(avalue,"true")) {
value = g_strdup("1");
} else if(!strcmp(avalue,"false")) {
value = g_strdup("0");
} else {
- return FALSE; /* TODO Add error message */
+ /* TODO Add error message */
+ return FALSE;
}
} else {
value = g_strdup (avalue);
@@ -859,114 +881,124 @@
}
}
- char **s;
+ where_field = tracker_field_data_get_where_field (field_data->data);
switch (data->current_operator) {
-
- case OP_EQUALS:
-
+ case OP_EQUALS:
sub = strchr (data->current_value, '*');
+
if (sub) {
- g_string_append_printf (str, " (%s glob '%s') ", ((FieldData *)field_data->data)->where_field, data->current_value);
+ g_string_append_printf (str, " (%s glob '%s') ",
+ where_field,
+ data->current_value);
} else {
- if (((FieldData *)field_data->data)->data_type == TRACKER_FIELD_TYPE_DATE
- || ((FieldData *)field_data->data)->data_type == TRACKER_FIELD_TYPE_INTEGER
- || ((FieldData *)field_data->data)->data_type == TRACKER_FIELD_TYPE_DOUBLE) {
- g_string_append_printf (str, " (%s = %s) ", ((FieldData *)field_data->data)->where_field, value);
+ TrackerFieldType data_type;
+
+ data_type = tracker_field_data_get_data_type (field_data->data);
+
+ if (data_type == TRACKER_FIELD_TYPE_DATE ||
+ data_type == TRACKER_FIELD_TYPE_INTEGER ||
+ data_type == TRACKER_FIELD_TYPE_DOUBLE) {
+ g_string_append_printf (str, " (%s = %s) ",
+ where_field,
+ value);
} else {
- g_string_append_printf (str, " (%s = '%s') ", ((FieldData *)field_data->data)->where_field, value);
+ g_string_append_printf (str, " (%s = '%s') ",
+ where_field,
+ value);
}
}
-
break;
case OP_GREATER:
-
- g_string_append_printf (str, " (%s > %s) ", ((FieldData *)field_data->data)->where_field, value);
-
+ g_string_append_printf (str, " (%s > %s) ",
+ where_field,
+ value);
break;
case OP_GREATER_EQUAL:
-
- g_string_append_printf (str, " (%s >= %s) ", ((FieldData *)field_data->data)->where_field, value);
-
+ g_string_append_printf (str, " (%s >= %s) ",
+ where_field,
+ value);
break;
case OP_LESS:
-
- g_string_append_printf (str, " (%s < %s) ", ((FieldData *)field_data->data)->where_field, value);
-
+ g_string_append_printf (str, " (%s < %s) ",
+ where_field,
+ value);
break;
case OP_LESS_EQUAL:
-
- g_string_append_printf (str, " (%s <= %s) ", ((FieldData *)field_data->data)->where_field, value);
-
+ g_string_append_printf (str, " (%s <= %s) ",
+ where_field,
+ value);
break;
case OP_CONTAINS:
-
sub = strchr (data->current_value, '*');
if (sub) {
- g_string_append_printf (str, " (%s like '%s%s%s') ", ((FieldData *)field_data->data)->where_field, "%", data->current_value, "%");
+ g_string_append_printf (str, " (%s like '%%%s%%') ",
+ where_field,
+ data->current_value);
} else {
- g_string_append_printf (str, " (%s like '%s%s%s') ", ((FieldData *)field_data->data)->where_field, "%", data->current_value, "%");
+ g_string_append_printf (str, " (%s like '%%%s%%') ",
+ where_field,
+ data->current_value);
}
-
break;
case OP_STARTS:
-
sub = strchr (data->current_value, '*');
if (sub) {
- g_string_append_printf (str, " (%s like '%s') ", ((FieldData *)field_data->data)->where_field, data->current_value);
+ g_string_append_printf (str, " (%s like '%s') ",
+ where_field,
+ data->current_value);
} else {
- g_string_append_printf (str, " (%s like '%s%s') ", ((FieldData *)field_data->data)->where_field, data->current_value, "%");
+ g_string_append_printf (str, " (%s like '%s%%') ",
+ where_field,
+ data->current_value);
}
break;
case OP_REGEX:
-
- g_string_append_printf (str, " (%s REGEXP '%s') ", ((FieldData *)field_data->data)->where_field, data->current_value);
-
+ g_string_append_printf (str, " (%s REGEXP '%s') ",
+ where_field,
+ data->current_value);
break;
case OP_SET:
-
s = g_strsplit (data->current_value, ",", 0);
if (s && s[0]) {
+ gchar **p;
- g_string_append_printf (str, " (%s in ('%s'", ((FieldData *)field_data->data)->where_field, s[0]);
+ g_string_append_printf (str, " (%s in ('%s'",
+ where_field,
+ s[0]);
- char **p;
- for (p = s+1; *p; p++) {
- g_string_append_printf (str, ",'%s'", *p);
+ for (p = s + 1; *p; p++) {
+ g_string_append_printf (str, ",'%s'", *p);
}
+
g_string_append_printf (str, ") ) " );
-
}
-
break;
default:
-
break;
}
data->sql_where = g_string_append (data->sql_where, str->str);
g_string_free (str, TRUE);
field_data = g_list_next (field_data);
-
}
data->sql_where = g_string_append (data->sql_where, " ) ");
g_free (avalue);
-
g_free (data->current_field);
data->current_field = NULL;
@@ -1222,19 +1254,31 @@
*where = NULL;
} else {
- const GSList *tmp;
- FieldData *tmp_field;
+ GSList *l;
- for (tmp = data.fields; tmp; tmp = tmp->next) {
- tmp_field = tmp->data;
-
- if (!tmp_field->is_condition) {
- if (tmp_field->needs_join) {
- g_string_append_printf (data.sql_from, "\n LEFT OUTER JOIN %s %s ON (S.ID = %s.ServiceID and %s.MetaDataID = %s) ", tmp_field->table_name, tmp_field->alias, tmp_field->alias, tmp_field->alias, tmp_field->id_field);
+ for (l = data.fields; l; l = l->next) {
+ if (!tracker_field_data_get_is_condition (l->data)) {
+ if (tracker_field_data_get_needs_join (l->data)) {
+ g_string_append_printf (data.sql_from,
+ "\n LEFT OUTER JOIN %s %s ON (S.ID = %s.ServiceID and %s.MetaDataID = %s) ",
+ tracker_field_data_get_table_name (l->data),
+ tracker_field_data_get_alias (l->data),
+ tracker_field_data_get_alias (l->data),
+ tracker_field_data_get_alias (l->data),
+ tracker_field_data_get_id_field (l->data));
}
} else {
- char *related_metadata = tracker_get_related_metadata_names (db_con, tmp_field->field_name);
- g_string_append_printf (data.sql_from, "\n INNER JOIN %s %s ON (S.ID = %s.ServiceID and %s.MetaDataID in (%s)) ", tmp_field->table_name, tmp_field->alias, tmp_field->alias, tmp_field->alias, related_metadata);
+ gchar *related_metadata;
+
+ related_metadata = tracker_get_related_metadata_names (db_con,
+ tracker_field_data_get_field_name (l->data));
+ g_string_append_printf (data.sql_from,
+ "\n INNER JOIN %s %s ON (S.ID = %s.ServiceID and %s.MetaDataID in (%s)) ",
+ tracker_field_data_get_table_name (l->data),
+ tracker_field_data_get_alias (l->data),
+ tracker_field_data_get_alias (l->data),
+ tracker_field_data_get_alias (l->data),
+ related_metadata);
g_free (related_metadata);
}
}
@@ -1246,7 +1290,7 @@
g_string_free (data.sql_where, TRUE);
}
- g_slist_foreach (data.fields, (GFunc) tracker_free_metadata_field, NULL);
+ g_slist_foreach (data.fields, (GFunc) g_object_unref, NULL);
g_slist_free (data.fields);
g_slist_free (data.stack);
Modified: branches/xesam-support/src/trackerd/tracker-xesam.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam.c Fri May 23 18:14:30 2008
@@ -27,18 +27,19 @@
#include "tracker-xesam.h"
#include "tracker-main.h"
-extern Tracker *tracker;
-
-
static GHashTable *xesam_sessions;
+static gchar *xesam_dir;
static gboolean live_search_handler_running = FALSE;
GQuark
tracker_xesam_error_quark (void)
{
static GQuark quark = 0;
- if (quark == 0)
+
+ if (quark == 0) {
quark = g_quark_from_static_string ("TrackerXesam");
+ }
+
return quark;
}
@@ -53,6 +54,8 @@
g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
+
+ xesam_dir = g_build_filename (g_get_home_dir (), ".xesam", NULL);
}
void
@@ -62,7 +65,11 @@
return;
}
+ g_free (xesam_dir);
+ xesam_dir = NULL;
+
g_hash_table_unref (xesam_sessions);
+ xesam_sessions = NULL;
}
TrackerXesamSession *
@@ -318,4 +325,10 @@
return key;
}
+gboolean
+tracker_xesam_is_uri_in_xesam_dir (const gchar *uri)
+{
+ g_return_val_if_fail (uri != NULL, FALSE);
+ return g_str_has_prefix (uri, xesam_dir);
+}
Modified: branches/xesam-support/src/trackerd/tracker-xesam.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam.h (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam.h Fri May 23 18:14:30 2008
@@ -57,6 +57,7 @@
GError **error);
void tracker_xesam_wakeup (guint32 last_id);
gchar * tracker_xesam_generate_unique_key (void);
+gboolean tracker_xesam_is_uri_in_xesam_dir (const gchar *uri);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]