tracker r2510 - in branches/uri: . docs/reference/libtracker-common src/libtracker-common src/libtracker-data src/tracker-indexer src/tracker-indexer/modules src/trackerd tests/libtracker-common



Author: juergbi
Date: Mon Nov 17 15:28:59 2008
New Revision: 2510
URL: http://svn.gnome.org/viewvc/tracker?rev=2510&view=rev

Log:
2008-11-17  JÃrg Billeter  <j bitron ch>

	* docs/reference/libtracker-common/libtracker-common-sections.txt:
	* src/libtracker-common/tracker-file-utils.c:
	* src/libtracker-common/tracker-file-utils.h:
	* src/libtracker-data/tracker-data-query.c:
	* src/libtracker-data/tracker-data-update.c:
	* src/libtracker-data/tracker-data-update.h:
	* src/tracker-indexer/modules/applications.c:
	* src/tracker-indexer/modules/dummy.c:
	* src/tracker-indexer/modules/evolution.c:
	* src/tracker-indexer/modules/files.c:
	* src/tracker-indexer/tracker-indexer-module.c:
	* src/tracker-indexer/tracker-indexer-module.h:
	* src/tracker-indexer/tracker-indexer.c:
	* src/tracker-indexer/tracker-metadata-utils.c:
	* src/tracker-indexer/tracker-metadata-utils.h:
	* src/tracker-indexer/tracker-module.h:
	* src/trackerd/tracker-files.c:
	* src/trackerd/tracker-main.c:
	* tests/libtracker-common/tracker-file-utils-test.c:

	Use real URIs to identify services, use GFile instead of file paths


Modified:
   branches/uri/ChangeLog
   branches/uri/docs/reference/libtracker-common/libtracker-common-sections.txt
   branches/uri/src/libtracker-common/tracker-file-utils.c
   branches/uri/src/libtracker-common/tracker-file-utils.h
   branches/uri/src/libtracker-data/tracker-data-query.c
   branches/uri/src/libtracker-data/tracker-data-update.c
   branches/uri/src/libtracker-data/tracker-data-update.h
   branches/uri/src/tracker-indexer/modules/applications.c
   branches/uri/src/tracker-indexer/modules/dummy.c
   branches/uri/src/tracker-indexer/modules/evolution.c
   branches/uri/src/tracker-indexer/modules/files.c
   branches/uri/src/tracker-indexer/tracker-indexer-module.c
   branches/uri/src/tracker-indexer/tracker-indexer-module.h
   branches/uri/src/tracker-indexer/tracker-indexer.c
   branches/uri/src/tracker-indexer/tracker-metadata-utils.c
   branches/uri/src/tracker-indexer/tracker-metadata-utils.h
   branches/uri/src/tracker-indexer/tracker-module.h
   branches/uri/src/trackerd/tracker-files.c
   branches/uri/src/trackerd/tracker-main.c
   branches/uri/tests/libtracker-common/tracker-file-utils-test.c

Modified: branches/uri/docs/reference/libtracker-common/libtracker-common-sections.txt
==============================================================================
--- branches/uri/docs/reference/libtracker-common/libtracker-common-sections.txt	(original)
+++ branches/uri/docs/reference/libtracker-common/libtracker-common-sections.txt	Mon Nov 17 15:28:59 2008
@@ -111,13 +111,8 @@
 tracker_file_close
 tracker_file_get_mime_type
 tracker_file_get_mtime
-tracker_file_get_path_and_name
 tracker_file_get_size
-tracker_file_is_directory
-tracker_file_is_indexable
-tracker_file_is_valid
 tracker_file_open
-tracker_file_unlink
 tracker_path_evaluate_name
 tracker_path_hash_table_filter_duplicates
 tracker_path_is_in_path

Modified: branches/uri/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- branches/uri/src/libtracker-common/tracker-file-utils.c	(original)
+++ branches/uri/src/libtracker-common/tracker-file-utils.c	Mon Nov 17 15:28:59 2008
@@ -40,19 +40,19 @@
 #define TEXT_SNIFF_SIZE 4096
 
 gint
-tracker_file_open (const gchar *uri,
+tracker_file_open (const gchar *path,
 		   gboolean	readahead)
 {
 	gint fd;
 
 #if defined(__linux__)
-	fd = open (uri, O_RDONLY | O_NOATIME);
+	fd = open (path, O_RDONLY | O_NOATIME);
 
 	if (fd == -1) {
-		fd = open (uri, O_RDONLY);
+		fd = open (path, O_RDONLY);
 	}
 #else
-	fd = open (uri, O_RDONLY);
+	fd = open (path, O_RDONLY);
 #endif
 
 	if (fd == -1) {
@@ -84,179 +84,25 @@
 	close (fd);
 }
 
-gboolean
-tracker_file_unlink (const gchar *uri)
-{
-	gchar	 *str;
-	gboolean  result;
-
-	str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
-	result = g_unlink (str) == 0;
-	g_free (str);
-
-	return result;
-}
-
 guint32
-tracker_file_get_size (const gchar *uri)
+tracker_file_get_size (const gchar *path)
 {
 	struct stat finfo;
 
-	if (g_lstat (uri, &finfo) == -1) {
+	if (g_lstat (path, &finfo) == -1) {
 		return 0;
 	} else {
 		return (guint32) finfo.st_size;
 	}
 }
 
-static inline gboolean
-is_utf8 (const gchar *buffer,
-	 gint	      buffer_length)
-{
-	gchar *end;
-
-	/* Code in this function modified from gnome-vfs */
-	if (g_utf8_validate ((gchar*) buffer,
-			     buffer_length,
-			     (const gchar**) &end)) {
-		return TRUE;
-	} else {
-		/* Check whether the string was truncated in the middle of
-		 * a valid UTF8 char, or if we really have an invalid
-		 * UTF8 string.
-		 */
-		gunichar validated;
-		gint	 remaining_bytes;
-
-		remaining_bytes  = buffer_length;
-		remaining_bytes -= end - ((gchar *) buffer);
-
-		if (remaining_bytes > 4) {
-			return FALSE;
-		}
-
-		validated = g_utf8_get_char_validated (end, (gsize) remaining_bytes);
-
-		if (validated == (gunichar) - 2) {
-			return TRUE;
-		}
-	}
-
-	return FALSE;
-}
-
-gboolean
-tracker_file_is_valid (const gchar *uri)
-{
-	gchar	 *str;
-	gboolean  is_valid = TRUE;
-
-	str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
-
-	if (!str) {
-		g_warning ("URI:'%s' could not be converted to locale format",
-			   uri);
-		return FALSE;
-	}
-
-	/* g_file_test (file,G_FILE_TEST_EXISTS) uses the access ()
-	 * system call and so needs locale filenames.
-	 */
-	is_valid &= uri != NULL;
-	is_valid &= g_file_test (str,
-				 G_FILE_TEST_IS_REGULAR |
-				 G_FILE_TEST_IS_DIR |
-				 G_FILE_TEST_IS_SYMLINK);
-
-	g_free (str);
-
-	return is_valid;
-}
-
-gboolean
-tracker_file_is_directory (const gchar *uri)
-{
-	gchar	 *str;
-	gboolean  is_directory;
-
-	str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
-
-	if (!str) {
-		g_warning ("URI:'%s' could not be converted to locale format",
-			   str);
-		return FALSE;
-	}
-
-	is_directory = g_file_test (str, G_FILE_TEST_IS_DIR);
-	g_free (str);
-
-	return is_directory;
-}
-
-gboolean
-tracker_file_is_indexable (const gchar *uri)
-{
-	gchar	    *str;
-	struct stat  finfo;
-	gboolean     is_indexable;
-
-	g_return_val_if_fail (uri != NULL, FALSE);
-
-	str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
-
-	if (!str) {
-		g_warning ("URI:'%s' could not be converted to locale format",
-			   str);
-		return FALSE;
-	}
-
-	g_lstat (str, &finfo);
-	g_free (str);
-
-	is_indexable  = TRUE;
-	is_indexable &= !S_ISDIR (finfo.st_mode);
-	is_indexable &= S_ISREG (finfo.st_mode);
-
-	g_debug ("URI:'%s' %s indexable",
-		 uri,
-		 is_indexable ? "is" : "is not");
-
-	return is_indexable;
-}
-
-gint32
-tracker_file_get_mtime (const gchar *uri)
-{
-	struct stat  finfo;
-	gchar	    *str;
-
-	str = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
-
-	if (str) {
-		if (g_lstat (str, &finfo) == -1) {
-			g_free (str);
-			return 0;
-		}
-	} else {
-		g_warning ("URI:'%s' could not be converted to locale format",
-			   uri);
-		return 0;
-	}
-
-	g_free (str);
-
-	return (gint32) finfo.st_mtime;
-}
-
 gchar *
-tracker_file_get_mime_type (const gchar *path)
+tracker_file_get_mime_type (GFile *file)
 {
 	GFileInfo *info;
-	GFile	  *file;
 	GError	  *error = NULL;
 	gchar	  *content_type;
 
-	file = g_file_new_for_path (path);
 	info = g_file_query_info (file,
 				  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
 				  G_FILE_QUERY_INFO_NONE,
@@ -273,140 +119,20 @@
 		g_object_unref (info);
 	}
 
-	g_object_unref (file);
-
 	return content_type ? content_type : g_strdup ("unknown");
 }
 
-static gchar *
-tracker_file_get_vfs_path (const gchar *uri)
-{
-	gchar *p;
-
-	if (!uri || !strchr (uri, G_DIR_SEPARATOR)) {
-		return NULL;
-	}
-
-	p = (gchar*) uri + strlen (uri) - 1;
-
-	/* Skip trailing slash */
-	if (p != uri && *p == G_DIR_SEPARATOR) {
-		p--;
-	}
-
-	/* Search backwards to the next slash. */
-	while (p != uri && *p != G_DIR_SEPARATOR) {
-		p--;
-	}
-
-	if (p[0] != '\0') {
-		gchar *new_uri_text;
-		gint   length;
-
-		length = p - uri;
-
-		if (length == 0) {
-			new_uri_text = g_strdup (G_DIR_SEPARATOR_S);
-		} else {
-			new_uri_text = g_malloc (length + 1);
-			memcpy (new_uri_text, uri, length);
-			new_uri_text[length] = '\0';
-		}
-
-		return new_uri_text;
-	} else {
-		return g_strdup (G_DIR_SEPARATOR_S);
-	}
-}
-
-static gchar *
-tracker_file_get_vfs_name (const gchar *uri)
-{
-	gchar *p, *res, *tmp, *result;
-
-	if (!uri || !strchr (uri, G_DIR_SEPARATOR)) {
-		return g_strdup (" ");
-	}
-
-	tmp = g_strdup (uri);
-	p = tmp + strlen (uri) - 1;
-
-	/* Skip trailing slash */
-	if (p != tmp && *p == G_DIR_SEPARATOR) {
-		*p = '\0';
-	}
-
-	/* Search backwards to the next slash.	*/
-	while (p != tmp && *p != G_DIR_SEPARATOR) {
-		p--;
-	}
-
-	res = p + 1;
-
-	if (res && res[0] != '\0') {
-		result = g_strdup (res);
-		g_free (tmp);
-
-		return result;
-	}
-
-	g_free (tmp);
-
-	return g_strdup (" ");
-}
-
-
-static gchar *
-normalize_uri (const gchar *uri) {
-
-	GFile  *f;
-	gchar *normalized;
-
-	f = g_file_new_for_path (uri);
-	normalized =  g_file_get_path (f);
-	g_object_unref (f);
-
-	return normalized;
-}
-
-void
-tracker_file_get_path_and_name (const gchar *uri,
-				gchar **path,
-				gchar **name)
-{
-
-	g_return_if_fail (uri);
-	g_return_if_fail (path);
-	g_return_if_fail (name);
-
-	if (uri[0] == G_DIR_SEPARATOR) {
-		gchar *checked_uri;
-
-		checked_uri = normalize_uri (uri);
-		*name = g_path_get_basename (checked_uri);
-		*path = g_path_get_dirname (checked_uri);
-
-		g_free (checked_uri);
-	} else {
-		*name = tracker_file_get_vfs_name (uri);
-		*path = tracker_file_get_vfs_path (uri);
-	}
-
-}
-
-
-
 void
-tracker_path_remove (const gchar *uri)
+tracker_path_remove (const gchar *path)
 {
 	GQueue *dirs;
 	GSList *dirs_to_remove = NULL;
 
-	g_return_if_fail (uri != NULL);
+	g_return_if_fail (path != NULL);
 
 	dirs = g_queue_new ();
 
-	g_queue_push_tail (dirs, g_strdup (uri));
+	g_queue_push_tail (dirs, g_strdup (path));
 
 	while (!g_queue_is_empty (dirs)) {
 		GDir  *p;
@@ -628,7 +354,7 @@
 }
 
 gchar *
-tracker_path_evaluate_name (const gchar *uri)
+tracker_path_evaluate_name (const gchar *path)
 {
 	gchar	     *final_path;
 	gchar	    **tokens;
@@ -638,12 +364,12 @@
 	const gchar  *env;
 	gchar	     *expanded;
 
-	if (!uri || uri[0] == '\0') {
+	if (!path || path[0] == '\0') {
 		return NULL;
 	}
 
 	/* First check the simple case of using tilder */
-	if (uri[0] == '~') {
+	if (path[0] == '~') {
 		const char *home = g_get_home_dir ();
 
 		if (!home || home[0] == '\0') {
@@ -652,14 +378,14 @@
 
 		return g_build_path (G_DIR_SEPARATOR_S,
 				     home,
-				     uri + 1,
+				     path + 1,
 				     NULL);
 	}
 
 	/* Second try to find any environment variables and expand
 	 * them, like $HOME or ${FOO}
 	 */
-	tokens = g_strsplit (uri, G_DIR_SEPARATOR_S, -1);
+	tokens = g_strsplit (path, G_DIR_SEPARATOR_S, -1);
 
 	for (token = tokens; *token; token++) {
 		if (**token != '$') {
@@ -691,7 +417,7 @@
 		expanded = g_strjoinv (G_DIR_SEPARATOR_S, tokens);
 		g_strfreev (tokens);
 	} else {
-		expanded = g_strdup (uri);
+		expanded = g_strdup (path);
 	}
 
 	/* Only resolve relative paths if there is a directory

Modified: branches/uri/src/libtracker-common/tracker-file-utils.h
==============================================================================
--- branches/uri/src/libtracker-common/tracker-file-utils.h	(original)
+++ branches/uri/src/libtracker-common/tracker-file-utils.h	Mon Nov 17 15:28:59 2008
@@ -27,27 +27,20 @@
 #endif
 
 #include <glib.h>
+#include <gio/gio.h>
 
-gint	 tracker_file_open			   (const gchar *uri,
+gint	 tracker_file_open			   (const gchar *path,
 						    gboolean	 readahead);
 void	 tracker_file_close			   (gint	 fd,
 						    gboolean	 no_longer_needed);
-gboolean tracker_file_unlink			   (const gchar *uri);
-gboolean tracker_file_is_valid			   (const gchar *uri);
-gboolean tracker_file_is_directory		   (const gchar *uri);
-gboolean tracker_file_is_indexable		   (const gchar *uri);
-guint32  tracker_file_get_size			   (const gchar *uri);
-gint32	 tracker_file_get_mtime			   (const gchar *uri);
-gchar *  tracker_file_get_mime_type		   (const gchar *uri);
-void	 tracker_file_get_path_and_name		   (const gchar *uri,
-						    gchar **path,
-						    gchar **name);
-void	 tracker_path_remove			   (const gchar *uri);
+guint32  tracker_file_get_size			   (const gchar *path);
+gchar *  tracker_file_get_mime_type		   (GFile	*file);
+void	 tracker_path_remove			   (const gchar *path);
 gboolean tracker_path_is_in_path		   (const gchar *path,
 						    const gchar *in_path);
 void	 tracker_path_hash_table_filter_duplicates (GHashTable	*roots);
 GSList * tracker_path_list_filter_duplicates	   (GSList	*roots);
-gchar *  tracker_path_evaluate_name		   (const gchar *uri);
+gchar *  tracker_path_evaluate_name		   (const gchar *path);
 gboolean tracker_env_check_xdg_dirs		   (void);
 
 #endif /* __LIBTRACKER_COMMON_FILE_UTILS_H__ */

Modified: branches/uri/src/libtracker-data/tracker-data-query.c
==============================================================================
--- branches/uri/src/libtracker-data/tracker-data-query.c	(original)
+++ branches/uri/src/libtracker-data/tracker-data-query.c	Mon Nov 17 15:28:59 2008
@@ -251,13 +251,13 @@
 
 guint32
 tracker_data_query_file_id (const gchar    *service_type,
-			    const gchar	   *path)
+			    const gchar	   *uri)
 {
 	TrackerDBResultSet *result_set;
 	TrackerDBInterface *iface;
 	guint32		    id = 0;
 
-	g_return_val_if_fail (path != NULL, 0);
+	g_return_val_if_fail (uri != NULL, 0);
 
 	iface = tracker_db_manager_get_db_interface_by_service (service_type);
 	
@@ -269,7 +269,7 @@
 
 	result_set = tracker_data_manager_exec_proc (iface,
 					   "GetServiceID",
-					   path,
+					   uri,
 					   NULL);
 
 	if (result_set) {
@@ -282,13 +282,13 @@
 
 gchar *
 tracker_data_query_file_id_as_string (const gchar	*service_type,
-				      const gchar	*path)
+				      const gchar	*uri)
 {
 	guint32	id;
 
-	g_return_val_if_fail (path != NULL, NULL);
+	g_return_val_if_fail (uri != NULL, NULL);
 
-	id = tracker_data_query_file_id (service_type, path);
+	id = tracker_data_query_file_id (service_type, uri);
 
 	if (id > 0) {
 		return tracker_guint_to_string (id);

Modified: branches/uri/src/libtracker-data/tracker-data-update.c
==============================================================================
--- branches/uri/src/libtracker-data/tracker-data-update.c	(original)
+++ branches/uri/src/libtracker-data/tracker-data-update.c	Mon Nov 17 15:28:59 2008
@@ -228,19 +228,19 @@
 
 void
 tracker_data_update_delete_service_recursively (TrackerService *service,
-						const gchar    *service_path)
+						const gchar    *service_uri)
 {
 	TrackerDBInterface *iface;
 	gchar              *str;
 
 	g_return_if_fail (TRACKER_IS_SERVICE (service));
-	g_return_if_fail (service_path != NULL);
+	g_return_if_fail (service_uri != NULL);
 
 	iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
 							     TRACKER_DB_CONTENT_TYPE_METADATA);
 
 	/* Delete from services table recursively */
-	str = g_strconcat (service_path, "/%", NULL);
+	str = g_strconcat (service_uri, "/%", NULL);
 
 	/* We have to give two arguments. One is the actual path and
 	 * the second is a string representing the likeness to match
@@ -259,12 +259,11 @@
 void
 tracker_data_update_move_service (TrackerService *service,
 				  const gchar	*from,
-				  const gchar	*to)
+				  const gchar	*to,
+				  const gchar   *new_filename)
 {
 	TrackerDBInterface *iface;
 	GError *error = NULL;
-	gchar *to_dirname;
-	gchar *to_basename;
 
 	g_return_if_fail (TRACKER_IS_SERVICE (service));
 	g_return_if_fail (from != NULL);
@@ -273,14 +272,10 @@
 	iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
 							     TRACKER_DB_CONTENT_TYPE_METADATA);
 
-	tracker_file_get_path_and_name (to,
-	                                &to_dirname,
-	                                                                &to_basename);
-
 	tracker_db_interface_execute_procedure (iface,
 						NULL,
 						"MoveService",
-						to, to_basename,
+						to, new_filename,
 						from,
 						NULL);
 
@@ -292,9 +287,6 @@
 						to,
 						from,
 						NULL);
-
-	g_free (to_dirname);
-	g_free (to_basename);
 }
 
 void

Modified: branches/uri/src/libtracker-data/tracker-data-update.h
==============================================================================
--- branches/uri/src/libtracker-data/tracker-data-update.h	(original)
+++ branches/uri/src/libtracker-data/tracker-data-update.h	Mon Nov 17 15:28:59 2008
@@ -46,10 +46,11 @@
 void     tracker_data_update_delete_service             (TrackerService      *service,
 							 guint32              service_id);
 void     tracker_data_update_delete_service_recursively (TrackerService      *service,
-							 const gchar         *service_path);
+							 const gchar         *service_uri);
 void     tracker_data_update_move_service               (TrackerService      *service,
 							 const gchar         *from,
-							 const gchar         *to);
+							 const gchar         *to,
+							 const gchar         *new_filename);
 
 /* Metadata */
 void     tracker_data_update_set_metadata               (TrackerService      *service,

Modified: branches/uri/src/tracker-indexer/modules/applications.c
==============================================================================
--- branches/uri/src/tracker-indexer/modules/applications.c	(original)
+++ branches/uri/src/tracker-indexer/modules/applications.c	Mon Nov 17 15:28:59 2008
@@ -105,24 +105,29 @@
 {
 	TrackerDataMetadata *metadata;
 	GKeyFile *key_file;
-	gchar *type, *filename;
+	gchar *type, *path;
+
+	path = g_file_get_path (file->file);
 
 	/* Check we're dealing with a desktop file */
-	if (!g_str_has_suffix (file->path, ".desktop")) {
+	if (!g_str_has_suffix (path, ".desktop")) {
+		g_free (path);
 		return NULL;
 	}
 
 	key_file = g_key_file_new ();
 
-	if (!g_key_file_load_from_file (key_file, file->path, G_KEY_FILE_NONE, NULL)) {
-                g_debug ("Couldn't load desktop file:'%s'", file->path);
+	if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, NULL)) {
+		g_debug ("Couldn't load desktop file:'%s'", path);
 		g_key_file_free (key_file);
+		g_free (path);
 		return NULL;
 	}
 
 	if (g_key_file_get_boolean (key_file, GROUP_DESKTOP_ENTRY, KEY_HIDDEN, NULL)) {
                 g_debug ("Desktop file is 'hidden', not gathering metadata for it");
 		g_key_file_free (key_file);
+	g_free (path);
 		return NULL;
 	}
 
@@ -132,6 +137,7 @@
                 g_debug ("Desktop file is not of type 'Application', not gathering metadata for it");
 		g_key_file_free (key_file);
 		g_free (type);
+		g_free (path);
 		return NULL;
 	}
 
@@ -148,11 +154,11 @@
 	insert_list_from_desktop_file (metadata, METADATA_APP_MIMETYPE, key_file, KEY_MIMETYPE, FALSE);
 	insert_list_from_desktop_file (metadata, METADATA_APP_CATEGORIES, key_file, KEY_CATEGORIES, FALSE);
 
-	filename = g_filename_display_basename (file->path);
-	tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, filename);
+	insert_data_from_desktop_file (metadata, METADATA_FILE_NAME, key_file, KEY_NAME, FALSE);
 
 	g_key_file_free (key_file);
 	g_free (type);
+	g_free (path);
 
 	return metadata;
 }

Modified: branches/uri/src/tracker-indexer/modules/dummy.c
==============================================================================
--- branches/uri/src/tracker-indexer/modules/dummy.c	(original)
+++ branches/uri/src/tracker-indexer/modules/dummy.c	Mon Nov 17 15:28:59 2008
@@ -46,7 +46,7 @@
 }
 
 gpointer
-tracker_module_file_get_data (const gchar *path)
+tracker_module_file_get_data (GFile *file)
 {
 	/* Implementing this function is optional.
 	 *

Modified: branches/uri/src/tracker-indexer/modules/evolution.c
==============================================================================
--- branches/uri/src/tracker-indexer/modules/evolution.c	(original)
+++ branches/uri/src/tracker-indexer/modules/evolution.c	Mon Nov 17 15:28:59 2008
@@ -108,8 +108,8 @@
 };
 
 
-static gchar *local_dir = NULL;
-static gchar *imap_dir = NULL;
+static GFile *local_dir = NULL;
+static GFile *imap_dir = NULL;
 static GHashTable *accounts = NULL;
 
 
@@ -246,11 +246,18 @@
 void
 tracker_module_init (void)
 {
+	char *path;
+
 	g_mime_init (0);
 	get_imap_accounts ();
 
-	local_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "local", G_DIR_SEPARATOR_S, NULL);
-	imap_dir = g_build_filename (g_get_home_dir (), ".evolution", "mail", "imap", G_DIR_SEPARATOR_S, NULL);
+	path = g_build_filename (g_get_home_dir (), ".evolution", "mail", "local", G_DIR_SEPARATOR_S, NULL);
+	local_dir = g_file_new_for_path (path);
+	g_free (path);
+
+	path = g_build_filename (g_get_home_dir (), ".evolution", "mail", "imap", G_DIR_SEPARATOR_S, NULL);
+	imap_dir = g_file_new_for_path (path);
+	g_free (path);
 }
 
 void
@@ -259,8 +266,8 @@
 	g_mime_shutdown ();
 
 	g_hash_table_destroy (accounts);
-	g_free (local_dir);
-	g_free (imap_dir);
+	g_object_unref (local_dir);
+	g_object_unref (imap_dir);
 }
 
 G_CONST_RETURN gchar *
@@ -418,17 +425,18 @@
 }
 
 static MailStorageType
-get_mail_storage_type_from_path (const gchar *path)
+get_mail_storage_type_from_file (GFile *file)
 {
 	MailStorageType type = MAIL_STORAGE_NONE;
-	gchar *basename;
+	gchar *basename, *path;
 
-	basename = g_path_get_basename (path);
+	basename = g_file_get_basename (file);
+	path = g_file_get_path (file);
 
-	if (g_str_has_prefix (path, local_dir) &&
+	if (g_file_has_prefix (file, local_dir) &&
 	    strchr (basename, '.') == NULL) {
 		type = MAIL_STORAGE_LOCAL;
-	} else if (g_str_has_prefix (path, imap_dir) &&
+	} else if (g_file_has_prefix (file, imap_dir) &&
 		   strcmp (basename, "summary") == 0) {
 		type = MAIL_STORAGE_IMAP;
 	}
@@ -444,6 +452,7 @@
 	}
 
 	g_free (basename);
+	g_free (path);
 
 	return type;
 }
@@ -503,17 +512,20 @@
 }
 
 gpointer
-tracker_module_file_get_data (const gchar *path)
+tracker_module_file_get_data (GFile *file)
 {
 	EvolutionFileData *data = NULL;
 	MailStorageType type;
+	char *path;
 
-	type = get_mail_storage_type_from_path (path);
+	type = get_mail_storage_type_from_file (file);
 
 	if (type == MAIL_STORAGE_NONE) {
 		return NULL;
 	}
 
+	path = g_file_get_path (file);
+
 	data = g_slice_new0 (EvolutionFileData);
 	data->type = type;
 
@@ -525,6 +537,7 @@
 		imap_data->fd = tracker_file_open (path, TRUE);
 
 		if (imap_data->fd == -1) {
+			g_free (path);
 			return NULL;
 		}
 
@@ -558,6 +571,8 @@
 		}
 	}
 
+	g_free (path);
+
 	return data;
 }
 
@@ -655,7 +670,7 @@
                 return;
         }
 
-	dir = tracker_string_replace (file->path, local_dir, NULL);
+	dir = g_file_get_relative_path (local_dir, file->file);
 	dir = tracker_string_remove (dir, ".sbd");
 
 	*uri = g_strdup_printf ("email://local local/%s;uid=%d", dir, message_id);
@@ -679,7 +694,7 @@
                 return;
         }
 
-	dir = tracker_string_replace (file->path, local_dir, NULL);
+	dir = g_file_get_relative_path (local_dir, file->file);
 	dir = tracker_string_remove (dir, ".sbd");
 
 	*uri = g_strdup_printf ("email://local local/%s;uid=%d/%s",
@@ -739,10 +754,16 @@
 	stream = g_mime_stream_fs_new (fd);
 
 	if (g_mime_data_wrapper_write_to_stream (wrapper, stream) != -1) {
+		GFile *file;
+
 		g_mime_stream_flush (stream);
 
-		metadata = tracker_metadata_utils_get_data (path);
+		file = g_file_new_for_path (path);
+
+		metadata = tracker_metadata_utils_get_data (file);
 		g_unlink (path);
+
+		g_object_unref (file);
 	}
 
 	g_mime_stream_close (stream);
@@ -987,15 +1008,17 @@
 	      gchar	  **uri)
 {
 	GList *keys, *k;
+	GFile *dir_file;
 	gchar *path, *dir, *subdirs;
 
-	path = file->path;
+	path = g_file_get_path (file->file);
 	keys = g_hash_table_get_keys (accounts);
 	*uri = NULL;
 
 	for (k = keys; k; k = k->next) {
 		if (strstr (path, k->data)) {
-			dir = g_build_filename (imap_dir, k->data, NULL);
+			dir_file = g_file_get_child (imap_dir, k->data);
+			dir = g_file_get_path (dir_file);
 
 			/* now remove all relevant info to create the email:// basename */
 			subdirs = g_strdup (path);
@@ -1008,6 +1031,7 @@
                                                (gchar *) g_hash_table_lookup (accounts, k->data),
                                                subdirs, uid);
 
+			g_object_unref (dir_file);
 			g_free (subdirs);
 			g_free (dir);
 
@@ -1016,6 +1040,7 @@
 	}
 
 	g_list_free (keys);
+	g_free (path);
 
 	return;
 }
@@ -1066,12 +1091,16 @@
 get_imap_message_path (TrackerFile *file,
 		       const gchar *uid)
 {
-	gchar *prefix, *message_path;
+	gchar *prefix, *message_path, *path;
 
-	prefix = g_strndup (file->path, strlen (file->path) - strlen ("summary"));
+	path = g_file_get_path (file->file);
+
+	prefix = g_strndup (path, strlen (path) - strlen ("summary"));
 	message_path = g_strconcat (prefix, uid, ".", NULL);
 	g_free (prefix);
 
+	g_free (path);
+
 	return message_path;
 }
 

Modified: branches/uri/src/tracker-indexer/modules/files.c
==============================================================================
--- branches/uri/src/tracker-indexer/modules/files.c	(original)
+++ branches/uri/src/tracker-indexer/modules/files.c	Mon Nov 17 15:28:59 2008
@@ -62,7 +62,7 @@
 	gchar *mime_type;
 	gchar *service_type;
 
-	mime_type = tracker_file_get_mime_type (file->path);
+	mime_type = tracker_file_get_mime_type (file->file);
 	service_type = tracker_ontology_get_service_by_mime (mime_type);
 	g_free (mime_type);
 
@@ -148,7 +148,7 @@
 	}
 #endif /* ENABLE_FILE_EXCLUDE_CHECKING */
 
-	return tracker_metadata_utils_get_data (file->path);
+	return tracker_metadata_utils_get_data (file->file);
 }
 
 gchar *
@@ -160,5 +160,5 @@
 	}
 #endif /* ENABLE_FILE_EXCLUDE_CHECKING */
 
-	return tracker_metadata_utils_get_text (file->path);
+	return tracker_metadata_utils_get_text (file->file);
 }

Modified: branches/uri/src/tracker-indexer/tracker-indexer-module.c
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-indexer-module.c	(original)
+++ branches/uri/src/tracker-indexer/tracker-indexer-module.c	Mon Nov 17 15:28:59 2008
@@ -82,16 +82,16 @@
 
 TrackerFile *
 tracker_indexer_module_file_new (GModule     *module,
-				 const gchar *path)
+				 GFile       *gfile)
 {
 	TrackerModuleFileGetDataFunc func;
 	TrackerFile *file = NULL;
 
 	file = g_slice_new0 (TrackerFile);
-	file->path = g_strdup (path);
+	file->file = g_object_ref (gfile);
 
 	if (g_module_symbol (module, "tracker_module_file_get_data", (gpointer *) &func)) {
-		file->data = (func) (path);
+		file->data = (func) (gfile);
 	}
 
 	return file;
@@ -108,7 +108,7 @@
 		(func) (file->data);
 	}
 
-	g_free (file->path);
+	g_object_unref (file->file);
 	g_slice_free (TrackerFile, file);
 }
 
