Skip to content

Commit

Permalink
Merge pull request #328 from thundernest/v12.0.0
Browse files Browse the repository at this point in the history
V12.0.0
  • Loading branch information
cleidigh authored Jul 3, 2022
2 parents 67de343 + 325c988 commit 0ecb8b7
Show file tree
Hide file tree
Showing 40 changed files with 4,092 additions and 4,972 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "ImportExportTools NG",
"name": "import-export-tools-ng",
"version": "10.1.0-b1",
"version": "12.0.0",
"description": "Import and export next-gen tools for messages and folders",
"author": "Christopher Leidigh",
"engines": {
Expand All @@ -16,7 +16,6 @@
"target_include_manifest": "true"
},
"scripts": {
"build-xpi-bat": ".\\scripts\\build-xpi.bat",
"build-xpi": "node ./scripts/build-xpi.js"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions scripts/translate-gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ function sleep(ms) {
async function translateHelpPage() {
var localeFolders = _getAllFilesOrFolders(localeDir, true);

// var supportedLocales = ['ca', 'da', 'de', 'en-US', 'es-ES', 'fr', 'gl-ES', 'hu-HU', 'hy-AM'];
var supportedLocales = ['ca', 'da', 'de', 'en-US', 'es-ES', 'fr', 'gl-ES', 'hu-HU', 'hy-AM'];

var supportedLocales = ['it', 'ja', 'ko-KR', 'nl', 'pl', 'pt-PT', 'ru', 'sk-SK', 'sl-SI', 'sv-SE', 'zh-CN', 'el'];
//var supportedLocales = ['it', 'ja', 'ko-KR', 'nl', 'pl', 'pt-PT', 'ru', 'sk-SK', 'sl-SI', 'sv-SE', 'zh-CN', 'el'];

// const supportedLocales2 = ['pl', 'pt-PT', 'ru', 'sk-SK', 'sl-SI', 'sv-SE' ];
// supportedLocales = ['es-ES'];
Expand Down
7 changes: 6 additions & 1 deletion src/api/SessionRestore/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
var { ExtensionCommon } = ChromeUtils.import("resource://gre/modules/ExtensionCommon.jsm");
var { ExtensionSupport } = ChromeUtils.import("resource:///modules/ExtensionSupport.jsm");
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { SessionStoreManager } = ChromeUtils.import("resource:///modules/SessionStoreManager.jsm");

var SessionRestore = class extends ExtensionCommon.ExtensionAPI {
getAPI(context) {
Expand All @@ -25,9 +26,13 @@ var SessionRestore = class extends ExtensionCommon.ExtensionAPI {
return {
SessionRestore: {

isRestored() {
return !!SessionStoreManager._restored;
},

onStartupSessionRestore: new ExtensionCommon.EventManager({
context,
name: "SessionRestore.onNotifyBackground",
name: "SessionRestore.onStartupSessionRestore",
register: (fire) => {
let trackerId = self.observerTrackerNext++;
self.observerTracker[trackerId] = fire.sync;
Expand Down
10 changes: 9 additions & 1 deletion src/api/SessionRestore/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
"description": "Fired when the session has been restored after startup.",
"parameters": []
}
]
],
"functions": [
{
"name": "isRestored",
"type": "function",
"async": true,
"parameters": []
}
]
}
]
1 change: 1 addition & 0 deletions src/api/WindowListener/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Usage description can be found in the [wiki](https://github.com/thundernest/addon-developer-support/wiki/Using-the-WindowListener-API-to-convert-a-Legacy-Overlay-WebExtension-into-a-MailExtension-for-Thunderbird-78).
6 changes: 5 additions & 1 deletion src/api/WindowListener/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version: 1.57
-------------
- fix race condition which could prevent the AOM tab to be monkey patched correctly

Version: 1.56
-------------
- be precise on which revision the wrench symbol should be displayed, instead of
Expand Down Expand Up @@ -143,4 +147,4 @@ Version: 1.7
Version: 1.6
-------------
- added mutation observer to be able to inject into browser elements
- use larger icons as fallback
- use larger icons as fallback
86 changes: 41 additions & 45 deletions src/api/WindowListener/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file is provided by the addon-developer-support repository at
* https://github.com/thundernest/addon-developer-support
*
* Version: 1.56
* Version: 1.57
*
* Author: John Bieling ([email protected])
*
Expand Down Expand Up @@ -200,7 +200,7 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI {
// returns the outer browser, not the nested browser of the add-on manager
// events must be attached to the outer browser
getAddonManagerFromTab(tab) {
if (tab.browser) {
if (tab.browser && tab.mode.name == "contentTab") {
let win = tab.browser.contentWindow;
if (win && win.location.href == "about:addons") {
return win;
Expand All @@ -211,9 +211,28 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI {
getAddonManagerFromWindow(window) {
let tabMail = this.getTabMail(window);
for (let tab of tabMail.tabInfo) {
let win = this.getAddonManagerFromTab(tab);
if (win) {
return win;
let managerWindow = this.getAddonManagerFromTab(tab);
if (managerWindow) {
return managerWindow;
}
}
}

async getAddonManagerFromWindowWaitForLoad(window) {
let { setTimeout } = Services.wm.getMostRecentWindow("mail:3pane");

let tabMail = this.getTabMail(window);
for (let tab of tabMail.tabInfo) {
if (tab.browser && tab.mode.name == "contentTab") {
// Instead of registering a load observer, wait until its loaded. Not nice,
// but gets aroud a lot of edge cases.
while(!tab.pageLoaded) {
await new Promise(r => setTimeout(r, 150));
}
let managerWindow = this.getAddonManagerFromTab(tab);
if (managerWindow) {
return managerWindow;
}
}
}
}
Expand Down Expand Up @@ -329,41 +348,20 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI {

// TabMonitor to detect opening of tabs, to setup the options button in the add-on manager.
this.tabMonitor = {
onTabTitleChanged(aTab) { },
onTabClosing(aTab) { },
onTabPersist(aTab) { },
onTabRestored(aTab) { },
onTabSwitched(aNewTab, aOldTab) {
//self.setupAddonManager(self.getAddonManagerFromTab(aNewTab));
},
async onTabOpened(aTab) {
if (aTab.browser) {
if (!aTab.pageLoaded) {
// await a location change if browser is not loaded yet
await new Promise((resolve) => {
let reporterListener = {
QueryInterface: ChromeUtils.generateQI([
"nsIWebProgressListener",
"nsISupportsWeakReference",
]),
onStateChange() { },
onProgressChange() { },
onLocationChange(
/* in nsIWebProgress*/ aWebProgress,
/* in nsIRequest*/ aRequest,
/* in nsIURI*/ aLocation
) {
aTab.browser.removeProgressListener(reporterListener);
resolve();
},
onStatusChange() { },
onSecurityChange() { },
onContentBlockingEvent() { },
};
aTab.browser.addProgressListener(reporterListener);
});
onTabTitleChanged(tab) { },
onTabClosing(tab) { },
onTabPersist(tab) { },
onTabRestored(tab) { },
onTabSwitched(aNewTab, aOldTab) { },
async onTabOpened(tab) {
if (tab.browser && tab.mode.name == "contentTab") {
let { setTimeout } = Services.wm.getMostRecentWindow("mail:3pane");
// Instead of registering a load observer, wait until its loaded. Not nice,
// but gets aroud a lot of edge cases.
while(!tab.pageLoaded) {
await new Promise(r => setTimeout(r, 150));
}
self.setupAddonManager(self.getAddonManagerFromTab(aTab));
self.setupAddonManager(self.getAddonManagerFromTab(tab));
}
},
};
Expand Down Expand Up @@ -594,16 +592,14 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI {
self
);
} else {
// Setup the options button/menu in the add-on manager, if it is already open.
self.setupAddonManager(
self.getAddonManagerFromWindow(window),
true
);
// Add a tabmonitor, to be able to setup the options button/menu in the add-on manager.
self
.getTabMail(window)
.registerTabMonitor(self.tabMonitor);
window[self.uniqueRandomID].hasTabMonitor = true;
// Setup the options button/menu in the add-on manager, if it is already open.
let managerWindow = await self.getAddonManagerFromWindowWaitForLoad(window);
self.setupAddonManager(managerWindow, true);
}
}
}
Expand Down Expand Up @@ -1183,4 +1179,4 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI {
this.chromeHandle = null;
}
}
};
};
45 changes: 38 additions & 7 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
// background.js - this kicks off the WindowListener framework


// console.debug('background Start');


browser.SessionRestore.onStartupSessionRestore.addListener(main);
// Have to wrap top level asyncs in anon func to pass ATN

await ((async () => {
var tbVersionParts = await getThunderbirdVersion();

// must delay startup for #284 using SessionRestore for 91, bypass for 102
// does this by default
var startupDelay;
if (tbVersionParts.major < 92) {
startupDelay = await new Promise(async (resolve) => {
const restoreListener = (window, state = true) => {
browser.SessionRestore.onStartupSessionRestore.removeListener(restoreListener);
resolve(state);
}
browser.SessionRestore.onStartupSessionRestore.addListener(restoreListener);

let isRestored = await browser.SessionRestore.isRestored();
if (isRestored) {
restoreListener(null, false);
}
});
}

})());

// now start
main();


async function getThunderbirdVersion() {
let browserInfo = await messenger.runtime.getBrowserInfo();
let parts = browserInfo.version.split(".");
return {
major: parseInt(parts[0]),
minor: parseInt(parts[1]),
revision: parts.length > 2 ? parseInt(parts[2]) : 0,
}
}

function main() {
browser.SessionRestore.onStartupSessionRestore.removeListener(main);

messenger.WindowListener.registerDefaultPrefs("defaults/preferences/prefs.js");

// Register all necessary content, Resources, and locales
Expand Down
2 changes: 1 addition & 1 deletion src/chrome/content/mboximport/exportTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ function exportAllMsgs(type, t) {
} catch (e) { }

IETglobalMsgFolders = GetSelectedMsgFolders();
console.debug(IETglobalMsgFolders[0].name);
//console.debug(IETglobalMsgFolders[0].name);

IETglobalMsgFoldersExported = 0;
for (var i = 0; i < IETglobalMsgFolders.length; i++) {
Expand Down
Loading

0 comments on commit 0ecb8b7

Please sign in to comment.