[maemo-commits] [maemo-commits] r16491 - in projects/haf/trunk/hildon-thumbnail: . daemon daemon/plugins

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Oct 27 10:48:03 EET 2008
Author: pvanhoof
Date: 2008-10-27 10:47:59 +0200 (Mon, 27 Oct 2008)
New Revision: 16491

Modified:
   projects/haf/trunk/hildon-thumbnail/ChangeLog
   projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c
   projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.h
   projects/haf/trunk/hildon-thumbnail/daemon/plugin-runner.c
   projects/haf/trunk/hildon-thumbnail/daemon/plugin-runner.xml
   projects/haf/trunk/hildon-thumbnail/daemon/plugins/exec-plugin.c
   projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c
   projects/haf/trunk/hildon-thumbnail/daemon/plugins/gstreamer-video-plugin.c
   projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer-marshal.list
   projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c
   projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.xml
Log:
2008-10-27  Philip Van Hoof  <philip at codeminded.be>

	* daemon/hildon-thumbnail-plugin.h
	* daemon/plugins/gdkpixbuf-plugin.c
	* daemon/plugins/exec-plugin.c
	* daemon/plugins/gstreamer-video-plugin.c
	* daemon/plugin-runner.c
	* daemon/thumbnailer.c
	* daemon/plugin-runner.xml
	* daemon/thumbnailer-marshal.list
	* daemon/thumbnailer.xml
	* daemon/hildon-thumbnail-plugin.c: Improved error reporting, passing
	of failed_uris everywhere



Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-thumbnail/ChangeLog	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/ChangeLog	2008-10-27 08:47:59 UTC (rev 16491)
@@ -1,3 +1,17 @@
+2008-10-27  Philip Van Hoof  <philip at codeminded.be>
+
+	* daemon/hildon-thumbnail-plugin.h
+	* daemon/plugins/gdkpixbuf-plugin.c
+	* daemon/plugins/exec-plugin.c
+	* daemon/plugins/gstreamer-video-plugin.c
+	* daemon/plugin-runner.c
+	* daemon/thumbnailer.c
+	* daemon/plugin-runner.xml
+	* daemon/thumbnailer-marshal.list
+	* daemon/thumbnailer.xml
+	* daemon/hildon-thumbnail-plugin.c: Improved error reporting, passing
+	of failed_uris everywhere
+
 2008-10-24  Philip Van Hoof  <philip at codeminded.be>
 
 	* daemon/thumbnailer.c: Copying to removable devices in .localthumbs

Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c	2008-10-27 08:47:59 UTC (rev 16491)
@@ -78,14 +78,14 @@
 	}
 }
 
-typedef void (*CreateFunc) (GStrv uris, gchar *mime_hint, GError **error);
+typedef void (*CreateFunc) (GStrv uris, gchar *mime_hint, GStrv *failed_uris, GError **error);
 
 void 
-hildon_thumbnail_plugin_do_create (GModule *module, GStrv uris, gchar *mime_hint, GError **error)
+hildon_thumbnail_plugin_do_create (GModule *module, GStrv uris, gchar *mime_hint, GStrv *failed_uris, GError **error)
 {
 	CreateFunc func;
 	if (g_module_symbol (module, "hildon_thumbnail_plugin_create", (gpointer *) &func)) {
-		(func) (uris, mime_hint, error);
+		(func) (uris, mime_hint, failed_uris, error);
 	}
 }
 

Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.h
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.h	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.h	2008-10-27 08:47:59 UTC (rev 16491)
@@ -43,6 +43,7 @@
 void        hildon_thumbnail_plugin_do_create     (GModule *module, 
 						   GStrv uris, 
 						   gchar *mime_hint,
+						   GStrv *failed_uris, 
 						   GError **error);
 void        hildon_thumbnail_plugin_do_stop       (GModule *module);
 

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugin-runner.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugin-runner.c	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugin-runner.c	2008-10-27 08:47:59 UTC (rev 16491)
@@ -96,15 +96,20 @@
 {
 	DaemonPrivate *priv = DAEMON_GET_PRIVATE (object);
 	GError *error = NULL;
+	GStrv failed_uris = NULL;
 
 	keep_alive ();
 
-	hildon_thumbnail_plugin_do_create (priv->module, uris, mime_hint, &error);
+	hildon_thumbnail_plugin_do_create (priv->module, uris, mime_hint, &failed_uris, &error);
+
 	if (error) {
 		dbus_g_method_return_error (context, error);
 		g_error_free (error);
 	} else
-		dbus_g_method_return (context);
+		dbus_g_method_return (context, failed_uris);
+
+	if (failed_uris)
+		g_strfreev (failed_uris);
 }
 
 #include "plugin-runner-glue.h"

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugin-runner.xml
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugin-runner.xml	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugin-runner.xml	2008-10-27 08:47:59 UTC (rev 16491)
@@ -5,6 +5,7 @@
       <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="as" name="uris" direction="in" />
       <arg type="s" name="mime_hint" direction="in" />
