diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 08:00:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 08:00:07 +0000 |
commit | 71b1940231738aac70ede9ecb211614eae8873aa (patch) | |
tree | d42a8e658862d9e2c3d2ec144394170bc321f5a0 /content/bootstrap.js | |
parent | Initial commit. (diff) | |
download | eas4tbsync-71b1940231738aac70ede9ecb211614eae8873aa.tar.xz eas4tbsync-71b1940231738aac70ede9ecb211614eae8873aa.zip |
Adding upstream version 4.7.upstream/4.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'content/bootstrap.js')
-rw-r--r-- | content/bootstrap.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/content/bootstrap.js b/content/bootstrap.js new file mode 100644 index 0000000..5fb33c8 --- /dev/null +++ b/content/bootstrap.js @@ -0,0 +1,55 @@ +/* + * This file is part of EAS-4-TbSync. + * + * 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/. + */ + +// no need to create namespace, we are in a sandbox + +var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + +let onInitDoneObserver = { + observe: async function (aSubject, aTopic, aData) { + let valid = false; + try { + var { TbSync } = ChromeUtils.import("chrome://tbsync/content/tbsync.jsm"); + valid = TbSync.enabled; + } catch (e) { + // If this fails, TbSync is not loaded yet and we will get the notification later again. + } + + //load this provider add-on into TbSync + if (valid) { + await TbSync.providers.loadProvider(extension, "eas", "chrome://eas4tbsync/content/provider.js"); + } + } +} + +function startup(data, reason) { + // Possible reasons: APP_STARTUP, ADDON_ENABLE, ADDON_INSTALL, ADDON_UPGRADE, or ADDON_DOWNGRADE. + + Services.obs.addObserver(onInitDoneObserver, "tbsync.observer.initialized", false); + + // Did we miss the observer? + onInitDoneObserver.observe(); +} + +function shutdown(data, reason) { + // Possible reasons: APP_STARTUP, ADDON_ENABLE, ADDON_INSTALL, ADDON_UPGRADE, or ADDON_DOWNGRADE. + + // When the application is shutting down we normally don't have to clean up. + if (reason == APP_SHUTDOWN) { + return; + } + + Services.obs.removeObserver(onInitDoneObserver, "tbsync.observer.initialized"); + //unload this provider add-on from TbSync + try { + var { TbSync } = ChromeUtils.import("chrome://tbsync/content/tbsync.jsm"); + TbSync.providers.unloadProvider("eas"); + } catch (e) { + //if this fails, TbSync has been unloaded already and has unloaded this addon as well + } +} |