* all:
[modest] / src / modest-tny-platform-factory.c
index 1e3ae1e..4b6cb25 100644 (file)
@@ -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);
 }
@@ -192,11 +197,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_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;
 
        return;
 }
@@ -218,7 +223,7 @@ modest_tny_platform_factory_new_account_store (TnyPlatformFactory *self)
 
        if (!priv->account_store) {
                if (!priv->account_mgr)
-                       modest_tny_platform_factory_get_modest_account_mgr_instance (self);
+                       modest_tny_platform_factory_get_account_mgr_instance (MODEST_TNY_PLATFORM_FACTORY (self));
 
                priv->account_store = modest_tny_account_store_new (priv->account_mgr);
        }
@@ -235,7 +240,7 @@ modest_tny_platform_factory_new_device (TnyPlatformFactory *self)
 #elif MODEST_PLATFORM_ID==2
        return TNY_DEVICE (tny_maemo_device_new ());
 #else
-       return NULL;
+       g_return_val_if_reached (NULL);
 #endif /* MODEST_PLATFORM */
 }
 
@@ -268,16 +273,17 @@ modest_tny_platform_factory_new_header (TnyPlatformFactory *self)
 
 
 ModestAccountMgr *
-modest_tny_platform_factory_get_modest_account_mgr_instance (TnyPlatformFactory *fact)
+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_modest_conf_instance (fact);
-
+                       modest_tny_platform_factory_get_conf_instance (fact);
                priv->account_mgr = modest_account_mgr_new (priv->conf);
        }
 
@@ -285,10 +291,12 @@ modest_tny_platform_factory_get_modest_account_mgr_instance (TnyPlatformFactory
 }
 
 ModestConf *
-modest_tny_platform_factory_get_modest_conf_instance (TnyPlatformFactory *fact)
+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)
@@ -298,10 +306,12 @@ modest_tny_platform_factory_get_modest_conf_instance (TnyPlatformFactory *fact)
 }
 
 ModestMailOperationQueue*   
-modest_tny_platform_factory_get_modest_mail_operation_queue_instance (TnyPlatformFactory *fact)
+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)
@@ -309,3 +319,20 @@ modest_tny_platform_factory_get_modest_mail_operation_queue_instance (TnyPlatfor
 
        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;
+}