[maemo-commits] [maemo-commits] r15999 - projects/haf/branches/hildon-thumbnail/daemonize/daemon

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Sep 3 19:32:09 EEST 2008
Author: pvanhoof
Date: 2008-09-03 19:32:07 +0300 (Wed, 03 Sep 2008)
New Revision: 15999

Modified:
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.h
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.xml
Log:
Spec change

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c	2008-09-03 15:33:51 UTC (rev 15998)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c	2008-09-03 16:32:07 UTC (rev 15999)
@@ -100,6 +100,21 @@
 
 	g_mutex_lock (priv->mutex);
 
+	mime_proxy = g_hash_table_lookup (priv->handlers, 
+					  mime_type);
+
+	if (mime_proxy) {
+		GError *error = NULL;
+		g_set_error (&error, 
+			     DBUS_ERROR, 
+			     0,
+			     "MIME type already registered");
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
+		g_mutex_unlock (priv->mutex);
+		return;
+	}
+
 	sender = dbus_g_method_get_sender (context);
 
 	mime_proxy = dbus_g_proxy_new_for_name (priv->connection, sender, 
@@ -117,6 +132,8 @@
 			  object);
 
 	g_mutex_unlock (priv->mutex);
+
+	dbus_g_method_return (context);
 }
 
 static void

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c	2008-09-03 15:33:51 UTC (rev 15998)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c	2008-09-03 16:32:07 UTC (rev 15999)
@@ -97,7 +97,7 @@
 get_some_file_infos (const gchar *uri, gchar **mime_type, gboolean *has_thumb, GError **error)
 {
 	const gchar *content_type, *tp;
-	GFileInfo *info;
+	GFileInfo *info, *thumb_info = NULL;
 	GFile *file;
 
 	*mime_type = NULL;
@@ -110,16 +110,29 @@
 				  G_FILE_QUERY_INFO_NONE,
 				  NULL, error);
 
+	if (info)
+		thumb_info = g_object_ref (info);
+
+/*	thumb_info = g_file_query_info (file,
+					 G_FILE_ATTRIBUTE_THUMBNAIL_PATH,
+					 G_FILE_QUERY_INFO_NONE,
+					 NULL, NULL);
+*/
 	if (info) {
 		content_type = g_file_info_get_content_type (info);
+		*mime_type = content_type?g_strdup (content_type):g_strdup ("unknown/unknown");
+		g_object_unref (info);
+	}
+
+	if (thumb_info) {
 		tp	     = g_file_info_get_attribute_byte_string (info, 
 					G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
 		*has_thumb = tp?g_file_test (tp, G_FILE_TEST_EXISTS):FALSE;
-		*mime_type = content_type?g_strdup (content_type):g_strdup ("unknown/unknown");
 		// g_print ("T: %s\n", tp);
-		g_object_unref (info);
+		g_object_unref (thumb_info);
 	}
 
+
 	g_object_unref (file);
 }
 
@@ -160,7 +173,7 @@
 }
 
 void
-thumbnailer_queue (Thumbnailer *object, GStrv urls, DBusGMethodInvocation *context)
+thumbnailer_queue (Thumbnailer *object, GStrv urls, guint handle_to_unqueue, DBusGMethodInvocation *context)
 {
 	ThumbnailerPrivate *priv = THUMBNAILER_GET_PRIVATE (object);
 	WorkTask *task = g_slice_new (WorkTask);
@@ -174,6 +187,7 @@
 	task->urls = g_strdupv (urls);
 
 	g_mutex_lock (priv->mutex);
+	g_list_foreach (priv->tasks, (GFunc) mark_unqueued, (gpointer) handle_to_unqueue);
 	priv->tasks = g_list_prepend (priv->tasks, task);
 	g_thread_pool_push (priv->pool, task, NULL);
 	g_mutex_unlock (priv->mutex);
@@ -255,10 +269,9 @@
 		copy = g_list_next (copy);
 		i++;
 	}
-
 	cached_items[i] = NULL;
-
-	g_signal_emit (task->object, signals[READY_SIGNAL], 0,
+	if (i > 0)
+		g_signal_emit (task->object, signals[READY_SIGNAL], 0,
 			       cached_items);
 
 	g_list_free (thumb_items);
@@ -271,6 +284,7 @@
 
 	while (g_hash_table_iter_next (&iter, &key, &value)) {
 
+		gchar *mime_type = g_strdup (key);
 		GList *urlm = value, *copy = urlm;
 		GStrv urlss;
 		DBusGProxy *proxy;
@@ -295,7 +309,7 @@
 		/* If we have a third party thumbnailer for this mime-type, we
 		 * proxy the call */
 
-		proxy = manager_get_handler (priv->manager, key);
+		proxy = manager_get_handler (priv->manager, mime_type);
 		if (proxy) {
 			GError *error = NULL;
 
@@ -343,6 +357,7 @@
 			}
 		}
 
+		g_free (mime_type);
 		g_strfreev (urlss);
 	}
 

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.h
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.h	2008-09-03 15:33:51 UTC (rev 15998)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.h	2008-09-03 16:32:07 UTC (rev 15999)
@@ -56,7 +56,7 @@
 
 GType thumbnailer_get_type (void);
 
-void thumbnailer_queue (Thumbnailer *object, GStrv urls, DBusGMethodInvocation *context);
+void thumbnailer_queue (Thumbnailer *object, GStrv urls, guint handle_to_unqueue, DBusGMethodInvocation *context);
 void thumbnailer_unqueue (Thumbnailer *object, guint handle, DBusGMethodInvocation *context);
 void thumbnailer_move (Thumbnailer *object, GStrv from_urls, GStrv to_urls, DBusGMethodInvocation *context);
 void thumbnailer_copy (Thumbnailer *object, GStrv from_urls, GStrv to_urls, DBusGMethodInvocation *context);

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.xml
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.xml	2008-09-03 15:33:51 UTC (rev 15998)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.xml	2008-09-03 16:32:07 UTC (rev 15999)
@@ -5,6 +5,7 @@
     <method name="Queue">
       <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="as" name="uris" direction="in" />
+      <arg type="u" name="handle_to_unqueue" direction="out" />
       <arg type="u" name="handle" direction="out" />
     </method>
 


More information about the maemo-commits mailing list