@@ -125,7 +125,7 @@
 	if (g_module_symbol (module, "tracker_module_file_get_uri", (gpointer *) &func)) {
 		(func) (file, &tmp_uri);
 	} else {
-		tmp_uri = g_strdup (file->path);
+		tmp_uri = g_file_get_uri (file->file);
 	}
 
 	if (tmp_uri) {

Modified: branches/uri/src/tracker-indexer/tracker-indexer-module.h
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-indexer-module.h	(original)
+++ branches/uri/src/tracker-indexer/tracker-indexer-module.h	Mon Nov 17 15:28:59 2008
@@ -36,7 +36,7 @@
 G_CONST_RETURN gchar *	tracker_indexer_module_get_name		      (GModule	    *module);
 
 TrackerFile *		tracker_indexer_module_file_new		      (GModule	    *module,
-								       const gchar  *path);
+								       GFile        *file);
 void			tracker_indexer_module_file_free	      (GModule	    *module,
 								       TrackerFile  *file);
 

Modified: branches/uri/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-indexer.c	(original)
+++ branches/uri/src/tracker-indexer/tracker-indexer.c	Mon Nov 17 15:28:59 2008
@@ -205,18 +205,18 @@
 static PathInfo *
 path_info_new (GModule *module,
 	       const gchar *module_name,
-	       const gchar *path,
-	       const gchar *other_path)
+	       GFile *file,
+	       GFile *other_file)
 {
 	PathInfo *info;
 
 	info = g_slice_new (PathInfo);
 	info->module = module;
 	info->module_name = g_strdup (module_name);
-	info->file = tracker_indexer_module_file_new (module, path);
+	info->file = tracker_indexer_module_file_new (module, file);
 
-	if (G_UNLIKELY (other_path)) {
-		info->other_file = tracker_indexer_module_file_new (module, other_path);
+	if (G_UNLIKELY (other_file)) {
+		info->other_file = tracker_indexer_module_file_new (module, other_file);
 	} else {
 		info->other_file = NULL;
 	}
@@ -822,9 +822,9 @@
 	priv->in_transaction = FALSE;
 	priv->dir_queue = g_queue_new ();
 	priv->file_queue = g_queue_new ();
-	priv->mtime_cache = g_hash_table_new_full (g_str_hash,
-						   g_str_equal,
-						   g_free,
+	priv->mtime_cache = g_hash_table_new_full (g_file_hash,
+						   (GEqualFunc) g_file_equal,
+						   g_object_unref,
 						   NULL);
 	priv->modules_queue = g_queue_new ();
 	priv->config = tracker_config_new ();
@@ -1388,6 +1388,8 @@
 	TrackerDataMetadata *metadata;
 	gchar *service_type;
 	guint32 id;
+	gchar *new_uri;
+	GFileInfo *new_file_info;
 
 	service_type = tracker_indexer_module_file_get_service_type (info->module,
 								     info->other_file);
@@ -1403,9 +1405,11 @@
 		return;
 	}
 
+	new_uri = g_file_get_uri (info->other_file->file);
+
 	g_debug ("Moving item from '%s' to '%s'",
-		 info->file->path,
-		 info->other_file->path);
+		 uri,
+		 new_uri);
 
 	/* Get 'source' ID */
 	if (!tracker_data_query_service_exists (service,
@@ -1413,13 +1417,20 @@
 				       &id,
 				       NULL)) {
 		g_message ("Source file '%s' not found in database to move",
-			   info->file->path);
+			   uri);
+		g_free (new_uri);
 		return;
 	}
 
+	new_file_info = g_file_query_info (info->other_file->file,
+					G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
+					G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+					NULL, NULL);
+
 	tracker_data_update_move_service (service,
-				 info->file->path,
-				 info->other_file->path);
+				 uri,
+				 new_uri,
+				 g_file_info_get_display_name (new_file_info));
 
 	/*
 	 * Using DB directly: get old (embedded) metadata, unindex,
@@ -1428,6 +1439,9 @@
 	metadata = tracker_data_query_embedded_metadata (service, id);
 	unindex_metadata (indexer, id, service, metadata);
 	index_metadata (indexer, id, service, metadata);
+
+	g_free (new_uri);
+	g_object_unref (new_file_info);
 }
 
 static void
@@ -1778,11 +1792,12 @@
 {
 	TrackerService *service;
 	gchar *service_type;
-	gchar *str;
+	GFile *dir_file;
 	gboolean is_dir;
 	gboolean should_be_cached;
-	struct stat st;
+	GFileInfo *file_info;
 	time_t mtime;
+	gchar *path;
 
 	service_type = tracker_indexer_module_file_get_service_type (info->module, info->file);
 
@@ -1813,7 +1828,8 @@
 	 * the database. If it does, then we can ignore any files
 	 * immediately in this parent directory.
 	 */
