tracker r1447 - in branches/indexer-split: . src/trackerd
- From: ifrade svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1447 - in branches/indexer-split: . src/trackerd
- Date: Mon, 19 May 2008 15:55:18 +0000 (UTC)
Author: ifrade
Date: Mon May 19 15:55:17 2008
New Revision: 1447
URL: http://svn.gnome.org/viewvc/tracker?rev=1447&view=rev
Log:
Moved FieldDef to GObject. Operations to tracker-service-manager, now renamed to tracker-ontology
Added:
branches/indexer-split/src/trackerd/tracker-field.c
branches/indexer-split/src/trackerd/tracker-field.h
branches/indexer-split/src/trackerd/tracker-ontology.c
branches/indexer-split/src/trackerd/tracker-ontology.h
Removed:
branches/indexer-split/src/trackerd/tracker-service-manager.c
branches/indexer-split/src/trackerd/tracker-service-manager.h
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/trackerd/Makefile.am
branches/indexer-split/src/trackerd/tracker-apps.c
branches/indexer-split/src/trackerd/tracker-db-email.c
branches/indexer-split/src/trackerd/tracker-db-sqlite.c
branches/indexer-split/src/trackerd/tracker-db-sqlite.h
branches/indexer-split/src/trackerd/tracker-db.c
branches/indexer-split/src/trackerd/tracker-db.h
branches/indexer-split/src/trackerd/tracker-dbus-files.c
branches/indexer-split/src/trackerd/tracker-dbus-keywords.c
branches/indexer-split/src/trackerd/tracker-dbus-metadata.c
branches/indexer-split/src/trackerd/tracker-dbus-search.c
branches/indexer-split/src/trackerd/tracker-dbus-xesam.c
branches/indexer-split/src/trackerd/tracker-email-utils.c
branches/indexer-split/src/trackerd/tracker-indexer.c
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-main.h
branches/indexer-split/src/trackerd/tracker-metadata.c
branches/indexer-split/src/trackerd/tracker-process-files.c
branches/indexer-split/src/trackerd/tracker-query-tree.c
branches/indexer-split/src/trackerd/tracker-rdf-query.c
branches/indexer-split/src/trackerd/tracker-xesam-query.c
Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am (original)
+++ branches/indexer-split/src/trackerd/Makefile.am Mon May 19 15:55:17 2008
@@ -101,6 +101,8 @@
tracker-email.h \
tracker-email-utils.c \
tracker-email-utils.h \
+ tracker-field.c \
+ tracker-field.h \
tracker-indexer.c \
tracker-indexer.h \
tracker-index-stage.c \
@@ -110,6 +112,8 @@
tracker-marshal-main.c \
tracker-metadata.c \
tracker-metadata.h \
+ tracker-ontology.c \
+ tracker-ontology.h \
tracker-parser.c \
tracker-parser.h \
tracker-process-files.c \
@@ -122,8 +126,6 @@
tracker-utils.h \
tracker-service.c \
tracker-service.h \
- tracker-service-manager.c \
- tracker-service-manager.h \
tracker-ioprio.c \
tracker-ioprio.h \
tracker-os-dependant.h \
Modified: branches/indexer-split/src/trackerd/tracker-apps.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-apps.c (original)
+++ branches/indexer-split/src/trackerd/tracker-apps.c Mon May 19 15:55:17 2008
@@ -45,7 +45,7 @@
/* Add user defined applications path to service directory list */
if (dir) {
tracker_log ("Registering path %s as belonging to service Applications", dir);
- tracker_service_directories_add ("Applications", dir);
+ tracker_ontology_add_dir_to_service_type ("Applications", dir);
g_free (dir);
}
@@ -59,7 +59,7 @@
for (i = 0; dir_array[i] != NULL; ++i) {
dir = g_strdup_printf ("%s/applications", dir_array[i]);
tracker_info ("Registering path %s as belonging to service Applications", dir);
- tracker_service_directories_add ("Applications", dir);
+ tracker_ontology_add_dir_to_service_type ("Applications", dir);
g_free (dir);
}
g_strfreev (dir_array);
@@ -67,8 +67,8 @@
} else {
tracker_log ("Registering path %s as belonging to service Applications", "/usr/local/share/applications");
tracker_log ("Registering path %s as belonging to service Applications", "/usr/share/applications");
- tracker_service_directories_add ("Applications", "/usr/local/share/applications");
- tracker_service_directories_add ("Applications", "/usr/share/applications");
+ tracker_ontology_add_dir_to_service_type ("Applications", "/usr/local/share/applications");
+ tracker_ontology_add_dir_to_service_type ("Applications", "/usr/share/applications");
}
}
}
Modified: branches/indexer-split/src/trackerd/tracker-db-email.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-email.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-email.c Mon May 19 15:55:17 2008
@@ -488,7 +488,7 @@
attachment_service = get_attachment_service_name (mail_app);
}
- type_id = tracker_service_manager_get_id_for_service (service);
+ type_id = tracker_ontology_get_id_for_service_type (service);
if (type_id == -1) {
tracker_error ("ERROR: service %s not found", service);
g_free (attachment_service);
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.c Mon May 19 15:55:17 2008
@@ -44,7 +44,7 @@
#include "tracker-metadata.h"
#include "tracker-utils.h"
#include "tracker-watch.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-query-tree.h"
#include "tracker-xesam.h"
#include "tracker-main.h"
@@ -354,7 +354,7 @@
GValue result = { 0, };
gchar *str;
- str = tracker_service_manager_get_service_by_id (g_value_get_int (&values[0]));
+ str = tracker_ontology_get_service_type_by_id (g_value_get_int (&values[0]));
g_value_init (&result, G_TYPE_STRING);
g_value_take_string (&result, str);
@@ -369,7 +369,7 @@
GValue result = { 0, };
gint id;
- id = tracker_service_manager_get_id_for_service (g_value_get_string (&values[0]));
+ id = tracker_ontology_get_id_for_service_type (g_value_get_string (&values[0]));
g_value_init (&result, G_TYPE_INT);
g_value_set_int (&result, id);
@@ -384,7 +384,7 @@
GValue result = { 0, };
gint id;
- id = tracker_service_manager_get_id_for_service (g_value_get_string (&values[0]));
+ id = tracker_ontology_get_id_for_service_type (g_value_get_string (&values[0]));
g_value_init (&result, G_TYPE_INT);
g_value_set_int (&result, id);
@@ -458,7 +458,7 @@
tracker_log ("Trying to obtain service %s in cache", *group);
- service = tracker_service_manager_get_service (*group);
+ service = tracker_ontology_get_service_type_by_name (*group);
if (!service) {
tracker_db_exec_proc (iface, "InsertServiceType", *group, NULL);
@@ -568,7 +568,7 @@
gchar *service_file, *str_id;
gchar **groups, **keys;
gchar **group, **key;
- FieldDef *def;
+ const TrackerField *def;
gint id;
gchar *DataTypeArray[11] = {"Keyword", "Indexable", "CLOB",
"String", "Integer", "Double",
@@ -591,13 +591,14 @@
for (group = groups; *group; group++) {
- def = tracker_db_get_field_def (*group);
+ def = tracker_ontology_get_field_def (*group);
if (!def) {
tracker_db_exec_proc (iface, "InsertMetadataType", *group, NULL);
id = tracker_db_interface_sqlite_get_last_insert_id (TRACKER_DB_INTERFACE_SQLITE (iface));
} else {
- id = atoi (def->id);
+ id = atoi (tracker_field_get_id (def));
+ g_error ("Duplicated metadata description %s", *group);
}
str_id = tracker_uint_to_string (id);
@@ -723,27 +724,6 @@
}
-
-FieldDef *
-tracker_db_get_field_def (const char *field_name)
-{
- FieldDef *def;
- char *name;
-
- name = g_utf8_strdown (field_name, -1);
- def = g_hash_table_lookup (tracker->metadata_table, name);
- g_free (name);
-
- return def;
-}
-
-
-void
-tracker_db_free_field_def (FieldDef *def)
-{
-}
-
-
gboolean
tracker_db_load_prepared_queries (void)
{
@@ -1585,7 +1565,7 @@
static gint
tracker_metadata_is_key (const gchar *service, const gchar *meta_name)
{
- return tracker_service_manager_metadata_in_service (service, meta_name);
+ return tracker_ontology_metadata_key_in_service (service, meta_name);
}
@@ -1595,6 +1575,7 @@
return (strcasecmp (s1, s2) == 0);
}
+/* Replace with tracker_ontology_get_field_column_in_services */
char *
tracker_db_get_field_name (const char *service, const char *meta_name)
{
@@ -1616,21 +1597,6 @@
}
-
-char *
-tracker_db_get_display_field (FieldDef *def)
-{
- if (def->type == DATA_INDEX || def->type == DATA_STRING || def->type == DATA_DOUBLE) {
- return g_strdup ("MetaDataDisplay");
- }
-
- return g_strdup ("MetaDataValue");
-
-}
-
-
-
-
GHashTable *
tracker_db_get_file_contents_words (DBConnection *db_con, guint32 id, GHashTable *old_table)
{
@@ -1743,11 +1709,11 @@
static void
save_full_text_bytes (DBConnection *blob_db_con, const char *str_file_id, GByteArray *byte_array)
{
- FieldDef *def;
+ const gchar *id;
- def = tracker_db_get_field_def ("File:Contents");
+ id = tracker_ontology_get_field_id ("File:Contents");
- if (!def) {
+ if (!id) {
tracker_error ("WARNING: metadata not found for type %s", "File:Contents");
return;
}
@@ -1756,7 +1722,7 @@
NULL,
"SaveServiceContents",
str_file_id, -1,
- def->id, -1,
+ id, -1,
byte_array->data, byte_array->len,
NULL);
}
@@ -1767,7 +1733,7 @@
{
gchar *compressed, *value = NULL;
gint bytes_compressed;
- FieldDef *def;
+ const gchar *field_id;
compressed = function_compress_string (text, length, &bytes_compressed);
@@ -1781,9 +1747,9 @@
}
- def = tracker_db_get_field_def ("File:Contents");
+ field_id = tracker_ontology_get_field_id ("File:Contents");
- if (!def) {
+ if (!field_id) {
tracker_error ("WARNING: metadata not found for type %s", "File:Contents");
g_free (value);
return;
@@ -1793,7 +1759,7 @@
NULL,
"SaveServiceContents",
str_file_id, -1,
- def->id, -1,
+ field_id, -1,
value, bytes_compressed,
NULL);
g_free (value);
@@ -2175,32 +2141,40 @@
TrackerDBResultSet *
tracker_db_search_metadata (DBConnection *db_con, const char *service, const char *field, const char *text, int offset, int limit)
{
- FieldDef *def;
+ const TrackerField *def;
TrackerDBResultSet *result_set;
g_return_val_if_fail ((service && field && text), NULL);
- def = tracker_db_get_field_def (field);
+ def = tracker_ontology_get_field_def (field);
if (!def) {
tracker_error ("ERROR: metadata not found for type %s", field);
return NULL;
}
- switch (def->type) {
+ /* FIXME This method was broken: Using wrong tables!?!?!?!?!? */
+ switch (tracker_field_get_data_type (def)) {
- case 0:
- case 1: result_set = tracker_exec_proc (db_con, "SearchMetadata", def->id, text, NULL); break;
+ case TRACKER_FIELD_TYPE_KEYWORD:
+ case TRACKER_FIELD_TYPE_INDEX:
+ result_set = tracker_exec_proc (db_con, "SearchMetadata", tracker_field_get_id (def), text, NULL);
+ break;
- case 2:
- case 3: result_set = tracker_exec_proc (db_con, "SearchMetadataNumeric", def->id, text, NULL); break;
+ case TRACKER_FIELD_TYPE_FULLTEXT:
+ case TRACKER_FIELD_TYPE_STRING:
+ result_set = tracker_exec_proc (db_con, "SearchMetadataNumeric", tracker_field_get_id (def), text, NULL);
+ break;
- case 5: result_set = tracker_exec_proc (db_con, "SearchMetadataKeywords", def->id, text, NULL); break;
+ case TRACKER_FIELD_TYPE_INTEGER:
+ result_set = tracker_exec_proc (db_con, "SearchMetadataKeywords", tracker_field_get_id (def), text, NULL);
+ break;
- default: tracker_error ("ERROR: metadata could not be retrieved as type %d is not supported", def->type); result_set = NULL;
+ default:
+ tracker_error ("ERROR: metadata could not be retrieved as type %d is not supported", tracker_field_get_data_type (def));
+ result_set = NULL;
}
-
return result_set;
}
@@ -2217,36 +2191,37 @@
tracker_db_get_metadata (DBConnection *db_con, const char *service, const char *id, const char *key)
{
TrackerDBResultSet *result_set;
- FieldDef *def;
+ const TrackerField *def;
g_return_val_if_fail (id, NULL);
- def = tracker_db_get_field_def (key);
+ def = tracker_ontology_get_field_def (key);
if (!def) {
tracker_error ("ERROR: metadata not found for id %s and type %s", id, key);
return NULL;
}
- switch (def->type) {
- case DATA_INDEX:
- case DATA_STRING:
- case DATA_DOUBLE:
- result_set = tracker_exec_proc (db_con, "GetMetadata", id, def->id, NULL);
+ switch (tracker_field_get_data_type (def)) {
+ case TRACKER_FIELD_TYPE_INDEX:
+ case TRACKER_FIELD_TYPE_STRING:
+ case TRACKER_FIELD_TYPE_DOUBLE:
+ result_set = tracker_exec_proc (db_con, "GetMetadata", id, tracker_field_get_id (def), NULL);
break;
- case DATA_INTEGER:
- case DATA_DATE:
- result_set = tracker_exec_proc (db_con, "GetMetadataNumeric", id, def->id, NULL);
+ case TRACKER_FIELD_TYPE_INTEGER:
+ case TRACKER_FIELD_TYPE_DATE:
+ result_set = tracker_exec_proc (db_con, "GetMetadataNumeric", id, tracker_field_get_id (def), NULL);
break;
- case DATA_FULLTEXT:
- result_set = tracker_exec_proc (db_con, "GetContents", id, def->id, NULL);
+ case TRACKER_FIELD_TYPE_FULLTEXT:
+ result_set = tracker_exec_proc (db_con, "GetContents", id, tracker_field_get_id (def), NULL);
break;
- case DATA_KEYWORD:
- result_set = tracker_exec_proc (db_con, "GetMetadataKeyword", id, def->id, NULL);
+ case TRACKER_FIELD_TYPE_KEYWORD:
+ result_set = tracker_exec_proc (db_con, "GetMetadataKeyword", id, tracker_field_get_id (def), NULL);
break;
default:
- tracker_error ("ERROR: metadata could not be retrieved as type %d is not supported", def->type); result_set = NULL;
+ tracker_error ("ERROR: metadata could not be retrieved as type %d is not supported", tracker_field_get_data_type (def));
+ result_set = NULL;
}
return result_set;
@@ -2291,7 +2266,7 @@
static void
-update_metadata_index (const char *id, const char *service, FieldDef *def, const char *old_value, const char *new_value)
+update_metadata_index (const char *id, const char *service, const TrackerField *def, const char *old_value, const char *new_value)
{
GHashTable *old_table, *new_table;
gint sid;
@@ -2308,30 +2283,30 @@
if (old_value) {
old_table = tracker_parser_text (old_table,
old_value,
- def->weight,
+ tracker_field_get_weight (def),
tracker->language,
tracker_config_get_max_words_to_index (tracker->config),
tracker_config_get_max_word_length (tracker->config),
tracker_config_get_min_word_length (tracker->config),
- def->filtered,
- def->delimited);
+ tracker_field_get_filtered (def),
+ tracker_field_get_delimited (def));
}
/* parse new metadata value */
if (new_value) {
new_table = tracker_parser_text (new_table,
new_value,
- def->weight,
+ tracker_field_get_weight (def),
tracker->language,
tracker_config_get_max_words_to_index (tracker->config),
tracker_config_get_max_word_length (tracker->config),
tracker_config_get_min_word_length (tracker->config),
- def->filtered,
- def->delimited);
+ tracker_field_get_filtered (def),
+ tracker_field_get_delimited (def));
}
/* we only do differential updates so only changed words scores are updated */
- sid = tracker_service_manager_get_id_for_service (service);
+ sid = tracker_ontology_get_id_for_service_type (service);
tracker_db_update_differential_index (old_table, new_table, id, sid);
tracker_parser_text_free (old_table);
@@ -2396,24 +2371,27 @@
char *
-tracker_get_metadata_table (DataTypes type)
+tracker_get_metadata_table (TrackerFieldType type)
{
switch (type) {
- case DATA_INDEX:
- case DATA_STRING:
- case DATA_DOUBLE:
+ case TRACKER_FIELD_TYPE_INDEX:
+ case TRACKER_FIELD_TYPE_STRING:
+ case TRACKER_FIELD_TYPE_DOUBLE:
return g_strdup ("ServiceMetaData");
- case DATA_INTEGER:
- case DATA_DATE:
+ case TRACKER_FIELD_TYPE_INTEGER:
+ case TRACKER_FIELD_TYPE_DATE:
return g_strdup ("ServiceNumericMetaData");
- case DATA_BLOB: return g_strdup("ServiceBlobMetaData");
+ case TRACKER_FIELD_TYPE_BLOB:
+ return g_strdup("ServiceBlobMetaData");
- case DATA_KEYWORD: return g_strdup("ServiceKeywordMetaData");
+ case TRACKER_FIELD_TYPE_KEYWORD:
+ return g_strdup("ServiceKeywordMetaData");
- default: return NULL;
+ default:
+ return NULL;
}
return NULL;
@@ -2460,19 +2438,20 @@
tracker_db_insert_embedded_metadata (DBConnection *db_con, const gchar *service, const gchar *id, const gchar *key, gchar **values, gint length, GHashTable *table)
{
gint key_field = 0;
+ const TrackerField *def;
if (!service || !id || !key || !values || !values[0]) {
return;
}
- FieldDef *def = tracker_db_get_field_def (key);
+ def = tracker_ontology_get_field_def (key);
if (!def) {
tracker_error ("ERROR: metadata %s not found", key);
return;
}
- g_return_if_fail (def->embedded);
+ g_return_if_fail (tracker_field_get_embedded (def));
if (length == -1) {
length = 0;
@@ -2481,11 +2460,11 @@
}
}
- key_field = tracker_metadata_is_key (service, key);
+ key_field = tracker_ontology_metadata_key_in_service (service, key);
- switch (def->type) {
+ switch (tracker_field_get_data_type (def)) {
- case DATA_KEYWORD: {
+ case TRACKER_FIELD_TYPE_KEYWORD: {
gint i;
for (i = 0; i < length; i++) {
if (!values[i] || !values[i][0]) {
@@ -2502,17 +2481,17 @@
FALSE,
FALSE,
FALSE);
- table = tracker_parser_text_fast (table, mvalue, def->weight);
+ table = tracker_parser_text_fast (table, mvalue, tracker_field_get_weight (def));
g_free (mvalue);
}
- tracker_exec_proc (db_con, "SetMetadataKeyword", id, def->id, values[i], NULL);
+ tracker_exec_proc (db_con, "SetMetadataKeyword", id, tracker_field_get_id (def), values[i], NULL);
}
break;
}
- case DATA_INDEX: {
+ case TRACKER_FIELD_TYPE_INDEX: {
gint i;
for (i = 0; i < length; i++) {
gchar *mvalue;
@@ -2525,22 +2504,22 @@
tracker->language,
tracker_config_get_max_word_length (tracker->config),
tracker_config_get_min_word_length (tracker->config),
- def->filtered,
- def->filtered,
- def->delimited);
+ tracker_field_get_filtered (def),
+ tracker_field_get_filtered (def),
+ tracker_field_get_delimited (def));
if (table) {
- table = tracker_parser_text_fast (table, mvalue, def->weight);
+ table = tracker_parser_text_fast (table, mvalue, tracker_field_get_weight (def));
}
- tracker_exec_proc (db_con, "SetMetadata", id, def->id, mvalue, values[i], NULL);
+ tracker_exec_proc (db_con, "SetMetadata", id, tracker_field_get_id (def), mvalue, values[i], NULL);
g_free (mvalue);
}
break;
}
- case DATA_FULLTEXT: {
+ case TRACKER_FIELD_TYPE_FULLTEXT: {
gint i;
for (i = 0; i < length; i++) {
if (!values[i] || !values[i][0]) {
@@ -2550,13 +2529,13 @@
if (table) {
table = tracker_parser_text (table,
values[i],
- def->weight,
+ tracker_field_get_weight (def),
tracker->language,
tracker_config_get_max_words_to_index (tracker->config),
tracker_config_get_max_word_length (tracker->config),
tracker_config_get_min_word_length (tracker->config),
- def->filtered,
- def->delimited);
+ tracker_field_get_filtered (def),
+ tracker_field_get_delimited (def));
}
save_full_text (db_con->blob, id, values[i], strlen (values[i]));
@@ -2564,19 +2543,19 @@
break;
}
- case DATA_DOUBLE: {
+ case TRACKER_FIELD_TYPE_DOUBLE: {
gint i;
for (i = 0; i < length; i++) {
if (!values[i]) {
continue;
}
- tracker_exec_proc (db_con, "SetMetadata", id, def->id, " ", values[i], NULL);
+ tracker_exec_proc (db_con, "SetMetadata", id, tracker_field_get_id (def), " ", values[i], NULL);
}
break;
}
- case DATA_STRING: {
+ case TRACKER_FIELD_TYPE_STRING: {
gint i;
for (i = 0; i < length; i++) {
gchar *mvalue;
@@ -2589,29 +2568,29 @@
tracker->language,
tracker_config_get_max_word_length (tracker->config),
tracker_config_get_min_word_length (tracker->config),
- def->filtered,
- def->filtered,
- def->delimited);
- tracker_exec_proc (db_con, "SetMetadata", id, def->id, mvalue, values[i], NULL);
+ tracker_field_get_filtered (def),
+ tracker_field_get_filtered (def),
+ tracker_field_get_delimited (def));
+ tracker_exec_proc (db_con, "SetMetadata", id, tracker_field_get_id (def), mvalue, values[i], NULL);
g_free (mvalue);
}
break;
}
- case DATA_INTEGER: {
+ case TRACKER_FIELD_TYPE_INTEGER: {
gint i;
for (i = 0; i < length; i++) {
if (!values[i]) {
continue;
}
- tracker_exec_proc (db_con, "SetMetadataNumeric", id, def->id, values[i], NULL);
+ tracker_exec_proc (db_con, "SetMetadataNumeric", id, tracker_field_get_id (def), values[i], NULL);
}
break;
}
- case DATA_DATE: {
+ case TRACKER_FIELD_TYPE_DATE: {
gint i;
for (i = 0; i < length; i++) {
if (!values[i]) {
@@ -2625,7 +2604,7 @@
continue;
}
- tracker_exec_proc (db_con, "SetMetadataNumeric", id, def->id, mvalue, NULL);
+ tracker_exec_proc (db_con, "SetMetadataNumeric", id, tracker_field_get_id (def), mvalue, NULL);
g_free (mvalue);
}
@@ -2634,7 +2613,7 @@
}
default: {
tracker_error ("ERROR: metadata could not be set as type %d for metadata %s is not supported",
- def->type, key);
+ tracker_field_get_data_type (def), key);
break;
}
}
@@ -2644,7 +2623,7 @@
if (values[0]) {
gchar *esc_value = NULL;
- if (def->type == DATA_DATE) {
+ if (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_DATE) {
esc_value = format_date (values[0]);
if (!esc_value) {
@@ -2748,16 +2727,16 @@
}
-char *
-tracker_db_set_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, char **values, int length, gboolean do_backup)
+gchar *
+tracker_db_set_metadata (DBConnection *db_con, const char *service, const gchar *id, const gchar *key, gchar **values, gint length, gboolean do_backup)
{
- FieldDef *def;
- char *old_value = NULL, *new_value = NULL;
- gboolean update_index;
- int key_field = 0;
- int i;
- GString *str = NULL;
- char *res_service;
+ const TrackerField *def;
+ gchar *old_value = NULL, *new_value = NULL;
+ gboolean update_index;
+ gint key_field = 0;
+ gint i;
+ GString *str = NULL;
+ gchar *res_service;
g_return_val_if_fail (id && values && key && service, NULL);
@@ -2766,7 +2745,7 @@
return NULL;
}
- def = tracker_db_get_field_def (key);
+ def = tracker_ontology_get_field_def (key);
if (!def) {
tracker_error ("metadata type %s not found", key);
@@ -2781,14 +2760,16 @@
return NULL;
}
- if (def->multiple_values && length > 1) {
+ if (tracker_field_get_multiple_values (def) && length > 1) {
str = g_string_new ("");
}
- key_field = tracker_metadata_is_key (res_service, key);
- update_index = (def->type == DATA_INDEX || def->type == DATA_KEYWORD || def->type == DATA_FULLTEXT);
+ key_field = tracker_ontology_metadata_key_in_service (res_service, key);
+ update_index = (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_INDEX
+ || tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_KEYWORD
+ || tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_FULLTEXT);
if (update_index) {
@@ -2796,26 +2777,26 @@
}
/* delete old value if metadata does not support multiple values */
- if (!def->multiple_values) {
+ if (!tracker_field_get_multiple_values (def)) {
tracker_db_delete_metadata (db_con, service, id, key, FALSE);
}
- switch (def->type) {
+ switch (tracker_field_get_data_type (def)) {
- case DATA_KEYWORD:
+ case TRACKER_FIELD_TYPE_KEYWORD:
for (i=0; i<length; i++) {
if (!values[i] || !values[i][0]) continue;
- tracker_exec_proc (db_con, "SetMetadataKeyword", id, def->id, values[i], NULL);
+ tracker_exec_proc (db_con, "SetMetadataKeyword", id, tracker_field_get_id (def), values[i], NULL);
/* backup non-embedded data for embedded services */
if (do_backup &&
- !def->embedded &&
- tracker_service_manager_is_service_embedded (service)) {
- backup_non_embedded_metadata (db_con, id, def->id, values[i]);
+ !tracker_field_get_embedded (def) &&
+ tracker_ontology_service_type_has_embedded (service)) {
+ backup_non_embedded_metadata (db_con, id, tracker_field_get_id (def), values[i]);
}
if (str) {
@@ -2829,7 +2810,7 @@
break;
- case DATA_INDEX:
+ case TRACKER_FIELD_TYPE_INDEX:
for (i = 0; i < length; i++) {
gchar *mvalue;
@@ -2846,19 +2827,19 @@
/* backup non-embedded data for embedded services */
if (do_backup &&
- !def->embedded &&
- tracker_service_manager_is_service_embedded (service)) {
- backup_non_embedded_metadata (db_con, id, def->id, values[i]);
+ !tracker_field_get_embedded (def) &&
+ tracker_ontology_service_type_has_embedded (service)) {
+ backup_non_embedded_metadata (db_con, id, tracker_field_get_id (def), values[i]);
}
mvalue = tracker_parser_text_to_string (values[i],
tracker->language,
tracker_config_get_max_word_length (tracker->config),
tracker_config_get_min_word_length (tracker->config),
- def->filtered,
- def->filtered,
- def->delimited);
- tracker_exec_proc (db_con, "SetMetadata", id, def->id, mvalue, values[i], NULL);
+ tracker_field_get_filtered (def),
+ tracker_field_get_filtered (def),
+ tracker_field_get_delimited (def));
+ tracker_exec_proc (db_con, "SetMetadata", id, tracker_field_get_id (def), mvalue, values[i], NULL);
g_free (mvalue);
@@ -2866,7 +2847,7 @@
break;
- case DATA_FULLTEXT:
+ case TRACKER_FIELD_TYPE_FULLTEXT:
/* we do not support multiple values for fulltext clobs */
@@ -2878,7 +2859,7 @@
break;
- case DATA_STRING:
+ case TRACKER_FIELD_TYPE_STRING:
for (i = 0; i < length; i++) {
gchar *mvalue;
@@ -2889,25 +2870,25 @@
/* backup non-embedded data for embedded services */
if (do_backup &&
- !def->embedded &&
- tracker_service_manager_is_service_embedded (service)) {
- backup_non_embedded_metadata (db_con, id, def->id, values[i]);
+ !tracker_field_get_embedded (def) &&
+ tracker_ontology_service_type_has_embedded (service)) {
+ backup_non_embedded_metadata (db_con, id, tracker_field_get_id (def), values[i]);
}
mvalue = tracker_parser_text_to_string (values[i],
tracker->language,
tracker_config_get_max_word_length (tracker->config),
tracker_config_get_min_word_length (tracker->config),
- def->filtered,
- def->filtered,
- def->delimited);
- tracker_exec_proc (db_con, "SetMetadata", id, def->id, mvalue, values[i], NULL);
+ tracker_field_get_filtered (def),
+ tracker_field_get_filtered (def),
+ tracker_field_get_delimited (def));
+ tracker_exec_proc (db_con, "SetMetadata", id, tracker_field_get_id (def), mvalue, values[i], NULL);
g_free (mvalue);
}
break;
- case DATA_DOUBLE:
+ case TRACKER_FIELD_TYPE_DOUBLE:
for (i=0; i<length; i++) {
@@ -2916,38 +2897,38 @@
/* backup non-embedded data for embedded services */
if (do_backup &&
- !def->embedded &&
- tracker_service_manager_is_service_embedded (service)) {
- backup_non_embedded_metadata (db_con, id, def->id, values[i]);
+ !tracker_field_get_embedded (def) &&
+ tracker_ontology_service_type_has_embedded (service)) {
+ backup_non_embedded_metadata (db_con, id, tracker_field_get_id (def), values[i]);
}
- tracker_exec_proc (db_con, "SetMetadata", id, def->id, " ", values[i], NULL);
+ tracker_exec_proc (db_con, "SetMetadata", id, tracker_field_get_id (def), " ", values[i], NULL);
}
break;
- case DATA_INTEGER:
+ case TRACKER_FIELD_TYPE_INTEGER:
for (i=0; i<length; i++) {
if (!values[i] || !values[i][0]) continue;
/* backup non-embedded data for embedded services */
if (do_backup &&
- !def->embedded &&
- tracker_service_manager_is_service_embedded (service)) {
- backup_non_embedded_metadata (db_con, id, def->id, values[i]);
+ !tracker_field_get_embedded (def) &&
+ tracker_ontology_service_type_has_embedded (service)) {
+ backup_non_embedded_metadata (db_con, id, tracker_field_get_id (def), values[i]);
}
- tracker_exec_proc (db_con, "SetMetadataNumeric", id, def->id, values[i], NULL);
+ tracker_exec_proc (db_con, "SetMetadataNumeric", id, tracker_field_get_id (def), values[i], NULL);
}
break;
- case DATA_DATE:
+ case TRACKER_FIELD_TYPE_DATE:
for (i=0; i<length; i++) {
@@ -2961,13 +2942,13 @@
}
- tracker_exec_proc (db_con, "SetMetadataNumeric", id, def->id, mvalue, NULL);
+ tracker_exec_proc (db_con, "SetMetadataNumeric", id, tracker_field_get_id (def), mvalue, NULL);
/* backup non-embedded data for embedded services */
if (do_backup &&
- !def->embedded &&
- tracker_service_manager_is_service_embedded (service)) {
- backup_non_embedded_metadata (db_con, id, def->id, mvalue);
+ !tracker_field_get_embedded (def) &&
+ tracker_ontology_service_type_has_embedded (service)) {
+ backup_non_embedded_metadata (db_con, id, tracker_field_get_id (def), mvalue);
}
@@ -2978,7 +2959,7 @@
default :
- tracker_error ("ERROR: metadata could not be set as type %d for metadata %s is not supported", def->type, key);
+ tracker_error ("ERROR: metadata could not be set as type %d for metadata %s is not supported", tracker_field_get_data_type (def), key);
break;
@@ -2993,7 +2974,7 @@
if (values[0]) {
char *esc_value = NULL;
- if (def->type == DATA_DATE) {
+ if (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_DATE) {
esc_value = format_date (values[0]);
if (!esc_value) return NULL;
@@ -3074,23 +3055,23 @@
tracker_db_delete_metadata_value (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value)
{
- char *old_value = NULL, *new_value = NULL, *mvalue;
- FieldDef *def;
- gboolean update_index;
+ char *old_value = NULL, *new_value = NULL, *mvalue;
+ const TrackerField *def;
+ gboolean update_index;
g_return_if_fail (id && key && service && db_con);
/* get type details */
- def = tracker_db_get_field_def (key);
+ def = tracker_ontology_get_field_def (key);
if (!def) {
return;
}
- if (!def->embedded &&
- tracker_service_manager_is_service_embedded (service)) {
- backup_delete_non_embedded_metadata_value (db_con, id, def->id, value);
+ if (!tracker_field_get_embedded (def) &&
+ tracker_ontology_service_type_has_embedded (service)) {
+ backup_delete_non_embedded_metadata_value (db_con, id, tracker_field_get_id (def), value);
}
@@ -3103,7 +3084,8 @@
int key_field = tracker_metadata_is_key (res_service, key);
- update_index = (def->type == DATA_INDEX || def->type == DATA_KEYWORD);
+ update_index = (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_INDEX
+ || tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_KEYWORD);
if (update_index) {
@@ -3122,41 +3104,41 @@
/* perform deletion */
- switch (def->type) {
+ switch (tracker_field_get_data_type (def)) {
- case DATA_INDEX:
- case DATA_STRING:
+ case TRACKER_FIELD_TYPE_INDEX:
+ case TRACKER_FIELD_TYPE_STRING:
mvalue = tracker_parser_text_to_string (value,
tracker->language,
tracker_config_get_max_word_length (tracker->config),
tracker_config_get_min_word_length (tracker->config),
- def->filtered,
- def->filtered,
- def->delimited);
- tracker_exec_proc (db_con, "DeleteMetadataValue", id, def->id, mvalue, NULL);
+ tracker_field_get_filtered (def),
+ tracker_field_get_filtered (def),
+ tracker_field_get_delimited (def));
+ tracker_exec_proc (db_con, "DeleteMetadataValue", id, tracker_field_get_id (def), mvalue, NULL);
g_free (mvalue);
break;
- case DATA_DOUBLE:
- tracker_exec_proc (db_con, "DeleteMetadataValue", id, def->id, value, NULL);
+ case TRACKER_FIELD_TYPE_DOUBLE:
+ tracker_exec_proc (db_con, "DeleteMetadataValue", id, tracker_field_get_id (def), value, NULL);
break;
- case DATA_INTEGER:
- case DATA_DATE:
+ case TRACKER_FIELD_TYPE_INTEGER:
+ case TRACKER_FIELD_TYPE_DATE:
- tracker_exec_proc (db_con, "DeleteMetadataNumericValue", id, def->id, value, NULL);
+ tracker_exec_proc (db_con, "DeleteMetadataNumericValue", id, tracker_field_get_id (def), value, NULL);
break;
- case DATA_KEYWORD:
+ case TRACKER_FIELD_TYPE_KEYWORD:
- tracker_exec_proc (db_con, "DeleteMetadataKeywordValue", id, def->id, value, NULL);
+ tracker_exec_proc (db_con, "DeleteMetadataKeywordValue", id, tracker_field_get_id (def), value, NULL);
break;
default:
- tracker_error ("ERROR: metadata could not be deleted as type %d for metadata %s is not supported", def->type, key);
+ tracker_error ("ERROR: metadata could not be deleted as type %d for metadata %s is not supported", tracker_field_get_data_type (def), key);
break;
@@ -3212,22 +3194,22 @@
tracker_db_delete_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, gboolean update_indexes)
{
char *old_value = NULL;
- FieldDef *def;
+ const TrackerField *def;
gboolean update_index;
g_return_if_fail (id && key && service && db_con);
/* get type details */
- def = tracker_db_get_field_def (key);
+ def = tracker_ontology_get_field_def(key);
if (!def) {
return;
}
- if (!def->embedded &&
- tracker_service_manager_is_service_embedded (service)) {
- backup_delete_non_embedded_metadata (db_con, id, def->id);
+ if (!tracker_field_get_embedded (def) &&
+ tracker_ontology_service_type_has_embedded (service)) {
+ backup_delete_non_embedded_metadata (db_con, id, tracker_field_get_id (def));
}
@@ -3241,7 +3223,7 @@
int key_field = tracker_metadata_is_key (res_service, key);
- update_index = update_indexes && (def->type == DATA_INDEX || def->type == DATA_KEYWORD);
+ update_index = update_indexes && (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_INDEX || tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_KEYWORD);
if (update_index) {
@@ -3261,31 +3243,31 @@
/* perform deletion */
- switch (def->type) {
+ switch (tracker_field_get_data_type (def)) {
- case DATA_INDEX:
- case DATA_STRING:
- case DATA_DOUBLE:
- tracker_exec_proc (db_con, "DeleteMetadata", id, def->id, NULL);
+ case TRACKER_FIELD_TYPE_INDEX:
+ case TRACKER_FIELD_TYPE_STRING:
+ case TRACKER_FIELD_TYPE_DOUBLE:
+ tracker_exec_proc (db_con, "DeleteMetadata", id, tracker_field_get_id (def), NULL);
break;
- case DATA_INTEGER:
- case DATA_DATE:
- tracker_exec_proc (db_con, "DeleteMetadataNumeric", id, def->id, NULL);
+ case TRACKER_FIELD_TYPE_INTEGER:
+ case TRACKER_FIELD_TYPE_DATE:
+ tracker_exec_proc (db_con, "DeleteMetadataNumeric", id, tracker_field_get_id (def), NULL);
break;
- case DATA_KEYWORD:
- tracker_exec_proc (db_con, "DeleteMetadataKeyword", id, def->id, NULL);
+ case TRACKER_FIELD_TYPE_KEYWORD:
+ tracker_exec_proc (db_con, "DeleteMetadataKeyword", id, tracker_field_get_id (def), NULL);
break;
- case DATA_FULLTEXT:
+ case TRACKER_FIELD_TYPE_FULLTEXT:
- tracker_exec_proc (db_con, "DeleteContent", id, def->id, NULL);
+ tracker_exec_proc (db_con, "DeleteContent", id, tracker_field_get_id (def), NULL);
break;
default:
- tracker_error ("ERROR: metadata could not be deleted as this operation is not supported by type %d for metadata %s", def->type, key);
+ tracker_error ("ERROR: metadata could not be deleted as this operation is not supported by type %d for metadata %s", tracker_field_get_data_type (def), key);
break;
}
@@ -3529,7 +3511,7 @@
str_mtime = tracker_gint32_to_string (info->mtime);
str_offset = tracker_gint32_to_string (info->offset);
- service_type_id = tracker_service_manager_get_id_for_service (service);
+ service_type_id = tracker_ontology_get_id_for_service_type (service);
if (info->mime) {
tracker_debug ("service id for %s is %d and sid is %s with mime %s", service, service_type_id, sid, info->mime);
@@ -3578,7 +3560,7 @@
if (b)
g_object_unref (b);
- parent = tracker_service_manager_get_parent_service (service);
+ parent = tracker_ontology_get_parent_service (service);
if (parent) {
b = tracker_exec_proc (db_con->common, "IncStat", parent, NULL);
@@ -3703,14 +3685,14 @@
{
gchar *service;
- service = tracker_service_manager_get_service_by_id (id);
+ service = tracker_ontology_get_service_type_by_id (id);
if (service) {
gchar *parent;
tracker_exec_proc (db_con->common, "DecStat", service, NULL);
- parent = tracker_service_manager_get_parent_service (service);
+ parent = tracker_ontology_get_parent_service (service);
if (parent) {
tracker_exec_proc (db_con->common, "DecStat", parent, NULL);
@@ -3733,7 +3715,7 @@
gint service_id;
guint32 id;
- service_id = tracker_service_manager_get_id_for_service (service);
+ service_id = tracker_ontology_get_id_for_service_type (service);
if (service_id == -1) {
return NULL;
@@ -4071,14 +4053,14 @@
result = NULL;
result_list = NULL;
- service_array[0] = tracker_service_manager_get_id_for_service ("Files");
- service_array[1] = tracker_service_manager_get_id_for_service ("Folders");
- service_array[2] = tracker_service_manager_get_id_for_service ("Documents");
- service_array[3] = tracker_service_manager_get_id_for_service ("Images");
- service_array[4] = tracker_service_manager_get_id_for_service ("Music");
- service_array[5] = tracker_service_manager_get_id_for_service ("Videos");
- service_array[6] = tracker_service_manager_get_id_for_service ("Text");
- service_array[7] = tracker_service_manager_get_id_for_service ("Other");
+ service_array[0] = tracker_ontology_get_id_for_service_type ("Files");
+ service_array[1] = tracker_ontology_get_id_for_service_type ("Folders");
+ service_array[2] = tracker_ontology_get_id_for_service_type ("Documents");
+ service_array[3] = tracker_ontology_get_id_for_service_type ("Images");
+ service_array[4] = tracker_ontology_get_id_for_service_type ("Music");
+ service_array[5] = tracker_ontology_get_id_for_service_type ("Videos");
+ service_array[6] = tracker_ontology_get_id_for_service_type ("Text");
+ service_array[7] = tracker_ontology_get_id_for_service_type ("Other");
services = g_array_new (TRUE, TRUE, sizeof (gint));
g_array_append_vals (services, service_array, 8);
@@ -4169,14 +4151,14 @@
location_prefix = g_strconcat (location, G_DIR_SEPARATOR_S, NULL);
- service_array[0] = tracker_service_manager_get_id_for_service ("Files");
- service_array[1] = tracker_service_manager_get_id_for_service ("Folders");
- service_array[2] = tracker_service_manager_get_id_for_service ("Documents");
- service_array[3] = tracker_service_manager_get_id_for_service ("Images");
- service_array[4] = tracker_service_manager_get_id_for_service ("Music");
- service_array[5] = tracker_service_manager_get_id_for_service ("Videos");
- service_array[6] = tracker_service_manager_get_id_for_service ("Text");
- service_array[7] = tracker_service_manager_get_id_for_service ("Other");
+ service_array[0] = tracker_ontology_get_id_for_service_type ("Files");
+ service_array[1] = tracker_ontology_get_id_for_service_type ("Folders");
+ service_array[2] = tracker_ontology_get_id_for_service_type ("Documents");
+ service_array[3] = tracker_ontology_get_id_for_service_type ("Images");
+ service_array[4] = tracker_ontology_get_id_for_service_type ("Music");
+ service_array[5] = tracker_ontology_get_id_for_service_type ("Videos");
+ service_array[6] = tracker_ontology_get_id_for_service_type ("Text");
+ service_array[7] = tracker_ontology_get_id_for_service_type ("Other");
services = g_array_new (TRUE, TRUE, sizeof (gint));
g_array_append_vals (services, service_array, 8);
@@ -4268,14 +4250,14 @@
location_prefix = g_strconcat (location, G_DIR_SEPARATOR_S, NULL);
- service_array[0] = tracker_service_manager_get_id_for_service ("Files");
- service_array[1] = tracker_service_manager_get_id_for_service ("Folders");
- service_array[2] = tracker_service_manager_get_id_for_service ("Documents");
- service_array[3] = tracker_service_manager_get_id_for_service ("Images");
- service_array[4] = tracker_service_manager_get_id_for_service ("Music");
- service_array[5] = tracker_service_manager_get_id_for_service ("Videos");
- service_array[6] = tracker_service_manager_get_id_for_service ("Text");
- service_array[7] = tracker_service_manager_get_id_for_service ("Other");
+ service_array[0] = tracker_ontology_get_id_for_service_type ("Files");
+ service_array[1] = tracker_ontology_get_id_for_service_type ("Folders");
+ service_array[2] = tracker_ontology_get_id_for_service_type ("Documents");
+ service_array[3] = tracker_ontology_get_id_for_service_type ("Images");
+ service_array[4] = tracker_ontology_get_id_for_service_type ("Music");
+ service_array[5] = tracker_ontology_get_id_for_service_type ("Videos");
+ service_array[6] = tracker_ontology_get_id_for_service_type ("Text");
+ service_array[7] = tracker_ontology_get_id_for_service_type ("Other");
services = g_array_new (TRUE, TRUE, sizeof (gint));
g_array_append_vals (services, service_array, 8);
@@ -4868,6 +4850,47 @@
return service;
}
+static TrackerField *
+db_row_to_field_def (TrackerDBResultSet *result_set) {
+
+ TrackerField *field_def;
+ TrackerFieldType field_type;
+ gchar *field_name, *name;
+ gint weight, id;
+ gboolean embedded, multiple_values, delimited, filtered, store_metadata;
+
+ field_def = tracker_field_new ();
+
+ tracker_db_result_set_get (result_set,
+ 0, &id,
+ 1, &name,
+ 2, &field_type,
+ 3, &field_name,
+ 4, &weight,
+ 5, &embedded,
+ 6, &multiple_values,
+ 7, &delimited,
+ 8, &filtered,
+ 9, &store_metadata,
+ -1);
+
+ tracker_field_set_id (field_def, tracker_int_to_string (id));
+ tracker_field_set_name (field_def, name);
+ tracker_field_set_field_name (field_def, field_name);
+ tracker_field_set_weight (field_def, weight);
+ tracker_field_set_embedded (field_def, embedded);
+ tracker_field_set_multiple_values (field_def, multiple_values);
+ tracker_field_set_delimited (field_def, delimited);
+ tracker_field_set_filtered (field_def, filtered);
+ tracker_field_set_store_metadata (field_def, store_metadata);
+
+ g_free (field_name);
+ g_free (name);
+
+ return field_def;
+}
+
+
/* get static data like metadata field definitions and services definitions and load them into hashtables */
void
tracker_db_get_static_data (DBConnection *db_con)
@@ -4884,49 +4907,31 @@
while (valid) {
TrackerDBResultSet *result_set2;
- gboolean embedded, multiple_values, delimited, filtered, store_metadata;
- FieldDef *def;
-
- def = g_new0 (FieldDef, 1);
-
- tracker_db_result_set_get (result_set,
- 0, &id,
- 1, &name,
- 2, &def->type,
- 3, &def->field_name,
- 4, &def->weight,
- 5, &embedded,
- 6, &multiple_values,
- 7, &delimited,
- 8, &filtered,
- 9, &store_metadata,
- -1);
+ TrackerField *def;
+ GSList *child_ids = NULL;
- def->id = tracker_int_to_string (id);
- def->embedded = embedded;
- def->multiple_values = multiple_values;
- def->delimited = delimited;
- def->filtered = filtered;
- def->store_metadata = store_metadata;
+ def = db_row_to_field_def (result_set);
- result_set2 = tracker_exec_proc (db_con, "GetMetadataAliases", def->id, NULL);
+ result_set2 = tracker_exec_proc (db_con, "GetMetadataAliases", tracker_field_get_id (def), NULL);
if (result_set2) {
valid = TRUE;
while (valid) {
tracker_db_result_set_get (result_set2, 1, &id, -1);
- def->child_ids = g_slist_prepend (def->child_ids,
- tracker_int_to_string (id));
+ child_ids = g_slist_prepend (child_ids,
+ tracker_int_to_string (id));
valid = tracker_db_result_set_iter_next (result_set2);
}
+ tracker_field_set_child_ids (def, child_ids);
g_object_unref (result_set2);
}
- g_hash_table_insert (tracker->metadata_table, g_utf8_strdown (name, -1), def);
- tracker_debug ("loading metadata def %s with weight %d", def->field_name, def->weight);
+ tracker_ontology_add_field (def);
+ tracker_debug ("loading metadata def %s with weight %d",
+ tracker_field_get_name (def), tracker_field_get_weight (def));
g_free (name);
@@ -4964,9 +4969,9 @@
mime_prefixes = tracker_db_get_mime_prefixes_for_service_id (db_con, id);
tracker_debug ("Adding service definition for %s with id %d", name, id);
- tracker_service_manager_add_service (service,
- mimes,
- mime_prefixes);
+ tracker_ontology_add_service_type (service,
+ mimes,
+ mime_prefixes);
g_slist_free (mimes);
g_slist_free (mime_prefixes);
@@ -4978,7 +4983,7 @@
g_object_unref (result_set);
/* check for web history */
- if (!tracker_service_manager_get_service ("Webhistory")) {
+ if (!tracker_ontology_get_service_type_by_name ("Webhistory")) {
tracker_log ("Adding missing Webhistory service");
tracker_exec_proc (db_con, "InsertServiceType", "Webhistory", NULL);
}
@@ -4990,7 +4995,7 @@
{
TrackerDBType type;
- type = tracker_service_manager_get_db_for_service (service);
+ type = tracker_ontology_get_db_for_service_type (service);
if (type == TRACKER_DB_TYPE_EMAIL) {
return db_con->emails;
@@ -5016,44 +5021,10 @@
return result;
}
-
-gboolean
-tracker_db_metadata_is_child (DBConnection *db_con, const char *child, const char *parent)
-{
- FieldDef *def_child, *def_parent;
-
- def_child = tracker_db_get_field_def (child);
-
- if (!def_child) {
- return FALSE;
- }
-
-
- def_parent = tracker_db_get_field_def (parent);
-
- if (!def_parent) {
- return FALSE;
- }
-
- GSList *tmp;
-
- for (tmp = def_parent->child_ids; tmp; tmp = tmp->next) {
-
- if (!tmp->data) return FALSE;
-
- if (strcmp (def_child->id, tmp->data) == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-
-}
-
// FIXME Do this in a non-retarded way
gboolean
-get_service_mapping(DBConnection *db_con, const char *type, GList **list)
+get_service_mapping (DBConnection *db_con, const char *type, GList **list)
{
TrackerDBResultSet *result_set;
gboolean valid = TRUE;
@@ -5409,11 +5380,8 @@
FieldData *
tracker_db_get_metadata_field (DBConnection *db_con, const char *service, const char *field_name, int field_count, gboolean is_select, gboolean is_condition)
{
- FieldData *field_data;
-
- field_data = NULL;
-
- FieldDef *def;
+ FieldData *field_data = NULL;
+ const TrackerField *def;
field_data = g_new0 (FieldData, 1);
@@ -5421,15 +5389,15 @@
field_data->is_condition = is_condition;
field_data->field_name = g_strdup (field_name);
- def = tracker_db_get_field_def (field_name);
+ def = tracker_ontology_get_field_def (field_name);
if (def) {
- field_data->table_name = tracker_get_metadata_table (def->type);
+ field_data->table_name = tracker_get_metadata_table (tracker_field_get_data_type (def));
field_data->alias = g_strdup_printf ("M%d", field_count);
- field_data->data_type = def->type;
- field_data->id_field = g_strdup (def->id);
- field_data->multiple_values = def->multiple_values;
+ field_data->data_type = tracker_field_get_data_type (def);
+ field_data->id_field = g_strdup (tracker_field_get_id (def));
+ field_data->multiple_values = tracker_field_get_multiple_values (def);
char *my_field = tracker_db_get_field_name (service, field_name);
@@ -5438,21 +5406,18 @@
g_free (my_field);
field_data->needs_join = FALSE;
} else {
- char *disp_field = tracker_db_get_display_field (def);
+ char *disp_field = tracker_ontology_get_display_field (def);
field_data->select_field = g_strdup_printf ("M%d.%s", field_count, disp_field);
g_free (disp_field);
field_data->needs_join = TRUE;
}
- if (def->type == DATA_DOUBLE) {
+ if (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_DOUBLE) {
field_data->where_field = g_strdup_printf ("M%d.MetaDataDisplay", field_count);
} else {
field_data->where_field = g_strdup_printf ("M%d.MetaDataValue", field_count);
}
-
- tracker_db_free_field_def (def);
-
} else {
g_free (field_data);
return NULL;
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.h (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.h Mon May 19 15:55:17 2008
@@ -26,7 +26,7 @@
#include <libtracker-db/tracker-db-interface.h>
#include <libtracker-db/tracker-db-file-info.h>
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-indexer.h"
#include "tracker-utils.h"
@@ -46,46 +46,18 @@
Indexer *word_index;
};
-typedef enum {
- DATA_KEYWORD,
- DATA_INDEX,
- DATA_FULLTEXT,
- DATA_STRING,
- DATA_INTEGER,
- DATA_DOUBLE,
- DATA_DATE,
- DATA_BLOB,
- DATA_STRUCT,
- DATA_LINK
-} DataTypes;
-
-typedef struct {
- char *id;
- DataTypes type;
- char *field_name;
- int weight;
- guint embedded : 1;
- guint multiple_values : 1;
- guint delimited : 1;
- guint filtered : 1;
- guint store_metadata : 1;
-
- GSList *child_ids; /* related child metadata ids */
-
-} FieldDef;
-
typedef struct {
- char *alias;
- char *field_name;
- char *select_field;
- char *where_field;
- char *table_name;
- char *id_field;
- DataTypes data_type;
- guint multiple_values : 1;
- guint is_select : 1;
- guint is_condition : 1;
- guint needs_join : 1;
+ char *alias;
+ char *field_name;
+ char *select_field;
+ char *where_field;
+ char *table_name;
+ char *id_field;
+ TrackerFieldType data_type;
+ guint multiple_values : 1;
+ guint is_select : 1;
+ guint is_condition : 1;
+ guint needs_join : 1;
} FieldData;
@@ -167,7 +139,7 @@
gint limit);
gchar * tracker_get_related_metadata_names (DBConnection *db_con,
const gchar *name);
-gchar * tracker_get_metadata_table (DataTypes type);
+gchar * tracker_get_metadata_table (TrackerFieldType type);
TrackerDBResultSet *tracker_db_search_text (DBConnection *db_con,
const gchar *service,
const gchar *search_string,
@@ -333,9 +305,6 @@
const gchar *service);
gchar * tracker_db_get_service_for_entity (DBConnection *db_con,
const gchar *id);
-gboolean tracker_db_metadata_is_child (DBConnection *db_con,
- const gchar *child,
- const gchar *parent);
GHashTable * tracker_db_get_file_contents_words (DBConnection *db_con,
guint32 id,
GHashTable *old_table);
@@ -346,7 +315,6 @@
gchar * tracker_db_get_field_name (const gchar *service,
const gchar *meta_name);
-gchar * tracker_db_get_display_field (FieldDef *def);
void tracker_free_metadata_field (FieldData *field_data);
void tracker_db_delete_service (DBConnection *db_con,
Modified: branches/indexer-split/src/trackerd/tracker-db.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db.c Mon May 19 15:55:17 2008
@@ -35,7 +35,7 @@
#include "tracker-db.h"
#include "tracker-email.h"
#include "tracker-metadata.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-process-files.h"
extern Tracker *tracker;
@@ -227,7 +227,7 @@
db_action = user_data;
/* auto-tag keyword related metadata */
- if (tracker_db_metadata_is_child (db_action->db_con, mtype, "DC:Keywords")) {
+ if (tracker_ontology_field_is_child_of (mtype, "DC:Keywords")) {
GSList *tmp;
for (tmp = value; tmp; tmp = tmp->next) {
@@ -360,23 +360,19 @@
gboolean
tracker_metadata_is_date (DBConnection *db_con, const char *meta)
{
- FieldDef *def;
- gboolean res;
+ const TrackerField *def;
- def = tracker_db_get_field_def (meta);
+ def = tracker_ontology_get_field_def (meta);
if (!def) {
tracker_error ("ERROR: failed to get info for metadata type %s", meta);
return FALSE;
}
-
+
+ /* FIXME: It is the same check again! */
g_return_val_if_fail (def, FALSE);
- res = (def->type == DATA_DATE);
-
- tracker_db_free_field_def (def);
-
- return res;
+ return tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_DATE;
}
@@ -875,7 +871,7 @@
uri = attachment_uri;
}
- info->service_type_id = tracker_service_manager_get_id_for_service (service);
+ info->service_type_id = tracker_ontology_get_id_for_service_type (service);
if (info->service_type_id == -1) {
tracker_log ("Service %s not supported yet", service);
@@ -977,7 +973,7 @@
}
if (attachment_service) {
- info->service_type_id = tracker_service_manager_get_id_for_service (attachment_service);
+ info->service_type_id = tracker_ontology_get_id_for_service_type (attachment_service);
}
/* save stuff to Db */
@@ -1148,7 +1144,7 @@
tracker_info ("mime is %s for %s", info->mime, info->uri);
- service_name = tracker_service_manager_get_service_type_for_mime (info->mime);
+ service_name = tracker_ontology_get_service_type_for_mime (info->mime);
}
@@ -1243,17 +1239,17 @@
service_has_metadata =
(is_external_service ||
(is_file_indexable &&
- tracker_service_manager_has_metadata (service_name))) &&
+ tracker_ontology_service_type_has_metadata (service_name))) &&
!is_sidecar;
service_has_fulltext =
(is_external_service ||
(is_file_indexable &&
- tracker_service_manager_has_text (service_name))) &&
+ tracker_ontology_service_type_has_text (service_name))) &&
!is_sidecar;
service_has_thumbs =
(is_external_service ||
(is_file_indexable &&
- tracker_service_manager_has_thumbnails (service_name)));
+ tracker_ontology_service_type_has_thumbnails (service_name)));
#ifdef HAVE_EXEMPI
if (!info->is_directory) {
Modified: branches/indexer-split/src/trackerd/tracker-db.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.h (original)
+++ branches/indexer-split/src/trackerd/tracker-db.h Mon May 19 15:55:17 2008
@@ -60,8 +60,6 @@
guint32 file_id);
gchar ** tracker_db_get_files_in_folder (DBConnection *db_con,
const gchar *folder_uri);
-FieldDef * tracker_db_get_field_def (const gchar *field_name);
-void tracker_db_free_field_def (FieldDef *def);
gboolean tracker_metadata_is_date (DBConnection *db_con,
const gchar *meta);
TrackerDBFileInfo *tracker_db_get_pending_file (DBConnection *db_con,
Modified: branches/indexer-split/src/trackerd/tracker-dbus-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-files.c Mon May 19 15:55:17 2008
@@ -33,7 +33,7 @@
#include "tracker-dbus-files.h"
#include "tracker-db.h"
#include "tracker-metadata.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-marshal.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_DBUS_FILES, TrackerDBusFilesPriv))
@@ -184,7 +184,7 @@
service = g_strdup ("Files");
} else {
info->mime = tracker_file_get_mime_type (uri);
- service = tracker_service_manager_get_service_type_for_mime (info->mime);
+ service = tracker_ontology_get_service_type_for_mime (info->mime);
info = tracker_db_file_info_get (info);
}
@@ -256,7 +256,7 @@
path = tracker_file_get_vfs_path (info->uri);
}
- service = tracker_service_manager_get_service_type_for_mime (mime);
+ service = tracker_ontology_get_service_type_for_mime (mime);
file_id = tracker_db_create_service (db_con, service, info);
tracker_db_file_info_free (info);
@@ -470,7 +470,7 @@
mime);
/* Get service from mime */
- *value = tracker_service_manager_get_service_type_for_mime (mime);
+ *value = tracker_ontology_get_service_type_for_mime (mime);
tracker_dbus_request_comment (request_id,
"Info for file '%s', "
@@ -673,7 +673,7 @@
offset,
max_hits);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -875,7 +875,7 @@
TrackerDBResultSet *result_set;
guint request_id;
DBConnection *db_con;
- FieldDef *defs[255];
+ const TrackerField *defs[255];
guint i;
gchar *uri_filtered;
guint32 file_id;
@@ -903,7 +903,7 @@
/* Get fields for metadata list provided */
for (i = 0; i < g_strv_length (fields); i++) {
- defs[i] = tracker_db_get_field_def (fields[i]);
+ defs[i] = tracker_ontology_get_field_def (fields[i]);
if (!defs[i]) {
tracker_dbus_request_failed (request_id,
@@ -951,7 +951,7 @@
} else {
gchar *display_field;
- display_field = tracker_db_get_display_field (defs[i]);
+ display_field = tracker_ontology_get_display_field (defs[i]);
g_string_append_printf (sql, ", M%d.%s ", i, display_field);
g_free (display_field);
needs_join[i - 1] = TRUE;
@@ -969,7 +969,7 @@
continue;
}
- table = tracker_get_metadata_table (defs[i]->type);
+ table = tracker_get_metadata_table (tracker_field_get_data_type (defs[i]));
g_string_append_printf (sql,
" LEFT OUTER JOIN %s M%d ON "
@@ -979,7 +979,7 @@
i+1,
i+1,
i+1,
- defs[i]->id);
+ tracker_field_get_id (defs[i]));
g_free (table);
}
Modified: branches/indexer-split/src/trackerd/tracker-dbus-keywords.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-keywords.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-keywords.c Mon May 19 15:55:17 2008
@@ -196,7 +196,7 @@
"service:'%s'",
service);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -247,7 +247,7 @@
service,
uri);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -320,7 +320,7 @@
service,
uri);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -391,7 +391,7 @@
service,
uri);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -463,7 +463,7 @@
service,
uri);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -540,7 +540,7 @@
offset,
max_hits);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
Modified: branches/indexer-split/src/trackerd/tracker-dbus-metadata.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-metadata.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-metadata.c Mon May 19 15:55:17 2008
@@ -177,7 +177,7 @@
db_con = priv->db_con;
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -322,7 +322,7 @@
"service:'%s'",
service);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
Modified: branches/indexer-split/src/trackerd/tracker-dbus-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-search.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-search.c Mon May 19 15:55:17 2008
@@ -34,7 +34,7 @@
#include "tracker-rdf-query.h"
#include "tracker-query-tree.h"
#include "tracker-indexer.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-marshal.h"
#define DEFAULT_SEARCH_MAX_HITS 1024
@@ -619,7 +619,7 @@
service,
search_text);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -637,23 +637,23 @@
/* Check we have the right database connection */
db_con = tracker_db_get_service_connection (db_con, service);
- services[count++] = tracker_service_manager_get_id_for_service (service);
+ services[count++] = tracker_ontology_get_id_for_service_type (service);
if (strcmp (service, "Files") == 0) {
- services[count++] = tracker_service_manager_get_id_for_service ("Folders");
- services[count++] = tracker_service_manager_get_id_for_service ("Documents");
- services[count++] = tracker_service_manager_get_id_for_service ("Images");
- services[count++] = tracker_service_manager_get_id_for_service ("Videos");
- services[count++] = tracker_service_manager_get_id_for_service ("Music");
- services[count++] = tracker_service_manager_get_id_for_service ("Text");
- services[count++] = tracker_service_manager_get_id_for_service ("Development");
- services[count++] = tracker_service_manager_get_id_for_service ("Other");
+ services[count++] = tracker_ontology_get_id_for_service_type ("Folders");
+ services[count++] = tracker_ontology_get_id_for_service_type ("Documents");
+ services[count++] = tracker_ontology_get_id_for_service_type ("Images");
+ services[count++] = tracker_ontology_get_id_for_service_type ("Videos");
+ services[count++] = tracker_ontology_get_id_for_service_type ("Music");
+ services[count++] = tracker_ontology_get_id_for_service_type ("Text");
+ services[count++] = tracker_ontology_get_id_for_service_type ("Development");
+ services[count++] = tracker_ontology_get_id_for_service_type ("Other");
} else if (strcmp (service, "Emails") == 0) {
- services[count++] = tracker_service_manager_get_id_for_service ("EvolutionEmails");
- services[count++] = tracker_service_manager_get_id_for_service ("KMailEmails");
- services[count++] = tracker_service_manager_get_id_for_service ("ThunderbirdEmails");
+ services[count++] = tracker_ontology_get_id_for_service_type ("EvolutionEmails");
+ services[count++] = tracker_ontology_get_id_for_service_type ("KMailEmails");
+ services[count++] = tracker_ontology_get_id_for_service_type ("ThunderbirdEmails");
} else if (strcmp (service, "Conversations") == 0) {
- services[count++] = tracker_service_manager_get_id_for_service ("GaimConversations");
+ services[count++] = tracker_ontology_get_id_for_service_type ("GaimConversations");
}
services[count] = 0;
@@ -735,7 +735,7 @@
g_value_init (&value, G_TYPE_STRING);
g_value_take_string (&value,
- tracker_service_manager_get_service_by_id (count.service_type_id));
+ tracker_ontology_get_service_type_by_id (count.service_type_id));
_tracker_db_result_set_set_value (result_set, 0, &value);
g_value_unset (&value);
@@ -796,7 +796,7 @@
offset,
max_hits);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -900,7 +900,7 @@
offset,
max_hits);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -970,7 +970,7 @@
search_text,
id);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -1123,7 +1123,7 @@
offset,
max_hits);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -1182,7 +1182,7 @@
search_text,
id);
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
@@ -1261,7 +1261,7 @@
max_hits,
sort_by_service ? "yes" : "no");
- if (!tracker_service_manager_is_valid_service (service)) {
+ if (!tracker_ontology_is_valid_service_type (service)) {
tracker_dbus_request_failed (request_id,
error,
"Service '%s' is invalid or has not been implemented yet",
Modified: branches/indexer-split/src/trackerd/tracker-dbus-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-xesam.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-xesam.c Mon May 19 15:55:17 2008
@@ -34,7 +34,7 @@
#include "tracker-rdf-query.h"
#include "tracker-query-tree.h"
#include "tracker-indexer.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-marshal.h"
enum {
Modified: branches/indexer-split/src/trackerd/tracker-email-utils.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-utils.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-utils.c Mon May 19 15:55:17 2008
@@ -63,14 +63,14 @@
email_unwatch_directory (const gchar *dir, const gchar *service)
{
tracker_log ("Registering path %s as belonging to service %s", dir, service);
- tracker_service_directories_remove (service, dir);
+ tracker_ontology_remove_dir_to_service_type (service, dir);
}
void
email_watch_directory (const gchar *dir, const gchar *service)
{
tracker_log ("Registering path %s as belonging to service %s", dir, service);
- tracker_service_directories_add (service, dir);
+ tracker_ontology_add_dir_to_service_type (service, dir);
}
Added: branches/indexer-split/src/trackerd/tracker-field.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-field.c Mon May 19 15:55:17 2008
@@ -0,0 +1,737 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "tracker-field.h"
+
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_FIELD, TrackerFieldPriv))
+
+typedef struct _TrackerFieldPriv TrackerFieldPriv;
+
+struct _TrackerFieldPriv {
+
+ gchar *id;
+ gchar *name;
+
+ TrackerFieldType data_type;
+ gchar *field_name;
+ gint weight;
+ gboolean embedded;
+ gboolean multiple_values;
+ gboolean delimited;
+ gboolean filtered;
+ gboolean store_metadata;
+
+ GSList *child_ids;
+};
+
+static void field_finalize (GObject *object);
+static void field_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void field_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+enum {
+ PROP_0,
+ PROP_ID,
+ PROP_NAME,
+ PROP_DATA_TYPE,
+ PROP_FIELD_NAME,
+ PROP_WEIGHT,
+ PROP_EMBEDDED,
+ PROP_MULTIPLE_VALUES,
+ PROP_DELIMITED,
+ PROP_FILTERED,
+ PROP_STORE_METADATA,
+ PROP_CHILD_IDS
+};
+
+GType
+tracker_field_type_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+
+
+ { TRACKER_FIELD_TYPE_KEYWORD,
+ "TRACKER_FIELD_TYPE_KEYWORD",
+ "keyword" },
+ { TRACKER_FIELD_TYPE_INDEX,
+ "TRACKER_FIELD_TYPE_INDEX",
+ "index" },
+ { TRACKER_FIELD_TYPE_FULLTEXT,
+ " TRACKER_FIELD_TYPE_FULLTEXT",
+ "fulltext" },
+ { TRACKER_FIELD_TYPE_STRING,
+ "TRACKER_FIELD_TYPE_STRING",
+ "string" },
+ { TRACKER_FIELD_TYPE_INTEGER,
+ "TRACKER_FIELD_TYPE_INTEGER",
+ "integer" },
+ { TRACKER_FIELD_TYPE_DOUBLE,
+ "TRACKER_FIELD_TYPE_DOUBLE",
+ "double" },
+ { TRACKER_FIELD_TYPE_DATE,
+ "TRACKER_FIELD_TYPE_DATE",
+ "date" },
+ { TRACKER_FIELD_TYPE_BLOB,
+ "TRACKER_FIELD_TYPE_BLOB",
+ "blob" },
+ { TRACKER_FIELD_TYPE_STRUCT,
+ "TRACKER_FIELD_TYPE_STRUCT",
+ "struct" },
+ { TRACKER_FIELD_TYPE_LINK,
+ "TRACKER_FIELD_TYPE_LINK",
+ "link" },
+ { 0, NULL, NULL }
+ };
+
+ etype = g_enum_register_static ("TrackerFieldType", values);
+ }
+
+ return etype;
+}
+
+G_DEFINE_TYPE (TrackerField, tracker_field, G_TYPE_OBJECT);
+
+static void
+tracker_field_class_init (TrackerFieldClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = field_finalize;
+ object_class->get_property = field_get_property;
+ object_class->set_property = field_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_ID,
+ g_param_spec_string ("id",
+ "id",
+ "Unique identifier for this field",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ "name",
+ "Field name",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_DATA_TYPE,
+ g_param_spec_enum ("data-type",
+ "data-type",
+ "Field data type",
+ tracker_field_type_get_type (),
+ TRACKER_FIELD_TYPE_INDEX,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_FIELD_NAME,
+ g_param_spec_string ("field-name",
+ "field-name",
+ "Column in services table with the contents of this metadata",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_WEIGHT,
+ g_param_spec_int ("weight",
+ "weight",
+ "Boost to the score",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_EMBEDDED,
+ g_param_spec_boolean ("embedded",
+ "embedded",
+ "Embedded",
+ TRUE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_MULTIPLE_VALUES,
+ g_param_spec_boolean ("multiple-values",
+ "multiple-values",
+ "Multiple values",
+ TRUE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_DELIMITED,
+ g_param_spec_boolean ("delimited",
+ "delimited",
+ "Delimited",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_FILTERED,
+ g_param_spec_boolean ("filtered",
+ "filtered",
+ "Filtered",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_STORE_METADATA,
+ g_param_spec_boolean ("store-metadata",
+ "store-metadata",
+ "Store metadata",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_CHILD_IDS,
+ g_param_spec_pointer ("child-ids",
+ "child-ids",
+ "Child ids",
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class, sizeof (TrackerFieldPriv));
+}
+
+static void
+tracker_field_init (TrackerField *field)
+{
+}
+
+static void
+field_finalize (GObject *object)
+{
+ TrackerFieldPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ g_free (priv->id);
+ g_free (priv->name);
+
+ if ( priv->field_name) {
+ g_free (priv->field_name);
+ }
+
+ g_slist_foreach (priv->child_ids, (GFunc) g_free, NULL);
+ g_slist_free (priv->child_ids);
+
+ (G_OBJECT_CLASS (tracker_field_parent_class)->finalize) (object);
+}
+
+static void
+field_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TrackerFieldPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_ID:
+ g_value_set_string (value, priv->id);
+ break;
+ case PROP_NAME:
+ g_value_set_string (value, priv->name);
+ break;
+ case PROP_DATA_TYPE:
+ g_value_set_enum (value, priv->data_type);
+ break;
+ case PROP_FIELD_NAME:
+ g_value_set_string (value, priv->field_name);
+ break;
+ case PROP_WEIGHT:
+ g_value_set_int (value, priv->weight);
+ break;
+ case PROP_EMBEDDED:
+ g_value_set_boolean (value, priv->embedded);
+ break;
+ case PROP_MULTIPLE_VALUES:
+ g_value_set_boolean (value, priv->multiple_values);
+ break;
+ case PROP_DELIMITED:
+ g_value_set_boolean (value, priv->delimited);
+ break;
+ case PROP_FILTERED:
+ g_value_set_boolean (value, priv->filtered);
+ break;
+ case PROP_STORE_METADATA:
+ g_value_set_boolean (value, priv->store_metadata);
+ break;
+ case PROP_CHILD_IDS:
+ g_value_set_pointer (value, priv->child_ids);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
+}
+
+static void
+field_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TrackerFieldPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_ID:
+ tracker_field_set_id (TRACKER_FIELD (object),
+ g_value_get_string (value));
+ break;
+ case PROP_NAME:
+ tracker_field_set_name (TRACKER_FIELD (object),
+ g_value_get_string (value));
+ break;
+ case PROP_DATA_TYPE:
+ tracker_field_set_data_type (TRACKER_FIELD (object),
+ g_value_get_enum (value));
+ break;
+ case PROP_FIELD_NAME:
+ tracker_field_set_field_name (TRACKER_FIELD (object),
+ g_value_get_string (value));
+ break;
+ case PROP_WEIGHT:
+ tracker_field_set_weight (TRACKER_FIELD (object),
+ g_value_get_int (value));
+ break;
+ case PROP_EMBEDDED:
+ tracker_field_set_embedded (TRACKER_FIELD (object),
+ g_value_get_boolean (value));
+ break;
+ case PROP_MULTIPLE_VALUES:
+ tracker_field_set_multiple_values (TRACKER_FIELD (object),
+ g_value_get_boolean (value));
+ break;
+ case PROP_DELIMITED:
+ tracker_field_set_delimited (TRACKER_FIELD (object),
+ g_value_get_boolean (value));
+ break;
+ case PROP_FILTERED:
+ tracker_field_set_filtered (TRACKER_FIELD (object),
+ g_value_get_boolean (value));
+ break;
+ case PROP_STORE_METADATA:
+ tracker_field_set_store_metadata (TRACKER_FIELD (object),
+ g_value_get_boolean (value));
+ break;
+ case PROP_CHILD_IDS:
+ tracker_field_set_child_ids (TRACKER_FIELD (object),
+ g_value_get_pointer (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
+}
+
+static gboolean
+field_int_validate (TrackerField *field,
+ const gchar *property,
+ gint value)
+{
+#ifdef G_DISABLE_CHECKS
+ GParamSpec *spec;
+ GValue value = { 0 };
+ gboolean valid;
+
+ spec = g_object_class_find_property (G_OBJECT_CLASS (field), property);
+ g_return_val_if_fail (spec != NULL, FALSE);
+
+ g_value_init (&value, spec->value_type);
+ g_value_set_int (&value, verbosity);
+ valid = g_param_value_validate (spec, &value);
+ g_value_unset (&value);
+
+ g_return_val_if_fail (valid != TRUE, FALSE);
+#endif
+
+ return TRUE;
+}
+
+TrackerField *
+tracker_field_new (void)
+{
+ TrackerField *field;
+
+ field = g_object_new (TRACKER_TYPE_FIELD, NULL);
+
+ return field;
+}
+
+const gchar *
+tracker_field_get_id (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), NULL);
+
+ priv = GET_PRIV (field);
+
+ return priv->id;
+}
+
+const gchar *
+tracker_field_get_name (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), NULL);
+
+ priv = GET_PRIV (field);
+
+ return priv->name;
+}
+
+TrackerFieldType
+tracker_field_get_data_type (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), TRACKER_FIELD_TYPE_STRING); //FIXME
+
+ priv = GET_PRIV (field);
+
+ return priv->data_type;
+}
+
+const gchar *
+tracker_field_get_field_name (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), NULL);
+
+ priv = GET_PRIV (field);
+
+ return priv->field_name;
+}
+
+gint
+tracker_field_get_weight (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), -1);
+
+ priv = GET_PRIV (field);
+
+ return priv->weight;
+}
+
+
+gboolean
+tracker_field_get_embedded (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), FALSE);
+
+ priv = GET_PRIV (field);
+
+ return priv->embedded;
+}
+
+
+gboolean
+tracker_field_get_multiple_values (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), FALSE);
+
+ priv = GET_PRIV (field);
+
+ return priv->multiple_values;
+}
+
+gboolean
+tracker_field_get_delimited (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), FALSE);
+
+ priv = GET_PRIV (field);
+
+ return priv->delimited;
+}
+
+gboolean
+tracker_field_get_filtered (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), FALSE);
+
+ priv = GET_PRIV (field);
+
+ return priv->filtered;
+}
+
+gboolean
+tracker_field_get_store_metadata (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), FALSE);
+
+ priv = GET_PRIV (field);
+
+ return priv->store_metadata;
+}
+
+
+const GSList *
+tracker_field_get_child_ids (const TrackerField *field)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_FIELD (field), NULL);
+
+ priv = GET_PRIV (field);
+
+ return priv->child_ids;
+}
+
+
+void
+tracker_field_set_id (TrackerField *field,
+ const gchar *value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ g_free (priv->id);
+
+ if (value) {
+ priv->id = g_strdup (value);
+ } else {
+ priv->id = NULL;
+ }
+
+ g_object_notify (G_OBJECT (field), "id");
+}
+
+void
+tracker_field_set_name (TrackerField *field,
+ const gchar *value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ g_free (priv->name);
+
+ if (value) {
+ priv->name = g_strdup (value);
+ } else {
+ priv->name = NULL;
+ }
+
+ g_object_notify (G_OBJECT (field), "name");
+}
+
+void
+tracker_field_set_data_type (TrackerField *field,
+ TrackerFieldType value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ priv->data_type = value;
+ g_object_notify (G_OBJECT (field), "data-type");
+}
+
+void
+tracker_field_set_field_name (TrackerField *field,
+ const gchar *value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ g_free (priv->field_name);
+
+ if (value) {
+ priv->field_name = g_strdup (value);
+ } else {
+ priv->field_name = NULL;
+ }
+
+ g_object_notify (G_OBJECT (field), "field-name");
+}
+
+void
+tracker_field_set_weight (TrackerField *field,
+ gint value)
+{
+ TrackerFieldPriv *priv;
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ if (!field_int_validate (field, "weight", value)) {
+ return;
+ }
+
+ priv = GET_PRIV (field);
+
+ priv->weight = value;
+ g_object_notify (G_OBJECT (field), "weight");
+
+}
+
+void
+tracker_field_set_embedded (TrackerField *field,
+ gboolean value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ priv->embedded = value;
+ g_object_notify (G_OBJECT (field), "embedded");
+}
+
+
+void
+tracker_field_set_multiple_values (TrackerField *field,
+ gboolean value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ priv->multiple_values = value;
+ g_object_notify (G_OBJECT (field), "multiple-values");
+}
+
+void
+tracker_field_set_delimited (TrackerField *field,
+ gboolean value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ priv->delimited = value;
+ g_object_notify (G_OBJECT (field), "delimited");
+}
+
+void
+tracker_field_set_filtered (TrackerField *field,
+ gboolean value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ priv->filtered = value;
+ g_object_notify (G_OBJECT (field), "filtered");
+}
+
+void
+tracker_field_set_store_metadata (TrackerField *field,
+ gboolean value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ priv->store_metadata = value;
+ g_object_notify (G_OBJECT (field), "store-metadata");
+}
+
+void
+tracker_field_set_child_ids (TrackerField *field,
+ const GSList *value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ g_slist_foreach (priv->child_ids, (GFunc) g_free, NULL);
+ g_slist_free (priv->child_ids);
+
+ if (value) {
+ GSList *new_list;
+ const GSList *l;
+
+ new_list = NULL;
+
+ for (l = value; l; l = l->next) {
+ new_list = g_slist_prepend (new_list, g_strdup (l->data));
+ }
+
+ new_list = g_slist_reverse (new_list);
+ priv->child_ids = new_list;
+ } else {
+ priv->child_ids = NULL;
+ }
+
+ g_object_notify (G_OBJECT (field), "child-ids");
+}
+
+void
+tracker_field_append_child_id (TrackerField *field,
+ const gchar *value)
+{
+ TrackerFieldPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_FIELD (field));
+
+ priv = GET_PRIV (field);
+
+ if (value) {
+ priv->child_ids = g_slist_append (priv->child_ids, g_strdup (value));
+ }
+
+ g_object_notify (G_OBJECT (field), "child-ids");
+}
Added: branches/indexer-split/src/trackerd/tracker-field.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-field.h Mon May 19 15:55:17 2008
@@ -0,0 +1,111 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TRACKERD_FIELD_H__
+#define __TRACKERD_FIELD_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_FIELD_TYPE (tracker_field_type_get_type ())
+
+typedef enum {
+ TRACKER_FIELD_TYPE_KEYWORD,
+ TRACKER_FIELD_TYPE_INDEX,
+ TRACKER_FIELD_TYPE_FULLTEXT,
+ TRACKER_FIELD_TYPE_STRING,
+ TRACKER_FIELD_TYPE_INTEGER,
+ TRACKER_FIELD_TYPE_DOUBLE,
+ TRACKER_FIELD_TYPE_DATE,
+ TRACKER_FIELD_TYPE_BLOB,
+ TRACKER_FIELD_TYPE_STRUCT,
+ TRACKER_FIELD_TYPE_LINK
+} TrackerFieldType;
+
+GType tracker_field_type_get_type (void) G_GNUC_CONST;
+
+
+
+#define TRACKER_TYPE_FIELD (tracker_field_get_type ())
+#define TRACKER_FIELD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_FIELD, TrackerField))
+#define TRACKER_FIELD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TRACKER_TYPE_FIELD, TrackerFieldClass))
+#define TRACKER_IS_FIELD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_FIELD))
+#define TRACKER_IS_FIELD_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TRACKER_TYPE_FIELD))
+#define TRACKER_FIELD_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_FIELD, TrackerFieldClass))
+
+typedef struct _TrackerField TrackerField;
+typedef struct _TrackerFieldClass TrackerFieldClass;
+
+struct _TrackerField {
+ GObject parent;
+};
+
+struct _TrackerFieldClass {
+ GObjectClass parent_class;
+};
+
+GType tracker_field_get_type (void) G_GNUC_CONST;
+
+TrackerField * tracker_field_new (void);
+
+const gchar * tracker_field_get_id (const TrackerField *field);
+const gchar * tracker_field_get_name (const TrackerField *field);
+TrackerFieldType tracker_field_get_data_type (const TrackerField *field);
+const gchar * tracker_field_get_field_name (const TrackerField *field);
+gint tracker_field_get_weight (const TrackerField *service);
+gboolean tracker_field_get_embedded (const TrackerField *field);
+gboolean tracker_field_get_multiple_values (const TrackerField *field);
+gboolean tracker_field_get_delimited (const TrackerField *field);
+gboolean tracker_field_get_filtered (const TrackerField *field);
+gboolean tracker_field_get_store_metadata (const TrackerField *field);
+const GSList * tracker_field_get_child_ids (const TrackerField *field);
+
+void tracker_field_set_id (TrackerField *field,
+ const gchar *value);
+void tracker_field_set_name (TrackerField *field,
+ const gchar *value);
+void tracker_field_set_data_type (TrackerField *field,
+ TrackerFieldType value);
+void tracker_field_set_field_name (TrackerField *field,
+ const gchar *value);
+void tracker_field_set_weight (TrackerField *field,
+ gint value);
+void tracker_field_set_embedded (TrackerField *field,
+ gboolean value);
+void tracker_field_set_multiple_values (TrackerField *field,
+ gboolean value);
+void tracker_field_set_delimited (TrackerField *field,
+ gboolean value);
+void tracker_field_set_filtered (TrackerField *field,
+ gboolean value);
+void tracker_field_set_store_metadata (TrackerField *field,
+ gboolean value);
+
+void tracker_field_set_child_ids (TrackerField *field,
+ const GSList *value);
+void tracker_field_append_child_id (TrackerField *field,
+ const gchar *id);
+
+G_END_DECLS
+
+#endif /* __TRACKERD_FIELD_H__ */
+
Modified: branches/indexer-split/src/trackerd/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-indexer.c (original)
+++ branches/indexer-split/src/trackerd/tracker-indexer.c Mon May 19 15:55:17 2008
@@ -61,7 +61,7 @@
#include "tracker-hal.h"
#include "tracker-process-files.h"
#include "tracker-query-tree.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-status.h"
#include "tracker-db-manager.h"
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Mon May 19 15:55:17 2008
@@ -53,7 +53,7 @@
#include "tracker-hal.h"
#include "tracker-indexer.h"
#include "tracker-process-files.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-status.h"
#include "tracker-watch.h"
#include "tracker-xesam.h"
@@ -373,10 +373,6 @@
log_option_list (no_watch_directory_roots, "NOT watching directory roots");
log_option_list (no_index_file_types, "NOT indexing file types");
- tracker->metadata_table = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- NULL,
- NULL);
}
static void
@@ -964,7 +960,9 @@
tracker->sys_tmp_root_dir);
tracker_xesam_init ();
tracker_cache_init ();
- tracker_service_manager_init ();
+
+ tracker_ontology_init ();
+
tracker_email_init (tracker->config);
#ifdef HAVE_HAL
@@ -1075,7 +1073,7 @@
tracker_email_shutdown ();
tracker_dbus_shutdown ();
- tracker_service_manager_shutdown ();
+ tracker_ontology_term ();
tracker_cache_shutdown ();
tracker_xesam_shutdown ();
tracker_db_manager_term ();
Modified: branches/indexer-split/src/trackerd/tracker-main.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.h (original)
+++ branches/indexer-split/src/trackerd/tracker-main.h Mon May 19 15:55:17 2008
@@ -97,9 +97,6 @@
gint grace_period;
gboolean request_waiting;
- /* Lookup tables for service and metadata IDs */
- GHashTable *metadata_table;
-
/* Email config options */
gint email_service_min;
gint email_service_max;
Modified: branches/indexer-split/src/trackerd/tracker-metadata.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-metadata.c (original)
+++ branches/indexer-split/src/trackerd/tracker-metadata.c Mon May 19 15:55:17 2008
@@ -37,7 +37,7 @@
#include "tracker-metadata.h"
#include "tracker-utils.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#include "tracker-main.h"
extern Tracker *tracker;
@@ -50,7 +50,7 @@
text_filter_file = NULL;
/* no need to filter text based files - index em directly */
- service_type = tracker_service_manager_get_service_type_for_mime (mime);
+ service_type = tracker_ontology_get_service_type_for_mime (mime);
if ( !strcmp ("Text", service_type) || !strcmp ("Development", service_type)) {
g_free (service_type);
@@ -177,12 +177,12 @@
return;
}
- service_type = tracker_service_manager_get_service_type_for_mime (mime);
+ service_type = tracker_ontology_get_service_type_for_mime (mime);
if (!service_type ) {
return;
}
- if (!tracker_service_manager_has_metadata (service_type)) {
+ if (!tracker_ontology_service_type_has_metadata (service_type)) {
g_free (service_type);
return;
}
Added: branches/indexer-split/src/trackerd/tracker-ontology.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-ontology.c Mon May 19 15:55:17 2008
@@ -0,0 +1,677 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+//#include <libtracker-common/tracker-file-utils.h>
+
+#include "tracker-ontology.h"
+
+typedef struct {
+ gchar *prefix;
+ gint service;
+} ServiceMimePrefixes;
+
+/* Hash (gint service_type_id, TrackerService *service) */
+static GHashTable *service_id_table;
+
+/* Hash (gchar *service_name, TrackerService *service) */
+static GHashTable *service_table;
+
+/* Hash (gchar *mime, gint service_type_id) */
+static GHashTable *mime_service;
+
+/* List of ServiceMimePrefixes */
+static GSList *mime_prefix_service;
+
+/* The service directory table is used to store a ServiceInfo struct
+ * for a directory path - used for determining which service a uri
+ * belongs to for things like files, emails, conversations etc
+ */
+static GHashTable *service_directory_table;
+static GSList *service_directory_list;
+
+/* Field descriptions */
+static GHashTable *metadata_table;
+
+
+
+static void
+ontology_mime_prefix_foreach (gpointer data,
+ gpointer user_data)
+{
+ ServiceMimePrefixes *mime_prefix;
+
+ mime_prefix = (ServiceMimePrefixes*) data;
+
+ g_free (mime_prefix->prefix);
+ g_free (mime_prefix);
+}
+
+gpointer
+ontology_hash_lookup_by_str (GHashTable *hash_table,
+ const gchar *str)
+{
+ gpointer *data;
+ gchar *str_lower;
+
+ str_lower = g_utf8_strdown (str, -1);
+ data = g_hash_table_lookup (hash_table, str_lower);
+ g_free (str_lower);
+
+ return data;
+}
+
+gpointer
+ontology_hash_lookup_by_id (GHashTable *hash_table,
+ gint id)
+{
+ gpointer *data;
+ gchar *str;
+
+ str = g_strdup_printf ("%d", id);
+ data = g_hash_table_lookup (hash_table, str);
+ g_free (str);
+
+ return data;
+}
+
+void
+tracker_ontology_init (void)
+{
+
+ g_return_if_fail (service_id_table == NULL
+ && service_table == NULL
+ && mime_service == NULL);
+
+ service_id_table = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ g_object_unref);
+
+ service_table = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ g_object_unref);
+
+ mime_service = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ NULL,
+ NULL);
+
+ service_directory_table = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ g_free);
+
+ metadata_table = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ NULL, //Pointer to the object name
+ g_object_unref);
+}
+
+void
+tracker_ontology_term (void)
+{
+ g_hash_table_remove_all (service_directory_table);
+ g_hash_table_remove_all (service_id_table);
+ g_hash_table_remove_all (service_table);
+ g_hash_table_remove_all (mime_service);
+ g_hash_table_remove_all (metadata_table);
+
+ if (mime_prefix_service) {
+ g_slist_foreach (mime_prefix_service,
+ ontology_mime_prefix_foreach,
+ NULL);
+ g_slist_free (mime_prefix_service);
+ }
+}
+
+void
+tracker_ontology_add_service_type (TrackerService *service,
+ GSList *mimes,
+ GSList *mime_prefixes)
+{
+
+ GSList *mime, *prefix;
+ ServiceMimePrefixes *service_mime_prefix;
+ gint id;
+ const gchar *name;
+
+ g_return_if_fail (TRACKER_IS_SERVICE (service));
+
+ id = tracker_service_get_id (service);
+ name = tracker_service_get_name (service);
+
+ g_hash_table_insert (service_table,
+ g_utf8_strdown (name, -1),
+ g_object_ref (service));
+ g_hash_table_insert (service_id_table,
+ g_strdup_printf ("%d", id),
+ g_object_ref (service));
+
+ for (mime = mimes; mime != NULL && mime->data != NULL; mime = mime->next) {
+ g_hash_table_insert (mime_service,
+ mime->data,
+ GINT_TO_POINTER (id));
+ }
+
+ for (prefix = mime_prefixes; prefix != NULL; prefix = prefix->next) {
+ service_mime_prefix = g_new0 (ServiceMimePrefixes, 1);
+ service_mime_prefix->prefix = prefix->data;
+ service_mime_prefix->service = id;
+ mime_prefix_service = g_slist_prepend (mime_prefix_service,
+ service_mime_prefix);
+ }
+}
+
+TrackerService *
+tracker_ontology_get_service_type_by_name (const gchar *service_str)
+{
+ return ontology_hash_lookup_by_str (service_table, service_str);
+}
+
+gchar *
+tracker_ontology_get_service_type_by_id (gint id)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_id (service_id_table, id);
+
+ if (!service) {
+ return NULL;
+ }
+
+ return g_strdup (tracker_service_get_name (service));
+}
+
+gchar *
+tracker_ontology_get_service_type_for_mime (const gchar *mime)
+{
+ gpointer *id;
+ ServiceMimePrefixes *item;
+ GSList *prefix_service;
+
+ /* Try a complete mime */
+ id = g_hash_table_lookup (mime_service, mime);
+ if (id) {
+ return tracker_ontology_get_service_type_by_id (GPOINTER_TO_INT (id));
+ }
+
+ /* Try in prefixes */
+ for (prefix_service = mime_prefix_service;
+ prefix_service != NULL;
+ prefix_service = prefix_service->next) {
+ item = prefix_service->data;
+ if (g_str_has_prefix (mime, item->prefix)) {
+ return tracker_ontology_get_service_type_by_id (item->service);
+ }
+ }
+
+ /* Default option */
+ return g_strdup ("Other");
+}
+
+gint
+tracker_ontology_get_id_for_service_type (const char *service_str)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (!service) {
+ return -1;
+ }
+
+ return tracker_service_get_id (service);
+}
+
+gchar *
+tracker_ontology_get_parent_service (const gchar *service_str)
+{
+ TrackerService *service;
+ const gchar *parent = NULL;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (service) {
+ parent = tracker_service_get_parent (service);
+ }
+
+ return g_strdup (parent);
+}
+
+gchar *
+tracker_ontology_get_parent_service_by_id (gint id)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_id (service_id_table, id);
+
+ if (!service) {
+ return NULL;
+ }
+
+ return g_strdup (tracker_service_get_parent (service));
+}
+
+gint
+tracker_ontology_get_parent_id_for_service_id (gint id)
+{
+ TrackerService *service;
+ const gchar *parent = NULL;
+
+ service = ontology_hash_lookup_by_id (service_id_table, id);
+
+ if (service) {
+ parent = tracker_service_get_parent (service);
+ }
+
+ if (!parent) {
+ return -1;
+ }
+
+ service = ontology_hash_lookup_by_str (service_table, parent);
+
+ if (!service) {
+ return -1;
+ }
+
+ return tracker_service_get_id (service);
+}
+/*
+gint
+tracker_ontology_get_id_of_parent_type (const gchar *service_str)
+{
+ TrackerService *service;
+ const gchar *parent = NULL;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (service) {
+ parent = tracker_service_get_parent (service);
+ }
+
+ if (!parent) {
+ return -1;
+ }
+
+ return tracker_ontology_get_id_for_service_type (parent);
+}
+*/
+
+TrackerDBType
+tracker_ontology_get_db_for_service_type (const gchar *service_str)
+{
+ TrackerDBType type;
+ gchar *str;
+
+ type = TRACKER_DB_TYPE_DATA;
+ str = g_utf8_strdown (service_str, -1);
+
+ if (g_str_has_prefix (str, "emails") ||
+ g_str_has_prefix (str, "attachments")) {
+ type = TRACKER_DB_TYPE_EMAIL;
+ }
+
+ g_free (str);
+
+ return type;
+}
+
+gboolean
+tracker_ontology_service_type_has_embedded (const gchar *service_str)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (!service) {
+ return FALSE;
+ }
+
+ return tracker_service_get_embedded (service);
+}
+
+gboolean
+tracker_ontology_is_valid_service_type (const gchar *service_str)
+{
+ return tracker_ontology_get_id_for_service_type (service_str) != -1;
+}
+
+gboolean
+tracker_ontology_service_type_has_metadata (const gchar *service_str)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (!service) {
+ return FALSE;
+ }
+
+ return tracker_service_get_has_metadata (service);
+}
+
+gboolean
+tracker_ontology_service_type_has_thumbnails (const gchar *service_str)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (!service) {
+ return FALSE;
+ }
+
+ return tracker_service_get_has_thumbs (service);
+}
+
+gboolean
+tracker_ontology_service_type_has_text (const char *service_str)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (!service) {
+ return FALSE;
+ }
+
+ return tracker_service_get_has_full_text (service);
+}
+
+gint
+tracker_ontology_metadata_key_in_service (const gchar *service_str,
+ const gchar *meta_name)
+{
+ TrackerService *service;
+ gint i;
+ const GSList *l;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (!service) {
+ return 0;
+ }
+
+ for (l = tracker_service_get_key_metadata (service), i = 0;
+ l;
+ l = l->next, i++) {
+ if (!l->data) {
+ continue;
+ }
+
+ if (strcasecmp (l->data, meta_name) == 0) {
+ return i;
+ }
+ }
+
+ return 0;
+}
+
+gboolean
+tracker_ontology_show_service_directories (const gchar *service_str)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (!service) {
+ return FALSE;
+ }
+
+ return tracker_service_get_show_service_directories (service);
+}
+
+gboolean
+tracker_ontology_show_service_files (const gchar *service_str)
+{
+ TrackerService *service;
+
+ service = ontology_hash_lookup_by_str (service_table, service_str);
+
+ if (!service) {
+ return FALSE;
+ }
+
+ return tracker_service_get_show_service_files (service);
+}
+
+/*
+ * Service directories
+ */
+GSList *
+tracker_ontology_get_dirs_for_service_type (const gchar *service)
+{
+ GSList *list = NULL;
+ GSList *l;
+
+ g_return_val_if_fail (service != NULL, NULL);
+
+ for (l = service_directory_list; l; l = l->next) {
+ gchar *str;
+
+ str = g_hash_table_lookup (service_directory_table, l->data);
+
+ if (strcasecmp (service, str) == 0) {
+ list = g_slist_prepend (list, l->data);
+ }
+ }
+
+ return list;
+}
+
+void
+tracker_ontology_add_dir_to_service_type (const gchar *service,
+ const gchar *path)
+{
+ g_return_if_fail (service != NULL);
+ g_return_if_fail (path != NULL);
+
+ /*
+ if (!tracker_file_is_valid (path)) {
+ g_debug ("Path:'%s' not valid, not adding it for service:'%s'", path, service);
+ return;
+ }
+ */
+ g_debug ("Adding path:'%s' for service:'%s'", path, service);
+
+ service_directory_list = g_slist_prepend (service_directory_list,
+ g_strdup (path));
+
+ g_hash_table_insert (service_directory_table,
+ g_strdup (path),
+ g_strdup (service));
+}
+
+void
+tracker_ontology_remove_dir_to_service_type (const gchar *service,
+ const gchar *path)
+{
+ GSList *found;
+
+ g_return_if_fail (service != NULL);
+ g_return_if_fail (path != NULL);
+
+ g_debug ("Removing path:'%s' for service:'%s'", path, service);
+
+ found = g_slist_find_custom (service_directory_list,
+ path,
+ (GCompareFunc) strcmp);
+ if (found) {
+ service_directory_list = g_slist_remove_link (service_directory_list, found);
+ g_free (found->data);
+ g_slist_free (found);
+ }
+
+ g_hash_table_remove (service_directory_table, path);
+}
+
+gchar *
+tracker_ontology_get_service_type_for_dir (const gchar *path)
+{
+ GSList *l;
+
+ g_return_val_if_fail (path != NULL, g_strdup ("Files"));
+
+ /* Check service dir list to see if a prefix */
+ for (l = service_directory_list; l; l = l->next) {
+ const gchar *str;
+
+ if (!l->data || !g_str_has_prefix (path, l->data)) {
+ continue;
+ }
+
+ str = g_hash_table_lookup (service_directory_table, l->data);
+
+ return g_strdup (str);
+ }
+
+ return g_strdup ("Files");
+}
+
+/* Field Handling */
+void
+tracker_ontology_add_field (TrackerField *field)
+{
+ g_return_if_fail (field != NULL && tracker_field_get_name (field) != NULL);
+
+ g_hash_table_insert (metadata_table,
+ g_utf8_strdown (tracker_field_get_name (field), -1),
+ field);
+
+}
+
+static inline gboolean
+is_equal (const char *s1, const char *s2)
+{
+ return (strcasecmp (s1, s2) == 0);
+}
+
+gchar *
+tracker_ontology_get_field_column_in_services (const TrackerField *field,
+ const gchar *service_type)
+{
+ const gchar *field_name;
+ const gchar *meta_name = tracker_field_get_name (field);
+
+ int key_field = tracker_ontology_metadata_key_in_service (service_type,
+ meta_name);
+
+ if (key_field > 0) {
+ return g_strdup_printf ("KeyMetadata%d", key_field);
+
+ }
+
+ /* TODO do it using field_name in TrackerField! */
+ field_name = tracker_field_get_field_name (field);
+ if (field_name) {
+ return g_strdup (field_name);
+ } else {
+ return NULL;
+ }
+/*
+
+ if (is_equal (meta_name, "File:Path")) return g_strdup ("Path");
+ if (is_equal (meta_name, "File:Name")) return g_strdup ("Name");
+ if (is_equal (meta_name, "File:Mime")) return g_strdup ("Mime");
+ if (is_equal (meta_name, "File:Size")) return g_strdup ("Size");
+ if (is_equal (meta_name, "File:Rank")) return g_strdup ("Rank");
+ if (is_equal (meta_name, "File:Modified")) return g_strdup ("IndexTime");
+
+ return NULL;
+*/
+}
+
+gchar *
+tracker_ontology_get_display_field (const TrackerField *field)
+{
+ TrackerFieldType type;
+
+ type = tracker_field_get_data_type (field);
+
+ if (type == TRACKER_FIELD_TYPE_INDEX
+ || type == TRACKER_FIELD_TYPE_STRING
+ || type == TRACKER_FIELD_TYPE_DOUBLE) {
+ return g_strdup ("MetaDataDisplay");
+ }
+
+ return g_strdup ("MetaDataValue");
+}
+
+gboolean
+tracker_ontology_field_is_child_of (const gchar *child, const gchar *parent) {
+
+ const TrackerField *def_child, *def_parent;
+
+ def_child = tracker_ontology_get_field_def (child);
+
+ if (!def_child) {
+ return FALSE;
+ }
+
+
+ def_parent = tracker_ontology_get_field_def (parent);
+
+ if (!def_parent) {
+ return FALSE;
+ }
+
+ const GSList *tmp;
+
+ for (tmp = tracker_field_get_child_ids (def_parent); tmp; tmp = tmp->next) {
+
+ if (!tmp->data) return FALSE;
+
+ if (strcmp (tracker_field_get_id (def_child), tmp->data) == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+
+}
+
+
+const TrackerField *
+tracker_ontology_get_field_def (const gchar *name)
+{
+ return ontology_hash_lookup_by_str (metadata_table, name);
+}
+
+const gchar *
+tracker_ontology_get_field_id (const gchar *name)
+{
+ const TrackerField *field;
+
+ field = tracker_ontology_get_field_def (name);
+
+ if (field) {
+ return tracker_field_get_id (field);
+ }
+
+ return NULL;
+}
+
Added: branches/indexer-split/src/trackerd/tracker-ontology.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-ontology.h Mon May 19 15:55:17 2008
@@ -0,0 +1,84 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TRACKERD_SERVICE_MANAGER_H__
+#define __TRACKERD_SERVICE_MANAGER_H__
+
+#include <glib-object.h>
+
+#include "tracker-service.h"
+#include "tracker-field.h"
+
+G_BEGIN_DECLS
+
+void tracker_ontology_init (void);
+void tracker_ontology_term (void);
+void tracker_ontology_add_service_type (TrackerService *service,
+ GSList *mimes,
+ GSList *mime_prefixes);
+TrackerService * tracker_ontology_get_service_type_by_name (const gchar *service_str);
+gchar * tracker_ontology_get_service_type_by_id (gint id);
+gchar * tracker_ontology_get_service_type_for_mime (const gchar *mime);
+gint tracker_ontology_get_id_for_service_type (const gchar *service_str);
+gchar * tracker_ontology_get_parent_service (const gchar *service_str);
+gchar * tracker_ontology_get_parent_service_by_id (gint id);
+gint tracker_ontology_get_parent_id_for_service_id (gint id);
+TrackerDBType tracker_ontology_get_db_for_service_type (const gchar *service_str);
+gboolean tracker_ontology_service_type_has_embedded (const gchar *service_str);
+gboolean tracker_ontology_is_valid_service_type (const gchar *service_str);
+gboolean tracker_ontology_service_type_has_metadata (const gchar *service_str);
+gboolean tracker_ontology_service_type_has_thumbnails (const gchar *service_str);
+gboolean tracker_ontology_service_type_has_text (const gchar *service_str);
+gint tracker_ontology_metadata_key_in_service (const gchar *service_str,
+ const gchar *meta_name);
+gboolean tracker_ontology_show_service_directories (const gchar *service_str);
+gboolean tracker_ontology_show_service_files (const gchar *service_str);
+
+
+
+/* Service directories */
+GSList * tracker_ontology_get_dirs_for_service_type (const gchar *service);
+void tracker_ontology_add_dir_to_service_type (const gchar *service,
+ const gchar *path);
+void tracker_ontology_remove_dir_to_service_type (const gchar *service,
+ const gchar *path);
+gchar * tracker_ontology_get_service_type_for_dir (const gchar *path);
+
+
+
+
+/* Field handling */
+void tracker_ontology_add_field (TrackerField *field);
+gchar * tracker_ontology_get_field_column_in_services (const TrackerField *field,
+ const gchar *service_type);
+gchar * tracker_ontology_get_display_field (const TrackerField *field);
+gboolean tracker_ontology_field_is_child_of (const gchar *child,
+ const gchar *parent);
+const TrackerField *tracker_ontology_get_field_def (const gchar *name);
+const gchar * tracker_ontology_get_field_id (const gchar *name);
+
+
+
+
+G_END_DECLS
+
+#endif /* __TRACKERD_SERVICE_MANAGER_H__ */
+
Modified: branches/indexer-split/src/trackerd/tracker-process-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-process-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-process-files.c Mon May 19 15:55:17 2008
@@ -496,14 +496,14 @@
tracker_throttle (100);
}
- service_info = tracker_service_directories_get_service (info->uri);
+ service_info = tracker_ontology_get_service_type_for_dir (info->uri);
if (!service_info) {
tracker_error ("ERROR: cannot find service for path %s", info->uri);
return;
}
- def = tracker_service_manager_get_service (service_info);
+ def = tracker_ontology_get_service_type_by_name (service_info);
if (!def) {
if (service_info) {
@@ -686,7 +686,7 @@
tracker_applications_add_service_directories ();
- list = tracker_service_directories_get ("Applications");
+ list = tracker_ontology_get_dirs_for_service_type ("Applications");
process_directory_list (tracker, list, FALSE, db_con);
tracker_db_interface_end_transaction (db_con->cache->db);
@@ -991,13 +991,13 @@
if (tracker_file_is_valid (gaim)) {
has_logs = TRUE;
- tracker_service_directories_add ("GaimConversations", gaim);
+ tracker_ontology_add_dir_to_service_type ("GaimConversations", gaim);
list = g_slist_prepend (NULL, gaim);
}
if (tracker_file_is_valid (purple)) {
has_logs = TRUE;
- tracker_service_directories_add ("GaimConversations", purple);
+ tracker_ontology_add_dir_to_service_type ("GaimConversations", purple);
list = g_slist_prepend (NULL, purple);
}
@@ -1026,7 +1026,7 @@
list = g_slist_prepend( NULL, firefox_dir);
tracker_log ("Starting Firefox web history indexing...");
- tracker_service_directories_add ("WebHistory", firefox_dir);
+ tracker_ontology_add_dir_to_service_type ("WebHistory", firefox_dir);
tracker_db_interface_start_transaction (db_con->cache->db);
process_directory_list (tracker, list, TRUE, db_con);
@@ -1084,7 +1084,7 @@
if (name) {
GSList *list;
- list = tracker_service_directories_get (name);
+ list = tracker_ontology_get_dirs_for_service_type (name);
process_directory_list (tracker, list, TRUE, db_con);
g_slist_free (list);
}
Modified: branches/indexer-split/src/trackerd/tracker-query-tree.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-query-tree.c (original)
+++ branches/indexer-split/src/trackerd/tracker-query-tree.c Mon May 19 15:55:17 2008
@@ -37,7 +37,7 @@
#include "tracker-query-tree.h"
#include "tracker-parser.h"
#include "tracker-utils.h"
-#include "tracker-service-manager.h"
+#include "tracker-ontology.h"
#define TRACKER_QUERY_TREE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_QUERY_TREE, TrackerQueryTreePrivate))
@@ -924,7 +924,7 @@
g_hash_table_insert (table, GINT_TO_POINTER (hit.service_type_id), GINT_TO_POINTER (count));
/* update service's parent count too (if it has a parent) */
- parent_id = tracker_service_manager_get_parent_id_for_service_id (hit.service_type_id);
+ parent_id = tracker_ontology_get_parent_id_for_service_id (hit.service_type_id);
if (parent_id != -1) {
count = GPOINTER_TO_INT (g_hash_table_lookup (table, GINT_TO_POINTER (parent_id)));
Modified: branches/indexer-split/src/trackerd/tracker-rdf-query.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-rdf-query.c (original)
+++ branches/indexer-split/src/trackerd/tracker-rdf-query.c Mon May 19 15:55:17 2008
@@ -690,7 +690,7 @@
return FALSE;
}
- if (field_data->data_type == DATA_DATE) {
+ if (field_data->data_type == TRACKER_FIELD_TYPE_DATE) {
char *bvalue;
int cvalue;
@@ -726,7 +726,9 @@
if (sub) {
g_string_append_printf (str, " (%s glob '%s') ", field_data->where_field, data->current_value);
} else {
- if (field_data->data_type == DATA_DATE || field_data->data_type == DATA_INTEGER || field_data->data_type == DATA_DOUBLE) {
+ if (field_data->data_type == TRACKER_FIELD_TYPE_DATE
+ || field_data->data_type == TRACKER_FIELD_TYPE_INTEGER
+ || field_data->data_type == TRACKER_FIELD_TYPE_DOUBLE) {
g_string_append_printf (str, " (%s = %s) ", field_data->where_field, value);
} else {
g_string_append_printf (str, " (%s = '%s') ", field_data->where_field, value);
@@ -1025,7 +1027,7 @@
int type;
result = g_string_new ("");
- type = tracker_service_manager_get_id_for_service (service);
+ type = tracker_ontology_get_id_for_service_type (service);
switch (type) {
Modified: branches/indexer-split/src/trackerd/tracker-xesam-query.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-query.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-query.c Mon May 19 15:55:17 2008
@@ -827,7 +827,7 @@
g_string_append (str, " OR ");
}
- if (((FieldData *)field_data->data)->data_type == DATA_DATE) {
+ if (((FieldData *)field_data->data)->data_type == TRACKER_FIELD_TYPE_DATE) {
char *bvalue;
int cvalue;
@@ -837,7 +837,7 @@
tracker_debug ("%d", cvalue);
value = tracker_int_to_string (cvalue);
g_free (bvalue);
- } else if (state == STATE_END_BOOLEAN) { /* FIXME We do a state check here, because DATA_BOOLEAN is not in db */
+ } else if (state == STATE_END_BOOLEAN) { /* FIXME We do a state check here, because TRACKER_FIELD_TYPE_BOOLEAN is not in db */
if (!strcmp(avalue,"true")) {
value = g_strdup("1");
} else if(!strcmp(avalue,"false")) {
@@ -869,7 +869,9 @@
if (sub) {
g_string_append_printf (str, " (%s glob '%s') ", ((FieldData *)field_data->data)->where_field, data->current_value);
} else {
- if (((FieldData *)field_data->data)->data_type == DATA_DATE || ((FieldData *)field_data->data)->data_type == DATA_INTEGER || ((FieldData *)field_data->data)->data_type == DATA_DOUBLE) {
+ if (((FieldData *)field_data->data)->data_type == TRACKER_FIELD_TYPE_DATE
+ || ((FieldData *)field_data->data)->data_type == TRACKER_FIELD_TYPE_INTEGER
+ || ((FieldData *)field_data->data)->data_type == TRACKER_FIELD_TYPE_DOUBLE) {
g_string_append_printf (str, " (%s = %s) ", ((FieldData *)field_data->data)->where_field, value);
} else {
g_string_append_printf (str, " (%s = '%s') ", ((FieldData *)field_data->data)->where_field, value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]