summaryrefslogtreecommitdiff
path: root/tumbler/tumbler-file-info.c
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis@xfce.org>2009-10-26 22:36:08 +0100
committerJannis Pohlmann <jannis@xfce.org>2009-10-26 22:36:08 +0100
commit7a1e43d0806ec976eb2872209affb3d8a0dad7d0 (patch)
treeb4dbedbee9a6c10e1a556b38ffa9f257963d409e /tumbler/tumbler-file-info.c
parent8258763e662bc2345051f230f2afc4b6da699726 (diff)
downloadtumbler-7a1e43d0806ec976eb2872209affb3d8a0dad7d0.tar.gz
Switch to a plugin API that only allows one cache backend at a time.
Tumbler will now only check for the file $(libdir)/tumbler-1/plugins/cache/tumbler-cache-plugin.so which is supposed to link to the cache backend that is being used. If the XDG cache is built, tumbler-cache-plugin.so is set up to link to this plugin. The fact that we only have a singleton cache makes things much less ambiguous.
Diffstat (limited to 'tumbler/tumbler-file-info.c')
-rw-r--r--tumbler/tumbler-file-info.c84
1 files changed, 31 insertions, 53 deletions
diff --git a/tumbler/tumbler-file-info.c b/tumbler/tumbler-file-info.c
index 80b8d69..c2cbde8 100644
--- a/tumbler/tumbler-file-info.c
+++ b/tumbler/tumbler-file-info.c
@@ -193,15 +193,14 @@ tumbler_file_info_load (TumblerFileInfo *info,
GError **error)
{
TumblerProviderFactory *provider_factory;
- GFileInfo *file_info;
- GError *err = NULL;
- GFile *file;
- GList *caches;
- GList *cp;
- GList *lp;
- GList *providers;
- GList *thumbnails;
- GList *tp;
+ TumblerCache *cache;
+ GFileInfo *file_info;
+ GError *err = NULL;
+ GFile *file;
+ GList *cp;
+ GList *lp;
+ GList *thumbnails;
+ GList *tp;
g_return_val_if_fail (TUMBLER_IS_FILE_INFO (info), FALSE);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
@@ -237,57 +236,36 @@ tumbler_file_info_load (TumblerFileInfo *info,
g_list_free (info->thumbnails);
info->thumbnails = NULL;
- /* get the provider factory */
- provider_factory = tumbler_provider_factory_get_default ();
-
- /* query a list of cache providers */
- providers = tumbler_provider_factory_get_providers (provider_factory,
- TUMBLER_TYPE_CACHE_PROVIDER);
-
- /* iterate over all available cache providers */
- for (lp = providers; err == NULL && lp != NULL; lp = lp->next)
+ /* query the default cache implementation */
+ cache = tumbler_cache_get_default ();
+ if (cache != NULL)
{
- /* query a list of cache implementations from the current provider */
- caches = tumbler_cache_provider_get_caches (lp->data);
+ /* check if the file itself is a thumbnail */
+ if (!tumbler_cache_is_thumbnail (cache, info->uri))
+ {
+ /* query thumbnail infos for this URI from the current cache */
+ thumbnails = tumbler_cache_get_thumbnails (cache, info->uri);
+
+ /* try to load thumbnail infos. the loop will terminate if
+ * one of them fails */
+ for (tp = thumbnails; err == NULL && tp != NULL; tp = tp->next)
+ tumbler_thumbnail_load (tp->data, cancellable, &err);
- /* iterate over all available cache implementations */
- for (cp = caches; err == NULL && cp != NULL; cp = cp->next)
+ /* add all queried thumbnails to the list */
+ info->thumbnails = g_list_concat (info->thumbnails,
+ thumbnails);
+ }
+ else
{
- /* check if the file itself is a thumbnail */
- if (!tumbler_cache_is_thumbnail (cp->data, info->uri))
- {
- /* query thumbnail infos for this URI from the current cache */
- thumbnails = tumbler_cache_get_thumbnails (cp->data, info->uri);
-
- /* try to load thumbnail infos. the loop will terminate if
- * one of them fails */
- for (tp = thumbnails; err == NULL && tp != NULL; tp = tp->next)
- tumbler_thumbnail_load (tp->data, cancellable, &err);
-
- /* add all queried thumbnails to the list */
- info->thumbnails = g_list_concat (info->thumbnails,
- thumbnails);
- }
- else
- {
- /* we don't allow the generation of thumbnails for thumbnails */
- g_set_error (&err, TUMBLER_ERROR, TUMBLER_ERROR_IS_THUMBNAIL,
- _("The file \"%s\" is a thumbnail itself"), info->uri);
- }
+ /* we don't allow the generation of thumbnails for thumbnails */
+ g_set_error (&err, TUMBLER_ERROR, TUMBLER_ERROR_IS_THUMBNAIL,
+ _("The file \"%s\" is a thumbnail itself"), info->uri);
}
- /* release cache references */
- g_list_foreach (caches, (GFunc) g_object_unref, NULL);
- g_list_free (caches);
+ /* release the cache */
+ g_object_unref (cache);
}
- /* release provider references */
- g_list_foreach (providers, (GFunc) g_object_unref, NULL);
- g_list_free (providers);
-
- /* release the provider factory */
- g_object_unref (provider_factory);
-
if (err != NULL)
{
/* propagate errors */