X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-platform-factory.c;h=84290ef4e85528cc0b44df3ca5541d8b13fe8978;hp=35123122afbd5908ff40e296f745886c7f4bc8d3;hb=e45958deaf9701399c552ea0d84c2447efacd4ca;hpb=b09daad954384d34091b51a04eda7fd3a57a5f22 diff --git a/src/modest-tny-platform-factory.c b/src/modest-tny-platform-factory.c index 3512312..84290ef 100644 --- a/src/modest-tny-platform-factory.c +++ b/src/modest-tny-platform-factory.c @@ -30,15 +30,20 @@ /* 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" +#ifdef MODEST_USE_MOZEMBED +#include +#else +#include +#endif /* 'private'/'protected' functions */ static void modest_tny_platform_factory_class_init (ModestTnyPlatformFactoryClass *klass); @@ -53,8 +58,6 @@ static TnyDevice* modest_tny_platform_factory_new_device (TnyPlatfo 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); -static TnyHeader* modest_tny_platform_factory_new_header (TnyPlatformFactory *self); - /* list my signals */ enum { @@ -63,24 +66,20 @@ enum { LAST_SIGNAL }; -typedef struct _ModestTnyPlatformFactoryPrivate ModestTnyPlatformFactoryPrivate; -struct _ModestTnyPlatformFactoryPrivate { - ModestTnyAccountStore *account_store; - ModestConf *conf; - ModestAccountMgr *account_mgr; - ModestMailOperationQueue *mail_op_queue; -}; +/* PRIVATE area commented as it's empty now. If you enable this again remember to enable also + * private area registration in class init */ + +/* typedef struct _ModestTnyPlatformFactoryPrivate ModestTnyPlatformFactoryPrivate; */ +/* struct _ModestTnyPlatformFactoryPrivate {}; */ + +/* #define MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ */ +/* MODEST_TYPE_TNY_PLATFORM_FACTORY, \ */ +/* ModestTnyPlatformFactoryPrivate)) */ -#define MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ - MODEST_TYPE_TNY_PLATFORM_FACTORY, \ - ModestTnyPlatformFactoryPrivate)) /* globals */ 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) { @@ -126,19 +125,13 @@ modest_tny_platform_factory_class_init (ModestTnyPlatformFactoryClass *klass) gobject_class->finalize = modest_tny_platform_factory_finalize; gobject_class->constructor = modest_tny_platform_factory_constructor; - g_type_class_add_private (gobject_class, sizeof(ModestTnyPlatformFactoryPrivate)); +/* g_type_class_add_private (gobject_class, sizeof(ModestTnyPlatformFactoryPrivate)); */ } 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; + /* empty */ } static GObject* @@ -163,22 +156,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); - - if (priv->conf) - g_object_unref (priv->conf); - - if (priv->account_store) - g_object_unref (priv->account_store); - - if (priv->mail_op_queue) - g_object_unref (priv->mail_op_queue); - G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -187,13 +164,11 @@ 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_msg_func = modest_tny_platform_factory_new_msg; - klass->new_mime_part_func = modest_tny_platform_factory_new_mime_part; - klass->new_header_func = modest_tny_platform_factory_new_header; - + klass->new_account_store = modest_tny_platform_factory_new_account_store; + klass->new_device = modest_tny_platform_factory_new_device; + klass->new_msg_view = modest_tny_platform_factory_new_msg_view; + klass->new_msg = modest_tny_platform_factory_new_msg; + klass->new_mime_part = modest_tny_platform_factory_new_mime_part; return; } @@ -208,38 +183,26 @@ 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* modest_tny_platform_factory_new_msg_view (TnyPlatformFactory *self) { - /* TODO */ - return NULL; + /* Here we'll select one of the implementations available */ +#ifdef MODEST_USE_MOZEMBED + return g_object_new (MODEST_TYPE_MOZEMBED_MSG_VIEW, NULL); +#else + return g_object_new (MODEST_TYPE_GTKHTML_MSG_VIEW, NULL); +#endif } static TnyMsg* @@ -256,52 +219,3 @@ modest_tny_platform_factory_new_mime_part (TnyPlatformFactory *self) } -static TnyHeader* -modest_tny_platform_factory_new_header (TnyPlatformFactory *self) -{ - return tny_camel_header_new (); -} - - -ModestAccountMgr * -modest_tny_platform_factory_get_modest_account_mgr_instance (TnyPlatformFactory *fact) -{ - 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; -} - -ModestConf * -modest_tny_platform_factory_get_modest_conf_instance (TnyPlatformFactory *fact) -{ - ModestTnyPlatformFactoryPrivate *priv; - - 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_modest_mail_operation_queue_instance (TnyPlatformFactory *fact) -{ - ModestTnyPlatformFactoryPrivate *priv; - - 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; -}