+      <arg type="as" name="failed_uris" direction="out" />
     </method>
   </interface>
 </node>

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/exec-plugin.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugins/exec-plugin.c	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/exec-plugin.c	2008-10-27 08:47:59 UTC (rev 16491)
@@ -234,10 +234,11 @@
 
 
 void
-hildon_thumbnail_plugin_create (GStrv uris, gchar *mime_hint, GError **error)
+hildon_thumbnail_plugin_create (GStrv uris, gchar *mime_hint, GStrv *failed_uris, GError **error)
 {
 	guint i = 0;
 	GString *errors = NULL;
+	GList *failed = NULL;
 
 	while (uris[i] != NULL) {
 		gchar *uri = uris[i];
@@ -299,6 +300,7 @@
 			g_string_append_printf (errors, "[`%s': %s] ", 
 								    uri, nerror->message);
 			g_error_free (nerror);
+			failed = g_list_prepend (failed, g_strdup (uri));
 			nerror = NULL;
 		}
 
@@ -314,7 +316,24 @@
 		i++;
 	}
 
-	if (errors) {
+	if (errors && failed) {
+		guint t = 0;
+		GStrv furis = (GStrv) g_malloc0 (sizeof (gchar*) * (g_list_length (failed) + 1));
+		GList *copy = failed;
+
+		t = 0;
+
+		while (copy) {
+			furis[t] = copy->data;
+			copy = g_list_next (copy);
+			t++;
+		}
+		furis[t] = NULL;
+
+		*failed_uris = furis;
+
+		g_list_free (failed);
+
 		g_set_error (error, EXEC_ERROR, 0,
 			     errors->str);
 		g_string_free (errors, TRUE);

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c	2008-10-27 08:47:59 UTC (rev 16491)
@@ -206,10 +206,11 @@
 }
 
 void
-hildon_thumbnail_plugin_create (GStrv uris, gchar *mime_hint, GError **error)
+hildon_thumbnail_plugin_create (GStrv uris, gchar *mime_hint, GStrv *failed_uris, GError **error)
 {
 	guint i = 0;
 	GString *errors = NULL;
+	GList *failed = NULL;
 
 	while (uris[i] != NULL) {
 		GError *nerror = NULL;
@@ -324,6 +325,7 @@
 				errors = g_string_new ("");
 			g_string_append_printf (errors, "[`%s': %s] ", 
 								    uri, nerror->message);
+			failed = g_list_prepend (failed, g_strdup (uri));
 			g_error_free (nerror);
 			nerror = NULL;
 		}
@@ -343,7 +345,24 @@
 		i++;
 	}
 
-	if (errors) {
+	if (errors && failed) {
+		guint t = 0;
+		GStrv furis = (GStrv) g_malloc0 (sizeof (gchar*) * (g_list_length (failed) + 1));
+		GList *copy = failed;
+
+		t = 0;
+
+		while (copy) {
+			furis[t] = copy->data;
+			copy = g_list_next (copy);
+			t++;
+		}
+		furis[t] = NULL;
+
+		*failed_uris = furis;
+
+		g_list_free (failed);
+
 		g_set_error (error, DEFAULT_ERROR, 0,
 			     errors->str);
 		g_string_free (errors, TRUE);

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gstreamer-video-plugin.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gstreamer-video-plugin.c	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gstreamer-video-plugin.c	2008-10-27 08:47:59 UTC (rev 16491)
@@ -420,7 +420,7 @@
 }
 
 void
-hildon_thumbnail_plugin_create (GStrv uris, gchar *mime_hint, GError **error)
+hildon_thumbnail_plugin_create (GStrv uris, gchar *mime_hint, GStrv *failed_uris, GError **error)
 {
 	VideoThumbnailer *thumber;
 	gchar *large    = NULL;
@@ -428,6 +428,7 @@
 	gchar *cropped  = NULL;
 	guint i         = 0;
 	GString *errors = NULL;
+	GList *failed   = NULL;
 
 	while (uris[i] != NULL) {
 		GError *nerror = NULL;
@@ -465,6 +466,7 @@
 			g_string_append_printf (errors, "[`%s': %s] ", 
 						uris[i], nerror->message);
 			g_error_free (nerror);
+			failed = g_list_prepend (failed, g_strdup (uris[i]));
 			nerror = NULL;
 		}
 
@@ -475,7 +477,23 @@
 		i++;
 	}
 
-	if (errors) {
+	if (errors && failed) {
+		guint t = 0;
+		GStrv furis = (GStrv) g_malloc0 (sizeof (gchar*) * (g_list_length (failed) + 1));
+		GList *copy = failed;
+
+		t = 0;
+
+		while (copy) {
+			furis[t] = copy->data;
+			copy = g_list_next (copy);
+			t++;
+		}
+		furis[t] = NULL;
+
+		*failed_uris = furis;
+
+		g_list_free (failed);
 		g_set_error (error, GSTP_ERROR, 0,
 			     errors->str);
 		g_string_free (errors, TRUE);

Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer-marshal.list
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer-marshal.list	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer-marshal.list	2008-10-27 08:47:59 UTC (rev 16491)
@@ -1 +1 @@
-VOID:UINT,INT,STRING
+VOID:UINT,BOXED,INT,STRING

Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c	2008-10-27 08:47:59 UTC (rev 16491)
@@ -252,6 +252,45 @@
 	return found;
 }
 
+static GStrv
+subtract_strv (GStrv a, GStrv b)
+{
+	guint i = 0;
+	GList *newlist = NULL;
+	GStrv retval = NULL;
+
+	while (a[i] != NULL) {
+		guint y = 0;
+		gboolean found = FALSE;
+
+		while (b[y] != NULL) {
+			if (strcmp (a[i], b[y]) == 0) {
+				found = TRUE;
+				break;
+			}
+			y++;
+		}
+		if (found)
+			newlist = g_list_append (newlist, g_strdup (a[i]));
+		i++;
+	}
+
+	if (newlist) {
+		guint t = 0;
+		GList *copy = newlist;
+		retval = (GStrv) g_malloc0 (sizeof (gchar*) * (g_list_length (newlist) + 1));
+		while (copy) {
+			retval[t] = copy->data;
+			copy = g_list_next (copy);
+			t++;
+		}
+		retval[t] = NULL;
+		g_list_free (newlist);
+	}
+
+	return retval;
+}
+
 /* This is the threadpool's function. This means that everything we do is 
  * asynchronous wrt to the mainloop (we aren't blocking it). Because it all 
  * happens in a thread, we must care about proper locking, too.
@@ -298,7 +337,6 @@
 
 	i = 0;
 
-
 	while (urls[i] != NULL) {
 		gchar *mime_type = NULL;
 		gboolean has_thumb = FALSE;
@@ -321,10 +359,13 @@
 		g_free (cropped);
 
 		if (error) {
-			
+			GStrv oneurl = (GStrv) g_malloc0 (sizeof (gchar*) * 2);
+			oneurl[0] = g_strdup (urls[i]);
+			oneurl[1] = NULL;
 			g_signal_emit (task->object, signals[ERROR_SIGNAL],
-				       0, task->num, 1, error->message);
+				       0, task->num, oneurl, 1, error->message);
 			g_error_free (error);
+			g_strfreev (oneurl);
 		} else {
 			if (mime_type && !has_thumb) {
 				GList *urls_for_mime = g_hash_table_lookup (hash, mime_type);
@@ -350,6 +391,7 @@
 		i++;
 	}
 	cached_items[i] = NULL;
+
 	if (i > 0)
 		g_signal_emit (task->object, signals[READY_SIGNAL], 0,
 			       cached_items);
@@ -390,8 +432,10 @@
 		 * proxy the call */
 
 		proxy = thumbnail_manager_get_handler (priv->manager, mime_type);
+
 		if (proxy) {
 			GError *error = NULL;
+			GStrv failed_urls = NULL;
 
 			keep_alive ();
 
@@ -399,6 +443,7 @@
 					   G_TYPE_STRV, urlss,
 					   G_TYPE_STRING, mime_type,
 					   G_TYPE_INVALID, 
+					   G_TYPE_STRV, &failed_urls,
 					   G_TYPE_INVALID);
 
 			keep_alive ();
@@ -406,14 +451,26 @@
 			g_object_unref (proxy);
 
 			if (error) {
+				GStrv newlist = subtract_strv (urlss, failed_urls);
+
+				if (newlist) {
+					g_signal_emit (task->object, signals[READY_SIGNAL], 
+						       0, newlist);
+					g_strfreev (newlist);
+				}
+
 				g_signal_emit (task->object, signals[ERROR_SIGNAL],
-					       0, task->num, 1, error->message);
+					       0, task->num, failed_urls, 1, 
+					       error->message);
 				g_clear_error (&error);
+
 				had_err = TRUE;
-			} else
+			} else 
 				g_signal_emit (task->object, signals[READY_SIGNAL], 
 					       0, urlss);
 
+			if (failed_urls)
+				g_strfreev (failed_urls);
 
 		/* If not if we have a plugin that can handle it, we let the 
 		 * plugin have a go at it */
@@ -426,28 +483,45 @@
 
 			if (module) {
 				GError *error = NULL;
+				GStrv failed_urls = NULL;
 
 				keep_alive ();
 
-				hildon_thumbnail_plugin_do_create (module, urlss, mime_type, &error);
+				hildon_thumbnail_plugin_do_create (module, urlss, 
+								   mime_type, 
+								   &failed_urls, 
+								   &error);
 
 				keep_alive ();
 
 				if (error) {
+					GStrv newlist = subtract_strv (urlss, failed_urls);
+
+					if (newlist) {
+						g_signal_emit (task->object, signals[READY_SIGNAL], 
+							       0, newlist);
+						g_strfreev (newlist);
+					}
+
 					g_signal_emit (task->object, signals[ERROR_SIGNAL],
-						       0, task->num, 1, error->message);
+						       0, task->num, failed_urls, 1, 
+						       error->message);
 					g_clear_error (&error);
 					had_err = TRUE;
 				} else
 					g_signal_emit (task->object, signals[READY_SIGNAL], 
 						       0, urlss);
 
+				if (failed_urls)
+					g_strfreev (failed_urls);
+
 			/* And if even that is not the case, we are very sorry */
 
 			} else {
 				gchar *str = g_strdup_printf ("No handler for %s", (gchar*) key);
 				g_signal_emit (task->object, signals[ERROR_SIGNAL],
-						       0, task->num, 0, str);
+						       0, task->num, urlss, 0, str);
+				had_err = TRUE;
 				g_free (str);
 			}
 		}
