File:  [mozdev] / cdn / install.js
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sun Mar 9 23:30:54 2003 UTC (16 years ago) by cdn
Branches: MAIN
CVS tags: HEAD
should have added these ages ago

//var fileName = "skypilotnu19g";
//var fileName = "skypilotmu19g";
var fileName = "skypilotm12u19g";

var themeName = "skypilot";

//var themeVersion = "1.9g_NS7.x";
//var themeVersion = "1.9g_MZ1.x";
var themeVersion = "1.9g_MZ1.2";

// this function verifies disk space in kilobytes
function verifyDiskSpace(dirPath, spaceRequired)
{
  var spaceAvailable;

  // Get the available disk space on the given path
  spaceAvailable = fileGetDiskSpaceAvailable(dirPath);

  // Convert the available disk space into kilobytes
  spaceAvailable = parseInt(spaceAvailable / 1024);

  // do the verification
  if(spaceAvailable < spaceRequired)
  {
    logComment("Insufficient disk space: " + dirPath);
    logComment("  required : " + spaceRequired + " K");
    logComment("  available: " + spaceAvailable + " K");
    return(false);
  }

  return(true);
}

var srDest = 300;
var err;
var fChrome;

var chromeNode = themeName + "/" + themeVersion;
// --- END LOCALIZABLE RESOURCES ---
var regName    = "skins/mozilla/" + chromeNode;
var chromeName = fileName + ".jar";

err = initInstall(themeName, regName, themeVersion); 
logComment("initInstall: " + err);

var messages = loadResources("install.properties");

fChrome = getFolder("Chrome");
logComment("fChrome: " + fChrome);

if (verifyDiskSpace(fChrome, srDest))
{
    var chromeType = SKIN;

    if (confirm(messages.install_opt_en))
    {
        logComment("attempting to install globally");
        err = addFile(themeName, chromeName, fChrome, "");
        logComment("addFile() returned: " + err);

        if (err != SUCCESS)
        {
            logComment("addFile() to " + fChrome + "failed!");
 
            // couldn't install globally, try installing to the profile

            resetError();
            chromeType |= PROFILE_CHROME;
            fChrome = getFolder(getFolder("Profile"),"chrome");
            logComment("try installing to the user profile:" + fChrome);
            err = addFile(themeName, chromeName, fChrome, "");
        }
        chromeType |= DELAYED_CHROME;
    }
    else
    {
        logComment("attempting to install locally");
        chromeType |= PROFILE_CHROME;
        fChrome = getFolder(getFolder("Profile"),"chrome");
        err = addFile(themeName, chromeName, fChrome, "");

    }
 
    setPackageFolder(fChrome);
 
    // check return value
    if ((err == SUCCESS) || (err == REBOOT_NEEDED))
    {
        var tellReboot = 0;
        if (err == REBOOT_NEEDED) {
           tellReboot = 1;
           resetError();
        }
        // register chrome
        var cf = getFolder(fChrome, chromeName);

        registerChrome(chromeType, cf, "");

        err = performInstall(); 
        logComment("performInstall() returned: " + err);
        if (err == REBOOT_NEEDED) {
           tellReboot = 1;
           resetError();
        }
        if (err == SUCCESS)
        {
           if (tellReboot == 1)
           {
               alert(themeName + " " + messages.success_reboot_en);
           }
           else
           {
               alert(themeName + " " +  messages.success_en);
           }
        }
        else
        {
               alert(themeName + " " +  messages.fail_en + " " +  err);
        }
    }
    else
    {
        cancelInstall(err);
        logComment("cancelInstall due to error: " + err);
        if (err == -202) {
           alert(themeName + " " +  messages.cancel_202_en + " " +  err);
        }
        else {
           alert(themeName + " " +  messages.cancel_en + " " +  err);
        }
    }
}
else
    cancelInstall(INSUFFICIENT_DISK_SPACE);

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