home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 January
/
01_02.iso
/
software
/
netscape62win
/
n2p.xpi
/
install.js
Wrap
Text File
|
2001-10-22
|
7KB
|
269 lines
// 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);
}
// this function deletes a file if it exists
function deleteThisFile(dirKey, file)
{
var fFileToDelete;
fFileToDelete = getFolder(dirKey, file);
logComment("File to delete: " + fFileToDelete);
if(File.isFile(fFileToDelete))
{
File.remove(fFileToDelete);
return(true);
}
else
return(false);
}
// this function deletes a folder if it exists
function deleteThisFolder(dirKey, folder, recursiveDelete)
{
var fToDelete;
if(typeof recursiveDelete == "undefined")
recursiveDelete = true;
fToDelete = getFolder(dirKey, folder);
logComment("folder to delete: " + fToDelete);
if(File.isDirectory(fToDelete))
{
File.dirRemove(fToDelete, recursiveDelete);
return(true);
}
else
return(false);
}
// OS type detection
// which platform?
function getPlatform()
{
var platformStr;
var platformNode;
if('platform' in Install)
{
platformStr = new String(Install.platform);
if (!platformStr.search(/^Macintosh/))
platformNode = 'mac';
else if (!platformStr.search(/^Win/))
platformNode = 'win';
else
platformNode = 'unix';
}
else
{
var fOSMac = getFolder("Mac System");
var fOSWin = getFolder("Win System");
logComment("fOSMac: " + fOSMac);
logComment("fOSWin: " + fOSWin);
if(fOSMac != null)
platformNode = 'mac';
else if(fOSWin != null)
platformNode = 'win';
else
platformNode = 'unix';
}
return platformNode;
}
function updateWinReg4Ren8dot3()
{
var fProgram = getFolder("Program");
var fTemp = getFolder("Temporary");
//Notes:
// can't use a double backslash before subkey - Windows already puts it in.
// subkeys have to exist before values can be put in.
var subkey; // the name of the subkey you are poking around in
var valname; // the name of the value you want to look at
var value; // the data in the value you want to look at.
var winreg = getWinRegistry() ;
if(winreg != null)
{
// Here, we get the current version.
winreg.setRootKey(winreg.HKEY_CURRENT_USER) ; // CURRENT_USER
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce" ;
winreg.createKey(subkey,"");
valname = "ren8dot3";
value = fProgram + "ren8dot3.exe " + fTemp + "ren8dot3.ini";
err = winreg.setValueString(subkey, valname, value);
}
}
function prepareRen8dot3(listLongFilePaths)
{
var fTemp = getFolder("Temporary");
var fProgram = getFolder("Program");
var fRen8dot3Ini = getWinProfile(fTemp, "ren8dot3.ini");
var bIniCreated = false;
var fLongFilePath;
var sShortFilePath;
if(fRen8dot3Ini != null)
{
for(i = 0; i < listLongFilePaths.length; i++)
{
fLongFilePath = getFolder(fProgram, listLongFilePaths[i]);
sShortFilePath = File.windowsGetShortName(fLongFilePath);
if(sShortFilePath)
{
fRen8dot3Ini.writeString("rename", sShortFilePath, fLongFilePath);
bIniCreated = true;
}
}
if(bIniCreated)
updateWinReg4Ren8dot3() ;
}
return(0);
}
function updateNet2FoneIni()
{
var fWindows;
var wpN2PIni;
var wpErr;
fWindows = getFolder("Windows");
wpN2PIni = getWinProfile(fWindows, "net2fone.ini");
wpErr = wpN2PIni.writeString("AccountInfo", "source", "NS_USA106");
wpErr = wpN2PIni.writeString("URLS" , "REGURL", "http://www.net2phone.com/cgi-bin/clienturl.cgi?brand=netscape&language=english&action=%X%&acctnum=%A%&source=%S%");
return(wpErr);
}
function getN2PFolder()
{
var fN2P;
var winReg = getWinRegistry();
if(winReg != null)
{
winReg.setRootKey(winReg.HKEY_LOCAL_MACHINE);
subKey = "SOFTWARE\\Net2Phone\\Install";
valueName = "Directory";
fN2Pstr = winReg.getValueString(subKey, valueName);
if((fN2Pstr == null) || (fN2Pstr == ""))
{
subKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion";
valueName = "ProgramFilesDir";
fCommonFilesDir = winReg.getValueString(subKey, valueName);
fN2Pstr = fCommonFilesDir + "\\Net2Phone\\";
}
fN2P = getFolder("file:///", fN2Pstr);
}
else
{
logComment("getWinRegsitry() failed: " + winReg);
}
return fN2P;
}
// main
var srDest;
var err;
var cErr;
var fN2P;
var fN2PFinal;
var fN2PExecute;
var fileN2PIni;
var fWindows;
var fTemp;
var rv;
srDest = 2433;
err = initInstall("Net2Phone", "/IDT/Net2Phone", "10.2.8.0");
logComment("initInstall() returned: " + err);
fN2PFinal = getN2PFolder();
fTemp = getFolder("Temporary");
fN2P = getFolder("Temporary");
if(verifyDiskSpace(fN2P, srDest))
{
setPackageFolder(fN2PFinal);
err = addDirectory("/IDT/Net2Phone",
"10.2.8.0",
"net2phone", // dir name in jar to extract
fN2P, // Where to put this file (Returned from getFolder)
"", // subdir name to create relative to communicatorFolder
true); // Force Flag
logComment("addDirectory() returned: " + err);
if(!err)
{
fWindows = getFolder("Windows");
fileN2PIni = getFolder("file:///", fWindows + "net2fone.ini");
rv = File.exists(fileN2PIni);
logComment("fileExists() returned: " + rv);
if(rv == false)
{
logComment("File not found: " + fileN2PIni);
fileN2PIni = getFolder("file:///", fTemp + "net2fone.ini");
cErr = File.copy(fileN2PIni, fWindows);
logComment("File.copy() of " + fileN2PIni + " returned: " + cErr);
}
else
{
logComment("File found: " + fileN2PIni);
wpErr = updateNet2FoneIni();
logComment("updateNet2Fone returned: " + wpErr);
}
}
else
cancelInstall(err);
// check return value
if(!err)
{
fN2PExecute = getFolder(fN2P, "setupN2P.exe");
err = fileExecute(fN2PExecute, "/nofax /noGUI /nostr /noOL");
logComment("fileExecute() returned: " + err);
fileN2PIni = getFolder("file:///", fTemp + "net2fone.ini");
err = fileDelete(fileN2PIni);
logComment("fileDelete() returned: " + err);
err = performInstall();
logComment("performInstall() returned: " + err);
}
else
cancelInstall(err);
}
else
cancelInstall(INSUFFICIENT_DISK_SPACE);
// end main