@@ -461,8 +535,13 @@
 				guint z = 0;
 				GError *error = NULL;
 
-				hildon_thumbnail_util_get_thumb_paths (urlss[i], &from[0], &from[1], &from[2], 
-								       &to[0], &to[1], &to[2]);
+				hildon_thumbnail_util_get_thumb_paths (urlss[i], 
+								       &from[0], 
+								       &from[1], 
+								       &from[2], 
+								       &to[0], 
+								       &to[1], 
+								       &to[2]);
 
 				for (z = 0; z < 3 && !error; z++) {
 					GFile *from_file, *to_file;
@@ -770,7 +849,7 @@
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (ThumbnailerClass, error),
 			      NULL, NULL,
-			      thumbnailer_marshal_VOID__UINT_INT_STRING,
+			      thumbnailer_marshal_VOID__UINT_BOXED_INT_STRING,
 			      G_TYPE_NONE,
 			      3,
 			      G_TYPE_UINT,

Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.xml
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.xml	2008-10-24 13:28:59 UTC (rev 16490)
+++ projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.xml	2008-10-27 08:47:59 UTC (rev 16491)
@@ -29,6 +29,7 @@
 
     <signal name="Error">
       <arg type="u" name="handle" />
+      <arg type="as" name="failed_uris" />
       <arg type="i" name="error_code" />
       <arg type="s" name="message" />
     </signal>


More information about the maemo-commits mailing list