From 75d7bfb7d7794fc09007643588642052d924210e Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Tue, 2 Feb 2016 13:43:38 +0300 Subject: [PATCH] Add compatibility with older Thunderbird versions. This also reverts commit 01c133a47c9379dce8004c344b38afc34a2f82c1 "Remove unneeded prefs variable reassignments." --- chrome/content/scripts/column.js | 4 ++++ chrome/content/scripts/messageHeader.js | 2 ++ chrome/content/scripts/spamness-load.js | 6 ++++-- chrome/content/scripts/spamness.js | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chrome/content/scripts/column.js b/chrome/content/scripts/column.js index 3a3848e..4462e82 100644 --- a/chrome/content/scripts/column.js +++ b/chrome/content/scripts/column.js @@ -2,6 +2,8 @@ var RspamdSpamnessColumn = {}; RspamdSpamnessColumn.handler = { getCellText: function(row, col) { + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); if (prefs.getIntPref("extensions.rspamd-spamness.display.column") == 2) return null; @@ -22,6 +24,8 @@ RspamdSpamnessColumn.handler = { getRowProperties: function(row, props) {}, getImageSrc: function(row, col) { + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); if (prefs.getIntPref("extensions.rspamd-spamness.display.column") == 1) return null; diff --git a/chrome/content/scripts/messageHeader.js b/chrome/content/scripts/messageHeader.js index aa24ae4..0a15a87 100644 --- a/chrome/content/scripts/messageHeader.js +++ b/chrome/content/scripts/messageHeader.js @@ -1,6 +1,8 @@ RspamdSpamness.Message = {}; RspamdSpamness.Message.displayHeaders = function() { + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); var showScore = prefs.getBoolPref("extensions.rspamd-spamness.display.messageScore"); var rowElScore = document.getElementById("expandedRspamdSpamnessRow"); var hdrElScore = document.getElementById("rspamdSpamnessScoreHeader"); diff --git a/chrome/content/scripts/spamness-load.js b/chrome/content/scripts/spamness-load.js index b3c31b5..a461281 100644 --- a/chrome/content/scripts/spamness-load.js +++ b/chrome/content/scripts/spamness-load.js @@ -1,14 +1,16 @@ const myAddonId = 'rspamd-spamness@alexander.moisseev' var optionObserver = { - observe(aSubject, aTopic, aData) { + observe: function(aSubject, aTopic, aData) { if (aTopic !== 'addon-options-displayed' || aData !== myAddonId) return; var doc = aSubject; var elem = doc.getElementById("advanced-options-button"); elem.addEventListener('command', this.eventHandler, true); }, - eventHandler(event) { + eventHandler: function(event) { + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); var previousSpamnessHeader = prefs.getCharPref("extensions.rspamd-spamness.header").toLowerCase(); window.openDialog( "chrome://rspamd-spamness/content/advancedOptions.xul", "", diff --git a/chrome/content/scripts/spamness.js b/chrome/content/scripts/spamness.js index 8f05380..b22b77f 100644 --- a/chrome/content/scripts/spamness.js +++ b/chrome/content/scripts/spamness.js @@ -33,6 +33,8 @@ RspamdSpamness.getMetricClass = function(rule) { } RspamdSpamness.getHeaderStr = function(hdr) { + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); var header = prefs.getCharPref("extensions.rspamd-spamness.header").toLowerCase(); var headerStr = hdr.getStringProperty(header); return (headerStr) ? headerStr : null;