-	if (g_lstat (info->file->path, &st) == -1) {
+	file_info = g_file_query_info (info->file->file, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL);
+	if (!file_info) {
 		return TRUE;
 	}
 
@@ -1847,27 +1863,29 @@
 	 *   3) Add to hash table
 	 *     --> return TRUE
 	 */
-	is_dir = S_ISDIR (st.st_mode);
+	is_dir = g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY;
 	should_be_cached = TRUE;
 
 	/* Choose the path we evaluate based on if we have a directory
 	 * or not. All operations are done using the same string.
 	 */
 	if (is_dir) {
-		str = g_strdup (info->file->path);
+		dir_file = g_object_ref (info->file->file);
 	} else {
-		str = g_path_get_basename (info->file->path);
+		dir_file = g_file_get_parent (info->file->file);
 	}
 
+	path = g_file_get_path (dir_file);
+
 	/* Step 1. */
-	if (g_hash_table_lookup (indexer->private->mtime_cache, str)) {
+	if (g_hash_table_lookup (indexer->private->mtime_cache, dir_file)) {
 		gboolean should_index;
 
 		if (!is_dir) {
 			/* Only index files in this directory which
 			 * have an old mtime.
 			 */
-			should_index = st.st_mtime > mtime;
+			should_index = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED) > mtime;
 		} else {
 			/* We always index directories */
 			should_index = TRUE;
@@ -1875,10 +1893,12 @@
 
 		g_debug ("%s:'%s' exists in cache, %s",
 			 is_dir ? "Path" : "Parent path",
-			 str,
+			 path,
 			 should_index ? "should index" : "should not index");
 
-		g_free (str);
+		g_object_unref (dir_file);
+		g_object_unref (file_info);
+		g_free (path);
 
 		return should_index;
 	}
@@ -1886,41 +1906,50 @@
 	/* Step 2. */
 	if (!is_dir) {
 		gboolean exists;
+		gchar *uri;
 
 		/* FIXME: What if there is no parent? */
 
 		/* We don't have the mtime for the dirname yet, we do
 		 * if this is a info->file->path of course.
 		 */
+		uri = g_file_get_uri (dir_file);
 		exists = tracker_data_query_service_exists (service,
-						   str,
+						   uri,
 						   NULL,
 						   &mtime);
+		g_free (uri);
+		g_object_unref (file_info);
+
 		if (!exists) {
 			g_message ("Expected path '%s' to exist, not in database?",
-				   str);
+				   path);
 
-			g_free (str);
+			g_free (path);
+			g_object_unref (dir_file);
 
 			return TRUE;
 		}
 
-		if (g_lstat (str, &st) == -1) {
+		file_info = g_file_query_info (dir_file, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL);
+		if (!file_info) {
 			g_message ("Expected path '%s' to exist, could not stat()",
-				   str);
+				   path);
 
-			g_free (str);
+			g_free (path);
+			g_object_unref (dir_file);
 
 			return TRUE;
 		}
 	}
 
