X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-singletons.c;h=32ada6ba5d37ccd1a701a51d621ab48849d6d39d;hb=af5acd53d0075c85e95effc8799dabb82cdcca97;hp=45d2e5b97f95152ba529e49cd944289ed421a4cf;hpb=46f5f01a6cf826f2a76914f770daea7c87b9e7d7;p=modest diff --git a/src/modest-singletons.c b/src/modest-singletons.c index 45d2e5b..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,""); @@ -166,10 +184,10 @@ modest_singletons_finalize (GObject *obj) priv->window_mgr = NULL; } - if (priv->email_clipboard) { - MODEST_DEBUG_VERIFY_OBJECT_LAST_REF(priv->email_clipboard,""); - g_object_unref (G_OBJECT(priv->email_clipboard)); - priv->email_clipboard = NULL; + if (priv->mail_op_queue) { + MODEST_DEBUG_VERIFY_OBJECT_LAST_REF(priv->mail_op_queue,""); + g_object_unref (G_OBJECT(priv->mail_op_queue)); + priv->mail_op_queue = NULL; } if (priv->cache_mgr) { @@ -189,11 +207,11 @@ modest_singletons_finalize (GObject *obj) g_object_unref (G_OBJECT(priv->platform_fact)); priv->platform_fact = NULL; } - - if (priv->mail_op_queue) { - MODEST_DEBUG_VERIFY_OBJECT_LAST_REF(priv->mail_op_queue,""); - g_object_unref (G_OBJECT(priv->mail_op_queue)); - priv->mail_op_queue = NULL; + + if (priv->email_clipboard) { + MODEST_DEBUG_VERIFY_OBJECT_LAST_REF(priv->email_clipboard,""); + g_object_unref (G_OBJECT(priv->email_clipboard)); + priv->email_clipboard = NULL; } /* It is important that the account manager is uninitialized after @@ -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; +}