summaryrefslogtreecommitdiff
path: root/chrome/content/preventCaching
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-10-03 14:24:48 -0300
committerdrebs <drebs@leap.se>2013-10-04 14:25:08 -0300
commit3c23f4aa7eeabff0382f7789cfb7ad0c3090615a (patch)
treeb7970f3d7fef0ceabb4293f135c97f257fe6baef /chrome/content/preventCaching
Initial import.
Diffstat (limited to 'chrome/content/preventCaching')
-rw-r--r--chrome/content/preventCaching/bitmaskAmOfflineOverlay.js67
-rw-r--r--chrome/content/preventCaching/bitmaskAmOfflineOverlay.xul8
2 files changed, 75 insertions, 0 deletions
diff --git a/chrome/content/preventCaching/bitmaskAmOfflineOverlay.js b/chrome/content/preventCaching/bitmaskAmOfflineOverlay.js
new file mode 100644
index 0000000..c88b2ab
--- /dev/null
+++ b/chrome/content/preventCaching/bitmaskAmOfflineOverlay.js
@@ -0,0 +1,67 @@
+/**
+ * preventCachingOverlay.js
+ * Copyright (C) 2013 LEAP
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along
+ */
+
+
+// The following variable will hold the current account being edited after
+// onPreInit() is called.
+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
+// can be accessed in Thunderbird by choosing:
+//
+// Edit -> Account Settings... -> Synchronization and Storage.
+function disableOfflineCaching()
+{
+ var disabled;
+ // 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)
+ disabled = true;
+ else
+ disabled = false;
+ // The "Keep messsages for this account on this computer" checkbox.
+ document.getElementById("offline.folders").disabled = disabled;
+ // The "Advanced..." button.
+ document.getElementById("selectImapFoldersButton").disabled = disabled;
+}
+
+
+// Clone 'am-offline.js' onPreInit() so we can store the current account.
+var oldOnPreInit = onPreInit.bind({});
+
+// Store current account and call old onPreInit().
+var onPreInit = function(account, accountValues)
+{
+ currentAccount = account;
+ oldOnPreInit(account, accountValues);
+}
+
+
+// Clone 'am-offline.js' onInit() so we can disable offline caching.
+var oldOnInit = onInit.bind({});
+
+// Call old onInit() and disable offline caching.
+var onInit = function(aPageId, aServerId)
+{
+ oldOnInit(aPageId, aServerId);
+ disableOfflineCaching();
+}
+
diff --git a/chrome/content/preventCaching/bitmaskAmOfflineOverlay.xul b/chrome/content/preventCaching/bitmaskAmOfflineOverlay.xul
new file mode 100644
index 0000000..a5b5039
--- /dev/null
+++ b/chrome/content/preventCaching/bitmaskAmOfflineOverlay.xul
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<overlay id="bitmaskPreventCachingOverlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://bitmask/content/serverConfig.js"/>
+ <script type="application/javascript"
+ src="chrome://bitmask/content/preventCaching/bitmaskAmOfflineOverlay.js"/>
+</overlay>