-	if (st.st_mtime <= mtime) {
+	if (g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED) <= mtime) {
 		g_debug ("%s:'%s' has indifferent mtime and should not be indexed",
 			 is_dir ? "Path" : "Parent path",
-			 str);
+			 path);
 
-		g_free (str);
+		g_free (path);
+		g_object_unref (dir_file);
 
 		return FALSE;
 	}
@@ -1928,13 +1957,14 @@
 	/* Step 3. */
 	g_debug ("%s:'%s' being added to cache and should be indexed",
 		 is_dir ? "Path" : "Parent path",
-		 str);
+		 path);
 
 	g_hash_table_replace (indexer->private->mtime_cache,
-			      g_strdup (str),
+			      g_object_ref (dir_file),
 			      GINT_TO_POINTER (1));
 
-	g_free (str);
+	g_free (path);
+	g_object_unref (dir_file);
 
 	return TRUE;
 }
@@ -1983,8 +2013,13 @@
 	 */
 	if (G_LIKELY (!info->other_file) && uri[0] == G_DIR_SEPARATOR) {
 		if (!should_index_file (indexer, info, uri)) {
-			g_debug ("File is already up to date: '%s'", info->file->path);
+			gchar *path;
+
+			path = g_file_get_path (info->file->file);
 
+			g_debug ("File is already up to date: '%s'", path);
+
+			g_free (path);
 			g_free (uri);
 
 			return TRUE;
@@ -2023,39 +2058,44 @@
 		   PathInfo *info,
 		   gboolean recurse)
 {
-	const gchar *name;
-	GDir *dir;
+	char *path;
+	GFileEnumerator *enumerator;
+	GFileInfo *file_info;
 
-	g_debug ("Processing directory:'%s'", info->file->path);
+	path = g_file_get_path (info->file->file);
+	g_debug ("Processing directory:'%s'", path);
+	g_free (path);
 
-	dir = g_dir_open (info->file->path, 0, NULL);
+	enumerator = g_file_enumerate_children (info->file->file, "standard::*", 0, NULL, NULL);
 
-	if (!dir) {
+	if (!enumerator) {
 		return;
 	}
 
-	while ((name = g_dir_read_name (dir)) != NULL) {
+	while ((file_info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) {
 		PathInfo *new_info;
-		gchar *path;
+		GFile *child;
 
-		if (name[0] == '.') {
+		if (g_file_info_get_is_hidden (file_info)) {
+			g_object_unref (file_info);
 			continue;
 		}
 
-		path = g_build_filename (info->file->path, name, NULL);
+		child = g_file_get_child (info->file->file, g_file_info_get_name (file_info));
 
-		new_info = path_info_new (info->module, info->module_name, path, NULL);
+		new_info = path_info_new (info->module, info->module_name, child, NULL);
 		add_file (indexer, new_info);
 
-		if (recurse && g_file_test (path, G_FILE_TEST_IS_DIR)) {
-			new_info = path_info_new (info->module, info->module_name, path, NULL);
+		if (recurse && g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) {
+			new_info = path_info_new (info->module, info->module_name, child, NULL);
 			add_directory (indexer, new_info);
 		}
 
-		g_free (path);
+		g_object_unref (child);
+		g_object_unref (file_info);
 	}
 
-	g_dir_close (dir);
+	g_object_unref (enumerator);
 }
 
 static void
@@ -2102,10 +2142,15 @@
 	g_return_if_fail (dirs != NULL);
 
 	for (d = dirs; d; d = d->next) {
+		GFile *file;
 		PathInfo *info;
 
-		info = path_info_new (module, module_name, d->data, NULL);
+		file = g_file_new_for_path (d->data);
+
+		info = path_info_new (module, module_name, file, NULL);
 		add_directory (indexer, info);
+
+		g_object_unref (file);
 	}
 
 	g_list_free (dirs);
@@ -2477,10 +2522,15 @@
 
 	/* Add files to the queue */
 	for (i = 0; files[i]; i++) {
+		GFile *file;
 		PathInfo *info;
 
-		info = path_info_new (module, module_name, files[i], NULL);
+		file = g_file_new_for_path (files[i]);
+
+		info = path_info_new (module, module_name, file, NULL);
 		add_file (indexer, info);
+
+		g_object_unref (file);
 	}
 
 	dbus_g_method_return (context);
@@ -2522,6 +2572,7 @@
 	GModule *module;
 	guint request_id;
 	GError *actual_error;
+	GFile *from_file, *to_file;
 	PathInfo *info;
 
 	tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), context);
@@ -2546,10 +2597,16 @@
 		return;
 	}
 
+	from_file = g_file_new_for_path (from);
+	to_file = g_file_new_for_path (to);
+
 	/* Add files to the queue */
-	info = path_info_new (module, module_name, from, to);
+	info = path_info_new (module, module_name, from_file, to_file);
 	add_file (indexer, info);
 
+	g_object_unref (from_file);
+	g_object_unref (to_file);
+
 	dbus_g_method_return (context);
 	tracker_dbus_request_success (request_id);
 }

Modified: branches/uri/src/tracker-indexer/tracker-metadata-utils.c
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-metadata-utils.c	(original)
+++ branches/uri/src/tracker-indexer/tracker-metadata-utils.c	Mon Nov 17 15:28:59 2008
@@ -64,7 +64,7 @@
 	gpointer data;
 } ProcessContext;
 
-static void get_file_thumbnail (const gchar *path,
+static void get_file_thumbnail (GFile *file,
 				const gchar *mime);
 
 static ProcessContext *metadata_context = NULL;
@@ -243,15 +243,15 @@
 }
 
 static gchar **
-metadata_query_file (const gchar *path,
+metadata_query_file (GFile       *file,
 		     const gchar *mimetype)
 {
-	gchar *utf_path, *str;
+	gchar *path, *str;
 	GPtrArray *array;
 	GIOStatus status;
 	GError *error = NULL;
 
-	if (!path || !mimetype) {
+	if (!file || !mimetype) {
 		return NULL;
 	}
 
@@ -259,17 +259,17 @@
 		return NULL;
 	}
 
-	utf_path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
+	path = g_file_get_path (file);
 
-	if (!utf_path) {
+	if (!path) {
 		return NULL;
 	}
 
 	array = g_ptr_array_sized_new (10);
 	metadata_context->data = array;
 
-	str = g_strdup_printf ("%s\n%s\n", utf_path, mimetype);
-	g_free (utf_path);
+	str = g_strdup_printf ("%s\n%s\n", path, mimetype);
+	g_free (path);
 
 	/* Write path and mimetype */
 	g_io_channel_write_chars (metadata_context->stdin_channel, str, -1, NULL, NULL);
@@ -316,7 +316,7 @@
 }
 
 static void
-metadata_utils_get_embedded (const char          *path,
+metadata_utils_get_embedded (GFile               *file,
 			     const char          *mime_type,
 			     TrackerDataMetadata *metadata)
 {
@@ -336,7 +336,7 @@
 
 	g_free (service_type);
 
-	values = metadata_query_file (path, mime_type);
+	values = metadata_query_file (file, mime_type);
 
 	if (!values) {
 		return;
@@ -485,9 +485,8 @@
 #endif /* TRY_LOCALE_TO_UTF8_CONVERSION */
 
 static gchar *
-get_file_content (const gchar *path)
+get_file_content (GFile *file)
 {
-	GFile		 *file;
 	GFileInputStream *stream;
 	GError		 *error = NULL;
 	GString		 *s;
@@ -499,8 +498,9 @@
 	gboolean	  has_more_data;
 	gboolean	  has_reached_max;
 	gboolean	  is_utf8;
+	gchar		 *path;
 
-	file = g_file_new_for_path (path);
+	path = g_file_get_path (file);
 	stream = g_file_read (file, NULL, &error);
 
 	if (error) {
@@ -508,7 +508,7 @@
 			   path,
 			   error->message);
 		g_error_free (error);
-		g_object_unref (file);
+		g_free (path);
 
 		return NULL;
 	}
@@ -609,7 +609,7 @@
 		g_error_free (error);
 		g_string_free (s, TRUE);
 		g_object_unref (stream);
-		g_object_unref (file);
+		g_free (path);
 
 		return NULL;
 	}
@@ -641,13 +641,14 @@
 #endif	/* TRY_LOCALE_TO_UTF8_CONVERSION */
 
 	g_object_unref (stream);
-	g_object_unref (file);
 
 	if (s->len < 1) {
 		g_string_free (s, TRUE);
 		s = NULL;
 	}
 
+	g_free (path);
+
 	return s ? g_string_free (s, FALSE) : NULL;
 }
 
@@ -726,7 +727,7 @@
 }
 
 static void
-get_file_thumbnail (const gchar *path,
+get_file_thumbnail (GFile *file,
 		    const gchar *mime)
 {
 #ifdef HAVE_HILDON_THUMBNAIL
@@ -752,19 +753,12 @@
 	}
 
 	if (count < 51 && thumbnail_this (thumbnailable, mime)) {
-		gchar *utf_path;
-
-		utf_path = g_filename_to_utf8 (path, -1, NULL, NULL, NULL);
-
-		if (utf_path) {
-			batch[count] = g_strdup_printf ("file://%s", utf_path);
-			if (mime)
-				hints[count] = g_strdup (mime);
-			else 
-				hints[count] = g_strdup ("unknown/unknown");
-			g_free (utf_path);
-			count++;
-		}
+		batch[count] = g_file_get_uri (file);
+		if (mime)
+			hints[count] = g_strdup (mime);
+		else 
+			hints[count] = g_strdup ("unknown/unknown");
+		count++;
 
 		if (!timeout_runs) {
 			timeout_runs = TRUE;
@@ -783,7 +777,7 @@
 	gchar *argv[5];
 
 	argv[0] = g_strdup (LIBEXEC_PATH G_DIR_SEPARATOR_S "tracker-thumbnailer");
-	argv[1] = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
+	argv[1] = g_file_get_path (file);
 	argv[2] = g_strdup (mime);
 	argv[3] = g_strdup ("normal");
 	argv[4] = NULL;
@@ -819,11 +813,11 @@
 #endif /* THUMBNIAL_RETRIEVAL_ENABLED */
 
 static gchar *
-get_file_content_by_filter (const gchar *path,
+get_file_content_by_filter (GFile       *file,
 			    const gchar *mime)
 {
 	ProcessContext *context;
-	gchar *str, *text_filter_file;
+	gchar *str, *text_filter_file, *path;
 	gchar **argv;
 	GString *text;
 
@@ -846,9 +840,11 @@
 		return NULL;
 	}
 
+	path = g_file_get_path (file);
+
 	argv = g_new0 (gchar *, 3);
 	argv[0] = text_filter_file;
-	argv[1] = (gchar *) path;
+	argv[1] = path;
 
 	g_message ("Extracting text for:'%s' using filter:'%s'", argv[1], argv[0]);
 
@@ -856,6 +852,7 @@
 					  get_file_content_read_cb);
 
 	g_free (text_filter_file);
+	g_free (path);
 	g_free (argv);
 
 	if (!context) {
@@ -884,22 +881,22 @@
  * Returns: A newly allocated string containing the file text, or %NULL.
  **/
 gchar *
-tracker_metadata_utils_get_text (const gchar *path)
+tracker_metadata_utils_get_text (GFile *file)
 {
 	gchar *mime_type;
 	gchar *service_type;
 	gchar *text;
 
-	mime_type = tracker_file_get_mime_type (path);
+	mime_type = tracker_file_get_mime_type (file);
 	service_type = tracker_ontology_get_service_by_mime (mime_type);
 
 	/* No need to filter text based files - index them directly */
 	if (service_type &&
 	    (strcmp (service_type, "Text") == 0 ||
 	     strcmp (service_type, "Development") == 0)) {
-		text = get_file_content (path);
+		text = get_file_content (file);
 	} else {
-		text = get_file_content_by_filter (path, mime_type);
+		text = get_file_content_by_filter (file, mime_type);
 	}
 
 	g_free (service_type);
@@ -918,32 +915,36 @@
  * Returns: A newly created #TrackerDataMetadata, or %NULL if the file is not found.
  **/
 TrackerDataMetadata *
-tracker_metadata_utils_get_data (const gchar *path)
+tracker_metadata_utils_get_data (GFile *file)
 {
 	TrackerDataMetadata *metadata;
-	struct stat st;
 	const gchar *ext;
-	gchar *mime_type;
+	gchar *mime_type, *basename;
+	GFileInfo *file_info;
+	guint64 time;
 
-	if (g_lstat (path, &st) < 0) {
+	file_info = g_file_query_info (file, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL);
+	if (!file_info) {
 		return NULL;
 	}
 
 	metadata = tracker_data_metadata_new ();
-	ext = strrchr (path, '.');
 
+	basename = g_file_get_basename (file);
+	ext = strrchr (basename, '.');
 	if (ext) {
 		tracker_data_metadata_insert (metadata, METADATA_FILE_EXT, g_strdup (ext + 1));
 	}
+	g_free (basename);
 
-	mime_type = tracker_file_get_mime_type (path);
+	mime_type = tracker_file_get_mime_type (file);
 
 	tracker_data_metadata_insert (metadata, METADATA_FILE_NAME,
-				 g_filename_display_basename (path));
+				 g_strdup (g_file_info_get_display_name (file_info)));
 	tracker_data_metadata_insert (metadata, METADATA_FILE_URI,
-				 g_strdup (path));
+				 g_file_get_uri (file));
 	tracker_data_metadata_insert (metadata, METADATA_FILE_NAME_DELIMITED,
-				 g_filename_to_utf8 (path, -1, NULL, NULL, NULL));
+				 g_strdup (g_file_info_get_display_name (file_info)));
 	tracker_data_metadata_insert (metadata, METADATA_FILE_MIMETYPE,
 				 mime_type);
 
@@ -952,27 +953,30 @@
 		 * We should determine here for which items we do and for which
 		 * items we don't want to pre-create the thumbnail. */
 
-		get_file_thumbnail (path, mime_type);
+		get_file_thumbnail (file, mime_type);
 	}
 
-	if (S_ISLNK (st.st_mode)) {
-		gchar *link_path;
+	if (g_file_info_get_is_symlink (file_info)) {
+		const gchar *link_path;
 
-		link_path = g_file_read_link (path, NULL);
+		link_path = g_file_info_get_symlink_target (file_info);
 		tracker_data_metadata_insert (metadata, METADATA_FILE_LINK,
 					 g_filename_to_utf8 (link_path, -1, NULL, NULL, NULL));
-		g_free (link_path);
 	}
 
 	/* FIXME: These should be dealt directly as integer/times/whatever, not strings */
 	tracker_data_metadata_insert (metadata, METADATA_FILE_SIZE,
-				 tracker_guint_to_string (st.st_size));
+				 tracker_guint_to_string (g_file_info_get_size (file_info)));
+
+	time = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
 	tracker_data_metadata_insert (metadata, METADATA_FILE_MODIFIED,
-				 tracker_date_to_string (st.st_mtime));
+				 tracker_date_to_string (time));
+
+	time = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_ACCESS);
 	tracker_data_metadata_insert (metadata, METADATA_FILE_ACCESSED,
-				 tracker_date_to_string (st.st_atime));
+				 tracker_date_to_string (time));
 
-	metadata_utils_get_embedded (path, mime_type, metadata);
+	metadata_utils_get_embedded (file, mime_type, metadata);
 
 	return metadata;
 }

Modified: branches/uri/src/tracker-indexer/tracker-metadata-utils.h
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-metadata-utils.h	(original)
+++ branches/uri/src/tracker-indexer/tracker-metadata-utils.h	Mon Nov 17 15:28:59 2008
@@ -22,12 +22,13 @@
 #ifndef __TRACKER_METADATA_UTILS_H__
 #define __TRACKER_METADATA_UTILS_H__
 
+#include <gio/gio.h>
 #include <libtracker-data/tracker-data-metadata.h>
 
 G_BEGIN_DECLS
 
-TrackerDataMetadata *tracker_metadata_utils_get_data (const gchar *path);
-gchar *		     tracker_metadata_utils_get_text (const gchar *path);
+TrackerDataMetadata *tracker_metadata_utils_get_data (GFile *file);
+gchar *		     tracker_metadata_utils_get_text (GFile *file);
 
 G_END_DECLS
 

Modified: branches/uri/src/tracker-indexer/tracker-module.h
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-module.h	(original)
+++ branches/uri/src/tracker-indexer/tracker-module.h	Mon Nov 17 15:28:59 2008
@@ -25,12 +25,13 @@
 G_BEGIN_DECLS
 
 #include <glib.h>
+#include <gio/gio.h>
 #include <libtracker-data/tracker-data-metadata.h>
 
 typedef struct TrackerFile TrackerFile;
 
 struct TrackerFile {
-	gchar	 *path;
+	GFile	 *file;
 	gpointer  data;
 };
 
@@ -40,7 +41,7 @@
 typedef const gchar *	  (* TrackerModuleGetNameFunc)		  (void);
 typedef gchar **	  (* TrackerModuleGetDirectoriesFunc)	  (void);
 
-typedef gpointer	  (* TrackerModuleFileGetDataFunc)	  (const gchar	*path);
+typedef gpointer	  (* TrackerModuleFileGetDataFunc)	  (GFile	*file);
 typedef void		  (* TrackerModuleFileFreeDataFunc)	  (gpointer	 data);
 
 typedef gchar *		  (* TrackerModuleFileGetServiceTypeFunc) (TrackerFile	*file);
@@ -55,7 +56,7 @@
 void		      tracker_module_init		   (void);
 void		      tracker_module_shutdown		   (void);
 G_CONST_RETURN gchar *tracker_module_get_name		   (void);
-gpointer	      tracker_module_file_get_data	   (const gchar  *path);
+gpointer	      tracker_module_file_get_data	   (GFile        *file);
 void		      tracker_module_file_free_data	   (gpointer	  file_data);
 gchar *		      tracker_module_file_get_service_type (TrackerFile  *file);
 void		      tracker_module_file_get_uri	   (TrackerFile  *file,

Modified: branches/uri/src/trackerd/tracker-files.c
==============================================================================
--- branches/uri/src/trackerd/tracker-files.c	(original)
+++ branches/uri/src/trackerd/tracker-files.c	Mon Nov 17 15:28:59 2008
@@ -433,8 +433,6 @@
 	TrackerDBInterface *iface;
 	TrackerDBResultSet *result_set = NULL;
 	guint		    request_id;
-	gchar		   *name = NULL;
-	gchar		   *path = NULL;
 	gchar		   *max_length_str;
 	gchar		   *value = NULL;
 	GError		   *actual_error = NULL;
@@ -454,8 +452,6 @@
 
 	iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
 
-	tracker_file_get_path_and_name (uri, &path, &name);
-
 	max_length_str = tracker_gint_to_string (max_length);
 
 	/* result_set = tracker_exec_proc (iface, */
@@ -468,8 +464,6 @@
 
 
 	g_free (max_length_str);
-	g_free (path);
-	g_free (name);
 
 	if (result_set) {
 		tracker_db_result_set_get (result_set, 0, value, -1);

Modified: branches/uri/src/trackerd/tracker-main.c
==============================================================================
--- branches/uri/src/trackerd/tracker-main.c	(original)
+++ branches/uri/src/trackerd/tracker-main.c	Mon Nov 17 15:28:59 2008
@@ -474,7 +474,7 @@
 	g_free (filename);
 
 	/* Remove existing log files */
-	tracker_file_unlink (private->log_filename);
+	g_unlink (private->log_filename);
 }
 
 static gboolean

Modified: branches/uri/tests/libtracker-common/tracker-file-utils-test.c
==============================================================================
--- branches/uri/tests/libtracker-common/tracker-file-utils-test.c	(original)
+++ branches/uri/tests/libtracker-common/tracker-file-utils-test.c	Mon Nov 17 15:28:59 2008
@@ -173,7 +173,7 @@
 	dir = g_file_new_for_path (dir_name);
 	g_file_make_directory (dir, NULL, NULL);
 
-	result = tracker_file_get_mime_type (dir_name);
+	result = tracker_file_get_mime_type (dir);
 
 	g_assert (tracker_test_helpers_cmpstr_equal (result, "inode/directory"));
 
@@ -183,55 +183,6 @@
 	g_free (dir_name);
 }
 
-static void
-test_file_get_path_and_name ()
-{
-
-	gchar *name = NULL;
-	gchar *path = NULL;
-
-	tracker_file_get_path_and_name ("/home/ivan/test/file.txt",
-					&path,
-					&name);
-
-	g_assert_cmpint (g_strcmp0 (name, "file.txt"), ==, 0);
-	g_assert_cmpint (g_strcmp0 (path, "/home/ivan/test"), ==, 0);
-
-	g_free (name);
-	g_free (path);
-	name = NULL;
-	path = NULL;
-
-	tracker_file_get_path_and_name ("/home/ivan//test/file.txt",
-					&path,
-					&name);
-
-	g_assert_cmpint (g_strcmp0 (name, "file.txt"), ==, 0);
-	g_assert_cmpint (g_strcmp0 (path, "/home/ivan/test"), ==, 0);
-
-	g_free (name);
-	g_free (path);
-	name = NULL;
-	path = NULL;
-/*
- *	TODO: Fix this case
- *
-	tracker_file_get_path_and_name ("file:///home/ivan//test/file.txt",
-					&path,
-					&name);
-
-	g_assert_cmpint (g_strcmp0 (name, "file.txt"), ==, 0);
-	g_print ("%s\n", path);
-	g_assert_cmpint (g_strcmp0 (path, "file:///home/ivan/test"), ==, 0);
-
-	g_free (name);
-	g_free (path);
-	name = NULL;
-	path = NULL;
-*/
-
-}
-
 int
 main (int argc, char **argv)
 {
@@ -250,9 +201,6 @@
 	g_test_add_func ("/tracker/libtracker-common/tracker-file-utils/file_get_mime_type",
 			 test_file_get_mime_type);
 
-	g_test_add_func ("/libtracker_common/tracker-file-utils/file_get_path_and_name",
-			 test_file_get_path_and_name);
-
 	result = g_test_run ();
 
 	return result;



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