From f13ee3532f108c708f45cbf7ea834ddd9a45ee52 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 13 May 2016 10:42:14 +0200 Subject: [PATCH] Add support for dist-bundles back --- .../settings/thunderbird/thunderbird.cfg/20Bundles | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/thunderbird/thunderbird.cfg/20Bundles diff --git a/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/thunderbird/thunderbird.cfg/20Bundles b/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/thunderbird/thunderbird.cfg/20Bundles new file mode 100644 index 0000000..d7379d9 --- /dev/null +++ b/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/thunderbird/thunderbird.cfg/20Bundles @@ -0,0 +1,66 @@ +{ + +$OUT =<<'_EOF'; + +// Javascript to enable the distribution/bundles directory + +const {classes: Cc, interfaces: Ci, utils: Cu} = Components; + +var gBundlePrefFiles = []; + +Cu.import("resource://gre/modules/Services.jsm"); + +function loadBundleDirs() { + var distributionBundleDir = Services.dirsvc.get("GreD", Ci.nsIFile); + distributionBundleDir.append("distribution"); + distributionBundleDir.append("bundles"); + if (!distributionBundleDir.exists() || !distributionBundleDir.isDirectory()) { + return; + } + var enumerator = distributionBundleDir.directoryEntries; + while (enumerator.hasMoreElements()) { + var file = enumerator.getNext().QueryInterface(Ci.nsIFile); + var dirName = file.leafName; + file.append("chrome.manifest"); + Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(file); + file.leafName = "defaults"; + file.append("preferences"); + if (!file.exists() || !file.isDirectory()) { + continue; + } + var resource = Services.io.getProtocolHandler("resource") + .QueryInterface(Components.interfaces.nsIResProtocolHandler); + // We can't use a file URL to load prefs. + // Create a resource URL that maps to the prefs directory. + var prefAlias = Services.io.newFileURI(file); + resource.setSubstitution(dirName + "_prefs", prefAlias); + var prefEnumerator = file.directoryEntries; + while (prefEnumerator.hasMoreElements()) { + var prefFile = prefEnumerator.getNext().QueryInterface(Ci.nsIFile); + gBundlePrefFiles.push("resource://" + dirName + "_prefs/" + prefFile.leafName); + } + } +} + +var loadPrefObserver = { + observe: function observe(subject, topic, data) { + if (gBundlePrefFiles.length > 0) { + // Create a temporary scope so the pref function works + var temp = {}; + temp.pref = function(a, b) { + defaultPref(a, b); + } + gBundlePrefFiles.forEach(function(prefFile) { + Services.scriptloader.loadSubScript(prefFile, temp); + }); + } + } +} +Services.obs.addObserver(loadPrefObserver, "load-extension-defaults", false); + +try { + loadBundleDirs(); +} catch(e) {} +_EOF + +}