From c29e78d2caa6bd0477e92ebab38c62f5bc18c857 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 3 Jun 2014 11:04:02 -0300 Subject: Only disable caching checkbox if caching is already disabled (#4811). --- ...o-not-disable-caching-checkbox-for-manual-accounts | 2 ++ .../content/preventCaching/bitmaskAmOfflineOverlay.js | 19 ++++++++++++++----- chrome/content/statusBar/statusBarOverlay.js | 17 +++++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 changes/bug_4811_do-not-disable-caching-checkbox-for-manual-accounts diff --git a/changes/bug_4811_do-not-disable-caching-checkbox-for-manual-accounts b/changes/bug_4811_do-not-disable-caching-checkbox-for-manual-accounts new file mode 100644 index 0000000..6804912 --- /dev/null +++ b/changes/bug_4811_do-not-disable-caching-checkbox-for-manual-accounts @@ -0,0 +1,2 @@ + o Do not disable caching checkbox for manual accounts when caching is turned + on (#4811). diff --git a/chrome/content/preventCaching/bitmaskAmOfflineOverlay.js b/chrome/content/preventCaching/bitmaskAmOfflineOverlay.js index c88b2ab..afc35a3 100644 --- a/chrome/content/preventCaching/bitmaskAmOfflineOverlay.js +++ b/chrome/content/preventCaching/bitmaskAmOfflineOverlay.js @@ -22,23 +22,32 @@ var currentAccount = null; -// The following function disables UI items that would allow a user to turn -// on offline caching for a LEAP account. It acts on am-offline.xul items that +// The following function disables UI items that would allow a user to turn on +// offline caching for a LEAP account. It acts on am-offline.xul items that // can be accessed in Thunderbird by choosing: // // Edit -> Account Settings... -> Synchronization and Storage. +// In order to be somewhat consistent, we only disable those items if the +// account already has its offline caching turned off. Accounts created with +// the Bitmask wizard are created with offline caching turned off (and so the +// UI items are disabled from the beginning). Accounts created manually will +// have offline caching turned on by default, and thus need a way to disable +// it if the user ever wants to. Once offline caching is disabled, then the +// user will not be able to turn it on again for Leap accounts. function disableOfflineCaching() { var disabled; - // for now, we consider a LEAP account every account whose incoming server + var checkbox = document.getElementById("offline.folders") + // For now, we consider a LEAP account every account whose incoming server // has a hostname equal to IMAP_HOST and port equal to IMAP_PORT. if (currentAccount.incomingServer.port == IMAP_PORT && - currentAccount.incomingServer.hostName == IMAP_HOST) + currentAccount.incomingServer.hostName == IMAP_HOST && + checkbox.checked == false) disabled = true; else disabled = false; // The "Keep messsages for this account on this computer" checkbox. - document.getElementById("offline.folders").disabled = disabled; + checkbox.disabled = disabled; // The "Advanced..." button. document.getElementById("selectImapFoldersButton").disabled = disabled; } diff --git a/chrome/content/statusBar/statusBarOverlay.js b/chrome/content/statusBar/statusBarOverlay.js index 31ec16a..c82b3f2 100644 --- a/chrome/content/statusBar/statusBarOverlay.js +++ b/chrome/content/statusBar/statusBarOverlay.js @@ -18,6 +18,7 @@ Components.utils.import("resource:///modules/mailServices.js"); +Components.utils.import("resource://gre/modules/Services.jsm"); var accountNotConfigured = getStringBundle( "chrome://bitmask/locale/statusBar.properties") @@ -51,6 +52,12 @@ function starUp() { updatePanel(); if (!isBitmaskAccountConfigured()) { launchAccountWizard(); + } else { + var server = getBitmaskServer(); + // TODO: add an alert that there exists a bitmask account with caching + // enabled. + //if (server.offlineDownload == true) + // alertPrompt('WARNING!'); } } @@ -86,9 +93,15 @@ function handleStatusBarClick() { * TODO: also verify for SMTP configuration? */ function isBitmaskAccountConfigured() { + return !!getBitmaskServer(); +} + +/** + * Get a configured bitmask account + */ +function getBitmaskServer() { var accountManager = Cc["@mozilla.org/messenger/account-manager;1"] .getService(Ci.nsIMsgAccountManager); - var existing = accountManager.findRealServer( + return accountManager.findRealServer( "", IMAP_HOST, "imap", IMAP_PORT); - return !!existing; } -- cgit v1.2.3