X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-singletons.c;h=32ada6ba5d37ccd1a701a51d621ab48849d6d39d;hp=3084cbd6667215bf6314ae7fb2085c6daf963f5c;hb=4f233ba7d5d71cd8cb848fd2e88b63ce6bc6fc21;hpb=0e1d967636205d5317d8cff2f8de52f22fe0647a diff --git a/src/modest-singletons.c b/src/modest-singletons.c index 3084cbd..32ada6b 100644 --- a/src/modest-singletons.c +++ b/src/modest-singletons.c @@ -30,6 +30,7 @@ #include "modest-singletons.h" #include "modest-runtime.h" #include "modest-debug.h" +#include /* 'private'/'protected' functions */ static void modest_singletons_class_init (ModestSingletonsClass *klass); @@ -46,6 +47,7 @@ struct _ModestSingletonsPrivate { TnyPlatformFactory *platform_fact; TnyDevice *device; ModestWindowMgr *window_mgr; + TnyStreamCache *images_cache; }; #define MODEST_SINGLETONS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_SINGLETONS, \ @@ -93,6 +95,7 @@ static void modest_singletons_init (ModestSingletons *obj) { ModestSingletonsPrivate *priv; + gchar *images_cache_path; priv = MODEST_SINGLETONS_GET_PRIVATE(obj); priv->conf = NULL; @@ -103,6 +106,7 @@ modest_singletons_init (ModestSingletons *obj) priv->platform_fact = NULL; priv->device = NULL; priv->window_mgr = NULL; + priv->images_cache = NULL; priv->conf = modest_conf_new (); if (!priv->conf) { @@ -151,6 +155,14 @@ modest_singletons_init (ModestSingletons *obj) g_printerr ("modest: cannot create modest window manager instance\n"); return; } + + images_cache_path = g_build_filename (g_get_home_dir (), MODEST_DIR, MODEST_IMAGES_CACHE_DIR, NULL); + priv->images_cache = tny_fs_stream_cache_new (images_cache_path, MODEST_IMAGES_CACHE_SIZE); + g_free (images_cache_path); + if (!priv->images_cache) { + g_printerr ("modest: cannot create images cache instance\n"); + return; + } } static void @@ -159,6 +171,12 @@ modest_singletons_finalize (GObject *obj) ModestSingletonsPrivate *priv; priv = MODEST_SINGLETONS_GET_PRIVATE(obj); + + if (priv->images_cache) { + MODEST_DEBUG_VERIFY_OBJECT_LAST_REF (priv->images_cache, ""); + g_object_unref (G_OBJECT (priv->images_cache)); + priv->images_cache = NULL; + } if (priv->window_mgr) { MODEST_DEBUG_VERIFY_OBJECT_LAST_REF(priv->window_mgr,""); @@ -301,3 +319,10 @@ modest_singletons_get_window_mgr (ModestSingletons *self) g_return_val_if_fail (self, NULL); return MODEST_SINGLETONS_GET_PRIVATE(self)->window_mgr; } + +TnyStreamCache* +modest_singletons_get_images_cache (ModestSingletons *self) +{ + g_return_val_if_fail (self, NULL); + return MODEST_SINGLETONS_GET_PRIVATE(self)->images_cache; +}