[Xfce4-commits] <tumbler:master> Report unsupported flavors back to clients via an error signal.

Jannis Pohlmann noreply at xfce.org
Thu Jan 7 10:10:02 CET 2010


Updating branch refs/heads/master
         to e461ed713aee38e8e62fd66e0f8db71384a27eaf (commit)
       from 549c7b3bc44d2d67a94776bb49ce21a61d1aed28 (commit)

commit e461ed713aee38e8e62fd66e0f8db71384a27eaf
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Thu Jan 7 10:05:25 2010 +0100

    Report unsupported flavors back to clients via an error signal.
    
    Thanks to Philip for the original commit.

 tumbler/tumbler-cache.c     |    5 ++++-
 tumbler/tumbler-error.h     |    1 +
 tumbler/tumbler-file-info.c |    5 +++--
 tumblerd/tumbler-service.c  |   32 +++++++++++++++++++++++++++-----
 4 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/tumbler/tumbler-cache.c b/tumbler/tumbler-cache.c
index a131a92..cc554dd 100644
--- a/tumbler/tumbler-cache.c
+++ b/tumbler/tumbler-cache.c
@@ -91,9 +91,12 @@ tumbler_cache_get_thumbnail (TumblerCache           *cache,
 {
   g_return_val_if_fail (TUMBLER_IS_CACHE (cache), NULL);
   g_return_val_if_fail (uri != NULL && *uri != '\0', NULL);
-  g_return_val_if_fail (TUMBLER_IS_THUMBNAIL_FLAVOR (flavor), NULL);
+  g_return_val_if_fail (flavor == NULL || TUMBLER_IS_THUMBNAIL_FLAVOR (flavor), NULL);
   g_return_val_if_fail (TUMBLER_CACHE_GET_IFACE (cache)->get_thumbnail != NULL, NULL);
 
+  if (flavor == NULL)
+    return NULL;
+
   return (TUMBLER_CACHE_GET_IFACE (cache)->get_thumbnail) (cache, uri, flavor);
 }
 
diff --git a/tumbler/tumbler-error.h b/tumbler/tumbler-error.h
index a8472ad..df2ec6b 100644
--- a/tumbler/tumbler-error.h
+++ b/tumbler/tumbler-error.h
@@ -45,6 +45,7 @@ typedef enum /*< enum >*/
   TUMBLER_ERROR_INVALID_FORMAT,
   TUMBLER_ERROR_IS_THUMBNAIL,
   TUMBLER_ERROR_SAVE_FAILED,
+  TUMBLER_ERROR_UNSUPPORTED_FLAVOR,
 } TumblerErrorEnum;
 
 G_END_DECLS
diff --git a/tumbler/tumbler-file-info.c b/tumbler/tumbler-file-info.c
index 3ab47eb..c4f162d 100644
--- a/tumbler/tumbler-file-info.c
+++ b/tumbler/tumbler-file-info.c
@@ -145,7 +145,8 @@ tumbler_file_info_finalize (GObject *object)
   if (info->thumbnail != NULL)
     g_object_unref (info->thumbnail);
 
-  g_object_unref (info->flavor);
+  if (info->flavor != NULL)
+    g_object_unref (info->flavor);
 
   g_free (info->mime_type);
   g_free (info->uri);
@@ -222,7 +223,7 @@ tumbler_file_info_new (const gchar            *uri,
 {
   g_return_val_if_fail (uri != NULL && *uri != '\0', NULL);
   g_return_val_if_fail (mime_type != NULL && *mime_type != '\0', NULL);
-  g_return_val_if_fail (TUMBLER_IS_THUMBNAIL_FLAVOR (flavor), NULL);
+  g_return_val_if_fail (flavor == NULL || TUMBLER_IS_THUMBNAIL_FLAVOR (flavor), NULL);
 
   return g_object_new (TUMBLER_TYPE_FILE_INFO, "uri", uri, "mime-type", mime_type,
                        "flavor", flavor, NULL);
diff --git a/tumblerd/tumbler-service.c b/tumblerd/tumbler-service.c
index a3fc687..32b12a7 100644
--- a/tumblerd/tumbler-service.c
+++ b/tumblerd/tumbler-service.c
@@ -647,9 +647,7 @@ tumbler_service_queue (TumblerService        *service,
   flavor = tumbler_cache_get_flavor (cache, flavor_name);
   g_object_unref (cache);
 
-  /* TODO we need to check if the flavor is supported first and otherwise
-   * emit an error signal */
-  g_assert (cache);
+  g_assert (TUMBLER_IS_CACHE (cache));
 
   infos = tumbler_file_info_array_new_with_flavor (uris, mime_hints, flavor,
                                                    &length);
@@ -693,8 +691,32 @@ tumbler_service_queue (TumblerService        *service,
   if (scheduler == NULL) 
     scheduler = TUMBLER_SCHEDULER (service->schedulers->data);
 
-  /* let the scheduler take it from here */
-  tumbler_scheduler_push (scheduler, scheduler_request);
+  /* report unsupported flavors back to the client */
+  if (flavor == NULL)
+    {
+      /* fake a started signal */
+      tumbler_service_scheduler_started (scheduler, handle, scheduler_request->origin,
+                                         service);
+
+      /* emit an error signal */
+      tumbler_service_scheduler_error (scheduler, handle, uris, 
+                                       TUMBLER_ERROR_UNSUPPORTED_FLAVOR, 
+                                       _("Unsupported thumbnail flavor requested"),
+                                       scheduler_request->origin,
+                                       service);
+
+      /* fake a finished signal */
+      tumbler_service_scheduler_finished (scheduler, handle, scheduler_request->origin,
+                                          service);
+
+      /* release the request */
+      tumbler_scheduler_request_free (scheduler_request);
+    }
+  else
+    {
+      /* let the scheduler take it from here */
+      tumbler_scheduler_push (scheduler, scheduler_request);
+    }
   
   /* free the thumbnailer array */
   tumbler_thumbnailer_array_free (thumbnailers, length);



More information about the Xfce4-commits mailing list