tracker r2120 - in branches/indexer-split: . src src/libtracker-common src/xdgmime



Author: carlosg
Date: Wed Aug 20 16:12:20 2008
New Revision: 2120
URL: http://svn.gnome.org/viewvc/tracker?rev=2120&view=rev

Log:
2008-08-20  Carlos Garnacho  <carlos imendio com>

        * src/libtracker-common/tracker-file-utils.c
        (tracker_file_get_mime_type): Replace mimetype checking with GIO.
        * configure.in:
        * src/Makefile.am:
        * src/xdgmime/*: Nuked the local xdgmime copy.


Removed:
   branches/indexer-split/src/xdgmime/Makefile.am
   branches/indexer-split/src/xdgmime/fnmatch.c
   branches/indexer-split/src/xdgmime/fnmatch.h
   branches/indexer-split/src/xdgmime/safe-ctype.c
   branches/indexer-split/src/xdgmime/safe-ctype.h
   branches/indexer-split/src/xdgmime/xdgmime.c
   branches/indexer-split/src/xdgmime/xdgmime.h
   branches/indexer-split/src/xdgmime/xdgmimealias.c
   branches/indexer-split/src/xdgmime/xdgmimealias.h
   branches/indexer-split/src/xdgmime/xdgmimecache.c
   branches/indexer-split/src/xdgmime/xdgmimecache.h
   branches/indexer-split/src/xdgmime/xdgmimeglob.c
   branches/indexer-split/src/xdgmime/xdgmimeglob.h
   branches/indexer-split/src/xdgmime/xdgmimeint.c
   branches/indexer-split/src/xdgmime/xdgmimeint.h
   branches/indexer-split/src/xdgmime/xdgmimemagic.c
   branches/indexer-split/src/xdgmime/xdgmimemagic.h
   branches/indexer-split/src/xdgmime/xdgmimeparent.c
   branches/indexer-split/src/xdgmime/xdgmimeparent.h
Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/configure.ac
   branches/indexer-split/src/Makefile.am
   branches/indexer-split/src/libtracker-common/tracker-file-utils.c

Modified: branches/indexer-split/configure.ac
==============================================================================
--- branches/indexer-split/configure.ac	(original)
+++ branches/indexer-split/configure.ac	Wed Aug 20 16:12:20 2008
@@ -983,7 +983,6 @@
 	src/tracker-search-tool/tracker-search-tool.desktop.in
 	src/tracker-thumbnailer/Makefile
 	src/tracker-utils/Makefile
-	src/xdgmime/Makefile
 	tests/common/Makefile
 	tests/libtracker-common/Makefile
 	tests/libtracker-db/Makefile

Modified: branches/indexer-split/src/Makefile.am
==============================================================================
--- branches/indexer-split/src/Makefile.am	(original)
+++ branches/indexer-split/src/Makefile.am	Wed Aug 20 16:12:20 2008
@@ -24,7 +24,6 @@
 
 SUBDIRS = 					\
 	libstemmer				\
-	xdgmime					\
 	$(build_qdbm)				\
 	$(build_libinotify)			\
 	libtracker-common 			\

Modified: branches/indexer-split/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-file-utils.c	(original)
+++ branches/indexer-split/src/libtracker-common/tracker-file-utils.c	Wed Aug 20 16:12:20 2008
@@ -32,8 +32,6 @@
 #include <glib.h>
 #include <gio/gio.h>
 
-#include <xdgmime/xdgmime.h>
-
 #include "tracker-log.h"
 #include "tracker-os-dependant.h"
 #include "tracker-file-utils.h"
@@ -296,56 +294,36 @@
 }
 
 gchar *
-tracker_file_get_mime_type (const gchar *uri)
+tracker_file_get_mime_type (const gchar *path)
 {
-	struct stat  finfo;
-	gchar	    *str;
-	const gchar *result;
-	gchar       *mime_type;
-
-	if (!tracker_file_is_valid (uri)) {
-		g_message ("URI:'%s' is no longer valid", 
-			   uri);
-		return g_strdup ("unknown");
-	}
+	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,
+				  NULL, &error);
+
+	if (error) {
+		g_warning ("Error guessing mimetype for '%s': %s\n", path, error->message);
+		g_error_free (error);
 
-	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 g_strdup ("unknown");
 	}
 
-	g_lstat (str, &finfo);
-
-	if (S_ISLNK (finfo.st_mode) && S_ISDIR (finfo.st_mode)) {
-	        g_free (str);
-		return g_strdup ("symlink");
-	}
+	content_type = g_strdup (g_file_info_get_content_type (info));
 
-	/* Handle iso files as they can be mistaken for video files */
-	if (g_str_has_suffix (uri, ".iso")) {
-		return g_strdup ("application/x-cd-image");
-	}
-
-	result = xdg_mime_get_mime_type_for_file (uri, NULL);
+	g_object_unref (info);
+	g_object_unref (file);
 
-	if (!result || result == XDG_MIME_TYPE_UNKNOWN) {
-		if (is_text_file (str)) {
-			mime_type = g_strdup ("text/plain");
-		} else if (S_ISDIR (finfo.st_mode)) {
-			mime_type = g_strdup ("x-directory/normal");
-		} else {
-			mime_type = g_strdup ("unknown");
-		}
-	} else {
-		mime_type = g_strdup (result);
+	if (!content_type) {
+		return g_strdup ("unknown");
 	}
 
-	g_free (str);
-
-	return mime_type;
+	return content_type;
 }
 
 gchar *



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