tracker r2486 - in trunk: . src src/libtracker-data src/tracker-indexer src/tracker-indexer/modules src/trackerd tests/tracker-indexer
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2486 - in trunk: . src src/libtracker-data src/tracker-indexer src/tracker-indexer/modules src/trackerd tests/tracker-indexer
- Date: Tue, 11 Nov 2008 15:51:19 +0000 (UTC)
Author: mr
Date: Tue Nov 11 15:51:19 2008
New Revision: 2486
URL: http://svn.gnome.org/viewvc/tracker?rev=2486&view=rev
Log:
* ALL: Merged libtracker-data branch into TRUNK.
Conflicts involved src/trackerd/tracker-search.c with the
tracker_search_sql_query() which was changed by Ivan for NB
#89965, if this regression still exists, it is my fault.
Added:
trunk/src/libtracker-data/
- copied from r2485, /branches/libtracker-data/src/libtracker-data/
Removed:
trunk/src/tracker-indexer/tracker-indexer-db.c
trunk/src/tracker-indexer/tracker-indexer-db.h
trunk/src/tracker-indexer/tracker-metadata.c
trunk/src/tracker-indexer/tracker-metadata.h
trunk/src/trackerd/tracker-db.c
trunk/src/trackerd/tracker-db.h
trunk/src/trackerd/tracker-query-tree.c
trunk/src/trackerd/tracker-query-tree.h
trunk/src/trackerd/tracker-rdf-query.c
trunk/src/trackerd/tracker-rdf-query.h
trunk/src/trackerd/tracker-xesam-query.c
trunk/src/trackerd/tracker-xesam-query.h
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/src/Makefile.am
trunk/src/libtracker-data/tracker-rdf-query.c
trunk/src/libtracker-data/tracker-rdf-query.h
trunk/src/tracker-indexer/Makefile.am
trunk/src/tracker-indexer/modules/applications.c
trunk/src/tracker-indexer/modules/dummy.c
trunk/src/tracker-indexer/modules/evolution.c
trunk/src/tracker-indexer/modules/files.c
trunk/src/tracker-indexer/tracker-indexer-module.c
trunk/src/tracker-indexer/tracker-indexer-module.h
trunk/src/tracker-indexer/tracker-indexer.c
trunk/src/tracker-indexer/tracker-main.c
trunk/src/tracker-indexer/tracker-metadata-utils.c
trunk/src/tracker-indexer/tracker-metadata-utils.h
trunk/src/tracker-indexer/tracker-module.h
trunk/src/trackerd/Makefile.am
trunk/src/trackerd/tracker-daemon.c
trunk/src/trackerd/tracker-dbus.c
trunk/src/trackerd/tracker-files.c
trunk/src/trackerd/tracker-keywords.c
trunk/src/trackerd/tracker-main.c
trunk/src/trackerd/tracker-metadata.c
trunk/src/trackerd/tracker-search.c
trunk/src/trackerd/tracker-search.h
trunk/src/trackerd/tracker-xesam-live-search.c
trunk/src/trackerd/tracker-xesam-manager.c
trunk/src/trackerd/tracker-xesam.c
trunk/src/trackerd/tracker-xesam.h
trunk/tests/tracker-indexer/Makefile.am
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Tue Nov 11 15:51:19 2008
@@ -1016,13 +1016,9 @@
tests/tracker-indexer/tracker-dbus.h:src/tracker-indexer/tracker-dbus.h
tests/tracker-indexer/tracker-indexer.c:src/tracker-indexer/tracker-indexer.c
tests/tracker-indexer/tracker-indexer.h:src/tracker-indexer/tracker-indexer.h
- tests/tracker-indexer/tracker-indexer-db.c:src/tracker-indexer/tracker-indexer-db.c
- tests/tracker-indexer/tracker-indexer-db.h:src/tracker-indexer/tracker-indexer-db.h
tests/tracker-indexer/tracker-indexer-module.c:src/tracker-indexer/tracker-indexer-module.c
tests/tracker-indexer/tracker-indexer-module.h:src/tracker-indexer/tracker-indexer-module.h
tests/tracker-indexer/tracker-marshal-main.c:src/tracker-indexer/tracker-marshal-main.c
- tests/tracker-indexer/tracker-metadata.c:src/tracker-indexer/tracker-metadata.c
- tests/tracker-indexer/tracker-metadata.h:src/tracker-indexer/tracker-metadata.h
tests/tracker-indexer/tracker-metadata-utils.c:src/tracker-indexer/tracker-metadata-utils.c
tests/tracker-indexer/tracker-metadata-utils.h:src/tracker-indexer/tracker-metadata-utils.h
tests/tracker-indexer/tracker-module.h:src/tracker-indexer/tracker-module.h
@@ -1106,6 +1102,7 @@
src/libinotify/Makefile
src/libstemmer/Makefile
src/libtracker-common/Makefile
+ src/libtracker-data/Makefile
src/libtracker-db/Makefile
src/libtracker-gtk/Makefile
src/libtracker/Makefile
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Nov 11 15:51:19 2008
@@ -34,6 +34,7 @@
$(build_libinotify) \
libtracker-common \
libtracker-db \
+ libtracker-data \
libtracker \
$(build_sqlite_fts) \
trackerd \
@@ -52,6 +53,7 @@
libinotify \
libtracker-common \
libtracker-db \
+ libtracker-data \
libtracker \
tracker-fts \
trackerd \
Modified: trunk/src/libtracker-data/tracker-rdf-query.c
==============================================================================
--- /branches/libtracker-data/src/libtracker-data/tracker-rdf-query.c (original)
+++ trunk/src/libtracker-data/tracker-rdf-query.c Tue Nov 11 15:51:19 2008
@@ -169,8 +169,6 @@
gchar *service;
} ParserData;
-static GQuark error_quark;
-
static void start_element_handler (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
@@ -256,7 +254,7 @@
va_end (args);
g_set_error (err,
- error_quark,
+ tracker_rdf_error_quark (),
error_code,
"Line %d character %d: %s",
line, ch, str);
@@ -401,11 +399,11 @@
if (!field_exists) {
field_data = tracker_data_schema_get_metadata_field (data->iface,
- data->service,
- field_name,
- g_slist_length (data->fields),
- is_select,
- is_condition);
+ 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) {
@@ -1058,7 +1056,6 @@
}
}
-
static void
text_handler (GMarkupParseContext *context,
const gchar *text,
@@ -1074,20 +1071,19 @@
switch (state) {
- case STATE_INTEGER:
- case STATE_STRING:
- case STATE_DATE:
- case STATE_FLOAT:
+ case STATE_INTEGER:
+ case STATE_STRING:
+ case STATE_DATE:
+ case STATE_FLOAT:
- data->current_value = g_strstrip (g_strndup (text, text_len));
- break;
+ data->current_value = g_strstrip (g_strndup (text, text_len));
+ break;
- default :
- break;
+ default :
+ break;
}
}
-
static void
error_handler (GMarkupParseContext *context,
GError *error,
@@ -1096,7 +1092,6 @@
g_message ("in rdf query parse: %s", error->message);
}
-
static GString *
get_select_header (const char *service)
{
@@ -1108,49 +1103,53 @@
switch (type) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- g_string_append_printf (result, " Select DISTINCT S.ID, (S.Path || '%s' || S.Name) as uri, GetServiceName(S.ServiceTypeID) as stype ", G_DIR_SEPARATOR_S);
- break;
-
- default :
- g_string_append_printf (result, " Select DISTINCT S.ID, (S.Path || '%s' || S.Name) as uri, GetServiceName(S.ServiceTypeID) as stype ", G_DIR_SEPARATOR_S);
- break;
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ g_string_append_printf (result, " Select DISTINCT S.ID, (S.Path || '%s' || S.Name) as uri, GetServiceName(S.ServiceTypeID) as stype ", G_DIR_SEPARATOR_S);
+ break;
+
+ default :
+ g_string_append_printf (result, " Select DISTINCT S.ID, (S.Path || '%s' || S.Name) as uri, GetServiceName(S.ServiceTypeID) as stype ", G_DIR_SEPARATOR_S);
+ break;
}
return result;
}
+GQuark
+tracker_rdf_error_quark (void)
+{
+ return g_quark_from_static_string (TRACKER_RDF_ERROR_DOMAIN);
+}
gchar *
tracker_rdf_query_to_sql (TrackerDBInterface *iface,
const gchar *query,
const gchar *service,
- gchar **fields,
+ const gchar **fields,
gint field_count,
const gchar *search_text,
const gchar *keyword,
gboolean sort_by_service,
- gchar **sort_fields,
+ const gchar **sort_fields,
gint sort_field_count,
gboolean sort_desc,
gint offset,
gint limit,
GError **error)
{
- static gboolean inited = FALSE;
- ParserData data;
- gchar *result;
- gchar *table_name;
- gboolean do_search = FALSE;
+ ParserData data;
+ gchar *result;
+ gchar *table_name;
+ gboolean do_search = FALSE;
g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (iface), NULL);
g_return_val_if_fail (query != NULL, NULL);
@@ -1159,11 +1158,6 @@
g_return_val_if_fail (search_text != NULL, NULL);
g_return_val_if_fail (keyword != NULL, NULL);
- if (!inited) {
- error_quark = g_quark_from_static_string ("RDF-parser-error-quark");
- inited = TRUE;
- }
-
memset (&data, 0, sizeof (data));
data.iface = iface;
data.statement_count = 0;
@@ -1180,7 +1174,7 @@
if (!field_data) {
g_set_error (error,
- error_quark,
+ tracker_rdf_error_quark (),
PARSE_ERROR,
"RDF Query failed, field:'%s' not found",
sort_fields[i]);
@@ -1215,7 +1209,7 @@
gchar *keyword_metadata;
keyword_metadata = tracker_data_schema_metadata_field_get_related_names (iface,
- "DC:Keywords");
+ "DC:Keywords");
g_string_append_printf (data.sql_from,
"\n INNER JOIN ServiceKeywordMetaData K ON S.ID = K.ServiceID and K.MetaDataID in (%s) and K.MetaDataValue = '%s' ",
keyword_metadata,
@@ -1258,7 +1252,7 @@
}
- if (sort_field_count>0) {
+ if (sort_field_count > 0) {
gint i;
for (i = 0; i < sort_field_count; i++) {
@@ -1268,7 +1262,7 @@
if (!field_data) {
g_set_error (error,
- error_quark,
+ tracker_rdf_error_quark (),
PARSE_ERROR,
"RDF Query failed, sort field:'%s' not found",
sort_fields[i]);
@@ -1340,7 +1334,7 @@
gchar *related_metadata;
related_metadata = tracker_data_schema_metadata_field_get_related_names (iface,
- tracker_field_data_get_field_name (l->data));
+ 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),
@@ -1402,19 +1396,13 @@
char **where,
GError **error)
{
- static gboolean inited = FALSE;
- ParserData data;
+ ParserData data;
g_return_if_fail (TRACKER_IS_DB_INTERFACE (iface));
g_return_if_fail (service != NULL);
g_return_if_fail (from != NULL);
g_return_if_fail (where != NULL);
- if (!inited) {
- error_quark = g_quark_from_static_string ("RDF-parser-error-quark");
- inited = TRUE;
- }
-
memset (&data, 0, sizeof (data));
data.iface = iface;
data.statement_count = 0;
@@ -1471,7 +1459,7 @@
gchar *related_metadata;
related_metadata = tracker_data_schema_metadata_field_get_related_names (iface,
- tracker_field_data_get_field_name (l->data));
+ 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),
@@ -1507,3 +1495,50 @@
g_free (data.parser);
}
+
+gchar *
+tracker_rdf_query_for_attr_value (const gchar *field,
+ const gchar *value)
+{
+ TrackerField *field_def;
+ gchar *rdf_type;
+ gchar *rdf_query;
+
+ field_def = tracker_ontology_get_field_by_name (field);
+
+ if (!field_def) {
+ return NULL;
+ }
+
+ switch (tracker_field_get_data_type (field_def)) {
+ case TRACKER_FIELD_TYPE_KEYWORD:
+ case TRACKER_FIELD_TYPE_INDEX:
+ case TRACKER_FIELD_TYPE_FULLTEXT:
+ case TRACKER_FIELD_TYPE_STRING:
+ rdf_type = "rdf:String";
+ break;
+
+ case TRACKER_FIELD_TYPE_INTEGER:
+ case TRACKER_FIELD_TYPE_DOUBLE:
+ case TRACKER_FIELD_TYPE_DATE:
+ rdf_type = "rdf:Integer";
+ break;
+
+ case TRACKER_FIELD_TYPE_BLOB:
+ case TRACKER_FIELD_TYPE_STRUCT:
+ case TRACKER_FIELD_TYPE_LINK:
+ g_warning ("Unsupport field type for property %s",
+ tracker_field_get_name (field_def));
+ return NULL;
+ }
+
+ rdf_query = g_strconcat ("<rdfq:Condition>",
+ " <rdfq:equals>",
+ " <rdfq:Property name=\"", field, "\"/>",
+ " <", rdf_type, ">", value, "</", rdf_type, ">",
+ " </rdfq:equals>"
+ "</rdfq:Condition>",
+ NULL);
+
+ return rdf_query;
+}
Modified: trunk/src/libtracker-data/tracker-rdf-query.h
==============================================================================
--- /branches/libtracker-data/src/libtracker-data/tracker-rdf-query.h (original)
+++ trunk/src/libtracker-data/tracker-rdf-query.h Tue Nov 11 15:51:19 2008
@@ -27,27 +27,34 @@
G_BEGIN_DECLS
-gchar *tracker_rdf_query_to_sql (TrackerDBInterface *iface,
- const gchar *query,
- const gchar *service,
- gchar **fields,
- gint field_count,
- const gchar *search_text,
- const gchar *keyword,
- gboolean sort_by_service,
- gchar **sort_fields,
- gint sort_field_count,
- gboolean sort_desc,
- gint offset,
- gint limit,
- GError **error);
-void tracker_rdf_filter_to_sql (TrackerDBInterface *iface,
- const gchar *query,
- const gchar *service,
- GSList **fields,
- gchar **from,
- gchar **where,
- GError **error);
+#define TRACKER_RDF_ERROR_DOMAIN "TrackerRDF"
+#define TRACKER_RDF_ERROR tracker_rdf_error_quark()
+
+GQuark tracker_rdf_error_quark (void);
+
+gchar *tracker_rdf_query_to_sql (TrackerDBInterface *iface,
+ const gchar *query,
+ const gchar *service,
+ const gchar **fields,
+ gint field_count,
+ const gchar *search_text,
+ const gchar *keyword,
+ gboolean sort_by_service,
+ const gchar **sort_fields,
+ gint sort_field_count,
+ gboolean sort_desc,
+ gint offset,
+ gint limit,
+ GError **error);
+void tracker_rdf_filter_to_sql (TrackerDBInterface *iface,
+ const gchar *query,
+ const gchar *service,
+ GSList **fields,
+ gchar **from,
+ gchar **where,
+ GError **error);
+gchar *tracker_rdf_query_for_attr_value (const gchar *field,
+ const gchar *value);
G_END_DECLS
Modified: trunk/src/tracker-indexer/Makefile.am
==============================================================================
--- trunk/src/tracker-indexer/Makefile.am (original)
+++ trunk/src/tracker-indexer/Makefile.am Tue Nov 11 15:51:19 2008
@@ -20,11 +20,9 @@
libtracker_indexer_LTLIBRARIES = libtracker-indexer.la
libtracker_indexer_la_SOURCES = \
- tracker-metadata.c \
tracker-metadata-utils.c
libtracker_indexerinclude_HEADERS = \
- tracker-metadata.h \
tracker-metadata-utils.h \
tracker-module.h
@@ -36,8 +34,6 @@
tracker-dbus.h \
tracker-indexer.c \
tracker-indexer.h \
- tracker-indexer-db.c \
- tracker-indexer-db.h \
tracker-indexer-module.c \
tracker-indexer-module.h \
tracker-main.c \
@@ -45,6 +41,7 @@
tracker_indexer_LDADD = \
libtracker-indexer.la \
+ $(top_builddir)/src/libtracker-data/libtracker-data.la \
$(top_builddir)/src/libtracker-db/libtracker-db.la \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(top_builddir)/src/libstemmer/libstemmer.la \
Modified: trunk/src/tracker-indexer/modules/applications.c
==============================================================================
--- trunk/src/tracker-indexer/modules/applications.c (original)
+++ trunk/src/tracker-indexer/modules/applications.c Tue Nov 11 15:51:19 2008
@@ -20,7 +20,7 @@
#include <stdlib.h>
#include <glib.h>
#include <tracker-indexer/tracker-module.h>
-#include <tracker-indexer/tracker-metadata.h>
+#include <libtracker-data/tracker-data-metadata.h>
#define GROUP_DESKTOP_ENTRY "Desktop Entry"
#define KEY_TYPE "Type"
@@ -51,7 +51,7 @@
}
static void
-insert_data_from_desktop_file (TrackerMetadata *metadata,
+insert_data_from_desktop_file (TrackerDataMetadata *metadata,
const gchar *metadata_key,
GKeyFile *desktop_file,
const gchar *key,
@@ -66,12 +66,12 @@
}
if (str) {
- tracker_metadata_insert (metadata, metadata_key, str);
+ tracker_data_metadata_insert (metadata, metadata_key, str);
}
}
static void
-insert_list_from_desktop_file (TrackerMetadata *metadata,
+insert_list_from_desktop_file (TrackerDataMetadata *metadata,
const gchar *metadata_key,
GKeyFile *desktop_file,
const gchar *key,
@@ -96,14 +96,14 @@
list = g_list_reverse (list);
g_free (arr);
- tracker_metadata_insert_multiple_values (metadata, metadata_key, list);
+ tracker_data_metadata_insert_values (metadata, metadata_key, list);
}
}
-TrackerMetadata *
+TrackerDataMetadata *
tracker_module_file_get_metadata (TrackerFile *file)
{
- TrackerMetadata *metadata;
+ TrackerDataMetadata *metadata;
GKeyFile *key_file;
gchar *type, *filename;
@@ -136,7 +136,7 @@
}
/* Begin collecting data */
- metadata = tracker_metadata_new ();
+ metadata = tracker_data_metadata_new ();
insert_data_from_desktop_file (metadata, METADATA_APP_NAME, key_file, KEY_NAME, FALSE);
insert_data_from_desktop_file (metadata, METADATA_APP_DISPLAY_NAME, key_file, KEY_NAME, TRUE);
@@ -149,7 +149,7 @@
insert_list_from_desktop_file (metadata, METADATA_APP_CATEGORIES, key_file, KEY_CATEGORIES, FALSE);
filename = g_filename_display_basename (file->path);
- tracker_metadata_insert (metadata, METADATA_FILE_NAME, filename);
+ tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, filename);
g_key_file_free (key_file);
g_free (type);
Modified: trunk/src/tracker-indexer/modules/dummy.c
==============================================================================
--- trunk/src/tracker-indexer/modules/dummy.c (original)
+++ trunk/src/tracker-indexer/modules/dummy.c Tue Nov 11 15:51:19 2008
@@ -18,7 +18,7 @@
*/
#include <glib.h>
-#include <tracker-indexer/tracker-metadata.h>
+#include <libtracker-data/tracker-data-metadata.h>
void
tracker_module_init (void)
Modified: trunk/src/tracker-indexer/modules/evolution.c
==============================================================================
--- trunk/src/tracker-indexer/modules/evolution.c (original)
+++ trunk/src/tracker-indexer/modules/evolution.c Tue Nov 11 15:51:19 2008
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <gconf/gconf-client.h>
#include <tracker-indexer/tracker-module.h>
-#include <tracker-indexer/tracker-metadata.h>
+#include <libtracker-data/tracker-data-metadata.h>
#include <tracker-indexer/tracker-metadata-utils.h>
#include <libtracker-common/tracker-utils.h>
#include <libtracker-common/tracker-file-utils.h>
@@ -731,10 +731,10 @@
return g_list_reverse (list);
}
-static TrackerMetadata *
+static TrackerDataMetadata *
get_metadata_for_data_wrapper (GMimeDataWrapper *wrapper)
{
- TrackerMetadata *metadata;
+ TrackerDataMetadata *metadata;
GMimeStream *stream;
gchar *path;
gint fd;
@@ -759,12 +759,12 @@
return metadata;
}
-static TrackerMetadata *
+static TrackerDataMetadata *
get_metadata_for_mbox_attachment (TrackerFile *file,
GMimeMessage *message,
GMimePart *part)
{
- TrackerMetadata *metadata;
+ TrackerDataMetadata *metadata;
GMimeDataWrapper *content;
content = g_mime_part_get_content_object (part);
@@ -781,8 +781,8 @@
get_mbox_attachment_uri (file, message, part,
&dirname, &basename);
- tracker_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
- tracker_metadata_insert (metadata, METADATA_FILE_NAME, basename);
+ tracker_data_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
+ tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, basename);
}
g_object_unref (content);
@@ -790,12 +790,12 @@
return metadata;
}
-static TrackerMetadata *
+static TrackerDataMetadata *
get_metadata_for_mbox (TrackerFile *file)
{
EvolutionLocalData *data;
GMimeMessage *message;
- TrackerMetadata *metadata;
+ TrackerDataMetadata *metadata;
gchar *dirname, *basename;
time_t date;
GList *list;
@@ -820,26 +820,26 @@
return get_metadata_for_mbox_attachment (file, message, data->current_mime_part->data);
}
- metadata = tracker_metadata_new ();
+ metadata = tracker_data_metadata_new ();
get_mbox_uri (file, message, &dirname, &basename);
- tracker_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
- tracker_metadata_insert (metadata, METADATA_FILE_NAME, basename);
+ tracker_data_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
+ tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, basename);
g_mime_message_get_date (message, &date, NULL);
- tracker_metadata_insert (metadata, METADATA_EMAIL_DATE,
+ tracker_data_metadata_insert (metadata, METADATA_EMAIL_DATE,
tracker_guint_to_string (date));
- tracker_metadata_insert (metadata, METADATA_EMAIL_SENDER,
+ tracker_data_metadata_insert (metadata, METADATA_EMAIL_SENDER,
g_strdup (g_mime_message_get_sender (message)));
- tracker_metadata_insert (metadata, METADATA_EMAIL_SUBJECT,
+ tracker_data_metadata_insert (metadata, METADATA_EMAIL_SUBJECT,
g_strdup (g_mime_message_get_subject (message)));
list = get_mbox_recipient_list (message, GMIME_RECIPIENT_TYPE_TO);
- tracker_metadata_insert_multiple_values (metadata, METADATA_EMAIL_SENT_TO, list);
+ tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_SENT_TO, list);
list = get_mbox_recipient_list (message, GMIME_RECIPIENT_TYPE_CC);
- tracker_metadata_insert_multiple_values (metadata, METADATA_EMAIL_CC, list);
+ tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_CC, list);
return metadata;
}
@@ -1087,11 +1087,11 @@
return message_path;
}
-static TrackerMetadata *
+static TrackerDataMetadata *
get_metadata_for_imap_attachment (TrackerFile *file,
const gchar *mime_file)
{
- TrackerMetadata *metadata;
+ TrackerDataMetadata *metadata;
GMimeStream *stream;
GMimeDataWrapper *wrapper;
GMimePartEncodingType encoding;
@@ -1129,8 +1129,8 @@
data->cur_message_uid,
&dirname, &basename);
- tracker_metadata_insert (metadata, METADATA_FILE_NAME, g_strdup (name));
- tracker_metadata_insert (metadata, METADATA_FILE_PATH,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, g_strdup (name));
+ tracker_data_metadata_insert (metadata, METADATA_FILE_PATH,
g_strdup_printf ("%s/%s", dirname, basename));
g_free (dirname);
@@ -1145,11 +1145,11 @@
return metadata;
}
-static TrackerMetadata *
+static TrackerDataMetadata *
get_metadata_for_imap (TrackerFile *file)
{
EvolutionImapData *data;
- TrackerMetadata *metadata = NULL;
+ TrackerDataMetadata *metadata = NULL;
gchar *dirname, *basename;
gchar *subject, *from, *to, *cc;
gint32 i, count, flags;
@@ -1199,23 +1199,23 @@
}
if (!deleted) {
- metadata = tracker_metadata_new ();
+ metadata = tracker_data_metadata_new ();
get_imap_uri (file, data->cur_message_uid, &dirname, &basename);
- tracker_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
- tracker_metadata_insert (metadata, METADATA_FILE_NAME, basename);
+ tracker_data_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
+ tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, basename);
- tracker_metadata_insert (metadata, METADATA_EMAIL_DATE,
+ tracker_data_metadata_insert (metadata, METADATA_EMAIL_DATE,
tracker_guint_to_string (date));
- tracker_metadata_insert (metadata, METADATA_EMAIL_SENDER, from);
- tracker_metadata_insert (metadata, METADATA_EMAIL_SUBJECT, subject);
+ tracker_data_metadata_insert (metadata, METADATA_EMAIL_SENDER, from);
+ tracker_data_metadata_insert (metadata, METADATA_EMAIL_SUBJECT, subject);
list = get_imap_recipient_list (to);
- tracker_metadata_insert_multiple_values (metadata, METADATA_EMAIL_SENT_TO, list);
+ tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_SENT_TO, list);
list = get_imap_recipient_list (cc);
- tracker_metadata_insert_multiple_values (metadata, METADATA_EMAIL_CC, list);
+ tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_CC, list);
}
g_free (to);
@@ -1284,7 +1284,7 @@
corruption:
/* assume corruption */
if (metadata) {
- tracker_metadata_free (metadata);
+ tracker_data_metadata_free (metadata);
}
return NULL;
@@ -1370,7 +1370,7 @@
return g_strdup ("EvolutionEmails");
}
-TrackerMetadata *
+TrackerDataMetadata *
tracker_module_file_get_metadata (TrackerFile *file)
{
EvolutionFileData *data;
Modified: trunk/src/tracker-indexer/modules/files.c
==============================================================================
--- trunk/src/tracker-indexer/modules/files.c (original)
+++ trunk/src/tracker-indexer/modules/files.c Tue Nov 11 15:51:19 2008
@@ -139,7 +139,7 @@
#endif /* ENABLE_FILE_EXCLUDE_CHECKING */
-TrackerMetadata *
+TrackerDataMetadata *
tracker_module_file_get_metadata (TrackerFile *file)
{
#ifdef ENABLE_FILE_EXCLUDE_CHECKING
Modified: trunk/src/tracker-indexer/tracker-indexer-module.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer-module.c (original)
+++ trunk/src/tracker-indexer/tracker-indexer-module.c Tue Nov 11 15:51:19 2008
@@ -175,7 +175,7 @@
}
-TrackerMetadata *
+TrackerDataMetadata *
tracker_indexer_module_file_get_metadata (GModule *module,
TrackerFile *file)
{
Modified: trunk/src/tracker-indexer/tracker-indexer-module.h
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer-module.h (original)
+++ trunk/src/tracker-indexer/tracker-indexer-module.h Tue Nov 11 15:51:19 2008
@@ -24,7 +24,7 @@
#include <glib.h>
#include "tracker-module.h"
-#include "tracker-metadata.h"
+#include <libtracker-data/tracker-data-metadata.h>
G_BEGIN_DECLS
@@ -46,7 +46,7 @@
gchar **basename);
gchar * tracker_indexer_module_file_get_service_type (GModule *module,
TrackerFile *file);
-TrackerMetadata * tracker_indexer_module_file_get_metadata (GModule *module,
+TrackerDataMetadata * tracker_indexer_module_file_get_metadata (GModule *module,
TrackerFile *file);
gchar * tracker_indexer_module_file_get_text (GModule *module,
TrackerFile *file);
Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c (original)
+++ trunk/src/tracker-indexer/tracker-indexer.c Tue Nov 11 15:51:19 2008
@@ -68,9 +68,11 @@
#include <libtracker-db/tracker-db-index-manager.h>
#include <libtracker-db/tracker-db-interface-sqlite.h>
+#include <libtracker-data/tracker-data-query.h>
+#include <libtracker-data/tracker-data-update.h>
+
#include "tracker-indexer.h"
#include "tracker-indexer-module.h"
-#include "tracker-indexer-db.h"
#include "tracker-marshal.h"
#include "tracker-module.h"
@@ -962,9 +964,9 @@
}
if (data->add) {
- tracker_db_set_metadata (data->service, data->id, field, (gchar *) value, parsed_value);
+ tracker_data_update_set_metadata (data->service, data->id, field, (gchar *) value, parsed_value);
} else {
- tracker_db_delete_metadata (data->service, data->id, field, (gchar *)value);
+ tracker_data_update_delete_metadata (data->service, data->id, field, (gchar *)value);
}
g_strfreev (arr);
@@ -1009,7 +1011,7 @@
index_metadata (TrackerIndexer *indexer,
guint32 id,
TrackerService *service,
- TrackerMetadata *metadata)
+ TrackerDataMetadata *metadata)
{
MetadataForeachData data;
@@ -1019,7 +1021,7 @@
data.id = id;
data.add = TRUE;
- tracker_metadata_foreach (metadata, index_metadata_foreach, &data);
+ tracker_data_metadata_foreach (metadata, index_metadata_foreach, &data);
schedule_flush (indexer, FALSE);
}
@@ -1028,7 +1030,7 @@
unindex_metadata (TrackerIndexer *indexer,
guint32 id,
TrackerService *service,
- TrackerMetadata *metadata)
+ TrackerDataMetadata *metadata)
{
MetadataForeachData data;
@@ -1038,7 +1040,7 @@
data.id = id;
data.add = FALSE;
- tracker_metadata_foreach (metadata, index_metadata_foreach, &data);
+ tracker_data_metadata_foreach (metadata, index_metadata_foreach, &data);
schedule_flush (indexer, FALSE);
}
@@ -1278,11 +1280,11 @@
/* Remove old text and set new one in the db */
if (old_text) {
- tracker_db_delete_text (service, id);
+ tracker_data_update_delete_content (service, id);
}
if (new_text) {
- tracker_db_set_text (service, id, new_text);
+ tracker_data_update_set_content (service, id, new_text);
}
g_hash_table_unref (old_words);
@@ -1294,7 +1296,7 @@
PathInfo *info,
const gchar *dirname,
const gchar *basename,
- TrackerMetadata *metadata)
+ TrackerDataMetadata *metadata)
{
TrackerService *service;
gchar *service_type;
@@ -1315,8 +1317,8 @@
return;
}
- if (tracker_db_check_service (service, dirname, basename, &id, NULL)) {
- TrackerMetadata *old_metadata;
+ if (tracker_data_query_service_exists (service, dirname, basename, &id, NULL)) {
+ TrackerDataMetadata *old_metadata;
gchar *old_text;
gchar *new_text;
@@ -1329,20 +1331,20 @@
* Using DB directly: get old (embedded) metadata,
* unindex, index the new metadata
*/
- old_metadata = tracker_db_get_all_metadata (service, id, TRUE);
+ old_metadata = tracker_data_query_embedded_metadata (service, id);
unindex_metadata (indexer, id, service, old_metadata);
index_metadata (indexer, id, service, metadata);
/* Take the old text -> the new one, calculate
* difference and add the words.
*/
- old_text = tracker_db_get_text (service, id);
+ old_text = tracker_data_query_content (service, id);
new_text = tracker_indexer_module_file_get_text (info->module, info->file);
item_update_content (indexer, service, id, old_text, new_text);
g_free (old_text);
g_free (new_text);
- tracker_metadata_free (old_metadata);
+ tracker_data_metadata_free (old_metadata);
return;
}
@@ -1352,16 +1354,16 @@
basename);
/* Service wasn't previously indexed */
- id = tracker_db_get_new_service_id (indexer->private->common);
+ id = tracker_data_update_get_new_service_id (indexer->private->common);
- tracker_db_create_service (service,
+ tracker_data_update_create_service (service,
id,
dirname,
basename,
metadata);
- tracker_db_create_event (indexer->private->cache, id, "Create");
- tracker_db_increment_stats (indexer->private->common, service);
+ tracker_data_update_create_event (indexer->private->cache, id, "Create");
+ tracker_data_update_increment_stats (indexer->private->common, service);
index_metadata (indexer, id, service, metadata);
@@ -1376,7 +1378,7 @@
1);
/* Save in the DB */
- tracker_db_set_text (service, id, text);
+ tracker_data_update_set_content (service, id, text);
g_free (text);
}
}
@@ -1388,7 +1390,7 @@
const gchar *basename)
{
TrackerService *service;
- TrackerMetadata *metadata;
+ TrackerDataMetadata *metadata;
gchar *service_type;
guint32 id;
@@ -1411,7 +1413,7 @@
info->other_file->path);
/* Get 'source' ID */
- if (!tracker_db_check_service (service,
+ if (!tracker_data_query_service_exists (service,
dirname,
basename,
&id,
@@ -1421,7 +1423,7 @@
return;
}
- tracker_db_move_service (service,
+ tracker_data_update_move_service (service,
info->file->path,
info->other_file->path);
@@ -1429,7 +1431,7 @@
* Using DB directly: get old (embedded) metadata, unindex,
* index the new metadata
*/
- metadata = tracker_db_get_all_metadata (service, id, TRUE);
+ metadata = tracker_data_query_embedded_metadata (service, id);
unindex_metadata (indexer, id, service, metadata);
index_metadata (indexer, id, service, metadata);
}
@@ -1458,7 +1460,7 @@
/* The file is not anymore in the filesystem. Obtain
* the service type from the DB.
*/
- service_type_id = tracker_db_get_service_type (dirname, basename);
+ service_type_id = tracker_data_query_service_type_id (dirname, basename);
if (service_type_id == 0) {
/* File didn't exist, nothing to delete */
@@ -1473,7 +1475,7 @@
service_type_id = tracker_service_get_id (service);
}
- tracker_db_check_service (service, dirname, basename, &service_id, NULL);
+ tracker_data_query_service_exists (service, dirname, basename, &service_id, NULL);
if (service_id < 1) {
g_debug (" File does not exist anyway "
@@ -1483,7 +1485,7 @@
}
/* Get content, unindex the words and delete the contents */
- content = tracker_db_get_text (service, service_id);
+ content = tracker_data_query_content (service, service_id);
if (content) {
unindex_text_with_parsing (indexer,
service_id,
@@ -1491,11 +1493,11 @@
content,
1);
g_free (content);
- tracker_db_delete_text (service, service_id);
+ tracker_data_update_delete_content (service, service_id);
}
/* Get metadata from DB to remove it from the index */
- metadata = tracker_db_get_parsed_metadata (service,
+ metadata = tracker_data_query_parsed_metadata (service,
service_id);
unindex_text_no_parsing (indexer,
service_id,
@@ -1507,7 +1509,7 @@
/* The weight depends on metadata, but a number high enough
* force deletion.
*/
- metadata = tracker_db_get_unparsed_metadata (service,
+ metadata = tracker_data_query_unparsed_metadata (service,
service_id);
unindex_text_with_parsing (indexer,
service_id,
@@ -1522,11 +1524,11 @@
basename,
NULL);
- tracker_db_delete_service (service, service_id);
- tracker_db_delete_service_recursively (service, service_path);
- tracker_db_delete_all_metadata (service, service_id);
+ tracker_data_update_delete_service (service, service_id);
+ tracker_data_update_delete_service_recursively (service, service_path);
+ tracker_data_update_delete_all_metadata (service, service_id);
- tracker_db_decrement_stats (indexer->private->common, service);
+ tracker_data_update_decrement_stats (indexer->private->common, service);
g_free (service_path);
}
@@ -1598,7 +1600,7 @@
tracker_file_get_path_and_name (uri, &dirname, &basename);
- tracker_db_check_service (service,
+ tracker_data_query_service_exists (service,
dirname,
basename,
&service_id,
@@ -1614,7 +1616,7 @@
return FALSE;
}
- old_contents = tracker_db_get_property_values (service,
+ old_contents = tracker_data_query_metadata_field_values (service,
service_id,
field);
if (!tracker_field_get_multiple_values (field) && old_contents) {
@@ -1638,7 +1640,7 @@
old_contents[0],
tracker_field_get_weight (field));
}
- tracker_db_delete_metadata (service, service_id, field, old_contents[0]);
+ tracker_data_update_delete_metadata (service, service_id, field, old_contents[0]);
}
}
@@ -1656,7 +1658,7 @@
continue;
}
- tracker_db_set_metadata (service, service_id, field, values[i], NULL);
+ tracker_data_update_set_metadata (service, service_id, field, values[i], NULL);
setted_values [j++] = values[i];
}
setted_values [j] = NULL;
@@ -1733,7 +1735,7 @@
tracker_file_get_path_and_name (uri, &dirname, &basename);
- tracker_db_check_service (service, dirname, basename, &service_id, NULL);
+ tracker_data_query_service_exists (service, dirname, basename, &service_id, NULL);
g_free (dirname);
g_free (basename);
@@ -1752,7 +1754,7 @@
*/
if (g_strv_length (values) > 0) {
for (i = 0; values[i] != NULL; i++) {
- tracker_db_delete_metadata (service,
+ tracker_data_update_delete_metadata (service,
service_id,
field,
values[i]);
@@ -1761,11 +1763,11 @@
} else {
gchar **old_contents;
- old_contents = tracker_db_get_property_values (service,
+ old_contents = tracker_data_query_metadata_field_values (service,
service_id,
field);
if (old_contents) {
- tracker_db_delete_metadata (service,
+ tracker_data_update_delete_metadata (service,
service_id,
field,
NULL);
@@ -1825,7 +1827,7 @@
/* Check the file/directory exists. If it doesn't we
* definitely want to index it.
*/
- if (!tracker_db_check_service (service,
+ if (!tracker_data_query_service_exists (service,
dirname,
basename,
NULL,
@@ -1920,7 +1922,7 @@
/* We don't have the mtime for the dirname yet, we do
* if this is a info->file->path of course.
*/
- exists = tracker_db_check_service (service,
+ exists = tracker_data_query_service_exists (service,
parent_dirname,
parent_basename,
NULL,
@@ -1973,7 +1975,7 @@
process_file (TrackerIndexer *indexer,
PathInfo *info)
{
- TrackerMetadata *metadata;
+ TrackerDataMetadata *metadata;
gchar *dirname;
gchar *basename;
@@ -2039,7 +2041,7 @@
if (metadata) {
item_add_or_update (indexer, info, dirname, basename, metadata);
- tracker_metadata_free (metadata);
+ tracker_data_metadata_free (metadata);
} else {
item_remove (indexer, info, dirname, basename);
}
Modified: trunk/src/tracker-indexer/tracker-main.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-main.c (original)
+++ trunk/src/tracker-indexer/tracker-main.c Tue Nov 11 15:51:19 2008
@@ -43,7 +43,7 @@
#include "tracker-dbus.h"
#include "tracker-indexer.h"
-#include "tracker-indexer-db.h"
+#include <libtracker-data/tracker-data-update.h>
#define ABOUT \
"Tracker " PACKAGE_VERSION "\n" \
Modified: trunk/src/tracker-indexer/tracker-metadata-utils.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-metadata-utils.c (original)
+++ trunk/src/tracker-indexer/tracker-metadata-utils.c Tue Nov 11 15:51:19 2008
@@ -316,9 +316,9 @@
}
static void
-metadata_utils_get_embedded (const char *path,
- const char *mime_type,
- TrackerMetadata *metadata)
+metadata_utils_get_embedded (const char *path,
+ const char *mime_type,
+ TrackerDataMetadata *metadata)
{
gchar **values;
gchar *service_type;
@@ -373,7 +373,7 @@
if (!utf_value)
continue;
- tracker_metadata_insert (metadata, name, utf_value);
+ tracker_data_metadata_insert (metadata, name, utf_value);
}
g_strfreev (values);
@@ -910,15 +910,15 @@
* tracker_metadata_utils_get_data:
* @path: Path to a local file
*
- * Returns a #TrackerMetadata filled with the most generic
+ * Returns a #TrackerDataMetadata filled with the most generic
* metadata for files, such as file size, MIME type, mtime...
*
- * Returns: A newly created #TrackerMetadata, or %NULL if the file is not found.
+ * Returns: A newly created #TrackerDataMetadata, or %NULL if the file is not found.
**/
-TrackerMetadata *
+TrackerDataMetadata *
tracker_metadata_utils_get_data (const gchar *path)
{
- TrackerMetadata *metadata;
+ TrackerDataMetadata *metadata;
struct stat st;
const gchar *ext;
gchar *mime_type;
@@ -927,22 +927,22 @@
return NULL;
}
- metadata = tracker_metadata_new ();
+ metadata = tracker_data_metadata_new ();
ext = strrchr (path, '.');
if (ext) {
- tracker_metadata_insert (metadata, METADATA_FILE_EXT, g_strdup (ext + 1));
+ tracker_data_metadata_insert (metadata, METADATA_FILE_EXT, g_strdup (ext + 1));
}
mime_type = tracker_file_get_mime_type (path);
- tracker_metadata_insert (metadata, METADATA_FILE_NAME,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_NAME,
g_filename_display_basename (path));
- tracker_metadata_insert (metadata, METADATA_FILE_PATH,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_PATH,
g_path_get_dirname (path));
- tracker_metadata_insert (metadata, METADATA_FILE_NAME_DELIMITED,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_NAME_DELIMITED,
g_filename_to_utf8 (path, -1, NULL, NULL, NULL));
- tracker_metadata_insert (metadata, METADATA_FILE_MIMETYPE,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_MIMETYPE,
mime_type);
if (mime_type) {
@@ -957,17 +957,17 @@
gchar *link_path;
link_path = g_file_read_link (path, NULL);
- tracker_metadata_insert (metadata, METADATA_FILE_LINK,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_LINK,
g_filename_to_utf8 (link_path, -1, NULL, NULL, NULL));
g_free (link_path);
}
/* FIXME: These should be dealt directly as integer/times/whatever, not strings */
- tracker_metadata_insert (metadata, METADATA_FILE_SIZE,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_SIZE,
tracker_guint_to_string (st.st_size));
- tracker_metadata_insert (metadata, METADATA_FILE_MODIFIED,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_MODIFIED,
tracker_date_to_string (st.st_mtime));
- tracker_metadata_insert (metadata, METADATA_FILE_ACCESSED,
+ tracker_data_metadata_insert (metadata, METADATA_FILE_ACCESSED,
tracker_date_to_string (st.st_atime));
metadata_utils_get_embedded (path, mime_type, metadata);
Modified: trunk/src/tracker-indexer/tracker-metadata-utils.h
==============================================================================
--- trunk/src/tracker-indexer/tracker-metadata-utils.h (original)
+++ trunk/src/tracker-indexer/tracker-metadata-utils.h Tue Nov 11 15:51:19 2008
@@ -22,12 +22,12 @@
#ifndef __TRACKER_METADATA_UTILS_H__
#define __TRACKER_METADATA_UTILS_H__
-#include "tracker-metadata.h"
+#include <libtracker-data/tracker-data-metadata.h>
G_BEGIN_DECLS
-TrackerMetadata *tracker_metadata_utils_get_data (const gchar *path);
-gchar * tracker_metadata_utils_get_text (const gchar *path);
+TrackerDataMetadata *tracker_metadata_utils_get_data (const gchar *path);
+gchar * tracker_metadata_utils_get_text (const gchar *path);
G_END_DECLS
Modified: trunk/src/tracker-indexer/tracker-module.h
==============================================================================
--- trunk/src/tracker-indexer/tracker-module.h (original)
+++ trunk/src/tracker-indexer/tracker-module.h Tue Nov 11 15:51:19 2008
@@ -25,7 +25,7 @@
G_BEGIN_DECLS
#include <glib.h>
-#include "tracker-metadata.h"
+#include <libtracker-data/tracker-data-metadata.h>
typedef struct TrackerFile TrackerFile;
@@ -48,7 +48,7 @@
gchar **dirname,
gchar **basename);
-typedef TrackerMetadata * (* TrackerModuleFileGetMetadataFunc) (TrackerFile *file);
+typedef TrackerDataMetadata * (* TrackerModuleFileGetMetadataFunc) (TrackerFile *file);
typedef gchar * (* TrackerModuleFileGetText) (TrackerFile *path);
typedef gboolean (* TrackerModuleFileIterContents) (TrackerFile *path);
@@ -62,7 +62,7 @@
void tracker_module_file_get_uri (TrackerFile *file,
gchar **dirname,
gchar **basename);
-TrackerMetadata * tracker_module_file_get_metadata (TrackerFile *file);
+TrackerDataMetadata * tracker_module_file_get_metadata (TrackerFile *file);
gchar * tracker_module_file_get_text (TrackerFile *file);
gboolean tracker_module_file_iter_contents (TrackerFile *file);
Modified: trunk/src/trackerd/Makefile.am
==============================================================================
--- trunk/src/trackerd/Makefile.am (original)
+++ trunk/src/trackerd/Makefile.am Tue Nov 11 15:51:19 2008
@@ -33,8 +33,6 @@
tracker-crawler.h \
tracker-daemon.c \
tracker-daemon.h \
- tracker-db.c \
- tracker-db.h \
tracker-dbus.c \
tracker-dbus.h \
tracker-files.c \
@@ -50,10 +48,6 @@
tracker-metadata.h \
tracker-monitor.c \
tracker-monitor.h \
- tracker-query-tree.c \
- tracker-query-tree.h \
- tracker-rdf-query.c \
- tracker-rdf-query.h \
tracker-search.c \
tracker-search.h \
tracker-status.c \
@@ -64,8 +58,6 @@
tracker-xesam.h \
tracker-xesam-manager.c \
tracker-xesam-manager.h \
- tracker-xesam-query.c \
- tracker-xesam-query.h \
tracker-xesam-session.c \
tracker-xesam-session.h \
tracker-xesam-live-search.c \
@@ -76,6 +68,7 @@
endif
trackerd_LDADD = \
+ $(top_builddir)/src/libtracker-data/libtracker-data.la \
$(top_builddir)/src/libtracker-db/libtracker-db.la \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(top_builddir)/src/libstemmer/libstemmer.la \
Modified: trunk/src/trackerd/tracker-daemon.c
==============================================================================
--- trunk/src/trackerd/tracker-daemon.c (original)
+++ trunk/src/trackerd/tracker-daemon.c Tue Nov 11 15:51:19 2008
@@ -35,7 +35,7 @@
#include "tracker-dbus.h"
#include "tracker-daemon.h"
-#include "tracker-db.h"
+#include <libtracker-data/tracker-data-manager.h>
#include "tracker-indexer-client.h"
#include "tracker-main.h"
#include "tracker-status.h"
@@ -172,7 +172,7 @@
* lookup the in a to compare in b, just compare index based.
* Maybe we want to change this nonetheless later?
*/
- result_set = tracker_db_exec_proc (iface, "GetStats", 0);
+ result_set = tracker_data_manager_exec_proc (iface, "GetStats", 0);
new_stats = tracker_dbus_query_result_to_ptr_array (result_set);
if (result_set) {
@@ -262,7 +262,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- result_set = tracker_db_exec_proc (iface, "GetStats", 0);
+ result_set = tracker_data_manager_exec_proc (iface, "GetStats", 0);
priv->last_stats = tracker_dbus_query_result_to_ptr_array (result_set);
if (result_set) {
@@ -449,7 +449,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- result_set = tracker_db_exec_proc (iface, "GetServices", 0);
+ result_set = tracker_data_manager_exec_proc (iface, "GetServices", 0);
values = tracker_dbus_query_result_to_hash_table (result_set);
if (result_set) {
@@ -488,7 +488,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- result_set = tracker_db_exec_proc (iface, "GetStats", 0);
+ result_set = tracker_data_manager_exec_proc (iface, "GetStats", 0);
values = tracker_dbus_query_result_to_ptr_array (result_set);
if (result_set) {
Modified: trunk/src/trackerd/tracker-dbus.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus.c (original)
+++ trunk/src/trackerd/tracker-dbus.c Tue Nov 11 15:51:19 2008
@@ -26,7 +26,7 @@
#include <libtracker-db/tracker-db-manager.h>
-#include "tracker-db.h"
+#include <libtracker-data/tracker-data-manager.h>
#include "tracker-dbus.h"
#include "tracker-daemon.h"
#include "tracker-daemon-glue.h"
Modified: trunk/src/trackerd/tracker-files.c
==============================================================================
--- trunk/src/trackerd/tracker-files.c (original)
+++ trunk/src/trackerd/tracker-files.c Tue Nov 11 15:51:19 2008
@@ -33,9 +33,13 @@
#include <libtracker-db/tracker-db-dbus.h>
#include <libtracker-db/tracker-db-manager.h>
+#include <libtracker-data/tracker-data-manager.h>
+#include <libtracker-data/tracker-data-query.h>
+#include <libtracker-data/tracker-data-schema.h>
+#include <libtracker-data/tracker-data-search.h>
+
#include "tracker-dbus.h"
#include "tracker-files.h"
-#include "tracker-db.h"
#include "tracker-marshal.h"
#include "tracker-indexer-client.h"
@@ -136,7 +140,7 @@
return;
}
- file_id = tracker_db_file_get_id (TRACKER_DB_FOR_VIRTUAL_SERVICE, uri);
+ file_id = tracker_data_query_file_id (TRACKER_DB_FOR_VIRTUAL_SERVICE, uri);
exists = file_id > 0;
dbus_g_method_return (context, exists);
@@ -226,17 +230,17 @@
static const gchar *
get_file_id_and_db_service (const gchar *uri, gint *id)
{
- *id = tracker_db_file_get_id (TRACKER_DB_FOR_FILE_SERVICE, uri);
+ *id = tracker_data_query_file_id (TRACKER_DB_FOR_FILE_SERVICE, uri);
if (*id) {
return TRACKER_DB_FOR_FILE_SERVICE;
}
- *id = tracker_db_file_get_id (TRACKER_DB_FOR_EMAIL_SERVICE, uri);
+ *id = tracker_data_query_file_id (TRACKER_DB_FOR_EMAIL_SERVICE, uri);
if (*id) {
return TRACKER_DB_FOR_EMAIL_SERVICE;
}
- *id = tracker_db_file_get_id (TRACKER_DB_FOR_VIRTUAL_SERVICE, uri);
+ *id = tracker_data_query_file_id (TRACKER_DB_FOR_VIRTUAL_SERVICE, uri);
if (*id) {
return TRACKER_DB_FOR_VIRTUAL_SERVICE;
}
@@ -286,7 +290,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service_type);
mime = NULL;
- result_set = tracker_db_metadata_get (iface,
+ result_set = tracker_data_query_metadata_field (iface,
file_id_str,
"File:Mime");
@@ -383,7 +387,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service_type);
service_id_str = g_strdup_printf ("%d", service_id);
- result_set = tracker_db_exec_proc (iface,
+ result_set = tracker_data_manager_exec_proc (iface,
"GetFileContents",
offset_str,
max_length_str,
@@ -526,7 +530,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service);
- result_set = tracker_db_files_get_by_service (iface,
+ result_set = tracker_data_search_files_get_by_service (iface,
service,
offset,
max_hits);
@@ -576,7 +580,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- result_set = tracker_db_files_get_by_mime (iface,
+ result_set = tracker_data_search_files_get_by_mime (iface,
mime_types,
g_strv_length (mime_types),
offset,
@@ -631,7 +635,7 @@
/* NOTE: The only difference between this function and the
* non-VFS version is the boolean in this function call:
*/
- result_set = tracker_db_files_get_by_mime (iface,
+ result_set = tracker_data_search_files_get_by_mime (iface,
mime_types,
g_strv_length (mime_types),
offset,
@@ -679,7 +683,7 @@
tracker_file_get_path_and_name (uri, &path, &name);
- result_set = tracker_db_exec_proc (iface,
+ result_set = tracker_data_manager_exec_proc (iface,
"GetFileMTime",
path,
name,
@@ -713,16 +717,8 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- TrackerField *defs[255];
guint request_id;
- guint i;
- gchar *uri_filtered;
- guint32 file_id;
- GString *sql;
- gboolean needs_join[255];
- gchar *query;
GPtrArray *values;
GError *actual_error = NULL;
@@ -739,112 +735,21 @@
uri,
g_strv_length (fields));
+ result_set = tracker_data_search_metadata_in_path (uri,
+ fields,
+ &actual_error);
- /* Get fields for metadata list provided */
- for (i = 0; i < g_strv_length (fields); i++) {
- defs[i] = tracker_ontology_get_field_by_name (fields[i]);
-
- if (!defs[i]) {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Metadata field '%s' was not found",
- fields[i]);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- }
- defs [g_strv_length (fields)] = NULL;
-
-
- if (g_str_has_suffix (uri, G_DIR_SEPARATOR_S)) {
- /* Remove trailing 'G_DIR_SEPARATOR' */
- uri_filtered = g_strndup (uri, strlen (uri) - 1);
- } else {
- uri_filtered = g_strdup (uri);
- }
-
- iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
-
- /* Get file ID in database */
- file_id = tracker_db_file_get_id (NULL, uri_filtered);
- if (file_id == 0) {
- g_free (uri_filtered);
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "File or directory was not in database, uri:'%s'",
- uri);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
+ if (actual_error) {
+ g_propagate_error (error, actual_error);
return;
}
- /* Build SELECT clause */
- sql = g_string_new (" ");
- g_string_append_printf (sql,
- "SELECT (F.Path || '%s' || F.Name) as PathName ",
- G_DIR_SEPARATOR_S);
-
- for (i = 1; i <= g_strv_length (fields); i++) {
- gchar *field;
-
- field = tracker_db_get_field_name ("Files", fields[i-1]);
-
- if (field) {
- g_string_append_printf (sql, ", F.%s ", field);
- g_free (field);
- needs_join[i - 1] = FALSE;
- } else {
- gchar *display_field;
-
- display_field = tracker_ontology_field_get_display_name (defs[i-1]);
- g_string_append_printf (sql, ", M%d.%s ", i, display_field);
- g_free (display_field);
- needs_join[i - 1] = TRUE;
- }
- }
-
- /* Build FROM clause */
- g_string_append (sql,
- " FROM Services F ");
-
- for (i = 0; i < g_strv_length (fields); i++) {
- const gchar *table;
-
- if (!needs_join[i]) {
- continue;
- }
-
- table = tracker_db_metadata_get_table (tracker_field_get_data_type (defs[i]));
-
- g_string_append_printf (sql,
- " LEFT OUTER JOIN %s M%d ON "
- "F.ID = M%d.ServiceID AND "
- "M%d.MetaDataID = %s ",
- table,
- i+1,
- i+1,
- i+1,
- tracker_field_get_id (defs[i]));
- }
-
- /* Build WHERE clause */
- g_string_append_printf (sql,
- " WHERE F.Path = '%s' ",
- uri_filtered);
- g_free (uri_filtered);
-
- query = g_string_free (sql, FALSE);
- result_set = tracker_db_interface_execute_query (iface, NULL, query);
values = tracker_dbus_query_result_to_ptr_array (result_set);
if (result_set) {
g_object_unref (result_set);
}
- g_free (query);
-
dbus_g_method_return (context, values);
tracker_dbus_results_ptr_array_free (&values);
@@ -878,7 +783,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- result_set = tracker_db_search_text_and_mime (iface, text, mime_types);
+ result_set = tracker_data_search_text_and_mime (iface, text, mime_types);
if (result_set) {
gboolean valid = TRUE;
@@ -940,7 +845,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- result_set = tracker_db_search_text_and_location (iface, text, uri);
+ result_set = tracker_data_search_text_and_location (iface, text, uri);
if (result_set) {
gboolean valid = TRUE;
@@ -1006,7 +911,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- result_set = tracker_db_search_text_and_mime_and_location (iface, text, mime_types, uri);
+ result_set = tracker_data_search_text_and_mime_and_location (iface, text, mime_types, uri);
if (result_set) {
gboolean valid = TRUE;
Modified: trunk/src/trackerd/tracker-keywords.c
==============================================================================
--- trunk/src/trackerd/tracker-keywords.c (original)
+++ trunk/src/trackerd/tracker-keywords.c Tue Nov 11 15:51:19 2008
@@ -29,9 +29,13 @@
#include <libtracker-db/tracker-db-index.h>
#include <libtracker-db/tracker-db-manager.h>
+#include <libtracker-data/tracker-data-manager.h>
+#include <libtracker-data/tracker-data-query.h>
+#include <libtracker-data/tracker-data-schema.h>
+#include <libtracker-data/tracker-data-search.h>
+
#include "tracker-dbus.h"
#include "tracker-keywords.h"
-#include "tracker-db.h"
#include "tracker-marshal.h"
#include "tracker-indexer-client.h"
@@ -144,7 +148,7 @@
}
iface = tracker_db_manager_get_db_interface_by_service (service_type);
- result_set = tracker_db_keywords_get_list (iface, service_type);
+ result_set = tracker_data_search_keywords_get_list (iface, service_type);
values = tracker_dbus_query_result_to_ptr_array (result_set);
if (result_set) {
@@ -201,7 +205,7 @@
return;
}
- id = tracker_db_file_get_id_as_string (service_type, uri);
+ id = tracker_data_query_file_id_as_string (service_type, uri);
if (!id) {
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -213,7 +217,7 @@
}
iface = tracker_db_manager_get_db_interface_by_service (service_type);
- result_set = tracker_db_metadata_get (iface,
+ result_set = tracker_data_query_metadata_field (iface,
id,
"User:Keywords");
values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
@@ -276,7 +280,7 @@
return;
}
- id = tracker_db_file_get_id_as_string (service_type, uri);
+ id = tracker_data_query_file_id_as_string (service_type, uri);
if (!id) {
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -373,7 +377,7 @@
}
/* Check the uri exists, so we dont start the indexer in vain */
- service_id = tracker_db_file_get_id_as_string (service_type, uri);
+ service_id = tracker_data_query_file_id_as_string (service_type, uri);
if (!service_id) {
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -450,7 +454,7 @@
}
/* Check the uri exists, so we dont start the indexer in vain */
- service_id = tracker_db_file_get_id_as_string (service_type, uri);
+ service_id = tracker_data_query_file_id_as_string (service_type, uri);
if (!service_id) {
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -496,15 +500,8 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
guint request_id;
- const gchar **p;
- GString *search;
- GString *select;
- GString *where;
- gchar *related_metadata;
- gchar *query;
gchar **values;
GError *actual_error = NULL;
@@ -522,79 +519,23 @@
offset,
max_hits);
- if (!tracker_ontology_service_is_valid (service_type)) {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Service_Type '%s' is invalid or has not been implemented yet",
- service_type);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
+ result_set = tracker_data_search_keywords (service_type,
+ keywords,
+ offset,
+ max_hits,
+ &actual_error);
+
+ if (actual_error) {
+ g_propagate_error (error, actual_error);
return;
}
- iface = tracker_db_manager_get_db_interface_by_service (service_type);
-
- /* Sanity check values */
- offset = MAX (offset, 0);
-
- /* Create keyword search string */
- search = g_string_new ("");
- g_string_append_printf (search,
- "'%s'",
- keywords[0]);
-
- for (p = keywords + 1; *p; p++) {
- g_string_append_printf (search, ", '%s'", *p);
- }
-
- tracker_dbus_request_comment (request_id,
- "Executing keyword search on %s",
- search->str);
-
- /* Create select string */
- select = g_string_new (" Select distinct S.Path || '");
- select = g_string_append (select, G_DIR_SEPARATOR_S);
- select = g_string_append (select,
- "' || S.Name as EntityName from Services S, ServiceKeywordMetaData M ");
-
- /* Create where string */
- related_metadata = tracker_db_metadata_get_related_names (iface, "User:Keywords");
-
- where = g_string_new ("");
- g_string_append_printf (where,
- " where S.ID = M.ServiceID and M.MetaDataID in (%s) and M.MetaDataValue in (%s) ",
- related_metadata,
- search->str);
- g_free (related_metadata);
- g_string_free (search, TRUE);
-
- g_string_append_printf (where,
- " and (S.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = '%s' or Parent = '%s')) ",
- service_type,
- service_type);
-
- /* Add offset and max_hits */
- g_string_append_printf (where,
- " Limit %d,%d",
- offset,
- max_hits);
-
- /* Finalize query */
- query = g_strconcat (select->str, where->str, NULL);
- g_string_free (select, TRUE);
- g_string_free (where, TRUE);
-
- g_debug (query);
-
- result_set = tracker_db_interface_execute_query (iface, NULL, query);
values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
if (result_set) {
g_object_unref (result_set);
}
- g_free (query);
-
dbus_g_method_return (context, values);
if (values) {
Modified: trunk/src/trackerd/tracker-main.c
==============================================================================
--- trunk/src/trackerd/tracker-main.c (original)
+++ trunk/src/trackerd/tracker-main.c Tue Nov 11 15:51:19 2008
@@ -500,7 +500,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
g_message ("*** DELETING STATS *** ");
- tracker_db_exec_no_reply (iface,
+ tracker_data_manager_exec_no_reply (iface,
"update ServiceTypes set TypeCount = 0 where Embedded = 1");
}
@@ -508,17 +508,17 @@
/* Check db integrity if not previously shut down cleanly */
if (!tracker_status_get_is_readonly () &&
!tracker_status_get_is_first_time_index () &&
- tracker_db_get_option_int ("IntegrityCheck") == 1) {
+ tracker_data_manager_get_db_option_int ("IntegrityCheck") == 1) {
g_message ("Performing integrity check as the daemon was not shutdown cleanly");
/* FIXME: Finish */
}
if (!tracker_status_get_is_readonly ()) {
- tracker_db_set_option_int ("IntegrityCheck", 1);
+ tracker_data_manager_set_db_option_int ("IntegrityCheck", 1);
}
if (tracker_status_get_is_first_time_index ()) {
- tracker_db_set_option_int ("InitialIndex", 1);
+ tracker_data_manager_set_db_option_int ("InitialIndex", 1);
}
return TRUE;
@@ -534,7 +534,7 @@
shutdown_databases (void)
{
/* Reset integrity status as threads have closed cleanly */
- tracker_db_set_option_int ("IntegrityCheck", 0);
+ tracker_data_manager_set_db_option_int ("IntegrityCheck", 0);
}
static void
@@ -859,7 +859,7 @@
return EXIT_FAILURE;
}
- tracker_db_init (config, language, file_index, email_index);
+ tracker_data_manager_init (config, language, file_index, email_index);
tracker_xesam_manager_init ();
private->processor = tracker_processor_new (config, hal);
@@ -951,7 +951,7 @@
tracker_dbus_shutdown ();
tracker_db_manager_shutdown ();
tracker_db_index_manager_shutdown ();
- tracker_db_shutdown ();
+ tracker_data_manager_shutdown ();
tracker_module_config_shutdown ();
tracker_nfs_lock_shutdown ();
tracker_status_shutdown ();
Modified: trunk/src/trackerd/tracker-metadata.c
==============================================================================
--- trunk/src/trackerd/tracker-metadata.c (original)
+++ trunk/src/trackerd/tracker-metadata.c Tue Nov 11 15:51:19 2008
@@ -33,16 +33,17 @@
#include <libtracker-db/tracker-db-index.h>
#include <libtracker-db/tracker-db-manager.h>
+#include <libtracker-data/tracker-data-manager.h>
+#include <libtracker-data/tracker-data-query.h>
+#include <libtracker-data/tracker-data-schema.h>
+#include <libtracker-data/tracker-data-search.h>
+#include <libtracker-data/tracker-rdf-query.h>
+
#include "tracker-indexer-client.h"
#include "tracker-dbus.h"
#include "tracker-metadata.h"
-#include "tracker-db.h"
#include "tracker-marshal.h"
-#include "tracker-rdf-query.h"
-
-#define DEFAULT_METADATA_MAX_HITS 1024
-
G_DEFINE_TYPE(TrackerMetadata, tracker_metadata, G_TYPE_OBJECT)
static void
@@ -65,67 +66,6 @@
* Functions
*/
-static gint
-metadata_sanity_check_max_hits (gint max_hits)
-{
- if (max_hits < 1) {
- return DEFAULT_METADATA_MAX_HITS;
- }
-
- return max_hits;
-}
-
-static TrackerFieldData *
-tracker_metadata_add_metadata_field (TrackerDBInterface *iface,
- const gchar *service,
- GSList **fields,
- const gchar *field_name,
- gboolean is_select,
- gboolean is_condition)
-{
- TrackerFieldData *field_data;
- gboolean field_exists;
- GSList *l;
-
- field_exists = FALSE;
- field_data = NULL;
-
- /* Check if field is already in list */
- for (l = *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);
- }
-
- break;
- }
- }
-
- if (!field_exists) {
- field_data = tracker_db_get_metadata_field (iface,
- service,
- field_name,
- g_slist_length (*fields),
- is_select,
- is_condition);
- if (field_data) {
- *fields = g_slist_prepend (*fields, field_data);
- }
- }
-
- return field_data;
-}
-
void
tracker_metadata_get (TrackerMetadata *object,
const gchar *service_type,
@@ -164,7 +104,7 @@
return;
}
- service_id = tracker_db_file_get_id_as_string (service_type, uri);
+ service_id = tracker_data_query_file_id_as_string (service_type, uri);
if (!service_id) {
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -196,7 +136,7 @@
*/
iface = tracker_db_manager_get_db_interface_by_service (service_type);
- service_result = tracker_db_service_get_by_entity (iface, service_id);
+ service_result = tracker_data_query_service_type_by_id (iface, service_id);
if (!service_result) {
g_free (service_id);
tracker_dbus_request_failed (request_id,
@@ -208,7 +148,7 @@
return;
}
- result_set = tracker_db_metadata_get_array (iface, service_result, service_id, keys);
+ result_set = tracker_data_query_metadata_fields (iface, service_result, service_id, keys);
if (result_set) {
values = tracker_dbus_query_result_columns_to_strv (result_set, -1, -1, TRUE);
g_object_unref (result_set);
@@ -264,7 +204,7 @@
return;
}
- service_id = tracker_db_file_get_id_as_string (service_type, uri);
+ service_id = tracker_data_query_file_id_as_string (service_type, uri);
if (!service_id) {
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -275,7 +215,7 @@
return;
}
- values = tracker_db_metadata_get_all (service_type, service_id);
+ values = tracker_data_query_all_metadata (service_type, service_id);
dbus_g_method_return (context, values);
g_ptr_array_foreach (values, (GFunc)g_strfreev, NULL);
@@ -324,7 +264,7 @@
}
/* Check the uri exists, so we dont start the indexer in vain */
- service_id = tracker_db_file_get_id_as_string (service_type, uri);
+ service_id = tracker_data_query_file_id_as_string (service_type, uri);
if (!service_id) {
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -533,12 +473,6 @@
tracker_dbus_request_success (request_id);
}
-static gboolean
-is_data_type_numeric (TrackerFieldType type) {
- return (type == TRACKER_FIELD_TYPE_INTEGER
- || type == TRACKER_FIELD_TYPE_DOUBLE);
-}
-
void
tracker_metadata_get_unique_values (TrackerMetadata *object,
const gchar *service_type,
@@ -550,26 +484,13 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
TrackerDBResultSet *result_set = NULL;
guint request_id;
GPtrArray *values = NULL;
- GSList *field_list = NULL;
- gchar *str_offset, *str_limit;
- GString *sql_select;
- GString *sql_from;
- GString *sql_where;
- GString *sql_order;
- gchar *sql;
-
- char *rdf_where;
- char *rdf_from;
GError *actual_error = NULL;
- guint i;
-
request_id = tracker_dbus_get_next_request_id ();
tracker_dbus_async_return_if_fail (service_type != NULL, context);
@@ -582,104 +503,18 @@
service_type,
query_condition);
- if (!tracker_ontology_service_is_valid (service_type)) {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Service_Type '%s' is invalid or has not been implemented yet",
- service_type);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- iface = tracker_db_manager_get_db_interface_by_service (service_type);
-
- sql_select = g_string_new ("SELECT DISTINCT ");
- sql_from = g_string_new ("\nFROM Services S ");
- sql_where = g_string_new ("\nWHERE ");
- sql_order = g_string_new ("\nORDER BY ");
-
- for (i=0;i<g_strv_length(fields);i++) {
- TrackerFieldData *def = NULL;
- def = tracker_metadata_add_metadata_field (iface, service_type, &field_list, fields[i], FALSE, TRUE);
-
- if (!def) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Invalid or non-existant metadata type '%s' specified",
- fields[i]);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- if (i) {
- g_string_append_printf (sql_select, ",");
- g_string_append_printf (sql_order, ",");
- }
-
- g_string_append_printf (sql_select, "%s", tracker_field_data_get_select_field (def));
- g_string_append_printf (sql_order, " %s %s",
- tracker_field_data_get_select_field (def),
- order_desc ? "DESC" : "ASC" );
-
- }
-
- tracker_rdf_filter_to_sql (iface, query_condition, service_type,
- &field_list, &rdf_from, &rdf_where, &actual_error);
+ result_set = tracker_data_search_get_unique_values (service_type, fields,
+ query_condition,
+ order_desc,
+ offset,
+ max_hits,
+ &actual_error);
if (actual_error) {
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
-
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- NULL);
-
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
+ g_propagate_error (error, actual_error);
return;
}
- g_string_append_printf (sql_from, " %s ", rdf_from);
- g_string_append_printf (sql_where, " %s ", rdf_where);
-
- g_free (rdf_from);
- g_free (rdf_where);
-
- str_offset = tracker_gint_to_string (offset);
- str_limit = tracker_gint_to_string (metadata_sanity_check_max_hits (max_hits));
-
- g_string_append_printf (sql_order, " LIMIT %s,%s", str_offset, str_limit);
-
- sql = g_strconcat (sql_select->str, " ", sql_from->str, " ", sql_where->str, " ", sql_order->str, NULL);
-
- g_free (str_offset);
- g_free (str_limit);
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
-
- g_slist_foreach (field_list, (GFunc) g_object_unref, NULL);
- g_slist_free (field_list);
-
- g_message ("Unique values query executed:\n%s", sql);
-
- result_set = tracker_db_interface_execute_query (iface, NULL, sql);
-
- g_free (sql);
-
values = tracker_dbus_query_result_to_ptr_array (result_set);
dbus_g_method_return (context, values);
@@ -707,27 +542,13 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
TrackerDBResultSet *result_set = NULL;
guint request_id;
GPtrArray *values = NULL;
- GSList *field_list = NULL;
- gchar *str_offset, *str_limit;
- GString *sql_select;
- GString *sql_from;
- GString *sql_where;
- GString *sql_order;
- GString *sql_group;
- gchar *sql;
-
- char *rdf_where;
- char *rdf_from;
GError *actual_error = NULL;
- guint i;
-
request_id = tracker_dbus_get_next_request_id ();
tracker_dbus_async_return_if_fail (service_type != NULL, context);
@@ -742,139 +563,20 @@
query_condition,
count_field);
- if (!tracker_ontology_service_is_valid (service_type)) {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Service_Type '%s' is invalid or has not been implemented yet",
- service_type);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- iface = tracker_db_manager_get_db_interface_by_service (service_type);
-
- sql_select = g_string_new ("SELECT DISTINCT ");
- sql_from = g_string_new ("\nFROM Services S ");
- sql_where = g_string_new ("\nWHERE ");
- sql_order = g_string_new ("\nORDER BY ");
- sql_group = g_string_new ("\nGROUP BY ");
-
-
- for (i=0;i<g_strv_length(fields);i++) {
- TrackerFieldData *def = NULL;
- def = tracker_metadata_add_metadata_field (iface, service_type, &field_list, fields[i], FALSE, TRUE);
-
- if (!def) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Invalid or non-existant metadata type '%s' specified",
- fields[i]);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- if (i) {
- g_string_append_printf (sql_select, ",");
- g_string_append_printf (sql_order, ",");
- g_string_append_printf (sql_group, ",");
- }
-
- g_string_append_printf (sql_select, "%s", tracker_field_data_get_select_field (def));
- g_string_append_printf (sql_order, " %s %s",
- tracker_field_data_get_select_field (def),
- order_desc ? "DESC" : "ASC" );
- g_string_append_printf (sql_group, "%s", tracker_field_data_get_select_field (def));
-
- }
-
- if (count_field && !(tracker_is_empty_string (count_field))) {
- TrackerFieldData *def = NULL;
-
- def = tracker_metadata_add_metadata_field (iface, service_type, &field_list, count_field, FALSE, TRUE);
-
- if (!def) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Invalid or non-existant metadata type '%s' specified",
- count_field);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- g_string_append_printf (sql_select, ", COUNT (DISTINCT %s)", tracker_field_data_get_select_field (def));
- }
-
- tracker_rdf_filter_to_sql (iface, query_condition, service_type,
- &field_list, &rdf_from, &rdf_where, &actual_error);
+ result_set = tracker_data_search_get_unique_values_with_count (service_type,
+ fields,
+ query_condition,
+ count_field,
+ order_desc,
+ offset,
+ max_hits,
+ &actual_error);
if (actual_error) {
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- NULL);
-
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
+ g_propagate_error (error, actual_error);
return;
}
- g_string_append_printf (sql_from, " %s ", rdf_from);
- g_string_append_printf (sql_where, " %s ", rdf_where);
-
- g_free (rdf_from);
- g_free (rdf_where);
-
- str_offset = tracker_gint_to_string (offset);
- str_limit = tracker_gint_to_string (metadata_sanity_check_max_hits (max_hits));
-
- g_string_append_printf (sql_order, " LIMIT %s,%s", str_offset, str_limit);
-
- sql = g_strconcat (sql_select->str, " ",
- sql_from->str, " ",
- sql_where->str, " ",
- sql_group->str, " ",
- sql_order->str, NULL);
-
- g_free (str_offset);
- g_free (str_limit);
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
- g_slist_foreach (field_list, (GFunc) g_object_unref, NULL);
- g_slist_free (field_list);
-
- g_message ("Unique values query executed:\n%s", sql);
-
- result_set = tracker_db_interface_execute_query (iface, NULL, sql);
-
- g_free (sql);
-
values = tracker_dbus_query_result_to_ptr_array (result_set);
dbus_g_method_return (context, values);
@@ -903,27 +605,13 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
TrackerDBResultSet *result_set = NULL;
guint request_id;
GPtrArray *values = NULL;
- GSList *field_list = NULL;
- gchar *str_offset, *str_limit;
- GString *sql_select;
- GString *sql_from;
- GString *sql_where;
- GString *sql_order;
- GString *sql_group;
- gchar *sql;
-
- char *rdf_where;
- char *rdf_from;
GError *actual_error = NULL;
- guint i;
-
request_id = tracker_dbus_get_next_request_id ();
tracker_dbus_async_return_if_fail (service_type != NULL, context);
@@ -940,181 +628,21 @@
count_field,
sum_field);
- if (!tracker_ontology_service_is_valid (service_type)) {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Service_Type '%s' is invalid or has not been implemented yet",
- service_type);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- iface = tracker_db_manager_get_db_interface_by_service (service_type);
-
- sql_select = g_string_new ("SELECT DISTINCT ");
- sql_from = g_string_new ("\nFROM Services S ");
- sql_where = g_string_new ("\nWHERE ");
- sql_order = g_string_new ("\nORDER BY ");
- sql_group = g_string_new ("\nGROUP BY ");
-
-
- for (i=0;i<g_strv_length(fields);i++) {
- TrackerFieldData *def = NULL;
- def = tracker_metadata_add_metadata_field (iface, service_type, &field_list, fields[i], FALSE, TRUE);
-
- if (!def) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Invalid or non-existant metadata type '%s' specified",
- fields[i]);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- if (i) {
- g_string_append_printf (sql_select, ",");
- g_string_append_printf (sql_order, ",");
- g_string_append_printf (sql_group, ",");
- }
-
- g_string_append_printf (sql_select, "%s", tracker_field_data_get_select_field (def));
- g_string_append_printf (sql_order, " %s %s",
- tracker_field_data_get_select_field (def),
- order_desc ? "DESC" : "ASC" );
- g_string_append_printf (sql_group, "%s", tracker_field_data_get_select_field (def));
-
- }
-
- if (count_field && !(tracker_is_empty_string (count_field))) {
- TrackerFieldData *def = NULL;
-
- def = tracker_metadata_add_metadata_field (iface, service_type, &field_list, count_field, FALSE, TRUE);
-
- if (!def) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Invalid or non-existant metadata type '%s' specified",
- count_field);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- g_string_append_printf (sql_select, ", COUNT (DISTINCT %s)", tracker_field_data_get_select_field (def));
- }
-
- if (sum_field && !(tracker_is_empty_string (sum_field))) {
- TrackerFieldData *def = NULL;
- TrackerFieldType data_type;
-
- def = tracker_metadata_add_metadata_field (iface, service_type, &field_list, sum_field, FALSE, TRUE);
-
- if (!def) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Invalid or non-existant metadata type '%s' specified",
- sum_field);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- data_type = tracker_field_data_get_data_type (def);
- if (!is_data_type_numeric (data_type)) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Cannot sum '%s': this metadata type is not numeric",
- sum_field);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- g_string_append_printf (sql_select, ", SUM (%s)", tracker_field_data_get_select_field (def));
- }
-
- tracker_rdf_filter_to_sql (iface, query_condition, service_type,
- &field_list, &rdf_from, &rdf_where, &actual_error);
+ result_set = tracker_data_search_get_unique_values_with_count_and_sum (service_type,
+ fields,
+ query_condition,
+ count_field,
+ sum_field,
+ order_desc,
+ offset,
+ max_hits,
+ &actual_error);
if (actual_error) {
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- NULL);
-
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
+ g_propagate_error (error, actual_error);
return;
}
- g_string_append_printf (sql_from, " %s ", rdf_from);
- g_string_append_printf (sql_where, " %s ", rdf_where);
-
- g_free (rdf_from);
- g_free (rdf_where);
-
- str_offset = tracker_gint_to_string (offset);
- str_limit = tracker_gint_to_string (metadata_sanity_check_max_hits (max_hits));
-
- g_string_append_printf (sql_order, " LIMIT %s,%s", str_offset, str_limit);
-
- sql = g_strconcat (sql_select->str, " ",
- sql_from->str, " ",
- sql_where->str, " ",
- sql_group->str, " ",
- sql_order->str, NULL);
-
- g_free (str_offset);
- g_free (str_limit);
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- g_string_free (sql_order, TRUE);
- g_string_free (sql_group, TRUE);
-
- g_slist_foreach (field_list, (GFunc) g_object_unref, NULL);
- g_slist_free (field_list);
-
- g_message ("Unique values query executed:\n%s", sql);
-
- result_set = tracker_db_interface_execute_query (iface, NULL, sql);
-
- g_free (sql);
-
values = tracker_dbus_query_result_to_ptr_array (result_set);
dbus_g_method_return (context, values);
@@ -1138,21 +666,10 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
- TrackerDBResultSet *result_set = NULL;
guint request_id;
gint sum;
- GSList *fields = NULL;
- TrackerFieldData *def = NULL;
- TrackerFieldType data_type;
- GString *sql_select;
- GString *sql_from;
- GString *sql_where;
- gchar *sql;
- char *rdf_where;
- char *rdf_from;
GError *actual_error = NULL;
request_id = tracker_dbus_get_next_request_id ();
@@ -1168,95 +685,16 @@
field,
query_condition);
- if (!tracker_ontology_service_is_valid (service_type)) {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Service '%s' is invalid or has not been implemented yet",
- service_type);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- iface = tracker_db_manager_get_db_interface_by_service (service_type);
-
- sql_select = g_string_new ("SELECT ");
- sql_from = g_string_new ("\nFROM Services S ");
- sql_where = g_string_new ("\nWHERE ");
-
- def = tracker_metadata_add_metadata_field (iface, service_type, &fields, field, FALSE, TRUE);
-
- if (!def) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Invalid or non-existant metadata type '%s' specified",
- field);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- data_type = tracker_field_data_get_data_type (def);
- if (!is_data_type_numeric (data_type)) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Cannot sum '%s': this metadata type is not numeric",
- field);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- g_string_append_printf (sql_select, "SUM (%s)", tracker_field_data_get_select_field (def));
-
- tracker_rdf_filter_to_sql (iface, query_condition, service_type,
- &fields, &rdf_from, &rdf_where, &actual_error);
+ sum = tracker_data_search_get_sum (service_type,
+ field,
+ query_condition,
+ &actual_error);
if (actual_error) {
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
-
- tracker_dbus_request_failed (request_id, &actual_error, NULL);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
+ g_propagate_error (error, actual_error);
return;
}
- g_string_append_printf (sql_from, " %s ", rdf_from);
- g_string_append_printf (sql_where, " %s ", rdf_where);
-
- g_free (rdf_from);
- g_free (rdf_where);
-
- sql = g_strconcat (sql_select->str, " ", sql_from->str, " ", sql_where->str, NULL);
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
-
- g_slist_foreach (fields, (GFunc) g_object_unref, NULL);
- g_slist_free (fields);
-
- g_debug ("Sum query executed:\n%s", sql);
-
- result_set = tracker_db_interface_execute_query (iface, NULL, sql);
-
- g_free (sql);
-
- tracker_db_result_set_get (result_set, 0, &sum, -1);
-
- if (result_set) {
- g_object_unref (result_set);
- }
-
dbus_g_method_return (context, sum);
tracker_dbus_request_success (request_id);
@@ -1273,20 +711,9 @@
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBInterface *iface;
- TrackerDBResultSet *result_set = NULL;
guint request_id;
gint count;
- GSList *fields = NULL;
- TrackerFieldData *def = NULL;
-
- GString *sql_select;
- GString *sql_from;
- GString *sql_where;
- gchar *sql;
- char *rdf_where;
- char *rdf_from;
GError *actual_error = NULL;
request_id = tracker_dbus_get_next_request_id ();
@@ -1302,84 +729,16 @@
field,
query_condition);
- if (!tracker_ontology_service_is_valid (service_type)) {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Service '%s' is invalid or has not been implemented yet",
- service_type);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- iface = tracker_db_manager_get_db_interface_by_service (service_type);
-
- sql_select = g_string_new ("SELECT ");
- sql_from = g_string_new ("\nFROM Services S ");
- sql_where = g_string_new ("\nWHERE ");
-
- def = tracker_metadata_add_metadata_field (iface, service_type, &fields, field, FALSE, TRUE);
-
- if (!def) {
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "Invalid or non-existant metadata type '%s' specified",
- field);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- return;
- }
-
- g_string_append_printf (sql_select, "COUNT (DISTINCT %s)", tracker_field_data_get_select_field (def));
-
- tracker_rdf_filter_to_sql (iface, query_condition, service_type,
- &fields, &rdf_from, &rdf_where, &actual_error);
+ count = tracker_data_search_get_count (service_type,
+ field,
+ query_condition,
+ &actual_error);
if (actual_error) {
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
-
- tracker_dbus_request_failed (request_id,
- &actual_error,
- NULL);
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
+ g_propagate_error (error, actual_error);
return;
}
- g_string_append_printf (sql_from, " %s ", rdf_from);
- g_string_append_printf (sql_where, " %s ", rdf_where);
-
- g_free (rdf_from);
- g_free (rdf_where);
-
- sql = g_strconcat (sql_select->str, " ", sql_from->str, " ", sql_where->str, NULL);
-
- g_string_free (sql_select, TRUE);
- g_string_free (sql_from, TRUE);
- g_string_free (sql_where, TRUE);
-
- g_slist_foreach (fields, (GFunc) g_object_unref, NULL);
- g_slist_free (fields);
-
- g_message ("Count query executed:\n%s", sql);
-
- result_set = tracker_db_interface_execute_query (iface, NULL, sql);
-
- g_free (sql);
-
- tracker_db_result_set_get (result_set, 0, &count, -1);
-
- if (result_set) {
- g_object_unref (result_set);
- }
-
dbus_g_method_return (context, count);
tracker_dbus_request_success (request_id);
Modified: trunk/src/trackerd/tracker-search.c
==============================================================================
--- trunk/src/trackerd/tracker-search.c (original)
+++ trunk/src/trackerd/tracker-search.c Tue Nov 11 15:51:19 2008
@@ -35,30 +35,31 @@
#include <libtracker-db/tracker-db-index.h>
#include <libtracker-db/tracker-db-manager.h>
-#include "tracker-db.h"
+#include <libtracker-data/tracker-data-manager.h>
+#include <libtracker-data/tracker-data-query.h>
+#include <libtracker-data/tracker-data-schema.h>
+#include <libtracker-data/tracker-data-search.h>
+#include <libtracker-data/tracker-query-tree.h>
+#include <libtracker-data/tracker-rdf-query.h>
+
#include "tracker-dbus.h"
#include "tracker-search.h"
-#include "tracker-rdf-query.h"
-#include "tracker-query-tree.h"
#include "tracker-marshal.h"
#define TRACKER_SEARCH_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_SEARCH, TrackerSearchPrivate))
-#define DEFAULT_SEARCH_MAX_HITS 1024
-#define SEARCH_KEEPALIVE_TIME_FOR_SQL_QUERY 600
-
-static GQuark error_quark;
+#define DEFAULT_SEARCH_MAX_HITS 1024
+#define KEEPALIVE_TIME_FOR_SQL_QUERY 600
typedef struct {
- TrackerConfig *config;
- TrackerLanguage *language;
- TrackerDBIndex *file_index;
- TrackerDBIndex *email_index;
-} TrackerSearchPrivate;
-
-static TrackerDBInterface *sql_query_iface = NULL;
-static guint sql_query_cleanup_timeout_id = 0;
+ TrackerConfig *config;
+ TrackerLanguage *language;
+ TrackerDBIndex *file_index;
+ TrackerDBIndex *email_index;
+ TrackerDBInterface *sql_query_iface;
+ guint sql_query_timeout_id;
+} TrackerSearchPrivate;
static void tracker_search_finalize (GObject *object);
@@ -88,6 +89,14 @@
priv = TRACKER_SEARCH_GET_PRIVATE (object);
+ if (priv->sql_query_timeout_id != 0) {
+ g_source_remove (priv->sql_query_timeout_id);
+ }
+
+ if (priv->sql_query_iface) {
+ g_object_unref (priv->sql_query_iface);
+ }
+
g_object_unref (priv->email_index);
g_object_unref (priv->file_index);
g_object_unref (priv->language);
@@ -413,6 +422,87 @@
}
}
+static TrackerDBResultSet *
+search_perform_rdf_query (gint request_id,
+ const gchar *service,
+ const gchar **fields,
+ const gchar *search_text,
+ const gchar *keyword,
+ const gchar *query_condition,
+ gboolean sort_by_service,
+ const gchar **sort_fields,
+ gboolean sort_desc,
+ gint offset,
+ gint max_hits,
+ GError **error)
+{
+ TrackerDBInterface *iface;
+ TrackerDBResultSet *result_set;
+
+ result_set = NULL;
+
+ iface = tracker_db_manager_get_db_interface_by_service (service);
+
+ if (query_condition) {
+ GError *query_error = NULL;
+ gchar *query_translated;
+
+ tracker_dbus_request_comment (request_id,
+ "Executing RDF query:'%s' with search "
+ "term:'%s' and keyword:'%s'",
+ query_condition,
+ search_text,
+ keyword);
+
+ query_translated = tracker_rdf_query_to_sql (iface,
+ query_condition,
+ service,
+ fields,
+ g_strv_length ((GStrv) fields),
+ search_text,
+ keyword,
+ sort_by_service,
+ sort_fields,
+ sort_fields ? g_strv_length ((GStrv) sort_fields) : 0,
+ sort_desc,
+ offset,
+ search_sanity_check_max_hits (max_hits),
+ &query_error);
+
+ if (query_error) {
+ g_propagate_error (error, query_error);
+ return NULL;
+ } else if (!query_translated) {
+ g_set_error (error,
+ tracker_rdf_error_quark (),
+ 0,
+ "Invalid rdf query, no error given");
+ return NULL;
+ }
+
+ tracker_dbus_request_comment (request_id,
+ "Translated RDF query:'%s'",
+ query_translated);
+
+ if (!tracker_is_empty_string (search_text)) {
+ tracker_data_search_text (iface,
+ service,
+ search_text,
+ 0,
+ 999999,
+ TRUE,
+ FALSE);
+ }
+
+ result_set = tracker_db_interface_execute_query (iface,
+ NULL,
+ query_translated);
+ g_free (query_translated);
+ }
+
+ return result_set;
+}
+
void
tracker_search_get_hit_count (TrackerSearch *object,
const gchar *service,
@@ -460,7 +550,7 @@
priv = TRACKER_SEARCH_GET_PRIVATE (object);
- array = tracker_db_create_array_of_services (service, FALSE);
+ array = tracker_data_schema_create_service_array (service, FALSE);
tree = tracker_query_tree_new (search_text,
priv->config,
priv->language,
@@ -510,7 +600,7 @@
priv = TRACKER_SEARCH_GET_PRIVATE (object);
- array = tracker_db_create_array_of_services (NULL, FALSE);
+ array = tracker_data_schema_create_service_array (NULL, FALSE);
tree = tracker_query_tree_new (search_text,
priv->config,
priv->language,
@@ -568,9 +658,9 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
+ GError *actual_error = NULL;
guint request_id;
gchar **strv = NULL;
@@ -612,7 +702,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service);
- result_set = tracker_db_search_text (iface,
+ result_set = tracker_data_search_text (iface,
service,
search_text,
offset,
@@ -672,9 +762,9 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
+ GError *actual_error = NULL;
guint request_id;
GPtrArray *values = NULL;
@@ -716,7 +806,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service);
- result_set = tracker_db_search_text (iface,
+ result_set = tracker_data_search_text (iface,
service,
search_text,
offset,
@@ -745,9 +835,9 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
+ GError *actual_error = NULL;
guint request_id;
gchar *snippet = NULL;
gchar *service_id;
@@ -788,7 +878,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service);
- service_id = tracker_db_file_get_id_as_string (service, id);
+ service_id = tracker_data_query_file_id_as_string (service, id);
if (!service_id) {
g_set_error (&actual_error,
TRACKER_DBUS_ERROR,
@@ -800,7 +890,7 @@
return;
}
- result_set = tracker_db_exec_proc (iface,
+ result_set = tracker_data_manager_exec_proc (iface,
"GetAllContents",
service_id,
NULL);
@@ -850,7 +940,6 @@
DBusGMethodInvocation *context,
GError **error)
{
- /* TrackerDBInterface *iface; */
TrackerDBResultSet *result_set;
guint request_id;
GHashTable *values = NULL;
@@ -869,14 +958,13 @@
max_hits,
group_results ? "yes" : "no");
- /* iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE); */
-
/* FIXME: This function no longer exists, it was returning
* NULL in every case, this DBus function needs rewriting or
* to be removed.
*/
result_set = NULL;
+ /* iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE); */
/* result_set = tracker_db_search_files_by_text (iface, */
/* search_text, */
/* offset, */
@@ -896,91 +984,6 @@
tracker_dbus_request_success (request_id);
}
-static TrackerDBResultSet *
-perform_rdf_query (gint request_id,
- const gchar *service,
- gchar **fields,
- const gchar *search_text,
- const gchar *keyword,
- const gchar *query_condition,
- gboolean sort_by_service,
- gchar **sort_fields,
- gboolean sort_desc,
- gint offset,
- gint max_hits,
- GError **error)
-{
- static gboolean inited = FALSE;
- TrackerDBInterface *iface;
- TrackerDBResultSet *result_set;
-
- if (!inited) {
- error_quark = g_quark_from_static_string ("RDF-processing-error");
- inited = TRUE;
- }
-
- result_set = NULL;
-
- iface = tracker_db_manager_get_db_interface_by_service (service);
-
- if (query_condition) {
- GError *query_error = NULL;
- gchar *query_translated;
-
- tracker_dbus_request_comment (request_id,
- "Executing RDF query:'%s' with search "
- "term:'%s' and keyword:'%s'",
- query_condition,
- search_text,
- keyword);
-
- query_translated = tracker_rdf_query_to_sql (iface,
- query_condition,
- service,
- fields,
- g_strv_length (fields),
- search_text,
- keyword,
- sort_by_service,
- sort_fields,
- (sort_fields ? g_strv_length (sort_fields) : 0),
- sort_desc,
- offset,
- search_sanity_check_max_hits (max_hits),
- &query_error);
-
- if (query_error) {
- g_propagate_error (error, query_error);
- return NULL;
- } else if (!query_translated) {
- g_set_error (error, error_quark, 0, "Invalid rdf query, no error given");
- return NULL;
- }
-
- tracker_dbus_request_comment (request_id,
- "Translated RDF query:'%s'",
- query_translated);
-
- if (!tracker_is_empty_string (search_text)) {
- tracker_db_search_text (iface,
- service,
- search_text,
- 0,
- 999999,
- TRUE,
- FALSE);
- }
-
- result_set = tracker_db_interface_execute_query (iface,
- NULL,
- query_translated);
- g_free (query_translated);
- }
-
- return result_set;
-}
-
-
void
tracker_search_metadata (TrackerSearch *object,
const gchar *service,
@@ -991,10 +994,15 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
TrackerDBResultSet *result_set;
+ GError *actual_error = NULL;
guint request_id;
gchar **values;
+ gchar *query_condition;
+ const gchar *fields[] = {
+ "File:NameDelimited",
+ NULL
+ };
/* FIXME: This function is completely redundant */
@@ -1035,13 +1043,21 @@
}
- gchar *fields[] = {"File:NameDelimited", NULL};
- gchar *query_condition = tracker_rdf_query_for_attr_value (field, search_text);
-
- result_set = perform_rdf_query (request_id, service, fields, "", "", query_condition,
- FALSE, NULL, FALSE, offset, max_hits, &actual_error);
-
+ query_condition = tracker_rdf_query_for_attr_value (field, search_text);
+ result_set = search_perform_rdf_query (request_id,
+ service,
+ fields,
+ "",
+ "",
+ query_condition,
+ FALSE,
+ NULL,
+ FALSE,
+ offset,
+ max_hits,
+ &actual_error);
g_free (query_condition);
+
values = tracker_dbus_query_result_to_strv (result_set, 1, NULL);
dbus_g_method_return (context, values);
@@ -1063,9 +1079,9 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
+ GError *actual_error = NULL;
guint request_id;
GHashTable *values = NULL;
@@ -1129,25 +1145,24 @@
tracker_dbus_request_success (request_id);
}
-
void
tracker_search_query (TrackerSearch *object,
gint live_query_id,
const gchar *service,
- gchar **fields,
+ const gchar **fields,
const gchar *search_text,
const gchar *keyword,
const gchar *query_condition,
gboolean sort_by_service,
- gchar **sort_fields,
+ const gchar **sort_fields,
gboolean sort_desc,
gint offset,
gint max_hits,
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
TrackerDBResultSet *result_set;
+ GError *actual_error = NULL;
guint request_id;
GPtrArray *values = NULL;
@@ -1185,8 +1200,18 @@
}
- result_set = perform_rdf_query (request_id, service, fields, search_text, keyword, query_condition,
- sort_by_service, sort_fields, sort_desc, offset, max_hits, &actual_error);
+ result_set = search_perform_rdf_query (request_id,
+ service,
+ fields,
+ search_text,
+ keyword,
+ query_condition,
+ sort_by_service,
+ sort_fields,
+ sort_desc,
+ offset,
+ max_hits,
+ &actual_error);
if (actual_error) {
tracker_dbus_request_failed (request_id,
@@ -1265,19 +1290,17 @@
tracker_dbus_request_success (request_id);
}
-
-static void
-sql_query_cleanup_destroy_notify_cb (gpointer user_data)
-{
- g_object_unref (user_data);
- sql_query_cleanup_timeout_id = 0;
-}
-
static gboolean
-cleanup_search_sql_query_iface (gpointer user_data)
+search_sql_iface_cleanup_cb (gpointer user_data)
{
- g_object_unref (sql_query_iface);
- sql_query_iface = NULL;
+ TrackerSearchPrivate *priv;
+
+ priv = TRACKER_SEARCH_GET_PRIVATE (user_data);
+
+ g_object_unref (priv->sql_query_iface);
+ priv->sql_query_iface = NULL;
+ priv->sql_query_timeout_id = 0;
+
return FALSE;
}
@@ -1287,8 +1310,9 @@
DBusGMethodInvocation *context,
GError **error)
{
- GError *actual_error = NULL;
+ TrackerSearchPrivate *priv;
TrackerDBResultSet *result_set;
+ GError *actual_error = NULL;
guint request_id;
request_id = tracker_dbus_get_next_request_id ();
@@ -1300,13 +1324,16 @@
"query:'%s'",
query);
- if (sql_query_cleanup_timeout_id != 0) {
- g_source_remove (sql_query_cleanup_timeout_id);
- sql_query_cleanup_timeout_id = 0;
+ priv = TRACKER_SEARCH_GET_PRIVATE (object);
+
+ if (priv->sql_query_timeout_id != 0) {
+ g_source_remove (priv->sql_query_timeout_id);
+ priv->sql_query_timeout_id = 0;
}
- if (!sql_query_iface) {
- sql_query_iface = tracker_db_manager_get_db_interfaces_ro (7,
+ if (priv->sql_query_iface == NULL) {
+ priv->sql_query_iface =
+ tracker_db_manager_get_db_interfaces_ro (7,
TRACKER_DB_CACHE,
TRACKER_DB_COMMON,
TRACKER_DB_FILE_CONTENTS,
@@ -1316,7 +1343,7 @@
TRACKER_DB_XESAM);
}
- result_set = tracker_db_interface_execute_query (sql_query_iface,
+ result_set = tracker_db_interface_execute_query (priv->sql_query_iface,
&actual_error,
query);
@@ -1332,11 +1359,10 @@
g_object_unref (result_set);
}
- sql_query_cleanup_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
- SEARCH_KEEPALIVE_TIME_FOR_SQL_QUERY,
- cleanup_search_sql_query_iface,
- g_object_ref (sql_query_iface),
- sql_query_cleanup_destroy_notify_cb);
+ priv->sql_query_timeout_id =
+ g_timeout_add_seconds (KEEPALIVE_TIME_FOR_SQL_QUERY,
+ search_sql_iface_cleanup_cb,
+ object);
tracker_dbus_request_success (request_id);
Modified: trunk/src/trackerd/tracker-search.h
==============================================================================
--- trunk/src/trackerd/tracker-search.h (original)
+++ trunk/src/trackerd/tracker-search.h Tue Nov 11 15:51:19 2008
@@ -113,12 +113,12 @@
void tracker_search_query (TrackerSearch *object,
gint live_query_id,
const gchar *service,
- gchar **fields,
+ const gchar **fields,
const gchar *search_text,
const gchar *keyword,
const gchar *query_condition,
gboolean sort_by_service,
- gchar **sort_fields,
+ const gchar **sort_fields,
gint sort_field_count,
gint offset,
gint max_hits,
Modified: trunk/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- trunk/src/trackerd/tracker-xesam-live-search.c (original)
+++ trunk/src/trackerd/tracker-xesam-live-search.c Tue Nov 11 15:51:19 2008
@@ -23,12 +23,14 @@
#include <dbus/dbus-glib-bindings.h>
+#include <libtracker-data/tracker-data-manager.h>
+#include <libtracker-data/tracker-data-live-search.h>
+#include <libtracker-data/tracker-xesam-query.h>
+
#include "tracker-xesam-live-search.h"
#include "tracker-xesam.h"
#include "tracker-xesam-manager.h"
-#include "tracker-xesam-query.h"
#include "tracker-dbus.h"
-#include "tracker-db.h"
struct _TrackerXesamLiveSearchPriv {
TrackerXesamSession *session;
@@ -283,7 +285,7 @@
/* Right now we are ignoring flags (both creates and updates are
* searched) */
- result_set = tracker_db_live_search_get_new_ids (iface,
+ result_set = tracker_data_live_search_get_new_ids (iface,
tracker_xesam_live_search_get_id (self),
tracker_xesam_live_search_get_from_query (self),
tracker_xesam_live_search_get_join_query (self),
@@ -352,7 +354,7 @@
*hits = NULL;
- result_set = tracker_db_live_search_get_all_ids (iface,
+ result_set = tracker_data_live_search_get_ids (iface,
tracker_xesam_live_search_get_id (self));
if (!result_set) {
@@ -414,7 +416,7 @@
if (flags & MATCH_WITH_EVENTS_DELETES) {
/* Deleted items */
- result_set = tracker_db_live_search_get_deleted_ids (iface,
+ result_set = tracker_data_live_search_get_deleted_ids (iface,
tracker_xesam_live_search_get_id (self));
if (result_set) {
@@ -484,7 +486,7 @@
g_message ("Closing search '%s'",
tracker_xesam_live_search_get_id (self));
- tracker_db_live_search_stop (iface,
+ tracker_data_live_search_stop (iface,
tracker_xesam_live_search_get_id (self));
}
@@ -527,7 +529,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
- result_set = tracker_db_live_search_get_hit_count (iface,
+ result_set = tracker_data_live_search_get_hit_count (iface,
tracker_xesam_live_search_get_id (self));
_tracker_db_result_set_get_value (result_set, 0, &value);
*count = g_value_get_int (&value);
@@ -869,7 +871,7 @@
/* For ottela: fetch results for get_hits */
- result_set = tracker_db_live_search_get_hit_data (iface,
+ result_set = tracker_data_live_search_get_hit_data (iface,
tracker_xesam_live_search_get_id (self),
fields);
@@ -934,7 +936,7 @@
fields = g_value_get_boxed (value);
- result_set = tracker_db_live_search_get_hit_data (iface,
+ result_set = tracker_data_live_search_get_hit_data (iface,
tracker_xesam_live_search_get_id (self),
fields);
@@ -1009,7 +1011,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
- result_set = tracker_db_live_search_get_hit_data (iface,
+ result_set = tracker_data_live_search_get_hit_data (iface,
tracker_xesam_live_search_get_id (self),
fields);
@@ -1054,7 +1056,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
- result_set = tracker_db_live_search_get_hit_data (iface,
+ result_set = tracker_data_live_search_get_hit_data (iface,
tracker_xesam_live_search_get_id (self),
fields);
@@ -1116,7 +1118,7 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_XESAM_SERVICE);
- tracker_db_live_search_start (iface,
+ tracker_data_live_search_start (iface,
tracker_xesam_live_search_get_from_query (self),
tracker_xesam_live_search_get_join_query (self),
tracker_xesam_live_search_get_where_query (self),
Modified: trunk/src/trackerd/tracker-xesam-manager.c
==============================================================================
--- trunk/src/trackerd/tracker-xesam-manager.c (original)
+++ trunk/src/trackerd/tracker-xesam-manager.c Tue Nov 11 15:51:19 2008
@@ -29,6 +29,8 @@
#include <libtracker-db/tracker-db-manager.h>
+#include <libtracker-data/tracker-data-update.h>
+
#include "tracker-xesam-manager.h"
#include "tracker-dbus.h"
#include "tracker-main.h"
@@ -385,7 +387,7 @@
g_list_free (sessions);
- tracker_db_xesam_delete_handled_events (xesam_db_iface);
+ tracker_data_update_delete_handled_events (xesam_db_iface);
return reason_to_live;
}
Modified: trunk/src/trackerd/tracker-xesam.c
==============================================================================
--- trunk/src/trackerd/tracker-xesam.c (original)
+++ trunk/src/trackerd/tracker-xesam.c Tue Nov 11 15:51:19 2008
@@ -36,8 +36,8 @@
#include "tracker-xesam.h"
#include "tracker-status.h"
#include "tracker-xesam-manager.h"
-#include "tracker-rdf-query.h"
-#include "tracker-query-tree.h"
+#include <libtracker-data/tracker-rdf-query.h>
+#include <libtracker-data/tracker-query-tree.h>
#include "tracker-marshal.h"
enum {
Modified: trunk/src/trackerd/tracker-xesam.h
==============================================================================
--- trunk/src/trackerd/tracker-xesam.h (original)
+++ trunk/src/trackerd/tracker-xesam.h Tue Nov 11 15:51:19 2008
@@ -28,7 +28,7 @@
#include <libtracker-db/tracker-db-index.h>
-#include "tracker-db.h"
+#include <libtracker-data/tracker-data-manager.h>
#define TRACKER_XESAM_SERVICE "org.freedesktop.xesam.searcher"
#define TRACKER_XESAM_PATH "/org/freedesktop/xesam/searcher/main"
Modified: trunk/tests/tracker-indexer/Makefile.am
==============================================================================
--- trunk/tests/tracker-indexer/Makefile.am (original)
+++ trunk/tests/tracker-indexer/Makefile.am Tue Nov 11 15:51:19 2008
@@ -25,19 +25,16 @@
tracker-dbus.h \
tracker-indexer.c \
tracker-indexer.h \
- tracker-indexer-db.c \
- tracker-indexer-db.h \
tracker-indexer-module.c \
tracker-indexer-module.h \
tracker-marshal-main.c \
- tracker-metadata.c \
- tracker-metadata.h \
tracker-metadata-utils.c \
tracker-metadata-utils.h \
tracker-metadata-utils-test.c \
tracker-module.h
tracker_metadata_utils_LDADD = \
+ $(top_builddir)/src/libtracker-data/libtracker-data.la \
$(top_builddir)/src/libtracker-db/libtracker-db.la \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(top_builddir)/tests/common/libtracker-testcommon.la \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]