diff options
author | Gaël Bonithon <gael@xfce.org> | 2021-12-26 00:06:34 +0100 |
---|---|---|
committer | Gaël Bonithon <gael@xfce.org> | 2021-12-26 18:30:04 +0100 |
commit | 49ffba98d7cf9626a1470bc49a53596300fe3550 (patch) | |
tree | 617a9acf683f60bcda0faa8446cacbefc8d423dc | |
parent | ef518751bd744a48a165dc7c285f98b960c64a75 (diff) | |
download | tumbler-49ffba98d7cf9626a1470bc49a53596300fe3550.tar.gz |
Error handling: Fit to the spec and complete message if needed
A parameter is added to Tumbler's internal error signals to account for
the error domain, and the error code `TUMBLER_ERROR_OTHER_ERROR_DOMAIN`
is added to indicate that the error originated from a third-party API.
When sending the error signal via D-Bus, cancelling errors are filtered
out, and when the error originates from a third-party API, the error
message is prefixed with the domain and code of that error, in a
possibly parsable format.
Fixes #49.
21 files changed, 116 insertions, 59 deletions
diff --git a/plugins/cover-thumbnailer/cover-thumbnailer.c b/plugins/cover-thumbnailer/cover-thumbnailer.c index 4758dee..e1448b0 100644 --- a/plugins/cover-thumbnailer/cover-thumbnailer.c +++ b/plugins/cover-thumbnailer/cover-thumbnailer.c @@ -673,7 +673,7 @@ cover_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { g_signal_emit_by_name (thumbnailer, "error", uri, - error->code, error->message); + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/desktop-thumbnailer/desktop-thumbnailer.c b/plugins/desktop-thumbnailer/desktop-thumbnailer.c index 7304ea6..96e357e 100644 --- a/plugins/desktop-thumbnailer/desktop-thumbnailer.c +++ b/plugins/desktop-thumbnailer/desktop-thumbnailer.c @@ -393,7 +393,8 @@ desktop_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c index f2edf1e..3b3494e 100644 --- a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c +++ b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c @@ -163,7 +163,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* there was an error, emit error signal */ g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, TUMBLER_ERROR_MESSAGE_CREATION_FAILED); - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); return; @@ -194,7 +195,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* there was an error, emit error signal */ g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT, TUMBLER_ERROR_MESSAGE_CREATION_FAILED); - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); /* clean up */ @@ -209,7 +211,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* there was an error, emit error signal */ g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT, TUMBLER_ERROR_MESSAGE_CREATION_FAILED); - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); /* clean up */ @@ -228,7 +231,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* there was an error, emit error signal */ g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT, TUMBLER_ERROR_MESSAGE_CREATION_FAILED); - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); /* clean up */ @@ -245,7 +249,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (v_pixbuf == NULL) { /* emit an error signal */ - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); /* clean up */ @@ -277,7 +282,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { /* emit an error signal */ - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/font-thumbnailer/font-thumbnailer.c b/plugins/font-thumbnailer/font-thumbnailer.c index f9ed136..a816cdf 100644 --- a/plugins/font-thumbnailer/font-thumbnailer.c +++ b/plugins/font-thumbnailer/font-thumbnailer.c @@ -429,7 +429,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* there was an error in the freetype initialization, abort */ error_msg = g_strdup_printf (_("Could not initialize freetype: %s"), ft_strerror (font_thumbnailer->library_error)); - g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_UNSUPPORTED, error_msg); + g_signal_emit_by_name (thumbnailer, "error", uri, + TUMBLER_ERROR, TUMBLER_ERROR_UNSUPPORTED, error_msg); g_free (error_msg); return; } @@ -441,7 +442,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* there was an error, emit error signal */ error_msg = g_strdup_printf (_("Could not load file contents: %s"), error->message); - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error_msg); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error_msg); g_free (error_msg); /* clean up */ @@ -460,7 +462,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* the font file could not be loaded, emit an error signal */ error_msg = g_strdup_printf (_("Could not open font file: %s"), ft_strerror (ft_error)); - g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_NO_CONTENT, error_msg); + g_signal_emit_by_name (thumbnailer, "error", uri, + TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, error_msg); g_free (error_msg); /* clean up */ @@ -485,7 +488,7 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, error_msg = g_strdup_printf (_("Could not set the character map: %s"), ft_strerror (ft_error)); g_signal_emit_by_name (thumbnailer, "error", uri, - TUMBLER_ERROR_INVALID_FORMAT, error_msg); + TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT, error_msg); g_free (error_msg); /* clean up */ @@ -512,7 +515,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* emit an error signal */ error_msg = g_strdup_printf (_("Could not render glyphs: %s"), ft_strerror (ft_error)); - g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_INVALID_FORMAT, error_msg); + g_signal_emit_by_name (thumbnailer, "error", uri, + TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT, error_msg); g_free (error_msg); /* clean up */ @@ -543,7 +547,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { /* emit an error signal */ - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/gepub-thumbnailer/gepub-thumbnailer.c b/plugins/gepub-thumbnailer/gepub-thumbnailer.c index 98062c7..9b65762 100644 --- a/plugins/gepub-thumbnailer/gepub-thumbnailer.c +++ b/plugins/gepub-thumbnailer/gepub-thumbnailer.c @@ -170,7 +170,7 @@ gepub_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { g_signal_emit_by_name (thumbnailer, "error", uri, - error->code, error->message); + error->domain, error->code, error->message); g_error_free (error); g_object_unref (file); @@ -184,7 +184,7 @@ gepub_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (cover_mime == NULL) { g_signal_emit_by_name (thumbnailer, "error", uri, - TUMBLER_ERROR_NO_CONTENT, + TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, "Cover not found"); g_free (cover); @@ -228,8 +228,8 @@ gepub_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, - error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/gst-thumbnailer/gst-thumbnailer.c b/plugins/gst-thumbnailer/gst-thumbnailer.c index d68a3cb..461471b 100644 --- a/plugins/gst-thumbnailer/gst-thumbnailer.c +++ b/plugins/gst-thumbnailer/gst-thumbnailer.c @@ -546,7 +546,8 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* there was an error, emit error signal */ g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, TUMBLER_ERROR_MESSAGE_CREATION_FAILED); - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); return; @@ -607,7 +608,8 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else @@ -622,7 +624,8 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, TUMBLER_ERROR_MESSAGE_CREATION_FAILED); - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } diff --git a/plugins/jpeg-thumbnailer/jpeg-thumbnailer.c b/plugins/jpeg-thumbnailer/jpeg-thumbnailer.c index bf5c0d3..9df8224 100644 --- a/plugins/jpeg-thumbnailer/jpeg-thumbnailer.c +++ b/plugins/jpeg-thumbnailer/jpeg-thumbnailer.c @@ -928,7 +928,8 @@ jpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/odf-thumbnailer/odf-thumbnailer.c b/plugins/odf-thumbnailer/odf-thumbnailer.c index ff47bfc..7e62d1d 100644 --- a/plugins/odf-thumbnailer/odf-thumbnailer.c +++ b/plugins/odf-thumbnailer/odf-thumbnailer.c @@ -300,7 +300,8 @@ odf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, input = gsf_input_gio_new (file, &error); if (G_UNLIKELY (input == NULL)) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); g_object_unref (file); return; @@ -353,7 +354,8 @@ odf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c index 6395d7f..8ee8364 100644 --- a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c +++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c @@ -218,8 +218,8 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (stream == NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, - error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); return; @@ -239,8 +239,8 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (pixbuf == NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, - error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); g_object_unref (thumbnail); @@ -263,7 +263,8 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/poppler-thumbnailer/poppler-thumbnailer.c b/plugins/poppler-thumbnailer/poppler-thumbnailer.c index 8ee1083..e8aee20 100644 --- a/plugins/poppler-thumbnailer/poppler-thumbnailer.c +++ b/plugins/poppler-thumbnailer/poppler-thumbnailer.c @@ -259,7 +259,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* try to load the file contents using GIO */ if (!g_file_load_contents (file, cancellable, &contents, &length, NULL, &error)) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); g_object_unref (file); return; @@ -281,7 +282,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* emit an error if both ways to load the document failed */ if (document == NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); poppler_thumbnailer_free (contents); return; @@ -290,7 +292,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, /* check if the document has content (= at least one page) */ if (poppler_document_get_n_pages (document) <= 0) { - g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_NO_CONTENT, + g_signal_emit_by_name (thumbnailer, "error", uri, + TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, _("The document is empty")); g_object_unref (document); poppler_thumbnailer_free (contents); @@ -302,7 +305,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (page == NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_NO_CONTENT, + g_signal_emit_by_name (thumbnailer, "error", uri, + TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, _("First page of the document could not be read")); g_object_unref (document); poppler_thumbnailer_free (contents); @@ -353,7 +357,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/plugins/raw-thumbnailer/raw-thumbnailer.c b/plugins/raw-thumbnailer/raw-thumbnailer.c index 92ac01d..962736a 100644 --- a/plugins/raw-thumbnailer/raw-thumbnailer.c +++ b/plugins/raw-thumbnailer/raw-thumbnailer.c @@ -178,7 +178,8 @@ raw_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, + error->domain, error->code, error->message); g_error_free (error); } else diff --git a/tumbler/tumbler-error.h b/tumbler/tumbler-error.h index 036a7b8..938c67c 100644 --- a/tumbler/tumbler-error.h +++ b/tumbler/tumbler-error.h @@ -63,6 +63,7 @@ typedef enum /*< enum >*/ TUMBLER_ERROR_UNSUPPORTED_FLAVOR, TUMBLER_ERROR_NO_CONTENT, TUMBLER_ERROR_SHUTTING_DOWN, + TUMBLER_ERROR_OTHER_ERROR_DOMAIN, } TumblerErrorEnum; G_END_DECLS diff --git a/tumbler/tumbler-marshal.list b/tumbler/tumbler-marshal.list index 4a83ff1..acacac6 100644 --- a/tumbler/tumbler-marshal.list +++ b/tumbler/tumbler-marshal.list @@ -1,7 +1,4 @@ -VOID:STRING,INT,STRING -VOID:UINT,STRING,INT,STRING -VOID:UINT,BOXED,INT,STRING,STRING -VOID:STRING,INT,STRING +VOID:STRING,UINT,INT,STRING +VOID:UINT,BOXED,UINT,INT,STRING,STRING VOID:UINT,BOXED,STRING VOID:UINT,STRING -VOID:UINT,POINTER,INT,STRING diff --git a/tumbler/tumbler-thumbnailer.c b/tumbler/tumbler-thumbnailer.c index 67f0fc8..27d3177 100644 --- a/tumbler/tumbler-thumbnailer.c +++ b/tumbler/tumbler-thumbnailer.c @@ -114,10 +114,11 @@ tumbler_thumbnailer_default_init (TumblerThumbnailerIface *klass) G_STRUCT_OFFSET (TumblerThumbnailerIface, error), NULL, NULL, - tumbler_marshal_VOID__STRING_INT_STRING, + tumbler_marshal_VOID__STRING_UINT_INT_STRING, G_TYPE_NONE, - 3, + 4, G_TYPE_STRING, + G_TYPE_UINT, G_TYPE_INT, G_TYPE_STRING); diff --git a/tumbler/tumbler-thumbnailer.h b/tumbler/tumbler-thumbnailer.h index 285626e..b983d4e 100644 --- a/tumbler/tumbler-thumbnailer.h +++ b/tumbler/tumbler-thumbnailer.h @@ -50,6 +50,7 @@ struct _TumblerThumbnailerIface const gchar *uri); void (*error) (TumblerThumbnailer *thumbnailer, const gchar *failed_uri, + GQuark error_domain, gint error_code, const gchar *message); void (*unregister) (TumblerThumbnailer *thumbnailer); diff --git a/tumblerd/tumbler-group-scheduler.c b/tumblerd/tumbler-group-scheduler.c index ad6bda5..f756f7a 100644 --- a/tumblerd/tumbler-group-scheduler.c +++ b/tumblerd/tumbler-group-scheduler.c @@ -75,6 +75,7 @@ static void tumbler_group_scheduler_thread (gpointer gpointer user_data); static void tumbler_group_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer, const gchar *failed_uri, + GQuark error_domain, gint error_code, const gchar *message, GList **uri_errors); @@ -105,6 +106,7 @@ struct _TumblerGroupScheduler struct _UriError { guint error_code; + GQuark error_domain; gchar *message; gchar *failed_uri; }; @@ -373,12 +375,14 @@ tumbler_group_scheduler_dequeue_request (TumblerSchedulerRequest *request, static UriError * uri_error_new (gint code, + GQuark domain, const gchar *uri, const gchar *message) { UriError *error; error = g_slice_new0 (UriError); + error->error_domain = domain; error->error_code = code; error->failed_uri = g_strdup (uri); error->message = g_strdup (message); @@ -422,6 +426,7 @@ tumbler_group_scheduler_thread (gpointer data, GList *lp; guint n; gint error_code = 0; + GQuark error_domain = 0; g_return_if_fail (TUMBLER_IS_GROUP_SCHEDULER (scheduler)); g_return_if_fail (request != NULL); @@ -585,8 +590,11 @@ tumbler_group_scheduler_thread (gpointer data, uri_error = iter->data; /* we use the error code of the first failed URI */ - if (iter == uri_errors) - error_code = uri_error->error_code; + if (iter == uri_errors) + { + error_domain = uri_error->error_domain; + error_code = uri_error->error_code; + } if (uri_error->message != NULL) { @@ -607,7 +615,7 @@ tumbler_group_scheduler_thread (gpointer data, /* forward the error signal */ g_signal_emit_by_name (request->scheduler, "error", request->handle, - failed_uris, error_code, message->str, + failed_uris, error_domain, error_code, message->str, request->origin); /* free the failed URIs array. Its contents are owned by the URI errors */ @@ -655,6 +663,7 @@ tumbler_group_scheduler_thread (gpointer data, static void tumbler_group_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer, const gchar *failed_uri, + GQuark error_domain, gint error_code, const gchar *message, GList **uri_errors) @@ -667,7 +676,7 @@ tumbler_group_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer, g_return_if_fail (uri_errors != NULL); /* allocate a new URI error */ - error = uri_error_new (error_code, failed_uri, message); + error = uri_error_new (error_code, error_domain, failed_uri, message); /* add the error to the list */ *uri_errors = g_list_prepend (*uri_errors, error); diff --git a/tumblerd/tumbler-lifo-scheduler.c b/tumblerd/tumbler-lifo-scheduler.c index ce09930..e19d811 100644 --- a/tumblerd/tumbler-lifo-scheduler.c +++ b/tumblerd/tumbler-lifo-scheduler.c @@ -71,6 +71,7 @@ static void tumbler_lifo_scheduler_thread (gpointer gpointer user_data); static void tumbler_lifo_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer, const gchar *failed_uri, + GQuark error_domain, gint error_code, const gchar *message, TumblerSchedulerRequest *request); @@ -515,6 +516,7 @@ tumbler_lifo_scheduler_thread (gpointer data, static void tumbler_lifo_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer, const gchar *failed_uri, + GQuark error_domain, gint error_code, const gchar *message, TumblerSchedulerRequest *request) @@ -528,7 +530,7 @@ tumbler_lifo_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer, /* forward the error signal */ g_signal_emit_by_name (request->scheduler, "error", request->handle, failed_uris, - error_code, message, request->origin); + error_domain, error_code, message, request->origin); } diff --git a/tumblerd/tumbler-scheduler.c b/tumblerd/tumbler-scheduler.c index d15dfa1..2110bc2 100644 --- a/tumblerd/tumbler-scheduler.c +++ b/tumblerd/tumbler-scheduler.c @@ -99,11 +99,12 @@ tumbler_scheduler_default_init (TumblerSchedulerIface *klass) G_STRUCT_OFFSET (TumblerSchedulerIface, error), NULL, NULL, - tumbler_marshal_VOID__UINT_BOXED_INT_STRING_STRING, + tumbler_marshal_VOID__UINT_BOXED_UINT_INT_STRING_STRING, G_TYPE_NONE, - 5, + 6, G_TYPE_UINT, G_TYPE_STRV, + G_TYPE_UINT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING); diff --git a/tumblerd/tumbler-scheduler.h b/tumblerd/tumbler-scheduler.h index 6f50a00..6423166 100644 --- a/tumblerd/tumbler-scheduler.h +++ b/tumblerd/tumbler-scheduler.h @@ -46,6 +46,7 @@ struct _TumblerSchedulerIface void (*error) (TumblerScheduler *scheduler, guint32 handle, const gchar *const *failed_uris, + GQuark error_domain, gint error_code, const gchar *message); void (*finished) (TumblerScheduler *scheduler, diff --git a/tumblerd/tumbler-service.c b/tumblerd/tumbler-service.c index 94f06b5..8e6fbf1 100644 --- a/tumblerd/tumbler-service.c +++ b/tumblerd/tumbler-service.c @@ -95,6 +95,7 @@ static gboolean tumbler_service_get_flavors_cb (TumblerExportedService *skelet static void tumbler_service_scheduler_error (TumblerScheduler *scheduler, guint32 handle, const gchar *const *failed_uris, + GQuark error_domain, gint error_code, const gchar *message, const gchar *origin, @@ -425,6 +426,7 @@ static void tumbler_service_scheduler_error (TumblerScheduler *scheduler, guint32 handle, const gchar *const *failed_uris, + GQuark error_domain, gint error_code, const gchar *message, const gchar *origin, @@ -437,20 +439,34 @@ tumbler_service_scheduler_error (TumblerScheduler *scheduler, g_return_if_fail (message != NULL && *message != '\0'); g_return_if_fail (origin != NULL && *origin != '\0'); g_return_if_fail (TUMBLER_IS_SERVICE (service)); - - g_debug ("Error signal for job %d: Code %d, message: %s", - handle, error_code, message); - tumbler_util_dump_strv (G_LOG_DOMAIN, "URIs", failed_uris); + + /* request cancelled at some level after being handled by the thumbnailer: no signal, + * just as if it had been cancelled before */ + if (error_domain == G_IO_ERROR && error_code == G_IO_ERROR_CANCELLED) + return; info = g_slice_new0 (SchedulerIdleInfo); info->scheduler = g_object_ref (scheduler); info->handle = handle; info->uris = g_strdupv ((gchar **)failed_uris); - info->error_code = error_code; - info->message = g_strdup (message); info->origin = g_strdup (origin); info->service = g_object_ref (service); + if (error_domain == TUMBLER_ERROR) + { + info->error_code = error_code; + info->message = g_strdup (message); + } + else + { + info->error_code = TUMBLER_ERROR_OTHER_ERROR_DOMAIN; + info->message = g_strdup_printf ("(%s error, code %d) %s", + g_quark_to_string (error_domain), error_code, message); + } + + g_debug ("Error signal for job %d: Code %d, message: %s", + handle, info->error_code, info->message); + tumbler_util_dump_strv (G_LOG_DOMAIN, "URIs", failed_uris); g_idle_add (tumbler_service_error_idle, info); } @@ -783,7 +799,7 @@ tumbler_service_queue_cb (TumblerExportedService *skeleton, service); /* emit an error signal */ - tumbler_service_scheduler_error (scheduler, handle, uris, + tumbler_service_scheduler_error (scheduler, handle, uris, TUMBLER_ERROR, TUMBLER_ERROR_UNSUPPORTED_FLAVOR, TUMBLER_ERROR_MESSAGE_UNSUPPORTED_FLAVOR, scheduler_request->origin, diff --git a/tumblerd/tumbler-specialized-thumbnailer.c b/tumblerd/tumbler-specialized-thumbnailer.c index 01d9cee..85d18dd 100644 --- a/tumblerd/tumbler-specialized-thumbnailer.c +++ b/tumblerd/tumbler-specialized-thumbnailer.c @@ -361,7 +361,8 @@ thumbnailer_proxy_g_signal_cb (GDBusProxy *proxy, g_variant_get (parameters, "(u&si&s)", &handle, &uri, &error_code, &error_msg); if (info->handle == handle) { - g_signal_emit_by_name (info->thumbnailer, "error", uri, error_code, error_msg); + g_signal_emit_by_name (info->thumbnailer, "error", uri, + TUMBLER_ERROR, error_code, error_msg); } } } @@ -436,7 +437,8 @@ tumbler_specialized_thumbnailer_create (TumblerThumbnailer *thumbnailer, if (!g_cond_wait_until (&sinfo.condition, &sinfo.mutex, end_time)) { message = g_strdup (_("Failed to call the specialized thumbnailer: timeout")); - g_signal_emit_by_name (thumbnailer, "error", uri, 1, message); + g_signal_emit_by_name (thumbnailer, "error", uri, + TUMBLER_ERROR, TUMBLER_ERROR_CONNECTION_ERROR, message); g_free (message); } } @@ -446,7 +448,8 @@ tumbler_specialized_thumbnailer_create (TumblerThumbnailer *thumbnailer, { message = g_strdup_printf (_("Failed to call the specialized thumbnailer: %s"), error->message); - g_signal_emit_by_name (thumbnailer, "error", uri, 1, message); + g_signal_emit_by_name (thumbnailer, "error", uri, + TUMBLER_ERROR, TUMBLER_ERROR_CONNECTION_ERROR, message); g_free (message); g_clear_error (&error); } |