mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-14 15:37:55 +00:00
250 lines
7.8 KiB
Plaintext
250 lines
7.8 KiB
Plaintext
function registerProgramFolderKey(winreg, fFolderPath)
|
|
{
|
|
var subkey;
|
|
var valname;
|
|
var value;
|
|
var err;
|
|
|
|
/* set the Program Folder Path in the Mozilla key in the Windows Registry */
|
|
subkey = "SOFTWARE\\$CompanyName$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
valname = "CurrentVersion";
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
valname = "CurrentVersion";
|
|
value = "$UserAgent$";
|
|
err = winreg.setValueString(subkey, valname, value);
|
|
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main";
|
|
winreg.createKey(subkey,"");
|
|
|
|
valname = "Program Folder Path";
|
|
value = fFolderPath;
|
|
err = winreg.setValueString(subkey, valname, value);
|
|
}
|
|
|
|
function createShortcuts()
|
|
{
|
|
var subkey;
|
|
var valname;
|
|
var szStartMenuPrograms;
|
|
var szStartMenu;
|
|
var szFolderDesktop;
|
|
var szFolderQuickLaunch;
|
|
var szFolderSendTo;
|
|
var winreg;
|
|
var fWindows;
|
|
var fTemp;
|
|
var fProgram;
|
|
var fileExe;
|
|
var scExeDesc;
|
|
var scProfileDesc;
|
|
var scProfileDescParam;
|
|
var scFolderName;
|
|
var fFolderDesktop;
|
|
var fFolderPath;
|
|
var fFolderPathStr;
|
|
var is_winnt;
|
|
var szCurrentVersion;
|
|
var restrictedAccess;
|
|
var ikwDefined;
|
|
|
|
winreg = getWinRegistry();
|
|
fWindows = getFolder("Windows");
|
|
fProgram = getFolder("Program");
|
|
fTemp = fProgram + "$MainExeFile$";
|
|
fileExe = getFolder("file:///", fTemp);
|
|
scExeDesc = "Mail";
|
|
scParam = "-mail";
|
|
scFolderName = "$ProductName$";
|
|
if(winreg != null)
|
|
{
|
|
/* This will check to see if the user has restricted access or not.
|
|
* It checks to see if HKEY_LOCALMACHINE\SOFTWARE is writable. If
|
|
* it is, then access is not restricted. This is only used to
|
|
* determine which Desktop, Programs, and Start Menu folders
|
|
* are to used: common or per user
|
|
*/
|
|
restrictedAccess = false;
|
|
ikwDefined = typeof(winreg.isKeyWritable);
|
|
logComment("winreg.isKeyWritable(): " + ikwDefined);
|
|
if(ikwDefined == "function")
|
|
{
|
|
winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
|
|
if(!winreg.isKeyWritable("SOFTWARE"))
|
|
restrictedAccess = true;
|
|
}
|
|
|
|
/* determine if the script is running under NT or not */
|
|
winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
|
|
subkey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
|
|
valname = "CurrentVersion";
|
|
szCurrentVersion = winreg.getValueString(subkey, valname);
|
|
logComment("szCurrentVersion: " + szCurrentVersion);
|
|
if((szCurrentVersion == "") || (szCurrentVersion == null))
|
|
{
|
|
is_winnt = false;
|
|
}
|
|
else
|
|
{
|
|
is_winnt = true;
|
|
}
|
|
|
|
logComment("is_winnt value: " + is_winnt);
|
|
logComment("restrictedAccess value: " + restrictedAccess);
|
|
if(!is_winnt || restrictedAccess)
|
|
{
|
|
winreg.setRootKey(winreg.HKEY_CURRENT_USER);
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
|
valname = "Programs";
|
|
szStartMenuPrograms = winreg.getValueString(subkey, valname);
|
|
valname = "Start Menu";
|
|
szStartMenu = winreg.getValueString(subkey, valname);
|
|
valname = "Desktop";
|
|
szFolderDesktop = winreg.getValueString(subkey, valname);
|
|
}
|
|
else
|
|
{
|
|
winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
|
valname = "Common Programs";
|
|
szStartMenuPrograms = winreg.getValueString(subkey, valname);
|
|
valname = "Common Start Menu";
|
|
szStartMenu = winreg.getValueString(subkey, valname);
|
|
valname = "Common Desktop";
|
|
szFolderDesktop = winreg.getValueString(subkey, valname);
|
|
}
|
|
|
|
winreg.setRootKey(winreg.HKEY_CURRENT_USER);
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
|
valname = "SendTo";
|
|
szFolderSendTo = winreg.getValueString(subkey, valname);
|
|
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GrpConv\\MapGroups";
|
|
valname = "Quick Launch";
|
|
szFolderQuickLaunch = winreg.getValueString(subkey, valname);
|
|
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main";
|
|
valname = "Program Folder Path";
|
|
fFolderPathStr = winreg.getValueString(subkey, valname);
|
|
if((fFolderPathStr == "") || (fFolderPathStr == null))
|
|
{
|
|
fTemp = szStartMenuPrograms + "\\" + scFolderName;
|
|
fFolderPath = getFolder("file:///", fTemp);
|
|
}
|
|
else
|
|
{
|
|
/* convert the path string to a path folder object */
|
|
fFolderPath = getFolder("file:///", fFolderPathStr);
|
|
}
|
|
/* convert the path string to a path folder object */
|
|
fFolderDesktop = getFolder("file:///", szFolderDesktop);
|
|
|
|
logComment("Folder StartMenuPrograms: " + szStartMenuPrograms);
|
|
logComment("Folder StartMenu : " + szStartMenu);
|
|
logComment("Folder FolderDesktop : " + szFolderDesktop);
|
|
logComment("Folder FolderSendTo : " + szFolderSendTo);
|
|
logComment("Folder FolderQuickLaunch: " + szFolderQuickLaunch);
|
|
logComment("fileExe : " + fileExe);
|
|
logComment("fFolderPath : " + fFolderPath);
|
|
logComment("scExeDesc : " + scExeDesc);
|
|
logComment("fProgram : " + fProgram);
|
|
|
|
/* explicitly create the fFolderPath even though the windowsShortcut function creates the folder.
|
|
* This is so that the folder creation gets logged for uninstall to remove it. */
|
|
if(!File.exists(fFolderPath))
|
|
File.dirCreate(fFolderPath);
|
|
|
|
/* create the shortcuts */
|
|
File.windowsShortcut(fileExe, fFolderPath, scExeDesc, fProgram, scParam, fileExe, 0);
|
|
|
|
if(!restrictedAccess)
|
|
{
|
|
winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
|
|
registerProgramFolderKey(winreg, fFolderPath);
|
|
}
|
|
|
|
winreg.setRootKey(winreg.HKEY_CURRENT_USER);
|
|
registerProgramFolderKey(winreg, fFolderPath);
|
|
}
|
|
else
|
|
{
|
|
logComment("winreg is null");
|
|
}
|
|
}
|
|
|
|
function upgradeCleanup()
|
|
{
|
|
// Obsolete files from Netscape 6.0 and Netscape 6.01 that
|
|
// need to be cleaned up.
|
|
deleteThisFile("Components", "signed.dll");
|
|
}
|
|
|
|
// main
|
|
var srDest;
|
|
var err;
|
|
var fProgram;
|
|
|
|
$Ren8dot3List$
|
|
|
|
srDest = $SpaceRequired$:bin;
|
|
err = initInstall("Mozilla Mail", "Mail", "$Version$");
|
|
logComment("initInstall: " + err);
|
|
|
|
fProgram = getFolder("Program");
|
|
logComment("fProgram: " + fProgram);
|
|
|
|
if(verifyDiskSpace(fProgram, srDest))
|
|
{
|
|
setPackageFolder(fProgram);
|
|
|
|
$Ren8dot3Call$
|
|
|
|
err = addDirectory("",
|
|
"$Version$",
|
|
"bin", // dir name in jar to extract
|
|
fProgram, // Where to put this file (Returned from GetFolder)
|
|
"", // subdir name to create relative to fProgram
|
|
true); // Force Flag
|
|
logComment("addDirectory() returned: " + err);
|
|
|
|
// check return value
|
|
if( err == SUCCESS )
|
|
{
|
|
createShortcuts();
|
|
upgradeCleanup();
|
|
|
|
// we don't want to fail on errors for the above
|
|
resetError();
|
|
|
|
// register chrome
|
|
registerChrome(CONTENT | DELAYED_CHROME,
|
|
getFolder("Chrome","messenger.jar"),
|
|
"content/messenger/");
|
|
registerChrome(CONTENT | DELAYED_CHROME,
|
|
getFolder("Chrome","messenger.jar"),
|
|
"content/messenger-region/");
|
|
|
|
// check return value
|
|
err = getLastError();
|
|
if(err == SUCCESS)
|
|
{
|
|
err = performInstall();
|
|
logComment("performInstall() returned: " + err);
|
|
}
|
|
else
|
|
cancelInstall(err);
|
|
}
|
|
else
|
|
cancelInstall(err);
|
|
}
|
|
else
|
|
cancelInstall(INSUFFICIENT_DISK_SPACE);
|
|
|
|
// end main
|