From 4e21bb8ab68703d8bfbb71f71335f641c989ff3f Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Mon, 17 Aug 2009 13:16:59 +0200 Subject: [PATCH] Accounts are created in offline mode if automatic update is disabled Set accounts to online whenever the first window is registered if the automatic update is set to off --- src/modest-tny-account-store.c | 10 +++++++++- src/widgets/modest-window-mgr.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 68bbfe9..477ed1d 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -884,6 +884,7 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr, TnyAccount *local_account = NULL; TnyLockable *lockable; GnomeVFSVolumeMonitor* monitor = NULL; + gboolean auto_update; g_return_val_if_fail (account_mgr, NULL); g_return_val_if_fail (device, NULL); @@ -894,6 +895,13 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr, priv->account_mgr = g_object_ref (G_OBJECT(account_mgr)); priv->device = g_object_ref (device); + /* If autoupdate is off then we don't try to connect to the + accounts when they're added to the account store*/ + auto_update = modest_conf_get_bool (modest_runtime_get_conf (), + MODEST_CONF_AUTO_UPDATE, NULL); + if (!auto_update) + tny_device_force_offline (priv->device); + priv->session = tny_session_camel_new (TNY_ACCOUNT_STORE(obj)); if (!priv->session) { g_warning ("failed to get TnySessionCamel"); @@ -936,7 +944,7 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr, priv->store_accounts_outboxes = tny_simple_list_new (); /* Create the local folders account */ - local_account = + local_account = modest_tny_account_new_for_local_folders (priv->account_mgr, priv->session, NULL); tny_list_append (priv->store_accounts, G_OBJECT(local_account)); g_object_unref (local_account); diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index 8dc8cfc..e750488 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -33,6 +33,7 @@ #include "modest-tny-folder.h" #include "modest-ui-actions.h" #include "modest-platform.h" +#include "modest-defs.h" #include "widgets/modest-main-window.h" #include "widgets/modest-msg-edit-window.h" #include "widgets/modest-msg-view-window.h" @@ -535,6 +536,19 @@ modest_window_mgr_register_window (ModestWindowMgr *self, ModestWindow *window, ModestWindow *parent) { + /* If this is the first registered window then reset the + status of the TnyDevice as it might be forced to be offline + when modest is running in the background (see + modest_tny_account_store_new() and automatic updates are + disabled*/ + if (modest_window_mgr_get_num_windows (self) == 0) { + gboolean auto_update; + auto_update = modest_conf_get_bool (modest_runtime_get_conf (), + MODEST_CONF_AUTO_UPDATE, NULL); + if (!auto_update) + tny_device_reset (modest_runtime_get_device ()); + } + return MODEST_WINDOW_MGR_GET_CLASS (self)->register_window (self, window, parent); } -- 1.7.9.5