home *** CD-ROM | disk | FTP | other *** search
- // 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 DeleteObsoleteShortcutsOnUpgrade()
- {
- var subkey;
- var valname;
- var szStartMenuPrograms;
- var szFolderDesktop;
- var winreg;
- var is_winnt;
- var versionThreshold;
- var rv;
- var keyVersion;
- var fFileToCheck;
- var fileFound;
-
- winreg = getWinRegistry();
- if(winreg != null)
- {
- /* 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);
- 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 = "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 Desktop";
- szFolderDesktop = winreg.getValueString(subkey, valname);
- }
-
- versionThreshold = "6.20.0.2001100100";
- rv = InstallTrigger.compareVersion("Mail", versionThreshold);
- keyVersion = InstallTrigger.getVersion("Mail");
- fFileToCheck = getFolder("Program", "msgbsutl.dll");
- fileFound = File.isFile(fFileToCheck);
-
- logComment("Folder Desktop : " + szFolderDesktop);
- logComment("Folder StartMenuPrograms: " + szStartMenuPrograms);
- logComment("versionThreshold : " + versionThreshold);
- logComment("keyVersion : " + keyVersion);
- logComment("compare result : " + rv);
- logComment("file to check : " + fFileToCheck);
- logComment("file to check found : " + fileFound);
- }
-
- if(fileFound && (rv < 0) && (keyVersion != null))
- {
- deleteThisFile("file:///", szStartMenuPrograms + "\\Netscape 6\\Mail.lnk");
- deleteThisFile("file:///", szStartMenuPrograms + "\\Netscape 6\\Free Aol & Unlimited Internet.url");
- deleteThisFolder("file:///", szStartMenuPrograms + "\\Netscape 6", false);
- }
- }
-
- 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\\Netscape";
- winreg.createKey(subkey,"");
-
- valname = "CurrentVersion";
- subkey = "SOFTWARE\\Netscape\\Netscape 6";
- winreg.createKey(subkey,"");
-
- valname = "CurrentVersion";
- value = "6.2 (en)";
- err = winreg.setValueString(subkey, valname, value);
-
- subkey = "SOFTWARE\\Netscape\\Netscape 6\\6.2 (en)";
- winreg.createKey(subkey,"");
-
- subkey = "SOFTWARE\\Netscape\\Netscape 6\\6.2 (en)\\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 + "Netscp6.exe";
- fileExe = getFolder("file:///", fTemp);
- scExeDesc = "Mail";
- scParam = "-mail";
- scFolderName = "Netscape 6";
- 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\\Netscape\\Netscape 6\\6.2 (en)\\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 updateMapi()
- {
- var winreg;
- var szValue;
- var szMapiBackupDll;
- var szDefaultMailClient;
- var programMozMapi32File;
- var mainExePath;
- var sfpProgramMozMapi32File;
- var sfpMainExePath;
- var winsysMapi32File;
- var mapiProxyFile;
-
- winreg = getWinRegistry();
- if(winreg != null)
- {
- mainExePath = getFolder("Program", "Netscp6.exe");
- programMozMapi32File = getFolder("Program", "mozMapi32.dll");
- winsysMapi32File = getFolder("Win System", "Mapi32.dll");
- winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
-
- // If Mapi_backup_dll *and* the default var of
- // HKEY_LOCAL_MACHINE\Software\Clients\Mail is set, then install
- // mozMapi32.dll to the windows system dir as Mapi32.dll.
- szMapiBackupDll = winreg.getValueString("SOFTWARE\\Mozilla\\Desktop", "Mapi_backup_dll");
- szDefaultMailClient = winreg.getValueString("SOFTWARE\\Clients\\Mail", "");
- logComment("szMapiBackupDll: " + szMapiBackupDll);
- logComment("szDefaultMailClient: " + szDefaultMailClient);
- if((szMapiBackupDll != null) && (szMapiBackupDll != "") &&
- (szDefaultMailClient != null) && (szDefaultMailClient == "Netscape 6"))
- {
- // We do not want to log this file to be uninstalled because the
- // uninstaller already has a special way to deal with restoring the
- // appropriate previous Mapi32.dll.
- addFile("",
- "6.20.0.2001102218",
- "bin/mozMapi32.dll", // file name in jar to extract
- getFolder("Win System"), // Where to put this file (Returned from getFolder)
- "Mapi32.dll", // new name when installed
- DO_NOT_UNINSTALL);
- }
-
- sfpProgramMozMapi32File = File.windowsGetShortName(programMozMapi32File);
- sfpMainExePath = File.windowsGetShortName(mainExePath);
-
- szValue = winreg.getValueString("SOFTWARE\\Clients\\Mail\\Netscape 6", "DLLPath");
- if((szValue != null) && (szValue != ""))
- winreg.setValueString("SOFTWARE\\Clients\\Mail", "DLLPath", sfpProgramMozMapi32File);
-
- szValue = winreg.getValueString("SOFTWARE\\Clients\\Mail\\Netscape 6\\DefaultIcon", "");
- if((szValue != null) && (szValue != ""))
- winreg.setValueString("SOFTWARE\\Clients\\Mail\\Netscape 6\\DefaultIcon",
- "",
- + sfpMainExePath + ",0");
-
- szValue = winreg.getValueString("SOFTWARE\\Clients\\Mail\\Netscape 6\\protocols\\mailto\\shell\\open\\command", "");
- if((szValue != null) && (szValue != ""))
- winreg.setValueString("SOFTWARE\\Clients\\Mail\\Netscape 6\\protocols\\mailto\\shell\\open\\command",
- "",
- sfpMainExePath + " \"%1\"");
-
- szValue = winreg.getValueString("SOFTWARE\\Clients\\Mail\\Netscape 6\\shell\\open\\command", "");
- if((szValue != null) && (szValue != ""))
- winreg.setValueString("SOFTWARE\\Clients\\Mail\\Netscape 6\\shell\\open\\command",
- "",
- sfpMainExePath + " -mail");
-
- // Register MapiProxy.dll
- mapiProxyFile = getFolder("Program", "MapiProxy.dll");
- err = File.windowsRegisterServer(mapiProxyFile);
- logComment("File.windowsRegisterServer(" + mapiProxyFile + ") returned: " + err);
- }
- }
-
- function upgradeCleanup()
- {
- // Obsolete files from Netscape 6.0 and Netscape 6.01 that
- // need to be cleaned up.
- deleteThisFile("Components", "signed.dll");
- }
-
- function updateWinIni()
- {
- var fWinIni = getWinProfile(getFolder("Windows"), "win.ini");
-
- if(fWinIni != null)
- {
- fWinIni.writeString("Mail", "MAPI", "1");
- fWinIni.writeString("Mail", "MAPIX", "1");
- }
- }
-
- // main
- var srDest;
- var err;
- var communicatorFolder;
- var restrictedAccess;
-
- // This list contains filenames that are long filenames ( > 8.3) critical during installation time.
- // This list is automatically generated during the build process.
- // The filenames should include paths relative to the Netscape 6 folder.
- // '/' must be used as path delimiters regardless of platform.
- var listLongFilePaths = ["chrome/messenger.jar",
- "components/impComm4x.dll",
- "components/nsAB4xUpgrader.dll",
- "components/nsMapiRegistry.dll",
- "MapiProxy.dll",
- "mozMapi32.dll"];
-
- srDest = 3329;
- err = initInstall("Netscape Mail", "Mail", "6.20.0.2001102218");
- logComment("initInstall: " + err);
-
- communicatorFolder = getFolder("Program");
- logComment("communicatorFolder: " + communicatorFolder);
-
- if(verifyDiskSpace(communicatorFolder, srDest))
- {
- setPackageFolder(communicatorFolder);
-
- /* delete the obsolete shortcuts on upgrade */
- DeleteObsoleteShortcutsOnUpgrade();
-
- // Ren8dot3 process needs to be done before any files have been installed
- // (this includes the temp files during the prepare phase)
- prepareRen8dot3(listLongFilePaths);
-
- err = addDirectory("",
- "6.20.0.2001102218",
- "bin", // dir name in jar to extract
- communicatorFolder, // Where to put this file (Returned from getFolder)
- "", // subdir name to create relative to communicatorFolder
- true ); // Force Flag
- logComment("addDirectory() returned: " + err);
-
- // check return value
- if( err == SUCCESS )
- {
- createShortcuts();
- upgradeCleanup();
- updateWinIni();
- updateMapi();
-
- // 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/");
-
- // log comments for uninstalling the registry keys created by mail for setting
- // itself up in WinXP's Start menu
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6 []");
- logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6 []");
- logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6 [DLLPath]");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\DefaultIcon []");
- logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\DefaultIcon []");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\protocols []");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\protocols\\mailto []");
- logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\protocols\\mailto []");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\protocols\\mailto\\shell []");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\protocols\\mailto\\shell\\open []");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\protocols\\mailto\\shell\\open\\command []");
- logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\protocols\\mailto\\shell\\open\\command []");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\shell []");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\shell\\open []");
- logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\shell\\open\\command []");
- logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\Netscape 6\\shell\\open\\command []");
-
- // 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
-