tracker r1490 - in branches/xesam-support: . data src/trackerd



Author: pvanhoof
Date: Mon May 26 23:26:53 2008
New Revision: 1490
URL: http://svn.gnome.org/viewvc/tracker?rev=1490&view=rev

Log:
2008-05-27  Philip Van Hoof  <pvanhoof gnome org>

	* Fixes some bugs with xesam search structures and 
	field definitions
	* Patch by Ottela Mikael <mikael ottela ixonos com>



Added:
   branches/xesam-support/src/trackerd/tracker-xesam-ontology.c
   branches/xesam-support/src/trackerd/tracker-xesam-ontology.h
Modified:
   branches/xesam-support/ChangeLog
   branches/xesam-support/data/sqlite-cache.sql
   branches/xesam-support/data/sqlite-tracker.sql
   branches/xesam-support/src/trackerd/tracker-db-sqlite.c
   branches/xesam-support/src/trackerd/tracker-dbus-xesam.c
   branches/xesam-support/src/trackerd/tracker-xesam-live-search.c

Modified: branches/xesam-support/data/sqlite-cache.sql
==============================================================================
--- branches/xesam-support/data/sqlite-cache.sql	(original)
+++ branches/xesam-support/data/sqlite-cache.sql	Mon May 26 23:26:53 2008
@@ -78,7 +78,8 @@
 
 CREATE TABLE LiveSearches
 (
-	ID		Integer primary key not null,
 	ServiceID	Integer not null,
-	SearchID	Text
+	SearchID	Text,
+
+	Unique (ServiceID, SearchID)
 );

Modified: branches/xesam-support/data/sqlite-tracker.sql
==============================================================================
--- branches/xesam-support/data/sqlite-tracker.sql	(original)
+++ branches/xesam-support/data/sqlite-tracker.sql	Mon May 26 23:26:53 2008
@@ -21,9 +21,10 @@
 /* This should become a TEMPORARY table */
 CREATE TABLE LiveSearches
 (
-	ID		Integer primary key not null,
 	ServiceID	Integer not null,
-	SearchID	Text
+	SearchID	Text,
+
+	Unique (ServiceID, SearchID)
 );
 
 /* store volume and HAL info here for files */

Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.c	Mon May 26 23:26:53 2008
@@ -3339,9 +3339,13 @@
 	 * INTO LiveSearches
 	 * SELECT ID, SEARCH_ID FROM_QUERY WHERE_QUERY */
 
+	g_debug ("INSERT INTO LiveSearches SELECT S.ID, '%s' %s %s",
+			search_id, from_query, where_query);
+
 	tracker_db_exec_no_reply (db_con->db,
-		"INSERT INTO LiveSearches SELECT ID, '%s' %s %s",
+		"INSERT INTO LiveSearches SELECT S.ID, '%s' %s %s",
 			search_id, from_query, where_query);
+
 }
 
 TrackerDBResultSet* 
@@ -4574,6 +4578,7 @@
 
 	tracker_field_set_id (field_def, tracker_int_to_string (id));
 	tracker_field_set_name (field_def, name);
+	tracker_field_set_data_type (field_def, field_type);
 	tracker_field_set_field_name (field_def, field_name);
 	tracker_field_set_weight (field_def, weight);
 	tracker_field_set_embedded (field_def, embedded);
@@ -5104,6 +5109,8 @@
 		alias = g_strdup_printf ("M%d", field_count);
 		table_name = tracker_get_metadata_table (tracker_field_get_data_type (def));
 
+		g_debug("Field_name: %s :table_name is: %s for data_type: %i", field_name, table_name, tracker_field_get_data_type(def));
+
 		tracker_field_data_set_alias (field_data, alias);
 		tracker_field_data_set_table_name (field_data, table_name);
 		tracker_field_data_set_id_field (field_data, tracker_field_get_id (def));

Modified: branches/xesam-support/src/trackerd/tracker-dbus-xesam.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-dbus-xesam.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-dbus-xesam.c	Mon May 26 23:26:53 2008
@@ -304,6 +304,8 @@
 					my_sessions);
 
 		dbus_g_method_return (context, session_id);
