Browse Source

Fork iteratorUtils.jsm into our own source tree since it was removed from Thunderbird 90 in https://bugzilla.mozilla.org/show_bug.cgi?id=1518536.

master
Jörg Knobloch 1 year ago
parent
commit
63bef48f89
9 changed files with 84 additions and 8 deletions
  1. +1
    -1
      addon/content/TbHelper.js
  2. +1
    -1
      addon/content/dialogs/options.js
  3. +1
    -1
      addon/content/importRNP.js
  4. +76
    -0
      addon/content/modules/iteratorUtils.jsm
  5. +1
    -1
      addon/content/modules/pEp.js
  6. +1
    -1
      addon/content/pEpForThunderbird.js
  7. +1
    -1
      addon/content/pepmessengercompose.js
  8. +1
    -1
      addon/content/pepmsghdrview.js
  9. +1
    -1
      addon/content/sendMessage.js

+ 1
- 1
addon/content/TbHelper.js View File

@ -3,7 +3,7 @@
var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
var { fixIterator } = ChromeUtils.import("chrome://pEp4Tb/content/modules/iteratorUtils.jsm");
const TbHelper = {
messageBeingReplaced: null,


+ 1
- 1
addon/content/dialogs/options.js View File

@ -2,7 +2,7 @@
/* global Preferences */
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
var { fixIterator } = ChromeUtils.import("chrome://pEp4Tb/content/modules/iteratorUtils.jsm");
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { pEpUtils } = ChromeUtils.import("chrome://pEp4Tb/content/modules/utils.js");
var { pEp } = ChromeUtils.import("chrome://pEp4Tb/content/modules/pEp.js");


+ 1
- 1
addon/content/importRNP.js View File

@ -2,7 +2,7 @@
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
var { fixIterator } = ChromeUtils.import("chrome://pEp4Tb/content/modules/iteratorUtils.jsm");
var { RNP } = ChromeUtils.import("chrome://openpgp/content/modules/RNP.jsm");
var { PgpSqliteDb2 } = ChromeUtils.import("chrome://openpgp/content/modules/sqliteDb.jsm");
var { pEp } = ChromeUtils.import("chrome://pEp4Tb/content/modules/pEp.js");


+ 76
- 0
addon/content/modules/iteratorUtils.jsm View File

@ -0,0 +1,76 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// File copied from the Thunderbird source tree. It was removed in Thunderbird 90.
// We still need it for compatibility with Thunderbird 68.
// This is a stripped-down version only providing fixIterator.
/**
* This file contains helper methods for dealing with XPCOM iterators (arrays
* and enumerators) in JS-friendly ways.
*/
const EXPORTED_SYMBOLS = ["fixIterator"];
var JS_HAS_SYMBOLS = typeof Symbol === "function";
var ITERATOR_SYMBOL = JS_HAS_SYMBOLS ? Symbol.iterator : "@@iterator";
/**
* Given a JS array, JS iterator, or one of a variety of XPCOM collections or
* iterators, return a JS iterator suitable for use in a for...of expression.
*
* Currently, we support the following types of XPCOM iterators:
* nsIArray
* nsISimpleEnumerator
*
* Note that old-style JS iterators are explicitly not supported in this
* method, as they are going away.
*
* @param aEnum the enumerator to convert
* @param aIface (optional) an interface to QI each object to prior to
* returning
*
* @note This returns an object that can be used in 'for...of' loops.
* Do not use 'for each...in' or 'for...in'.
* This does *not* return an Array object. To create such an array, use
* let array = toArray(fixIterator(xpcomEnumerator));
*/
function fixIterator(aEnum, aIface) {
// If the input is an array, nsISimpleEnumerator or something that sports Symbol.iterator,
// then the original input is sufficient to directly return. However, if we want
// to support the aIface parameter, we need to do a lazy version of
// Array.prototype.map.
if (
Array.isArray(aEnum) ||
aEnum instanceof Ci.nsISimpleEnumerator ||
ITERATOR_SYMBOL in aEnum
) {
if (!aIface) {
return aEnum[ITERATOR_SYMBOL]();
}
return (function*() {
for (let o of aEnum) {
yield o.QueryInterface(aIface);
}
})();
}
let face = aIface || Ci.nsISupports;
// Figure out which kind of array object we have.
// First try nsIArray (covers nsIMutableArray too).
if (aEnum instanceof Ci.nsIArray) {
return (function*() {
let count = aEnum.length;
for (let i = 0; i < count; i++) {
yield aEnum.queryElementAt(i, face);
}
})();
}
// We got something unexpected, notify the caller loudly.
throw new Error(
"An unsupported object sent to fixIterator: " +
("toString" in aEnum ? aEnum.toString() : aEnum)
);
}

+ 1
- 1
addon/content/modules/pEp.js View File

@ -51,7 +51,7 @@ class pEp {
/*
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
var { fixIterator } = ChromeUtils.import("chrome://pEp4Tb/content/modules/iteratorUtils.jsm");
// This function was introduced to track down P4TB-355 (which turned out to be ENGINE-862).
// It erroneously shows an alert when a privacy handshake is made for a message sent to
// a mailing list. In this case, no Thunderbird identity exists, but an own identity


+ 1
- 1
addon/content/pEpForThunderbird.js View File

@ -25,7 +25,7 @@ var { pEpMimeEncrypt } = ChromeUtils.import("chrome://pEp4Tb/content/pEpMimeEncr
var { pEpUtils } = ChromeUtils.import("chrome://pEp4Tb/content/modules/utils.js");
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
var { fixIterator } = ChromeUtils.import("chrome://pEp4Tb/content/modules/iteratorUtils.jsm");
var {
RATING_COLOR_RED,


+ 1
- 1
addon/content/pepmessengercompose.js View File

@ -7,7 +7,7 @@ var { Handshake } = ChromeUtils.import("chrome://pEp4Tb/content/modules/handshak
var { TbHelper } = ChromeUtils.import("chrome://pEp4Tb/content/TbHelper.js");
var { TbContacts } = ChromeUtils.import("chrome://pEp4Tb/content/TbContacts.js");
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
var { fixIterator } = ChromeUtils.import("chrome://pEp4Tb/content/modules/iteratorUtils.jsm");
var {
PEP_ENCRYPTED_SUBJECT, RATING_COLOR_NO_COLOR, RATING_COLOR_YELLOW, RATING_COLOR_GREEN,


+ 1
- 1
addon/content/pepmsghdrview.js View File

@ -8,7 +8,7 @@ var { TbHelper } = ChromeUtils.import("chrome://pEp4Tb/content/TbHelper.js");
var { TbContacts } = ChromeUtils.import("chrome://pEp4Tb/content/TbContacts.js");
var { Handshake } = ChromeUtils.import("chrome://pEp4Tb/content/modules/handshake.js");
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
var { fixIterator } = ChromeUtils.import("chrome://pEp4Tb/content/modules/iteratorUtils.jsm");
const PEP_COLUMN_NAME = "pEpStatusCol";
const TAG_PRIVACY_NODE_ID = "pEp-msghdr-privacy-label";


+ 1
- 1
addon/content/sendMessage.js View File

@ -2,7 +2,7 @@
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
var { fixIterator } = ChromeUtils.import("chrome://pEp4Tb/content/modules/iteratorUtils.jsm");
var isEncrypted;


Loading…
Cancel
Save