commit 26a0def110411e65f0abad893533a705d30a4424 Author: Sukhbir Singh sukhbir@torproject.org Date: Mon May 16 17:28:35 2016 -0400
Reflect TorBirdy's state in UI after uninstall/disable (#10683)
When TorBirdy is uninstalled or disabled, the status bar text and colour is updated to reflect TorBirdy's current state. Prior to this commit, if a user uninstalled/disabled TorBirdy, the status bar text would still say "TorBirdy Enabled". Now the status bar is updated as TorBirdy's state changes to avoid confusing the user. --- chrome/content/overlay.js | 2 +- chrome/locale/en/torbirdy.properties | 1 + components/torbirdy.js | 31 +++++++++++++++++++++++++------ install.rdf | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/chrome/content/overlay.js b/chrome/content/overlay.js index f8b1051..1f72c9d 100644 --- a/chrome/content/overlay.js +++ b/chrome/content/overlay.js @@ -67,7 +67,7 @@ prefs.setBoolPref("extensions.torbirdy.whonix_run", false); } else { - myPanel.label = strbundle.getString("torbirdy.enabled.disabled"); + myPanel.label = strbundle.getString("torbirdy.disabled"); myPanel.style.color = "red"; } } diff --git a/chrome/locale/en/torbirdy.properties b/chrome/locale/en/torbirdy.properties index 2e01136..4f645eb 100644 --- a/chrome/locale/en/torbirdy.properties +++ b/chrome/locale/en/torbirdy.properties @@ -6,6 +6,7 @@ torbirdy.enabled.custom=TorBirdy Enabled: Custom Proxy torbirdy.enabled.torification=TorBirdy Enabled: Transparent Torification torbirdy.enabled.whonix=TorBirdy Enabled: Whonix torbirdy.disabled=TorBirdy: Disabled! +torbirdy.enabled=TorBirdy: Enabled
torbirdy.email.prompt=TorBirdy has disabled Thunderbird's auto-configuration wizard to protect your anonymity.\n\nThe recommended security settings for %S have been set.\n\nYou can now configure the other account settings manually.
diff --git a/components/torbirdy.js b/components/torbirdy.js index ead2508..eb64df6 100644 --- a/components/torbirdy.js +++ b/components/torbirdy.js @@ -1,9 +1,8 @@ -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/AddonManager.jsm"); +var { interfaces: Ci, utils: Cu, classes: Cc } = Components;
-var Ci = Components.interfaces; -var Cc = Components.classes; -var Cr = Components.results; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/imXPCOMUtils.jsm"); +Cu.import("resource://gre/modules/AddonManager.jsm");
var SERVICE_CTRID = "@torproject.org/torbirdy;1"; var SERVICE_ID = Components.ID("{ebd85413-18c8-4265-a708-a8890ec8d1ed}"); @@ -14,6 +13,10 @@ var kPrefBranch = "extensions.torbirdy.custom."; var kRestoreBranch = "extensions.torbirdy.restore."; var kTorBirdyBranch = "extensions.torbirdy.";
+XPCOMUtils.defineLazyGetter(this, "_", () => + l10nHelper("chrome://castironthunderbirdclub/locale/torbirdy.properties") +); + // Default preference values for TorBirdy. // These preferences values will be "enforced": even if the user decides to // change the preferences listed below, they will be reset to the TorBirdy @@ -380,7 +383,7 @@ var TorBirdyOldPrefs = [ // is rounded down to the nearest minute. function sanitizeDateHeaders() { // Import the jsmime module that is used to generate mail headers. - let { jsmime } = Components.utils.import("resource:///modules/jsmime.jsm"); + let { jsmime } = Cu.import("resource:///modules/jsmime.jsm"); // Inject our own structured encoder to the default header emitter, // to override the default Date encoder with a rounded-down version. jsmime.headeremitter.addStructuredEncoder("Date", function (date) { @@ -438,7 +441,22 @@ TorBirdy.prototype = { // This is a hack to cause Thunderbird to instantiate us ASAP! _xpcom_categories: [{ category: "profile-after-change"}, ],
+ onStateChange: function() { + let panel = Cc['@mozilla.org/appshell/window-mediator;1'] + .getService(Ci.nsIWindowMediator) + .getMostRecentWindow('mail:3pane').document.getElementById("torbirdy-my-panel"); + if (this._uninstall) { + panel.label = _("torbirdy.enabled"); + panel.style.color = "green"; + } + else { + panel.label = _("torbirdy.disabled"); + panel.style.color = "red"; + } + }, + onUninstalling: function(addon, needsRestart) { + this.onStateChange(); if (addon.id == TB_ID) { dump("Nooo! TorBirdy uninstall requested\n"); this._uninstall = true; @@ -447,6 +465,7 @@ TorBirdy.prototype = { },
onOperationCancelled: function(addon) { + this.onStateChange(); if (addon.id == TB_ID) { dump("Uninstall requested cancelled. Yayay!\n"); this._uninstall = false; diff --git a/install.rdf b/install.rdf index 34c634c..ffe53cd 100644 --- a/install.rdf +++ b/install.rdf @@ -12,7 +12,7 @@ <!-- Thunderbird --> <Description> em:id{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id> - em:minVersion38.*</em:minVersion> + em:minVersion37.*</em:minVersion> em:maxVersion45.*</em:maxVersion> </Description> </em:targetApplication>
tor-commits@lists.torproject.org