+
+		g_message ("Created new xesam session: %s", session_id);
 	}
 
 	g_free (session_id);
@@ -465,6 +467,8 @@
 		if (search)
 			g_object_unref (search);
 
+		g_debug("Created new xesam search: %s  for session: %s", search_id, session_id);
+
 		g_free (search_id);
 
 	} else if (error) {
@@ -475,8 +479,6 @@
 	if (session)
 		g_object_unref (session);
 
-	g_debug("tracker_dbus_xesam_new_search done");
-
 	tracker_dbus_request_success (request_id);
 }
 

Modified: branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-live-search.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.c	Mon May 26 23:26:53 2008
@@ -667,10 +667,13 @@
 		TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
 
 		g_object_get (proxy, "db-connection", &db_con, NULL);
+
+		g_debug ("The from query for activate: %s",tracker_xesam_live_search_get_from_query (self)); 
+
 		tracker_db_start_live_search (db_con, 
-			tracker_xesam_live_search_get_id (self),
 			tracker_xesam_live_search_get_from_query (self),
-			tracker_xesam_live_search_get_where_query (self));
+			tracker_xesam_live_search_get_where_query (self),
+			tracker_xesam_live_search_get_id (self));
 	}
 
 	priv->active = TRUE;
@@ -780,6 +783,8 @@
 		g_free (orig_where);
 	}
 
+	g_message ("Parsed to '%s' and '%s'", priv->from_sql, priv->where_sql);
+
 	return TRUE;
 }
 

