X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-platform-factory.c;h=dad5e4b5129830a7a9b281458ad5d26481cce761;hp=669f75760e48e87a167a54b9e88c06b6918f7fdb;hb=f7633249cd82c0808fa5a563b48b900e49988db7;hpb=b4744d6d5086a3ed2a6c6a40b6ffb285204e4c93 diff --git a/src/modest-tny-platform-factory.c b/src/modest-tny-platform-factory.c index 669f757..dad5e4b 100644 --- a/src/modest-tny-platform-factory.c +++ b/src/modest-tny-platform-factory.c @@ -30,12 +30,12 @@ /* modest-tny-platform-factory.c */ #include -/* MODES_PLATFORM_ID: 1 ==> gtk, 2==> maemo */ -#if MODEST_PLATFORM_ID==1 -#include -#elif MODEST_PLATFORM_ID==2 -#include -#endif +#include +#include + +#include +#include +#include #include "modest-tny-platform-factory.h" #include "modest-tny-account-store.h" @@ -47,9 +47,13 @@ static void modest_tny_platform_factory_finalize (GObject *obj); static GObject *modest_tny_platform_factory_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params); static void tny_platform_factory_init (gpointer g, gpointer iface_data); -static TnyAccountStore *modest_tny_platform_factory_new_account_store (TnyPlatformFactory *self); -static TnyDevice *modest_tny_platform_factory_new_device (TnyPlatformFactory *self); -static TnyMsgView *modest_tny_platform_factory_new_msg_view (TnyPlatformFactory *self); + +static TnyAccountStore* modest_tny_platform_factory_new_account_store (TnyPlatformFactory *self); +static TnyDevice* modest_tny_platform_factory_new_device (TnyPlatformFactory *self); +static TnyMsgView* modest_tny_platform_factory_new_msg_view (TnyPlatformFactory *self); +static TnyMsg* modest_tny_platform_factory_new_msg (TnyPlatformFactory *self); +static TnyMimePart* modest_tny_platform_factory_new_mime_part (TnyPlatformFactory *self); + /* list my signals */ enum { /* MY_SIGNAL_1, */ @@ -58,11 +62,8 @@ enum { }; typedef struct _ModestTnyPlatformFactoryPrivate ModestTnyPlatformFactoryPrivate; -struct _ModestTnyPlatformFactoryPrivate { - ModestTnyAccountStore *account_store; - ModestConf *conf; - ModestAccountMgr *account_mgr; -}; +struct _ModestTnyPlatformFactoryPrivate {}; + #define MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_TNY_PLATFORM_FACTORY, \ ModestTnyPlatformFactoryPrivate)) @@ -70,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) { @@ -124,12 +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; + /* empty */ } static GObject* @@ -154,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 (priv->account_mgr); - priv->account_mgr = NULL; - } - - if (priv->conf) { - g_object_unref (priv->conf); - priv->conf = NULL; - } - - if (priv->account_store) { - g_object_unref (priv->account_store); - priv->account_store = NULL; - } - G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -182,9 +156,10 @@ tny_platform_factory_init (gpointer g, gpointer iface_data) TnyPlatformFactoryIface *klass = (TnyPlatformFactoryIface *)g; klass->new_account_store_func = modest_tny_platform_factory_new_account_store; - klass->new_device_func = modest_tny_platform_factory_new_device; - klass->new_msg_view_func = modest_tny_platform_factory_new_msg_view; - + klass->new_device_func = modest_tny_platform_factory_new_device; + klass->new_msg_view_func = modest_tny_platform_factory_new_msg_view; + klass->new_msg_func = modest_tny_platform_factory_new_msg; + klass->new_mime_part_func = modest_tny_platform_factory_new_mime_part; return; } @@ -199,31 +174,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_modest_account_mgr_instance (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 - return NULL; -#endif /* MODEST_PLATFORM */ + return modest_platform_get_new_device (); } static TnyMsgView* @@ -233,32 +192,17 @@ modest_tny_platform_factory_new_msg_view (TnyPlatformFactory *self) return NULL; } -ModestAccountMgr * -modest_tny_platform_factory_get_modest_account_mgr_instance (TnyPlatformFactory *fact) +static TnyMsg* +modest_tny_platform_factory_new_msg (TnyPlatformFactory *self) { - ModestTnyPlatformFactoryPrivate *priv; - - priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact); - - if (!priv->account_mgr) { - if (!priv->conf) - modest_tny_platform_factory_get_modest_conf_instance (fact); - - priv->account_mgr = modest_account_mgr_new (priv->conf); - } - - return priv->account_mgr; + return tny_camel_msg_new (); } -ModestConf * -modest_tny_platform_factory_get_modest_conf_instance (TnyPlatformFactory *fact) -{ - ModestTnyPlatformFactoryPrivate *priv; - priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact); +static TnyMimePart* +modest_tny_platform_factory_new_mime_part (TnyPlatformFactory *self) +{ + return tny_camel_mime_part_new (); +} - if (!priv->conf) - priv->conf = modest_conf_new (); - return priv->conf; -}