/* modest-tny-platform-factory.c */
#include <config.h>
+#include <modest-runtime.h>
#include <tny-camel-header.h>
#include <tny-camel-mime-part.h>
#include <tny-camel-msg.h>
};
typedef struct _ModestTnyPlatformFactoryPrivate ModestTnyPlatformFactoryPrivate;
-struct _ModestTnyPlatformFactoryPrivate {
- ModestTnyAccountStore *account_store;
- ModestConf *conf;
- ModestAccountMgr *account_mgr;
- ModestMailOperationQueue *mail_op_queue;
- ModestCacheMgr *cache_mgr;
-};
+struct _ModestTnyPlatformFactoryPrivate {};
#define MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_TNY_PLATFORM_FACTORY, \
static GObjectClass *parent_class = NULL;
static ModestTnyPlatformFactory *singleton = NULL;
-/* uncomment the following if you have defined any signals */
-/* static guint signals[LAST_SIGNAL] = {0}; */
-
GType
modest_tny_platform_factory_get_type (void)
{
static void
modest_tny_platform_factory_init (ModestTnyPlatformFactory *obj)
{
- ModestTnyPlatformFactoryPrivate *priv;
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(obj);
-
- priv->account_mgr = NULL;
- priv->conf = NULL;
- priv->account_store = NULL;
- priv->mail_op_queue = NULL;
- priv->cache_mgr = NULL;
+ /* empty */
}
static GObject*
static void
modest_tny_platform_factory_finalize (GObject *obj)
{
- ModestTnyPlatformFactoryPrivate *priv;
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(obj);
-
- if (priv->account_mgr)
- g_object_unref (G_OBJECT(priv->account_mgr));
-
- if (priv->conf)
- g_object_unref (G_OBJECT(priv->conf));
-
- if (priv->account_store)
- g_object_unref (G_OBJECT(priv->account_store));
-
- if (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);
}
static TnyAccountStore *
modest_tny_platform_factory_new_account_store (TnyPlatformFactory *self)
{
- ModestTnyPlatformFactoryPrivate *priv;
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(self);
-
- if (!priv->account_store) {
- if (!priv->account_mgr)
- modest_tny_platform_factory_get_account_mgr_instance (MODEST_TNY_PLATFORM_FACTORY (self));
-
- priv->account_store = modest_tny_account_store_new (priv->account_mgr);
- }
-
- return TNY_ACCOUNT_STORE (priv->account_store);
+ return TNY_ACCOUNT_STORE(modest_tny_account_store_new
+ (modest_runtime_get_account_mgr()));
}
static TnyDevice *
{
return tny_camel_header_new ();
}
-
-
-ModestAccountMgr *
-modest_tny_platform_factory_get_account_mgr_instance (ModestTnyPlatformFactory *fact)
-{
- ModestTnyPlatformFactoryPrivate *priv;
-
- g_return_val_if_fail (fact, NULL);
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact);
-
- if (!priv->account_mgr) {
- if (!priv->conf)
- modest_tny_platform_factory_get_conf_instance (fact);
- priv->account_mgr = modest_account_mgr_new (priv->conf);
- }
-
- return priv->account_mgr;
-}
-
-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)
- priv->conf = modest_conf_new ();
-
- return priv->conf;
-}
-
-ModestMailOperationQueue*
-modest_tny_platform_factory_get_mail_operation_queue_instance (ModestTnyPlatformFactory *fact)
-{
- ModestTnyPlatformFactoryPrivate *priv;
-
- g_return_val_if_fail (fact, NULL);
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact);
-
- if (!priv->mail_op_queue)
- priv->mail_op_queue = modest_mail_operation_queue_new ();
-
- 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;
-}