Added: branches/xesam-support/src/trackerd/tracker-xesam-ontology.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam-ontology.c	Mon May 26 23:26:53 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-xesam-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
+xesam_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
+xesam_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
+xesam_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_xesam_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_xesam_ontology_shutdown (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, 
+				 xesam_ontology_mime_prefix_foreach, 
+				 NULL); 
+		g_slist_free (mime_prefix_service);
+	}
+}
+
+void 
+tracker_xesam_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_xesam_ontology_get_service_type_by_name (const gchar *service_str)
+{
+	return xesam_ontology_hash_lookup_by_str (service_table, service_str);
+}
+
+gchar *
+tracker_xesam_ontology_get_service_type_by_id (gint id)
+{
+	TrackerService *service;
+
+	service = xesam_ontology_hash_lookup_by_id (service_id_table, id);
+
+	if (!service) {
+		return NULL;
+	}
+
+	return g_strdup (tracker_service_get_name (service));
+}
+
+gchar *
+tracker_xesam_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_xesam_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_xesam_ontology_get_service_type_by_id (item->service);
+		}
+	}
+	
+	/* Default option */
+	return g_strdup ("Other");
+}
+
+gint
+tracker_xesam_ontology_get_id_for_service_type (const char *service_str)
+{
+	TrackerService *service;
+
+	service = xesam_ontology_hash_lookup_by_str (service_table, service_str);
+
+	if (!service) {
+		return -1;
+	}
+
+	return tracker_service_get_id (service);
+}
+
+gchar *
+tracker_xesam_ontology_get_parent_service (const gchar *service_str)
+{
+	TrackerService *service;
+	const gchar    *parent = NULL;
+
+	service = xesam_ontology_hash_lookup_by_str (service_table, service_str);
+	
+	if (service) {
+		parent = tracker_service_get_parent (service);
+	}
+
+	return g_strdup (parent);
+}
+
+gchar *
+tracker_xesam_ontology_get_parent_service_by_id (gint id)
+{
+	TrackerService *service;
+
+	service = xesam_ontology_hash_lookup_by_id (service_id_table, id);
+
+	if (!service) {
+		return NULL;
+	}
+
+	return g_strdup (tracker_service_get_parent (service));
+}
+
+gint
+tracker_xesam_ontology_get_parent_id_for_service_id (gint id)
+{
+	TrackerService *service;
+	const gchar    *parent = NULL;
+
+	service = xesam_ontology_hash_lookup_by_id (service_id_table, id);
+
+	if (service) {
+		parent = tracker_service_get_parent (service);
+	}
+
+	if (!parent) {
+		return -1;
+	}
+	
+	service = xesam_ontology_hash_lookup_by_str (service_table, parent);
+
+	if (!service) {
+		return -1;
+	}
+
+	return tracker_service_get_id (service);
+}
+/*
+gint
+tracker_xesam_ontology_get_id_of_parent_type (const gchar *service_str)
+{
+	TrackerService *service;
+	const gchar    *parent = NULL;
+
+	service = xesam_ontology_hash_lookup_by_str (service_table, service_str);
+
+	if (service) {
+		parent = tracker_service_get_parent (service);
+	}
+
+	if (!parent) {
+		return -1;
+	}
+
+	return tracker_xesam_ontology_get_id_for_service_type (parent);
+}
+*/
+
+TrackerDBType
+tracker_xesam_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_xesam_ontology_service_type_has_embedded (const gchar *service_str)
+{
+	TrackerService *service;
+
+	service = xesam_ontology_hash_lookup_by_str (service_table, service_str);
+
+	if (!service) {
+		return FALSE;
+	}
+
+	return tracker_service_get_embedded (service);
+}
+
+gboolean
+tracker_xesam_ontology_is_valid_service_type (const gchar *service_str)
+{
+	return tracker_xesam_ontology_get_id_for_service_type (service_str) != -1;
+}
+
+gboolean
+tracker_xesam_ontology_service_type_has_metadata (const gchar *service_str) 
+{
+	TrackerService *service;
+
+	service = xesam_ontology_hash_lookup_by_str (service_table, service_str);
+
+	if (!service) {
+		return FALSE;
+	}
+
+	return tracker_service_get_has_metadata (service);
+}
+
+/* gboolean */
+/* tracker_xesam_ontology_service_type_has_thumbnails (const gchar *service_str) */
+/* { */
+/* 	TrackerService *service; */
+
+/* 	service = xesam_ontology_hash_lookup_by_str (service_table, service_str); */
+
+/* 	if (!service) { */
+/* 		return FALSE; */
+/* 	} */
+
+/* 	return tracker_service_get_has_thumbs (service); */
+/* } */
+
+/* gboolean  */
+/* tracker_xesam_ontology_service_type_has_text (const char *service_str)  */
+/* { */
+/* 	TrackerService *service; */
+
+/* 	service = xesam_ontology_hash_lookup_by_str (service_table, service_str); */
+
+/* 	if (!service) { */
+/* 		return FALSE; */
+/* 	} */
+
+/* 	return tracker_service_get_has_full_text (service); */
+/* } */
+
+gint
+tracker_xesam_ontology_metadata_key_in_service (const gchar *service_str, 
+				      const gchar *meta_name)
+{
+	TrackerService *service;
+	gint            i;
+	const GSList   *l;
+
+	service = xesam_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_xesam_ontology_show_service_directories (const gchar *service_str) 
+{
+	TrackerService *service;
+
+	service = xesam_ontology_hash_lookup_by_str (service_table, service_str);
+
+	if (!service) {
+		return FALSE;
+	}
+
+	return tracker_service_get_show_service_directories (service);
+}
+
+gboolean
+tracker_xesam_ontology_show_service_files (const gchar *service_str) 
+{
+	TrackerService *service;
+
+	service = xesam_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_xesam_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_xesam_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_xesam_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_xesam_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_xesam_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_xesam_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_xesam_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_xesam_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_xesam_ontology_field_is_child_of (const gchar *child, const gchar *parent) {
+
+	const TrackerField *def_child, *def_parent;
+
+	def_child = tracker_xesam_ontology_get_field_def (child);
+
+	if (!def_child) {
+		return FALSE;
+	}
+
+
+	def_parent = tracker_xesam_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_xesam_ontology_get_field_def (const gchar *name) 
+{
+	return xesam_ontology_hash_lookup_by_str (metadata_table, name);
+}
+
+const gchar *
+tracker_xesam_ontology_get_field_id (const gchar *name)
+{
+	const TrackerField *field;
+
+	field = tracker_xesam_ontology_get_field_def (name);
+
+	if (field) {
+		return tracker_field_get_id (field);
+	}
+	
+	return NULL;
+}
+

Added: branches/xesam-support/src/trackerd/tracker-xesam-ontology.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam-ontology.h	Mon May 26 23:26:53 2008
@@ -0,0 +1,82 @@
+/* -*- 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_XESAM_ONTOLOGY_H__
+#define __TRACKERD_XESAM_ONTOLOGY_H__
+
+#include <glib-object.h>
+
+#include "tracker-service.h"
+#include "tracker-field.h"
+
+G_BEGIN_DECLS
+
+void                tracker_xesam_ontology_init                         (void);
+void                tracker_xesam_ontology_shutdown                     (void);
+void                tracker_xesam_ontology_add_service_type             (TrackerService *service,
+								   GSList         *mimes,
+								   GSList         *mime_prefixes);
+TrackerService *    tracker_xesam_ontology_get_service_type_by_name     (const gchar    *service_str);
+gchar *             tracker_xesam_ontology_get_service_type_by_id       (gint            id);
+/* gchar *             tracker_xesam_ontology_get_service_type_for_mime    (const gchar    *mime); */
+gint                tracker_xesam_ontology_get_id_for_service_type      (const gchar    *service_str);
+gchar *             tracker_xesam_ontology_get_parent_service           (const gchar    *service_str);
+gchar *             tracker_xesam_ontology_get_parent_service_by_id     (gint            id);
+gint                tracker_xesam_ontology_get_parent_id_for_service_id (gint            id);
+TrackerDBType       tracker_xesam_ontology_get_db_for_service_type      (const gchar    *service_str);
+/* gboolean            tracker_xesam_ontology_service_type_has_embedded    (const gchar    *service_str); */
+gboolean            tracker_xesam_ontology_is_valid_service_type        (const gchar    *service_str);
+/* gboolean            tracker_xesam_ontology_service_type_has_metadata    (const gchar    *service_str); */
+/* gboolean            tracker_xesam_ontology_service_type_has_thumbnails  (const gchar    *service_str); */
+/* gboolean            tracker_xesam_ontology_service_type_has_text        (const gchar    *service_str); */
+/* gint                tracker_xesam_ontology_metadata_key_in_service      (const gchar    *service_str, */
+/* 								   const gchar    *meta_name); */
+gboolean            tracker_xesam_ontology_show_service_directories     (const gchar    *service_str);
+gboolean            tracker_xesam_ontology_show_service_files           (const gchar    *service_str);
+
+
+
+/* Service directories */
+GSList *            tracker_xesam_ontology_get_dirs_for_service_type    (const gchar    *service);
+void                tracker_xesam_ontology_add_dir_to_service_type      (const gchar    *service,
+								   const gchar    *path);
+void                tracker_xesam_ontology_remove_dir_to_service_type   (const gchar    *service,
+								   const gchar    *path);
+gchar *             tracker_xesam_ontology_get_service_type_for_dir     (const gchar    *path);
+
+
+
+
+/* Field handling */
+void                tracker_xesam_ontology_add_field                    (TrackerField   *field);
+gchar *             tracker_xesam_ontology_get_field_column_in_services (const TrackerField   *field,
+								   const gchar    *service_type);
+gchar *             tracker_xesam_ontology_get_display_field            (const TrackerField   *field);
+gboolean            tracker_xesam_ontology_field_is_child_of            (const gchar    *child,
+								   const gchar    *parent);
+const TrackerField *tracker_xesam_ontology_get_field_def                (const gchar    *name);
+const gchar *       tracker_xesam_ontology_get_field_id                 (const gchar    *name);
+
+
+G_END_DECLS
+
+#endif /* __TRACKERD_XESAM_ONTOLOGY_H__ */
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]