function updateMapi() { var winreg; var szValue; var szMapiBackupDll; var szDefaultMailClient; var programMozMapi32File; var mainExePath; var sfpProgramMozMapi32File; var sfpMainExePath; var winsysMapi32File; var mapiProxyFile; var subkey; var oldVersionIsDefautClient = false; var mailDefaultDescription = "$ProductName$"; winreg = getWinRegistry(); if(winreg != null) { mainExePath = getFolder("Program", "$MainExeFile$"); 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 == "$ProductName$")) { // 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("", "$Version$", "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); subkey = "SOFTWARE\\Clients\\Mail\\$ProductName$"; winreg.createKey(subkey, ""); winreg.setValueString(subkey, "", mailDefaultDescription); winreg.setValueString(subkey, "DLLPath", sfpProgramMozMapi32File); winreg.createKey(subkey + "\\DefaultIcon", ""); winreg.setValueString(subkey + "\\DefaultIcon", "", sfpMainExePath + ",0"); // Register mailto protocol handler winreg.createKey(subkey + "\\protocols", ""); winreg.createKey(subkey + "\\protocols\\mailto", ""); winreg.setValueString(subkey + "\\protocols\\mailto", "", "URL:MailTo Protocol"); winreg.setValueString(subkey + "\\protocols\\mailto", "URL Protocol", ""); winreg.createKey(subkey + "\\protocols\\mailto\\shell", ""); winreg.createKey(subkey + "\\protocols\\mailto\\shell\\open", ""); winreg.createKey(subkey + "\\protocols\\mailto\\shell\\open\\command", ""); winreg.setValueString(subkey + "\\protocols\\mailto\\shell\\open\\command", "", sfpMainExePath + " -compose \"%1\""); winreg.createKey(subkey + "\\protocols\\mailto\\DefaultIcon", ""); winreg.setValueString(subkey + "\\protocols\\mailto\\DefaultIcon", sfpMainExePath + ",0"); // register shell open command for Mozilla Thunderbird product key under \Mail winreg.createKey(subkey + "\\shell", ""); winreg.createKey(subkey + "\\shell\\open", ""); winreg.createKey(subkey + "\\shell\\open\\command", ""); winreg.setValueString(subkey + "\\shell\\open\\command", "", sfpMainExePath); winreg.createKey(subkey + "\\shell\\properties", ""); winreg.setValueString(subkey + "\\shell\\properties", "", "Thunderbird &Options"); winreg.createKey(subkey + "\\shell\\properties\\command", ""); winreg.setValueString(subkey + "\\shell\\properties\\command", "", sfpMainExePath + " -options"); // Register Thunderbird as a News Reader subkey = "SOFTWARE\\Clients\\News\\$ProductName$"; winreg.createKey(subkey, ""); winreg.setValueString(subkey, "", mailDefaultDescription); winreg.setValueString(subkey, "DLLPath", sfpProgramMozMapi32File); winreg.createKey(subkey + "\\DefaultIcon", ""); winreg.setValueString(subkey + "\\DefaultIcon", "", sfpMainExePath + ",0"); // register shell open command for Mozilla Thunderbird product key under \News winreg.createKey(subkey + "\\shell", ""); winreg.createKey(subkey + "\\shell\\open", ""); winreg.createKey(subkey + "\\shell\\open\\command", ""); winreg.setValueString(subkey + "\\shell\\open\\command", "", sfpMainExePath); // Register News protocol handlers (news, snews, nntp) winreg.createKey(subkey + "\\protocols", ""); winreg.createKey(subkey + "\\protocols\\news", ""); winreg.setValueString(subkey + "\\protocols\\news", "", "URL:News Protocol"); winreg.setValueString(subkey + "\\protocols\\news", "URL Protocol", ""); winreg.createKey(subkey + "\\protocols\\news\\shell", ""); winreg.createKey(subkey + "\\protocols\\news\\shell\\open", ""); winreg.createKey(subkey + "\\protocols\\news\\shell\\open\\command", ""); winreg.setValueString(subkey + "\\protocols\\news\\shell\\open\\command", "", sfpMainExePath + " -mail \"%1\""); winreg.createKey(subkey + "\\protocols\\news\\DefaultIcon", ""); winreg.setValueString(subkey + "\\protocols\\news\\DefaultIcon", sfpMainExePath + ",0"); winreg.createKey(subkey + "\\protocols\\nntp", ""); winreg.setValueString(subkey + "\\protocols\\nntp", "", "URL:NNTP Protocol"); winreg.setValueString(subkey + "\\protocols\\nntp", "URL Protocol", ""); winreg.createKey(subkey + "\\protocols\\nntp\\shell", ""); winreg.createKey(subkey + "\\protocols\\nntp\\shell\\open", ""); winreg.createKey(subkey + "\\protocols\\nntp\\shell\\open\\command", ""); winreg.setValueString(subkey + "\\protocols\\nntp\\shell\\open\\command", "", sfpMainExePath + " -mail \"%1\""); winreg.createKey(subkey + "\\protocols\\nntp\\DefaultIcon", ""); winreg.setValueString(subkey + "\\protocols\\nntp\\DefaultIcon", sfpMainExePath + ",0"); winreg.createKey(subkey + "\\protocols\\snews", ""); winreg.setValueString(subkey + "\\protocols\\snews", "", "URL:Snews Protocol"); winreg.setValueString(subkey + "\\protocols\\snews", "URL Protocol", ""); winreg.createKey(subkey + "\\protocols\\snews\\shell", ""); winreg.createKey(subkey + "\\protocols\\snews\\shell\\open", ""); winreg.createKey(subkey + "\\protocols\\snews\\shell\\open\\command", ""); winreg.setValueString(subkey + "\\protocols\\snews\\shell\\open\\command", "", sfpMainExePath + " -mail \"%1\""); winreg.createKey(subkey + "\\protocols\\snews\\DefaultIcon", ""); winreg.setValueString(subkey + "\\protocols\\snews\\DefaultIcon", sfpMainExePath + ",0"); subkey = "SOFTWARE\\$ProductName$\\Desktop"; szCurrentVersion = winreg.getValueString(subkey, "CurrentVersion"); logComment("szCurrentVersion: " + szCurrentVersion); // Register MapiProxy.dll mapiProxyFile = getFolder("Program", "MapiProxy.dll"); err = File.windowsRegisterServer(mapiProxyFile); logComment("File.windowsRegisterServer(" + mapiProxyFile + ") returned: " + err); // Ok, we've registered ourselves as a Mail and News client. We've registered all of the protocols we support. // If the user was using Thunderbird as their default client but had Thunderbird installed in a different directory // than what the installer is installing into, then we end up with the wrong version of Thunderbird as the default app. // to work around this, we are going to test what the current default mail app is. If it contains Thunderbird and it is not // pointing to us, then write into the registry the values necessary for Thunderbird to re-ask the user about being the default // mail app the next time the newly installed version comes up. This case happens a lot because we've had so many releases without // an installer that everyone has ended up installing bits into their own locations. if (szDefaultMailClient == "$ProductName$") { // check to see if the location of the default mail protocol handler matches the location we just wrote to... // if it does not, then var szNewMailtoProtocolHandler = sfpMainExePath + " -compose \"%1\""; var szOldMailtoProtocolHandler = winreg.getValueString("Software\\Classes\\mailto\\shell\\open\\command", ""); if ((szOldMailtoProtocolHandler != null) && (szNewMailtoProtocolHandler != szOldMailtoProtocolHandler)) oldVersionIsDefautClient = true; logComment("oldVersionIsDefautClient: " + oldVersionIsDefautClient); } // now that we have registred ourselves as a mail and news client, make some notations in our scratch pad // so the client doesn't try to re-register the same keys all over again. subkey = "SOFTWARE\\$ProductName$"; winreg.createKey(subkey, ""); winreg.createKey(subkey + "\\Desktop", ""); winreg.setValueString(subkey + "\\Desktop", "registeredAsMailApp", "1"); winreg.setValueString(subkey + "\\Desktop", "registeredAsNewsApp", "1"); if (oldVersionIsDefautClient) { // ok here's a scenario where a different version of thunderbird is the default mail client in a different directory // from where the installer is putting it. So clear out our scratchpad registry entries to make Thunderbird ask the user // if it should be the default client again. logComment("Resetting showMapiDialog and defaultMailHasBeenSet"); winreg.setValueString(subkey + "\\Desktop", "showMapiDialog", "1"); winreg.setValueString(subkey + "\\Desktop", "defaultMailHasBeenSet", "0"); } } } 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 err2; var fProgram; var fWindowsSystem; var fileComponentRegStr; var fileComponentReg; var restrictedAccess; var fileToRegister; var args; args = new String(Install.arguments); logComment("args: " + args); srDest = $SpaceRequired$:bin; err = initInstall("$ProductName$", "Thunderbird", "$Version$"); logComment("initInstall: " + err); fProgram = getFolder("Program"); fWindowsSystem = getFolder("Win System"); logComment("fProgram: " + fProgram); if(verifyDiskSpace(fProgram, srDest)) { setPackageFolder(fProgram); removeOldFiles(); 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() of Program returned: " + err); // check return value if( err == SUCCESS ) { fileToRegister = getFolder(fProgram, "AccessibleMarshal.dll"); err2 = File.windowsRegisterServer(fileToRegister); logComment("windowsRegisterServer() returned: " + err2); updateWinIni(); updateMapi(); // we don't want to fail on errors for the above two resetError(); // Create the uninstall folder. err = File.dirCreate(getFolder("Program", "uninstall")); logComment("dirCreate() of Program/uninstall returned: " + err); /* Log files that are created after the installer is done, so they can be uninstalled */ logComment("Installing: " + fProgram + ".autoreg"); logComment("Installing: " + fProgram + "Xpcs Registry.dat"); logComment("Installing: " + fProgram + "xpcom.log"); logComment("Create Folder: " + fProgram + "components"); logComment("Installing: " + fProgram + "components\\xpti.dat"); logComment("Installing: " + fProgram + "components\\xptitemp.dat"); logComment("Installing: " + fProgram + "components\\compreg.dat"); logComment("Create Folder: " + fProgram + "chrome"); logComment("Create Folder: " + fProgram + "uninstall"); logComment("Installing: " + fProgram + "active-update.xml"); logComment("Installing: " + fProgram + "updates.xml"); logComment("Installing: " + fProgram + "last-update.log"); logComment("Create Folder: " + fProgram + "updates"); // 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\\$ProductName$ []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$ []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$ [DLLPath]"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\DefaultIcon []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\DefaultIcon []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\protocols []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\protocols\\mailto []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\protocols\\mailto []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\protocols\\mailto\\DefaultIcon []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\protocols\\mailto\\shell []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\protocols\\mailto\\shell\\open []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\protocols\\mailto\\shell\\open\\command []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\protocols\\mailto\\shell\\open\\command []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\shell []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\shell\\open []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\shell\\open\\command []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\$ProductName$\\shell\\open\\command []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$ []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$ []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$ [DLLPath]"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\DefaultIcon []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\DefaultIcon []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\news []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\news []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\news\\DefaultIcon []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\news\\shell []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\news\\shell\\open []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\news\\shell\\open\\command []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\news\\shell\\open\\command []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\snews []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\snews []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\snews\\DefaultIcon []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\snews\\shell []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\snews\\shell\\open []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\snews\\shell\\open\\command []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\snews\\shell\\open\\command []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\nntp []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\nntp []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\nntp\\DefaultIcon []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\nntp\\shell []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\nntp\\shell\\open []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\nntp\\shell\\open\\command []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\protocols\\nntp\\shell\\open\\command []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\shell []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\shell\\open []"); logComment("Create Registry Key: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\shell\\open\\command []"); logComment("Store Registry Value: HKEY_LOCAL_MACHINE\\Software\\Clients\\News\\$ProductName$\\shell\\open\\command []"); err = getLastError(); if (err == SUCCESS) { err = performInstall(); logComment("performInstall() returned: " + err); if (! ('buildID' in Install)) { logComment("Running Pre-Mozilla 0.9.1"); initInstall("Post-install Cleanup Utility", "Mail/xpicleanup", "$Version$"); cleanupUtility = getFolder(fProgram, "xpicleanup.exe"); err = File.execute(cleanupUtility); logComment("execute() returned: " + err); err = performInstall(); } } else cancelInstall(err); } else cancelInstall(err); } else cancelInstall(INSUFFICIENT_DISK_SPACE); // end main