Skip to content
Snippets Groups Projects
Commit 26a0def1 authored by Sukhbir Singh's avatar Sukhbir Singh
Browse files

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.
parent 31de9e49
No related branches found
No related tags found
No related merge requests found
......@@ -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";
}
}
......
......@@ -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.
......
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;
......
......@@ -12,7 +12,7 @@
<!-- Thunderbird -->
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>38.*</em:minVersion>
<em:minVersion>37.*</em:minVersion>
<em:maxVersion>45.*</em:maxVersion>
</Description>
</em:targetApplication>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment