X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-platform-factory.c;h=ded4a91ef5a88a6550d8e77164a513868c8964c0;hp=4b6cb25fd51e26370a30c9514220c556c2079f8f;hb=3e7a3b4e5759d63285d8795435b2ceedaf63b216;hpb=44167847c9153e99288b834efe5f7908ab5cc553 diff --git a/src/modest-tny-platform-factory.c b/src/modest-tny-platform-factory.c index 4b6cb25..ded4a91 100644 --- a/src/modest-tny-platform-factory.c +++ b/src/modest-tny-platform-factory.c @@ -30,17 +30,11 @@ /* modest-tny-platform-factory.c */ #include +#include #include #include #include -/* MODES_PLATFORM_ID: 1 ==> gtk, 2==> maemo */ -#if MODEST_PLATFORM_ID==1 -#include -#elif MODEST_PLATFORM_ID==2 -#include -#endif - #include "modest-tny-platform-factory.h" #include "modest-tny-account-store.h" @@ -68,13 +62,7 @@ enum { }; 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, \ @@ -83,9 +71,6 @@ struct _ModestTnyPlatformFactoryPrivate { 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) { @@ -137,14 +122,7 @@ modest_tny_platform_factory_class_init (ModestTnyPlatformFactoryClass *klass) 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* @@ -169,25 +147,6 @@ modest_tny_platform_factory_constructor (GType type, guint n_construct_params, 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); } @@ -217,31 +176,15 @@ modest_tny_platform_factory_get_instance (void) 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(), + modest_runtime_get_device())); } static TnyDevice * modest_tny_platform_factory_new_device (TnyPlatformFactory *self) { -/* MODES_PLATFORM_ID: 1 ==> gtk, 2==> maemo */ -#if MODEST_PLATFORM_ID==1 - return TNY_DEVICE (tny_gnome_device_new ()); -#elif MODEST_PLATFORM_ID==2 - return TNY_DEVICE (tny_maemo_device_new ()); -#else - g_return_val_if_reached (NULL); -#endif /* MODEST_PLATFORM */ + return modest_platform_get_new_device (); } static TnyMsgView* @@ -270,69 +213,3 @@ modest_tny_platform_factory_new_header (TnyPlatformFactory *self) { 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; -}