tracker r2417 - in trunk: . src/tracker-indexer



Author: pvanhoof
Date: Thu Oct 23 14:40:29 2008
New Revision: 2417
URL: http://svn.gnome.org/viewvc/tracker?rev=2417&view=rev

Log:
2008-10-23  Philip Van Hoof  <philip codeminded be>

	* src/tracker-indexer/tracker-metadata-utils.c
	* src/tracker-indexer/tracker-dbus.c
	* src/tracker-indexer/tracker-dbus.h: Fixes for requesting thumbnails



Modified:
   trunk/ChangeLog
   trunk/src/tracker-indexer/tracker-dbus.c
   trunk/src/tracker-indexer/tracker-dbus.h
   trunk/src/tracker-indexer/tracker-metadata-utils.c

Modified: trunk/src/tracker-indexer/tracker-dbus.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-dbus.c	(original)
+++ trunk/src/tracker-indexer/tracker-dbus.c	Thu Oct 23 14:40:29 2008
@@ -31,9 +31,13 @@
 #define THUMBNAILER_PATH	 "/org/freedesktop/thumbnailer/Generic"
 #define THUMBNAILER_INTERFACE	 "org.freedesktop.thumbnailer.Generic"
 
+#define THUMBMAN_PATH		 "/org/freedesktop/thumbnailer/Manager"
+#define THUMBMAN_INTERFACE	 "org.freedesktop.thumbnailer.Manager"
+
 static DBusGConnection *connection;
 static DBusGProxy      *proxy;
 static DBusGProxy      *thumb_proxy;
+static DBusGProxy      *thumbm_proxy;
 
 static gboolean
 dbus_register_service (DBusGProxy  *proxy,
@@ -113,6 +117,12 @@
 	return thumb_proxy;
 }
 
+DBusGProxy*
+tracker_dbus_get_thumb_manager (void)
+{
+	return thumbm_proxy;
+}
+
 static gboolean
 dbus_register_names (void)
 {
@@ -154,6 +164,11 @@
 						 THUMBNAILER_SERVICE,
 						 THUMBNAILER_PATH,
 						 THUMBNAILER_INTERFACE);
+
+	thumbm_proxy = dbus_g_proxy_new_for_name (connection,
+						 THUMBNAILER_SERVICE,
+						 THUMBMAN_PATH,
+						 THUMBMAN_INTERFACE);
 	return TRUE;
 }
 

Modified: trunk/src/tracker-indexer/tracker-dbus.h
==============================================================================
--- trunk/src/tracker-indexer/tracker-dbus.h	(original)
+++ trunk/src/tracker-indexer/tracker-dbus.h	Thu Oct 23 14:40:29 2008
@@ -28,10 +28,11 @@
 
 G_BEGIN_DECLS
 
-gboolean    tracker_dbus_init		  (void);
-void	    tracker_dbus_shutdown	  (void);
-gboolean    tracker_dbus_register_object  (GObject *object);
-DBusGProxy* tracker_dbus_get_thumbnailer  (void);
+gboolean    tracker_dbus_init		   (void);
+void	    tracker_dbus_shutdown	   (void);
+gboolean    tracker_dbus_register_object   (GObject *object);
+DBusGProxy* tracker_dbus_get_thumbnailer   (void);
+DBusGProxy* tracker_dbus_get_thumb_manager (void);
 
 G_END_DECLS
 

Modified: trunk/src/tracker-indexer/tracker-metadata-utils.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-metadata-utils.c	(original)
+++ trunk/src/tracker-indexer/tracker-metadata-utils.c	Thu Oct 23 14:40:29 2008
@@ -647,31 +647,68 @@
 
 #endif /* HAVE_HILDON_THUMBNAIL */
 
+static gboolean
+thumbnail_this (GStrv list, const gchar *mime)
+{
+	guint i = 0;
+	gboolean retval = FALSE;
+
+	if (!list)
+		return TRUE;
+
+	while (list[i] != NULL && !retval) {
+		if (g_ascii_strcasecmp (list[i], mime) == 0)
+			retval = TRUE;
+		i++;
+	}
+
+	return retval;
+}
+
 static void
 get_file_thumbnail (const gchar *path,
 		    const gchar *mime)
 {
 #ifdef HAVE_HILDON_THUMBNAIL
+
+	static guint    count = 0;
+	static gboolean tried = FALSE;
+
+	/* It's known that these 51 * 2 lists of strings are leaked at least
+	 * once at the end of the process. */
+
 	static gchar   *batch[51];
 	static gchar   *hints[51];
-	static guint	count = 0;
-	static gboolean not_available = FALSE;
 
-	if (not_available) {
-		return;
+	/* It's known that this relatively small GStrv is leaked */
+	static GStrv    thumbnailable = NULL;
+
+	if (!tried) {
+		GStrv mimes = NULL;
+		GError *error = NULL;
+
+		dbus_g_proxy_call (tracker_dbus_get_thumb_manager(),
+				   "GetSupported", &error, G_TYPE_INVALID,
+				   G_TYPE_STRV, &mimes, G_TYPE_INVALID);
+		if (error)
+			g_error_free (error);
+		else if (mimes)
+			thumbnailable = mimes;
+		tried = TRUE;
 	}
 
-	if (count < 51) {
+	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] = 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++;
 		}
 	}



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