From 44167847c9153e99288b834efe5f7908ab5cc553 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 22 Jan 2007 00:08:26 +0000 Subject: [PATCH] * modest-tny-platform-factory.[ch]: - add support for the ModestCacheMgr pmo-trunk-r683 --- src/modest-tny-platform-factory.c | 38 ++++++++++++++++++++++++++++++++----- src/modest-tny-platform-factory.h | 22 ++++++++++++++++++--- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/modest-tny-platform-factory.c b/src/modest-tny-platform-factory.c index d6a6a08..4b6cb25 100644 --- a/src/modest-tny-platform-factory.c +++ b/src/modest-tny-platform-factory.c @@ -73,6 +73,7 @@ struct _ModestTnyPlatformFactoryPrivate { ModestConf *conf; ModestAccountMgr *account_mgr; ModestMailOperationQueue *mail_op_queue; + ModestCacheMgr *cache_mgr; }; #define MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ @@ -143,6 +144,7 @@ modest_tny_platform_factory_init (ModestTnyPlatformFactory *obj) priv->conf = NULL; priv->account_store = NULL; priv->mail_op_queue = NULL; + priv->cache_mgr = NULL; } static GObject* @@ -172,16 +174,19 @@ modest_tny_platform_factory_finalize (GObject *obj) priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(obj); if (priv->account_mgr) - g_object_unref (priv->account_mgr); + g_object_unref (G_OBJECT(priv->account_mgr)); if (priv->conf) - g_object_unref (priv->conf); + g_object_unref (G_OBJECT(priv->conf)); if (priv->account_store) - g_object_unref (priv->account_store); + g_object_unref (G_OBJECT(priv->account_store)); if (priv->mail_op_queue) - g_object_unref (priv->mail_op_queue); + g_object_unref (G_OBJECT(priv->mail_op_queue)); + + if (priv->cache_mgr) + g_object_unref (G_OBJECT(priv->cache_mgr)); G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -272,6 +277,8 @@ modest_tny_platform_factory_get_account_mgr_instance (ModestTnyPlatformFactory * { ModestTnyPlatformFactoryPrivate *priv; + g_return_val_if_fail (fact, NULL); + priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact); if (!priv->account_mgr) { @@ -287,7 +294,9 @@ ModestConf * modest_tny_platform_factory_get_conf_instance (ModestTnyPlatformFactory *fact) { ModestTnyPlatformFactoryPrivate *priv; - + + g_return_val_if_fail (fact, NULL); + priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact); if (!priv->conf) @@ -301,6 +310,8 @@ modest_tny_platform_factory_get_mail_operation_queue_instance (ModestTnyPlatform { ModestTnyPlatformFactoryPrivate *priv; + g_return_val_if_fail (fact, NULL); + priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact); if (!priv->mail_op_queue) @@ -308,3 +319,20 @@ modest_tny_platform_factory_get_mail_operation_queue_instance (ModestTnyPlatform return priv->mail_op_queue; } + + + +ModestCacheMgr* +modest_tny_platform_factory_get_cache_mgr_instance (ModestTnyPlatformFactory *fact) +{ + ModestTnyPlatformFactoryPrivate *priv; + + g_return_val_if_fail (fact, NULL); + + priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact); + + if (!priv->cache_mgr) + priv->cache_mgr = modest_cache_mgr_new (); + + return priv->cache_mgr; +} diff --git a/src/modest-tny-platform-factory.h b/src/modest-tny-platform-factory.h index a9fa02b..6fbe553 100644 --- a/src/modest-tny-platform-factory.h +++ b/src/modest-tny-platform-factory.h @@ -35,9 +35,10 @@ #include #include -#include "modest-account-mgr.h" -#include "modest-conf.h" -#include "modest-mail-operation-queue.h" +#include +#include +#include +#include G_BEGIN_DECLS @@ -111,6 +112,21 @@ ModestConf* modest_tny_platform_factory_get_conf_instance (ModestTnyPlatform ModestMailOperationQueue* modest_tny_platform_factory_get_mail_operation_queue_instance (ModestTnyPlatformFactory *fact); +/** + * modest_tny_platform_factory_get_cache_mgr_instance: + * @fact: the #TnyPlatformFactory that holds the #ModestCacheMgr instance + * + * Gets a new instance of a #ModestCacheMgr if it is the + * first call to the function, or the current instantiated one + * otherwise. This object is supposed to be a singleton + * + * Returns: an instance of a #ModestCacheMgr. + **/ +ModestCacheMgr* modest_tny_platform_factory_get_cache_mgr_instance (ModestTnyPlatformFactory *fact); + + + + G_END_DECLS #endif /* __MODEST_TNY_PLATFORM_FACTORY_H__ */ -- 1.7.9.5