Diff for /calculator/src/install.js between versions 1.1 and 1.2

version 1.1, 2004/09/12 11:52:07 version 1.2, 2006/01/09 21:11:05
Line 1 Line 1
// XpiInstaller// This code is heavily inspired by Chris Pederick (useragentswitcher) install.js
// By Pike (Heavily inspired by code from Henrik Gemal and Stephen Clavering)var contentFlag         = CONTENT | PROFILE_CHROME;
var localeFlag          = LOCALE | PROFILE_CHROME;
var XpiInstaller = {var skinFlag            = SKIN | PROFILE_CHROME;
        // --- Editable items begin ---var displayName         = "Mozilla Calculator"; // The name displayed to the user (don't include the version)
        extFullName: 'Mozilla Calculator', // The name displayed to the user (don't include the version)var version             = "1.1.0";
        extShortName: 'calculator', // The leafname of the JAR file (without the .jar part)
        extVersion: '0.7',var name                = "calculator"; // The leafname of the JAR file (without the .jar part)
        extAuthor: 'Marc Belmont',var jarName             = name + ".jar";
        extLocaleNames: null, // e.g. ['en-US', 'en-GB']var jarFolder           = "content/" // + name + "/"
        extSkinNames: null, // e.g. ['classic', 'modern']
        extPostInstallMessage: 'Success! Please restart your browser to finish the installation.', // Set to null for no post-install messagevar error               = null;
        // --- Editable items end ---
var folder              = getFolder("Profile", "chrome");
        profileInstall: true,var prefFolder          = getFolder(getFolder("Program", "defaults"), "pref");
        silentInstall: false,
var existsInApplication = File.exists(getFolder(getFolder("chrome"), jarName));
        install: function()var existsInProfile     = File.exists(getFolder(folder, jarName));
        {
                var jarName = this.extShortName + '.jar';var locales             = new Array( "en-US", "it-IT", "fr-FR", "es-ES", "de-DE", "ja-JP", "pl-PL", "nl-NL", "tr-TR", "ru-RU", "sl-SI", "sk-SK" );
                var profileDir = Install.getFolder('Profile', 'chrome');var skins               = new Array( "classic" );
var prefs               = new Array( "prefs.js" );
                // Parse HTTP argumentsvar components          = new Array(  );
                this.parseArguments();
// Mozilla Suite/Seamonkey stores all pref files in a single directory
                // Check if extension is already installed in profile// under the application directory.  If the name of the preference file(s)
                if (File.exists(Install.getFolder(profileDir, jarName)))// is/are not unique enough, you may override other extension preferences.
                {// set this to true if you need to prevent this.
                        if (!this.silentInstall)var disambiguatePrefs   = true;
                        {
                                Install.alert('Updating existing Profile install of ' + this.extFullName + ' to version ' + this.extVersion + '.');// If the extension exists in the application folder or it doesn't exist
                        }// in the profile folder and the user doesn't want it installed to the
                        this.profileInstall = true;// profile folder
                }if(existsInApplication ||
                else if (!this.silentInstall)    (!existsInProfile &&
                {      !confirm( "Do you want to install the " + displayName +
                        // Ask user for install location, profile or browser dir?                " extension into your profile folder?\n" +
                        this.profileInstall = Install.confirm('Install ' + this.extFullName + ' ' + this.extVersion + ' to your Profile directory (OK) or your Browser directory (Cancel)?');                "(Cancel will install into the application folder)")))
                }{
    contentFlag = CONTENT | DELAYED_CHROME;
                // Init install    folder      = getFolder("chrome");
                var dispName = this.extFullName + ' ' + this.extVersion;    localeFlag  = LOCALE | DELAYED_CHROME;
                var regName = '/' + this.extAuthor + '/' + this.extShortName;    skinFlag    = SKIN | DELAYED_CHROME;
                Install.initInstall(dispName, regName, this.extVersion);}
                // Find directory to install intoinitInstall(displayName, name, version);
                var installPath;setPackageFolder(folder);
                if (this.profileInstall) installPath = profileDir;error = addFile(name, version, "chrome/" + jarName, folder, null);
                else installPath = Install.getFolder('chrome');
// If adding the JAR file succeeded
                // Add JAR fileif(error == SUCCESS)
                Install.addFile(null, 'chrome/' + jarName, installPath, null);{
    folder = getFolder(folder, jarName);
                // Register chrome
                var jarPath = Install.getFolder(installPath, jarName);    registerChrome(contentFlag, folder, jarFolder);
                var installType = this.profileInstall ? Install.PROFILE_CHROME : Install.DELAYED_CHROME;    for (var i = 0; i < locales.length; i++) {
        registerChrome(localeFlag, folder, "locale/" + locales[i] + "/");
                // Register content    }
                Install.registerChrome(Install.CONTENT | installType, jarPath, 'content/' + this.extShortName + '/');
    for (var i = 0; i < skins.length; i++) {
                // Register locales        registerChrome(skinFlag, folder, "skin/" + skins[i] + "/");
                for (var locale in this.extLocaleNames)    }
                {
                        var regPath = 'locale/' + this.extLocaleNames[locale] + '/' + this.extShortName + '/';    for (var i = 0; i < prefs.length; i++) {
                        Install.registerChrome(Install.LOCALE | installType, jarPath, regPath);        if (!disambiguatePrefs) {
                }            addFile(name + " Defaults", version, "defaults/preferences/" + prefs[i],
                prefFolder, prefs[i], true);
                // Register skins        } else {
                for (var skin in this.extSkinNames)            addFile(name + " Defaults", version, "defaults/preferences/" + prefs[i],
                {                prefFolder, name + "-" + prefs[i], true);
                        var regPath = 'skin/' + this.extSkinNames[skin] + '/' + this.extShortName + '/';        }
                        Install.registerChrome(Install.SKIN | installType, jarPath, regPath);    }
                }
    error = performInstall();
                // Perform install
                var err = Install.performInstall();    // If the install failed
                if (err == Install.SUCCESS || err == Install.REBOOT_NEEDED)    if(error != SUCCESS && error != REBOOT_NEEDED)
                {    {
                        if (!this.silentInstall && this.extPostInstallMessage)        displayError(error);
                        {        cancelInstall(error);
                                Install.alert(this.extPostInstallMessage);    }
                        }    else
                }    {
                else        alert("The installation of the " + displayName + " extension succeeded.");
                {    }
                        this.handleError(err);}
                        return;else
                }{
        },    displayError(error);
        cancelInstall(error);
        parseArguments: function()}
        {
                // Can't use string handling in install, so use if statement instead// Displays the error message to the user
                var args = Install.arguments;function displayError(error)
                if (args == 'p=0'){
                {    // If the error code was -215
                        this.profileInstall = false;    if(error == READ_ONLY)
                        this.silentInstall = true;    {
                }        alert("The installation of " + displayName +
                else if (args == 'p=1')            " failed.\nOne of the files being overwritten is read-only.");
                {    }
                        this.profileInstall = true;    // If the error code was -235
                        this.silentInstall = true;    else if(error == INSUFFICIENT_DISK_SPACE)
                }    {
        },        alert("The installation of " + displayName +
            " failed.\nThere is insufficient disk space.");
        handleError: function(err)    }
        {    // If the error code was -239
                if (!this.silentInstall)    else if(error == CHROME_REGISTRY_ERROR)
                {    {
                        Install.alert('Error: Could not install ' + this.extFullName + ' ' + this.extVersion + ' (Error code: ' + err + ')');        alert("The installation of " + displayName +
                }            " failed.\nChrome registration failed.");
                Install.cancelInstall(err);    }
        }    else
};    {
        alert("The installation of " + displayName +
XpiInstaller.install();            " failed.\nThe error code is: " + error);
     }
 }
   

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>