[Sunbird] Bug 470197 - Update installer. r=ctalbert
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 19 Dec 2008 16:02:38 -0800
changeset 1463 6611a5482754
parent 1462 e10a3baac8d7
child 1464 4daac073741d
push id1162
push userrstrong@mozilla.com
push dateSat, 20 Dec 2008 00:03:57 +0000
treeherdercomm-central@6611a5482754 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersctalbert
bugs470197
[Sunbird] Bug 470197 - Update installer. r=ctalbert
calendar/installer/removed-files.in
calendar/installer/windows/Makefile.in
calendar/installer/windows/nsis/defines.nsi.in
calendar/installer/windows/nsis/installer.nsi
calendar/installer/windows/nsis/shared.nsh
calendar/installer/windows/nsis/uninstaller.nsi
calendar/installer/windows/nsis/updater_append.ini
calendar/installer/windows/packages-static
calendar/locales/Makefile.in
calendar/locales/en-US/installer/custom.properties
calendar/locales/en-US/installer/mui.properties
calendar/locales/en-US/installer/override.properties
calendar/sunbird/locales/Makefile.in
--- a/calendar/installer/removed-files.in
+++ b/calendar/installer/removed-files.in
@@ -253,16 +253,18 @@ res/table-remove-row.gif
 res/viewer.properties
 dependentlibs.list
 mozctl.dll
 mozctlx.dll
 regxpcom.exe
 sunbird.url
 unins000.dat
 unins000.exe
+uninstall/UninstallSunbird.exe
+uninstall/uninst.exe
 xpcom_compat.dll
 components/nsInterfaceInfoToIDL.js
 xpcshell.exe
 xpidl.exe
 xpt_dump.exe
 xpt_link.exe
 #
 # Clean out obsolete files from Sunbird 0.5 installer
@@ -273,17 +275,16 @@ js/calWcapCachedCalendar.js
 #endif
 #
 #ifndef XP_MACOSX
 components/autocomplete.xpt
 #endif
 @DLL_PREFIX@zlib@DLL_SUFFIX@
 extensions/inspector@mozilla.org/components/inspector.xpt
 extensions/inspector@mozilla.org/components/@DLL_PREFIX@inspector@DLL_SUFFIX@
-uninstall/UninstallSunbird.exe
 #
 #
 # Clean out obsolete Talkback files
 #
 extensions/talkback@mozilla.org/
 extensions/talkback@mozilla.org/install.rdf
 extensions/talkback@mozilla.org/chrome.manifest
 extensions/talkback@mozilla.org/components/qfaservices.xpt
--- a/calendar/installer/windows/Makefile.in
+++ b/calendar/installer/windows/Makefile.in
@@ -50,16 +50,17 @@ SFX_MODULE = $(MOZILLA_SRCDIR)/other-lic
 PP_LOCALIZED_FILES = \
 	packages-static \
 	$(NULL)
 
 INSTALLER_FILES = \
 	app.tag \
 	nsis/installer.nsi \
 	nsis/uninstaller.nsi \
+	nsis/shared.nsh \
 	$(NULL)
 
 BRANDING_FILES = \
 	branding.nsi \
 	license.txt \
 	wizHeader.bmp \
 	wizHeaderRTL.bmp \
 	wizWatermark.bmp \
--- a/calendar/installer/windows/nsis/defines.nsi.in
+++ b/calendar/installer/windows/nsis/defines.nsi.in
@@ -1,11 +1,9 @@
 #filter substitution
 !define AppVersion            "@MOZ_APP_VERSION@"
 !define GREVersion            @MOZILLA_VERSION@
 !define AB_CD                 "@AB_CD@"
-!define FileInstallerEXE      "@PKG_BASENAME@.installer.exe"
-!define FileInstallerMSI      "@PKG_BASENAME@.installer.msi"
-!define FileInstallerNETRoot  "@PKG_BASENAME@.net-installer"
 
 !define FileMainEXE           "sunbird.exe"
 !define NO_UNINSTALL_SURVEY
 !define WindowClass           "SunbirdMessageWindow"
+!define MinSupportedVer       "Microsoft Windows 2000"
--- a/calendar/installer/windows/nsis/installer.nsi
+++ b/calendar/installer/windows/nsis/installer.nsi
@@ -29,98 +29,112 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
-# Also requires:
-# ShellLink plugin http://nsis.sourceforge.net/ShellLink_plug-in
+# Required Plugins:
+# AppAssocReg http://nsis.sourceforge.net/Application_Association_Registration_plug-in
+# ShellLink   http://nsis.sourceforge.net/ShellLink_plug-in
+# UAC         http://nsis.sourceforge.net/UAC_plug-in
 
 ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
 !verbose 3
 
 ; 7-Zip provides better compression than the lzma from NSIS so we add the files
 ; uncompressed and use 7-Zip to create a SFX archive of it
 SetDatablockOptimize on
 SetCompress off
 CRCCheck on
 
+RequestExecutionLevel user
+
 !addplugindir ./
 
 ; empty files - except for the comment line - for generating custom pages.
 !system 'echo ; > options.ini'
-!system 'echo ; > components.ini'
 !system 'echo ; > shortcuts.ini'
+!system 'echo ; > summary.ini'
+
+; USE_UAC_PLUGIN is temporary until all applications have been updated to use
+; the UAC plugin
+!define USE_UAC_PLUGIN
 
 Var TmpVal
 Var StartMenuDir
 Var InstallType
 Var AddStartMenuSC
 Var AddQuickLaunchSC
 Var AddDesktopSC
-Var fhInstallLog
-Var fhUninstallLog
 
 ; Other included files may depend upon these includes!
 ; The following includes are provided by NSIS.
 !include FileFunc.nsh
 !include LogicLib.nsh
-!include TextFunc.nsh
+!include MUI.nsh
 !include WinMessages.nsh
+!include WinVer.nsh
 !include WordFunc.nsh
-!include MUI.nsh
 
-!insertmacro FileJoin
-!insertmacro GetTime
-!insertmacro LineFind
+!insertmacro GetOptions
+!insertmacro GetParameters
+!insertmacro GetSize
 !insertmacro StrFilter
-!insertmacro TrimNewLines
-!insertmacro WordFind
 !insertmacro WordReplace
-!insertmacro GetSize
-!insertmacro GetParameters
-!insertmacro GetOptions
-!insertmacro GetRoot
-!insertmacro DriveSpace
 
 ; The following includes are custom.
 !include branding.nsi
 !include defines.nsi
 !include common.nsh
 !include locales.nsi
 !include version.nsh
 
 VIAddVersionKey "FileDescription" "${BrandShortName} Installer"
+VIAddVersionKey "OriginalFilename" "setup.exe"
 
+; Must be inserted before other macros that use logging
+!insertmacro _LoggingCommon
+
+!insertmacro ChangeMUIHeaderImage
+!insertmacro CheckForFilesInUse
+!insertmacro CleanUpdatesDir
+!insertmacro CopyFilesFromDir
+!insertmacro GetPathFromString
+!insertmacro GetParent
+!insertmacro ManualCloseAppPrompt
 !insertmacro RegCleanMain
 !insertmacro RegCleanUninstall
-!insertmacro CloseApp
+!insertmacro SetBrandNameVars
+!insertmacro UnloadUAC
 !insertmacro WriteRegStr2
 !insertmacro WriteRegDWORD2
-!insertmacro WriteRegStrHKCR
-!insertmacro CreateRegKey
-!insertmacro CanWriteToInstallDir
-!insertmacro CheckDiskSpace
+
+!include shared.nsh
 
-!include overrides.nsh
-!insertmacro LocateNoDetails
-!insertmacro TextCompareNoDetails
+; Helper macros for ui callbacks. Insert these after shared.nsh
+!insertmacro CheckCustomCommon
+!insertmacro InstallEndCleanupCommon
+!insertmacro InstallOnInitCommon
+!insertmacro InstallStartCleanupCommon
+!insertmacro LeaveDirectoryCommon
+!insertmacro OnEndCommon
+!insertmacro PreDirectoryCommon
 
 Name "${BrandFullName}"
 OutFile "setup.exe"
 InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" "InstallLocation"
-InstallDir "$PROGRAMFILES\${BrandFullName}"
+InstallDir "$PROGRAMFILES\${BrandFullName}\"
 ShowInstDetails nevershow
 
 ReserveFile options.ini
-ReserveFile components.ini
 ReserveFile shortcuts.ini
+ReserveFile summary.ini
 
 ################################################################################
 # Modern User Interface - MUI
 
 !define MUI_ABORTWARNING
 !define MUI_ICON setup.ico
 !define MUI_UNICON setup.ico
 !define MUI_WELCOMEPAGE_TITLE_3LINES
@@ -134,152 +148,103 @@ ReserveFile shortcuts.ini
 !else
 !define MUI_HEADERIMAGE_BITMAP wizHeader.bmp
 !endif
 
 /**
  * Installation Pages
  */
 ; Welcome Page
+!define MUI_PAGE_CUSTOMFUNCTION_PRE preWelcome
 !insertmacro MUI_PAGE_WELCOME
 
 ; License Page
-!define MUI_LICENSEPAGE_RADIOBUTTONS
+!define MUI_PAGE_CUSTOMFUNCTION_SHOW showLicense
+!define MUI_LICENSEPAGE_CHECKBOX
 !insertmacro MUI_PAGE_LICENSE license.txt
 
 ; Custom Options Page
 Page custom preOptions leaveOptions
 
-; Custom Components Page
-Page custom preComponents leaveComponents
-
 ; Select Install Directory Page
 !define MUI_PAGE_CUSTOMFUNCTION_PRE preDirectory
 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveDirectory
 !define MUI_DIRECTORYPAGE_VERIFYONLEAVE
 !insertmacro MUI_PAGE_DIRECTORY
 
 ; Custom Shortcuts Page
 Page custom preShortcuts leaveShortcuts
 
 ; Start Menu Folder Page Configuration
 !define MUI_PAGE_CUSTOMFUNCTION_PRE preStartMenu
+!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveStartMenu
 !define MUI_STARTMENUPAGE_NODISABLE
 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Main"
 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuDir
 
+; Custom Summary Page
+Page custom preSummary leaveSummary
+
 ; Install Files Page
-!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveInstFiles
 !insertmacro MUI_PAGE_INSTFILES
 
 ; Finish Page
-!define MUI_FINISHPAGE_NOREBOOTSUPPORT
 !define MUI_FINISHPAGE_TITLE_3LINES
 !define MUI_FINISHPAGE_RUN
 !define MUI_FINISHPAGE_RUN_FUNCTION LaunchApp
 !define MUI_FINISHPAGE_RUN_TEXT $(LAUNCH_TEXT)
 !define MUI_PAGE_CUSTOMFUNCTION_PRE preFinish
 !insertmacro MUI_PAGE_FINISH
 
+; Use the default dialog for IDD_VERIFY for a simple Banner
+ChangeUI IDD_VERIFY "${NSISDIR}\Contrib\UIs\default.exe"
+
 ################################################################################
 # Install Sections
 
-Section "-Application" Section1
-  SectionIn 1 RO
-  SetDetailsPrint textonly
+; Cleanup operations to perform at the start of the installation.
+Section "-InstallStartCleanup"
+  SetDetailsPrint both
   DetailPrint $(STATUS_CLEANUP)
   SetDetailsPrint none
-  SetOutPath $INSTDIR
 
-  ; Try to delete the app executable and if we can't delete it try to close the
-  ; app. This allows running an instance that is located in another directory.
+  SetOutPath "$INSTDIR"
+  ${StartInstallLog} "${BrandFullName}" "${AB_CD}" "${AppVersion}" "${GREVersion}"
+
+  ; Delete the app exe to prevent launching the app while we are installing.
   ClearErrors
-  ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
-    ${DeleteFile} "$INSTDIR\${FileMainEXE}"
-  ${EndIf}
+  ${DeleteFile} "$INSTDIR\${FileMainEXE}"
   ${If} ${Errors}
-    ClearErrors
-    ${CloseApp} "true" $(WARN_APP_RUNNING_INSTALL)
-    ; Try to delete it again to prevent launching the app while we are
-    ; installing.
+    ; If the user closed the application it can take several seconds for it to
+    ; shut down completely. If the application is being used by another user we
+    ; can rename the file and then delete is when the system is restarted.
+    Sleep 5000
     ${DeleteFile} "$INSTDIR\${FileMainEXE}"
     ClearErrors
   ${EndIf}
 
-  ${If} $InstallType != 1
-    ; Custom installs.
-    ; If DOMi is installed and this install includes DOMi remove it from
-    ; the installation directory. This will remove it if the user deselected
-    ; DOMi on the components page.
-    ${If} ${FileExists} "$INSTDIR\extensions\inspector@mozilla.org"
-    ${AndIf} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org"
-      RmDir /r "$INSTDIR\extensions\inspector@mozilla.org"
-    ${EndIf}
-  ${EndIf}
-
-  Call CleanupOldLogs
-
-  ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.log"
-    ; Diff cleanup.log with uninstall.bak
-    ${LogHeader} "Updating Uninstall Log With XPInstall Wizard Logs"
-    StrCpy $R0 "$INSTDIR\uninstall\uninstall.log"
-    StrCpy $R1 "$INSTDIR\uninstall\cleanup.log"
-    GetTempFileName $R2
-    FileOpen $R3 $R2 w
-    ${TextCompareNoDetails} "$R1" "$R0" "SlowDiff" "GetDiff"
-    FileClose $R3
-
-    ${Unless} ${Errors}
-      ${FileJoin} "$INSTDIR\uninstall\uninstall.log" "$R2" "$INSTDIR\uninstall\uninstall.log"
-    ${EndUnless}
-    ${DeleteFile} "$INSTDIR\uninstall\cleanup.log"
-    ${DeleteFile} "$R2"
-    ${DeleteFile} "$INSTDIR\uninstall\uninstall.bak"
-    Rename "$INSTDIR\uninstall\uninstall.log" "$INSTDIR\uninstall\uninstall.bak"
-  ${EndIf}
+  ; Remove the updates directory for Vista and above
+  ${CleanUpdatesDir} "Mozilla\Sunbird"
 
-  ${Unless} ${FileExists} "$INSTDIR\uninstall"
-    CreateDirectory "$INSTDIR\uninstall"
-  ${EndUnless}
-
-  FileOpen $fhUninstallLog "$INSTDIR\uninstall\uninstall.log" w
-  FileOpen $fhInstallLog "$INSTDIR\install.log" w
-
-  ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
-  FileWrite $fhInstallLog "${BrandFullName} Installation Started: $2-$1-$0 $4:$5:$6"
-  Call WriteLogSeparator
+  ${InstallStartCleanupCommon}
+SectionEnd
 
-  ${LogHeader} "Installation Details"
-  ${LogMsg} "Install Dir: $INSTDIR"
-  ${LogMsg} "Locale     : ${AB_CD}"
-  ${LogMsg} "App Version: ${AppVersion}"
-  ${LogMsg} "GRE Version: ${GREVersion}"
+Section "-Application" APP_IDX
+  ${StartUninstallLog}
 
-  ${If} ${FileExists} "$EXEDIR\removed-files.log"
-    ${LogHeader} "Removing Obsolete Files and Directories"
-    ${LineFind} "$EXEDIR\removed-files.log" "/NUL" "1:-1" "onInstallDeleteFile"
-    ${LineFind} "$EXEDIR\removed-files.log" "/NUL" "1:-1" "onInstallRemoveDir"
-  ${EndIf}
-
-  ${DeleteFile} "$INSTDIR\install_wizard.log"
-  ${DeleteFile} "$INSTDIR\install_status.log"
-
-  RmDir /r "$INSTDIR\updates"
-  ${DeleteFile} "$INSTDIR\updates.xml"
-  ${DeleteFile} "$INSTDIR\active-update.xml"
-
-  SetDetailsPrint textonly
+  SetDetailsPrint both
   DetailPrint $(STATUS_INSTALL_APP)
   SetDetailsPrint none
+
   ${LogHeader} "Installing Main Files"
-  StrCpy $R0 "$EXEDIR\nonlocalized"
-  StrCpy $R1 "$INSTDIR"
-  Call DoCopyFiles
+  ${CopyFilesFromDir} "$EXEDIR\nonlocalized" "$INSTDIR" \
+                      "$(ERROR_CREATE_DIRECTORY_PREFIX)" \
+                      "$(ERROR_CREATE_DIRECTORY_SUFFIX)"
 
   ; Register DLLs
   ; XXXrstrong - AccessibleMarshal.dll can be used by multiple applications but
   ; is only registered for the last application installed. When the last
   ; application installed is uninstalled AccessibleMarshal.dll will no longer be
   ; registered. bug 338878
   ${LogHeader} "DLL Registration"
   ClearErrors
@@ -299,29 +264,24 @@ Section "-Application" Section1
   ${LogUninstall} "File: \components\xpti.dat"
   ${LogUninstall} "File: \.autoreg"
   ${LogUninstall} "File: \active-update.xml"
   ${LogUninstall} "File: \install.log"
   ${LogUninstall} "File: \install_status.log"
   ${LogUninstall} "File: \install_wizard.log"
   ${LogUninstall} "File: \updates.xml"
 
-  SetDetailsPrint textonly
+  SetDetailsPrint both
   DetailPrint $(STATUS_INSTALL_LANG)
   SetDetailsPrint none
+
   ${LogHeader} "Installing Localized Files"
-  StrCpy $R0 "$EXEDIR\localized"
-  StrCpy $R1 "$INSTDIR"
-  Call DoCopyFiles
-
-  ${If} $InstallType != 4
-    ${If} ${FileExists} "$INSTDIR\extensions\inspector@mozilla.org"
-      Call installInspector
-    ${EndIf}
-  ${EndIf}
+  ${CopyFilesFromDir} "$EXEDIR\localized" "$INSTDIR" \
+                      "$(ERROR_CREATE_DIRECTORY_PREFIX)" \
+                      "$(ERROR_CREATE_DIRECTORY_SUFFIX)"
 
   ; Default for creating Start Menu folder and shortcuts
   ; (1 = create, 0 = don't create)
   ${If} $AddStartMenuSC == ""
     StrCpy $AddStartMenuSC "1"
   ${EndIf}
 
   ; Default for creating Quick Launch shortcut (1 = create, 0 = don't create)
@@ -329,348 +289,214 @@ Section "-Application" Section1
     StrCpy $AddQuickLaunchSC "1"
   ${EndIf}
 
   ; Default for creating Desktop shortcut (1 = create, 0 = don't create)
   ${If} $AddDesktopSC == ""
     StrCpy $AddDesktopSC "1"
   ${EndIf}
 
-  ; Remove registry entries for non-existent apps and for apps that point to our
-  ; install location in the Software\Mozilla key and uninstall registry entries
-  ; that point to our install location for both HKCU and HKLM.
+  ${LogHeader} "Adding Registry Entries"
   SetShellVarContext current  ; Set SHCTX to HKCU
   ${RegCleanMain} "Software\Mozilla"
   ${RegCleanUninstall}
 
-  SetShellVarContext all  ; Set SHCTX to HKLM
-  ${RegCleanMain} "Software\Mozilla"
-  ${RegCleanUninstall}
-
-  ${LogHeader} "Adding Registry Entries"
   ClearErrors
-  WriteRegStr HKLM "Software\Mozilla\InstallerTest" "InstallerTest" "Test"
+  WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
   ${If} ${Errors}
-    SetShellVarContext current  ; Set SHCTX to HKCU
     StrCpy $TmpVal "HKCU" ; used primarily for logging
   ${Else}
     SetShellVarContext all  ; Set SHCTX to HKLM
-    DeleteRegKey HKLM "Software\Mozilla\InstallerTest"
+    DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
     StrCpy $TmpVal "HKLM" ; used primarily for logging
+    ${RegCleanMain} "Software\Mozilla"
+    ${RegCleanUninstall}
   ${EndIf}
 
   ; The previous installer adds several regsitry values to both HKLM and HKCU.
   ; We now try to add to HKLM and if that fails to HKCU
 
   ; The order that reg keys and values are added is important if you use the
   ; uninstall log to remove them on uninstall. When using the uninstall log you
   ; MUST add children first so they will be removed first on uninstall so they
   ; will be empty when the key is deleted. This allows the uninstaller to
   ; specify that only empty keys will be deleted.
+  ${SetAppKeys}
 
-  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Main"
-  ${WriteRegStr2} $TmpVal "$0" "Install Directory" "$INSTDIR" 0
-  ${WriteRegStr2} $TmpVal "$0" "PathToExe" "$INSTDIR\${FileMainEXE}" 0
-  ${WriteRegStr2} $TmpVal "$0" "Program Folder Path" "$SMPROGRAMS\$StartMenuDir" 0
-  ${WriteRegDWORD2} $TmpVal "$0" "Create Quick Launch Shortcut" $AddQuickLaunchSC 0
-  ${WriteRegDWORD2} $TmpVal "$0" "Create Desktop Shortcut" $AddDesktopSC 0
+  ; XXXrstrong - this should be set in shared.nsh along with "Create Quick
+  ; Launch Shortcut" and Create Desktop Shortcut.
+  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Uninstall"
   ${WriteRegDWORD2} $TmpVal "$0" "Create Start Menu Shortcut" $AddStartMenuSC 0
 
-  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Uninstall"
-  ${WriteRegStr2} $TmpVal "$0" "Uninstall Log Folder" "$INSTDIR\uninstall" 0
-  ${WriteRegStr2} $TmpVal "$0" "Description" "${BrandFullNameInternal} (${AppVersion})" 0
-
-  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})"
-  ${WriteRegStr2} $TmpVal  "$0" "" "${AppVersion} (${AB_CD})" 0
-
-  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}\bin"
-  ${WriteRegStr2} $TmpVal "$0" "PathToExe" "$INSTDIR\${FileMainEXE}" 0
+  ; The following keys should only be set if we can write to HKLM
+  ${If} $TmpVal == "HKLM"
+    ; Uninstall keys can only exist under HKLM on some versions of windows.
+    ${SetUninstallKeys}
 
-  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}\extensions"
-  ${WriteRegStr2} $TmpVal "$0" "Components" "$INSTDIR\components" 0
-  ${WriteRegStr2} $TmpVal "$0" "Plugins" "$INSTDIR\plugins" 0
-
-  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}"
-  ${WriteRegStr2} $TmpVal "$0" "GeckoVer" "${GREVersion}" 0
-
-  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}"
-  ${WriteRegStr2} $TmpVal "$0" "" "${GREVersion}" 0
-  ${WriteRegStr2} $TmpVal "$0" "CurrentVersion" "${AppVersion} (${AB_CD})" 0
-
-  ; XXXrstrong - Add registry values for HKLM\Software\Clients\Calendar here.
-  ; See Thunderbird's installer.nsi for an example.
+    ; If we are writing to HKLM and create the quick launch and the desktop
+    ; shortcuts set IconsVisible to 1 otherwise to 0.
+    ${StrFilter} "${FileMainEXE}" "+" "" "" $R9
+    StrCpy $0 "Software\Clients\StartMenuInternet\$R9\InstallInfo"
+    ${If} $AddQuickLaunchSC == 1
+    ${OrIf} $AddDesktopSC == 1
+      WriteRegDWORD HKLM "$0" "IconsVisible" 1
+    ${Else}
+      WriteRegDWORD HKLM "$0" "IconsVisible" 0
+    ${EndIf}
+  ${EndIf}
 
   ; These need special handling on uninstall since they may be overwritten by
   ; an install into a different location.
   StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
   ${WriteRegStr2} $TmpVal "$0" "" "$INSTDIR\${FileMainEXE}" 0
   ${WriteRegStr2} $TmpVal "$0" "Path" "$INSTDIR" 0
 
-  ; Write the uninstall registry keys
-  StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})"
-  StrCpy $1 "$INSTDIR\uninstall\uninst.exe"
-
-  ${WriteRegStr2} $TmpVal "$0" "Comments" "${BrandFullNameInternal}" 0
-  ${WriteRegStr2} $TmpVal "$0" "DisplayIcon" "$INSTDIR\${FileMainEXE},0" 0
-  ${WriteRegStr2} $TmpVal "$0" "DisplayName" "${BrandFullNameInternal} (${AppVersion})" 0
-  ${WriteRegStr2} $TmpVal "$0" "DisplayVersion" "${AppVersion} (${AB_CD})" 0
-  ${WriteRegStr2} $TmpVal "$0" "InstallLocation" "$INSTDIR" 0
-  ${WriteRegStr2} $TmpVal "$0" "Publisher" "Mozilla" 0
-  ${WriteRegStr2} $TmpVal "$0" "UninstallString" "$1" 0
-  ${WriteRegStr2} $TmpVal "$0" "URLInfoAbout" "${URLInfoAbout}" 0
-  ${WriteRegStr2} $TmpVal "$0" "URLUpdateInfo" "${URLUpdateInfo}" 0
-  ${WriteRegDWORD2} $TmpVal "$0" "NoModify" 1 0
-  ${WriteRegDWORD2} $TmpVal "$0" "NoRepair" 1 0
   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
 
   ; Create Start Menu shortcuts
   ${LogHeader} "Adding Shortcuts"
   ${If} $AddStartMenuSC == 1
-    CreateDirectory "$SMPROGRAMS\$StartMenuDir"
+    ${Unless} ${FileExists} "$SMPROGRAMS\$StartMenuDir"
+      CreateDirectory "$SMPROGRAMS\$StartMenuDir"
+      ${LogMsg} "Added Start Menu Directory: $SMPROGRAMS\$StartMenuDir"
+    ${EndUnless}
     CreateShortCut "$SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
     ${LogUninstall} "File: $SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal}.lnk"
+    ${LogMsg} "Added Shortcut: $SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal}.lnk"
     CreateShortCut "$SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal} ($(SAFE_MODE)).lnk" "$INSTDIR\${FileMainEXE}" "-safe-mode" "$INSTDIR\${FileMainEXE}" 0
     ${LogUninstall} "File: $SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal} ($(SAFE_MODE)).lnk"
+    ${LogMsg} "Added Shortcut: $SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal} ($(SAFE_MODE)).lnk"
   ${EndIf}
 
   ; perhaps use the uninstall keys
   ${If} $AddQuickLaunchSC == 1
     CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
     ${LogUninstall} "File: $QUICKLAUNCH\${BrandFullName}.lnk"
+    ${LogMsg} "Added Shortcut: $QUICKLAUNCH\${BrandFullName}.lnk"
   ${EndIf}
 
-  ${LogHeader} "Updating Quick Launch Shortcuts"
   ${If} $AddDesktopSC == 1
     CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
     ${LogUninstall} "File: $DESKTOP\${BrandFullName}.lnk"
+    ${LogMsg} "Added Shortcut: $DESKTOP\${BrandFullName}.lnk"
   ${EndIf}
 
   !insertmacro MUI_STARTMENU_WRITE_END
+SectionEnd
+
+; Cleanup operations to perform at the end of the installation.
+Section "-InstallEndCleanup"
+  SetDetailsPrint both
+  DetailPrint "$(STATUS_CLEANUP)"
+  SetDetailsPrint none
+
+  ${LogHeader} "Updating Uninstall Log With Previous Uninstall Log"
 
   ; Refresh desktop icons
   System::Call "shell32::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)"
-SectionEnd
+
+  ${InstallEndCleanupCommon}
+
+  ; If we have to reboot give SHChangeNotify time to finish the refreshing
+  ; the icons so the OS doesn't display the icons from helper.exe
+  ${If} ${RebootFlag}
+    Sleep 10000
+    ${LogHeader} "Reboot Required To Finish Installation"
+    ; ${FileMainEXE}.moz-upgrade should never exist but just in case...
+    ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-upgrade"
+      Rename "$INSTDIR\${FileMainEXE}" "$INSTDIR\${FileMainEXE}.moz-upgrade"
+    ${EndUnless}
 
-Section /o "Developer Tools" Section2
-  Call installInspector
+    ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
+      ClearErrors
+      Rename "$INSTDIR\${FileMainEXE}" "$INSTDIR\${FileMainEXE}.moz-delete"
+      ${Unless} ${Errors}
+        Delete /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-delete"
+      ${EndUnless}
+    ${EndUnless}
+
+    ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}"
+      CopyFiles /SILENT "$INSTDIR\uninstall\helper.exe" "$INSTDIR"
+      FileOpen $0 "$INSTDIR\${FileMainEXE}" w
+      FileWrite $0 "Will be deleted on restart"
+      Rename /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-upgrade" "$INSTDIR\${FileMainEXE}"
+      FileClose $0
+      Delete "$INSTDIR\${FileMainEXE}"
+      Rename "$INSTDIR\helper.exe" "$INSTDIR\${FileMainEXE}"
+    ${EndUnless}
+  ${EndIf}
 SectionEnd
 
 ################################################################################
 # Helper Functions
 
-Function installInspector
-  ${If} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org"
-    SetDetailsPrint textonly
-    DetailPrint $(STATUS_INSTALL_OPTIONAL)
-    SetDetailsPrint none
-    ${RemoveDir} "$INSTDIR\extensions\inspector@mozilla.org"
-    ClearErrors
-    ${LogHeader} "Installing Developer Tools"
-    StrCpy $R0 "$EXEDIR\optional\extensions\inspector@mozilla.org"
-    StrCpy $R1 "$INSTDIR\extensions\inspector@mozilla.org"
-    Call DoCopyFiles
-  ${EndIf}
-FunctionEnd
+Function CheckExistingInstall
+  ; If there is a pending file copy from a previous uninstall don't allow
+  ; installing until after the system has rebooted.
+  IfFileExists "$INSTDIR\${FileMainEXE}.moz-upgrade" +1 +4
+  MessageBox MB_YESNO "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2
+  Reboot
+  Quit
+
+  ; If there is a pending file deletion from a previous uninstall don't allow
+  ; installing until after the system has rebooted.
+  IfFileExists "$INSTDIR\${FileMainEXE}.moz-delete" +1 +4
+  MessageBox MB_YESNO "$(WARN_RESTART_REQUIRED_UNINSTALL)" IDNO +2
+  Reboot
+  Quit
+
+  ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
+    Banner::show /NOUNLOAD "$(BANNER_CHECK_EXISTING)"
 
-; Adds a section divider to the human readable log.
-Function WriteLogSeparator
-  FileWrite $fhInstallLog "$\r$\n-------------------------------------------------------------------------------$\r$\n"
-FunctionEnd
+    ${If} "$TmpVal" == "FoundMessageWindow"
+      Sleep 5000
+    ${EndIf}
+
+    ${PushFilesToCheck}
 
-; Check whether to display the current page (e.g. if we aren't performing a
-; custom install don't display the custom pages).
-Function CheckCustom
-  ${If} $InstallType != 4
-    Abort
+    ; Store the return value in $TmpVal so it is less likely to be accidentally
+    ; overwritten elsewhere.
+    ${CheckForFilesInUse} $TmpVal
+
+    Banner::destroy
+
+    ${If} "$TmpVal" == "true"
+      StrCpy $TmpVal "FoundMessageWindow"
+      ${ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_INSTALL)"
+      StrCpy $TmpVal "true"
+    ${EndIf}
   ${EndIf}
 FunctionEnd
 
-Function onInstallDeleteFile
-  ${TrimNewLines} "$R9" "$R9"
-  StrCpy $R1 "$R9" 5
-  ${If} $R1 == "File:"
-    StrCpy $R9 "$R9" "" 6
-    ${If} ${FileExists} "$INSTDIR$R9"
-      ClearErrors
-      Delete "$INSTDIR$R9"
-      ${If} ${Errors}
-        ${LogMsg} "** ERROR Deleting File: $INSTDIR$R9 **"
-      ${Else}
-        ${LogMsg} "Deleted File: $INSTDIR$R9"
-      ${EndIf}
-    ${EndIf}
-  ${EndIf}
+Function LaunchApp
   ClearErrors
-  Push 0
-FunctionEnd
-
-; The previous installer removed directories even when they aren't empty so this
-; function does as well.
-Function onInstallRemoveDir
-  ${TrimNewLines} "$R9" "$R9"
-  StrCpy $R1 "$R9" 4
-  ${If} $R1 == "Dir:"
-    StrCpy $R9 "$R9" "" 5
-    StrCpy $R1 "$R9" "" -1
-    ${If} $R1 == "\"
-      StrCpy $R9 "$R9" -1
-    ${EndIf}
-    ${If} ${FileExists} "$INSTDIR$R9"
-      ClearErrors
-      RmDir /r "$INSTDIR$R9"
-      ${If} ${Errors}
-        ${LogMsg} "** ERROR Removing Directory: $INSTDIR$R9 **"
-      ${Else}
-        ${LogMsg} "Removed Directory: $INSTDIR$R9"
-      ${EndIf}
-    ${EndIf}
+  ${GetParameters} $0
+  ${GetOptions} "$0" "/UAC:" $1
+  ${If} ${Errors}
+    ${ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_LAUNCH)"
+    Exec "$INSTDIR\${FileMainEXE}"
+  ${Else}
+    GetFunctionAddress $0 LaunchAppFromElevatedProcess
+    UAC::ExecCodeSegment $0
   ${EndIf}
-  ClearErrors
-  Push 0
-FunctionEnd
-
-Function GetDiff
-  ${TrimNewLines} "$9" "$9"
-  ${If} $9 != ""
-    FileWrite $R3 "$9$\r$\n"
-    ${LogMsg} "Added To Uninstall Log: $9"
-  ${EndIf}
-  Push 0
-FunctionEnd
-
-Function DoCopyFiles
-  StrLen $R2 $R0
-  ${LocateNoDetails} "$R0" "/L=FD" "CopyFile"
 FunctionEnd
 
-Function CopyFile
-  StrCpy $R3 $R8 "" $R2
-  ${If} $R6 ==  ""
-    ${Unless} ${FileExists} "$R1$R3\$R7"
-      ClearErrors
-      CreateDirectory "$R1$R3\$R7"
-      ${If} ${Errors}
-        ${LogMsg}  "** ERROR Creating Directory: $R1$R3\$R7 **"
-      ${Else}
-        ${LogMsg}  "Created Directory: $R1$R3\$R7"
-      ${EndIf}
-    ${EndUnless}
-  ${Else}
-    ${Unless} ${FileExists} "$R1$R3"
-      ClearErrors
-      CreateDirectory "$R1$R3"
-      ${If} ${Errors}
-        ${LogMsg}  "** ERROR Creating Directory: $R1$R3 **"
-      ${Else}
-        ${LogMsg}  "Created Directory: $R1$R3"
-      ${EndIf}
-    ${EndUnless}
-    ${If} ${FileExists} "$R1$R3\$R7"
-      Delete "$R1$R3\$R7"
-    ${EndIf}
-    ClearErrors
-    CopyFiles /SILENT $R9 "$R1$R3"
-    ${If} ${Errors}
-      ; XXXrstrong - what should we do if there is an error installing a file?
-      ${LogMsg} "** ERROR Installing File: $R1$R3\$R7 **"
-    ${Else}
-      ${LogMsg} "Installed File: $R1$R3\$R7"
-    ${EndIf}
-    ; If the file is installed into the installation directory remove the
-    ; installation directory's path from the file path when writing to the
-    ; uninstall.log so it will be a relative path. This allows the same
-    ; uninst.exe to be used with zip builds if we supply an uninstall.log.
-    ${WordReplace} "$R1$R3\$R7" "$INSTDIR" "" "+" $R3
-    ${LogUninstall} "File: $R3"
-  ${EndIf}
-  Push 0
-FunctionEnd
-
-; Clean up the old log files. We only diff the first two found since it is
-; possible for there to be several MB and comparing that many would take a very
-; long time to diff.
-Function CleanupOldLogs
-  FindFirst $0 $TmpVal "$INSTDIR\uninstall\*wizard*"
-  StrCmp $TmpVal "" done
-  StrCpy $TmpVal "$INSTDIR\uninstall\$TmpVal"
-
-  FindNext $0 $1
-  StrCmp $1 "" cleanup
-  StrCpy $1 "$INSTDIR\uninstall\$1"
-  Push $1
-  Call DiffOldLogFiles
-  FindClose $0
-  ${DeleteFile} "$1"
+Function LaunchAppFromElevatedProcess
+  ${ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_LAUNCH)"
 
-  cleanup:
-    StrCpy $2 "$INSTDIR\uninstall\cleanup.log"
-    ${DeleteFile} "$2"
-    FileOpen $R2 $2 w
-    Push $TmpVal
-    ${LineFind} "$INSTDIR\uninstall\$TmpVal" "/NUL" "1:-1" "CleanOldLogFilesCallback"
-    ${DeleteFile} "$INSTDIR\uninstall\$TmpVal"
-  done:
-    FindClose $0
-    FileClose $R2
-    FileClose $R3
-FunctionEnd
-
-Function DiffOldLogFiles
-  StrCpy $R1 "$1"
-  GetTempFileName $R2
-  FileOpen $R3 $R2 w
-  ${TextCompareNoDetails} "$R1" "$TmpVal" "SlowDiff" "GetDiff"
-  FileClose $R3
-  ${FileJoin} "$TmpVal" "$R2" "$TmpVal"
-  ${DeleteFile} "$R2"
-FunctionEnd
-
-Function CleanOldLogFilesCallback
-  ${TrimNewLines} "$R9" $R9
-  ${WordReplace} "$R9" "$INSTDIR" "" "+" $R3
-  ${WordFind} "$R9" "	" "E+1}" $R0
-  IfErrors updater 0
-
-  ${WordFind} "$R0" "Installing: " "E+1}" $R1
-  ${Unless} ${Errors}
-    FileWrite $R2 "File: $R1$\r$\n"
-    GoTo done
-  ${EndUnless}
-
-  ${WordFind} "$R0" "Replacing: " "E+1}" $R1
-  ${Unless} ${Errors}
-    FileWrite $R2 "File: $R1$\r$\n"
-    GoTo done
-  ${EndUnless}
-
-  ${WordFind} "$R0" "Windows Shortcut: " "E+1}" $R1
-  ${Unless} ${Errors}
-    FileWrite $R2 "File: $R1.lnk$\r$\n"
-    GoTo done
-  ${EndUnless}
-
-  ${WordFind} "$R0" "Create Folder: " "E+1}" $R1
-  ${Unless} ${Errors}
-    FileWrite $R2 "Dir: $R1$\r$\n"
-    GoTo done
-  ${EndUnless}
-
-  updater:
-    ${WordFind} "$R9" "installing: " "E+1}" $R0
-    ${Unless} ${Errors}
-      FileWrite $R2 "File: $R0$\r$\n"
-    ${EndUnless}
-
-  done:
-    Push 0
-FunctionEnd
-
-Function LaunchApp
-  ${CloseApp} "true" $(WARN_APP_RUNNING_INSTALL)
-  Exec "$INSTDIR\${FileMainEXE}"
+  ; Find the installation directory when launching using GetFunctionAddress
+  ; from an elevated installer since $INSTDIR will not be set in this installer
+  ${StrFilter} "${FileMainEXE}" "+" "" "" $R9
+  ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" "DisplayIcon"
+  ${GetPathFromString} "$0" $0
+  ${GetParent} "$0" $1
+  ; Set our current working directory to the application's install directory
+  ; otherwise the 7-Zip temp directory will be in use and won't be deleted.
+  SetOutPath "$1"
+  Exec "$0"
 FunctionEnd
 
 ################################################################################
 # Language
 
 !insertmacro MOZ_MUI_LANGUAGE 'baseLocale'
 !verbose push
 !verbose 3
@@ -678,259 +504,271 @@ FunctionEnd
 !include "customLocale.nsh"
 !verbose pop
 
 ; Set this after the locale files to override it if it is in the locale
 ; using " " for BrandingText will hide the "Nullsoft Install System..." branding
 BrandingText " "
 
 ################################################################################
-# Page pre and leave functions
+# Page pre, show, and leave functions
+
+Function preWelcome
+  ${If} ${FileExists} "$EXEDIR\localized\distribution\modern-wizard.bmp"
+    Delete "$PLUGINSDIR\modern-wizard.bmp"
+    CopyFiles /SILENT "$EXEDIR\localized\distribution\modern-wizard.bmp" "$PLUGINSDIR\modern-wizard.bmp"
+  ${EndIf}
+FunctionEnd
+
+Function showLicense
+  ${If} ${FileExists} "$EXEDIR\localized\distribution\modern-header.bmp"
+  ${AndIf} $hHeaderBitmap == ""
+    Delete "$PLUGINSDIR\modern-header.bmp"
+    CopyFiles /SILENT "$EXEDIR\localized\distribution\modern-header.bmp" "$PLUGINSDIR\modern-header.bmp"
+    ${ChangeMUIHeaderImage} "$PLUGINSDIR\modern-header.bmp"
+  ${EndIf}
+FunctionEnd
 
 Function preOptions
   !insertmacro MUI_HEADER_TEXT "$(OPTIONS_PAGE_TITLE)" "$(OPTIONS_PAGE_SUBTITLE)"
   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "options.ini"
 FunctionEnd
 
 Function leaveOptions
   ${MUI_INSTALLOPTIONS_READ} $0 "options.ini" "Settings" "State"
   ${If} $0 != 0
     Abort
   ${EndIf}
   ${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 2" "State"
   StrCmp $R0 "1" +1 +2
-  StrCpy $InstallType "1"
+  StrCpy $InstallType ${INSTALLTYPE_BASIC}
   ${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 3" "State"
   StrCmp $R0 "1" +1 +2
-  StrCpy $InstallType "4"
-FunctionEnd
+  StrCpy $InstallType ${INSTALLTYPE_CUSTOM}
+
+  ${If} $InstallType != ${INSTALLTYPE_CUSTOM}
+!ifndef NO_INSTDIR_FROM_REG
+    SetShellVarContext all      ; Set SHCTX to HKLM
+    ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
+
+    StrCmp "$R9" "false" +1 fix_install_dir
 
-Function preComponents
-  Call CheckCustom
-  ; If DOMi isn't available skip the components page
-  ${Unless} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org"
-    Abort
-  ${EndUnless}
-  !insertmacro MUI_HEADER_TEXT "$(OPTIONAL_COMPONENTS_TITLE)" "$(OPTIONAL_COMPONENTS_SUBTITLE)"
-  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "components.ini"
-FunctionEnd
+    SetShellVarContext current  ; Set SHCTX to HKCU
+    ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
 
-Function leaveComponents
-  ${MUI_INSTALLOPTIONS_READ} $R0 "components.ini" "Field 2" "State"
-  ; State will be 1 for checked and 0 for unchecked so we can use that to set
-  ; the section flags for installation.
-  SectionSetFlags ${Section2} $R0
+    fix_install_dir:
+    StrCmp "$R9" "false" +2 +1
+    StrCpy $INSTDIR "$R9"
+!endif
+
+    Call CheckExistingInstall
+  ${EndIf}
 FunctionEnd
 
 Function preDirectory
-  ${If} $InstallType != 4
-    ${CheckDiskSpace} $R9
-    ${If} $R9 != "false"
-      ${CanWriteToInstallDir} $R9
-      ${If} $R9 != "false"
-        Abort
-      ${EndIf}
-    ${EndIf}
-  ${EndIf}
+  ${PreDirectoryCommon}
 FunctionEnd
 
 Function leaveDirectory
-  ${CheckDiskSpace} $R9
-  ${If} $R9 == "false"
-    MessageBox MB_OK "$(WARN_DISK_SPACE)"
-    Abort
-  ${EndIf}
-
-  ${CanWriteToInstallDir} $R9
-  ${If} $R9 == "false"
-    MessageBox MB_OK "$(WARN_WRITE_ACCESS)"
-    Abort
-  ${EndIf}
+  ${LeaveDirectoryCommon} "$(WARN_DISK_SPACE)" "$(WARN_WRITE_ACCESS)"
 FunctionEnd
 
 Function preShortcuts
-  Call CheckCustom
+  ${CheckCustomCommon}
   !insertmacro MUI_HEADER_TEXT "$(SHORTCUTS_PAGE_TITLE)" "$(SHORTCUTS_PAGE_SUBTITLE)"
   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "shortcuts.ini"
 FunctionEnd
 
 Function leaveShortcuts
   ${MUI_INSTALLOPTIONS_READ} $0 "shortcuts.ini" "Settings" "State"
   ${If} $0 != 0
     Abort
   ${EndIf}
   ${MUI_INSTALLOPTIONS_READ} $AddDesktopSC "shortcuts.ini" "Field 2" "State"
   ${MUI_INSTALLOPTIONS_READ} $AddStartMenuSC "shortcuts.ini" "Field 3" "State"
   ${MUI_INSTALLOPTIONS_READ} $AddQuickLaunchSC "shortcuts.ini" "Field 4" "State"
 FunctionEnd
 
 Function preStartMenu
-  Call CheckCustom
+  ${CheckCustomCommon}
   ${If} $AddStartMenuSC != 1
     Abort
   ${EndIf}
 FunctionEnd
 
-Function leaveInstFiles
-  FileClose $fhUninstallLog
-  ; Diff and add missing entries from the previous file log if it exists
-  ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.bak"
-    SetDetailsPrint textonly
-    DetailPrint $(STATUS_CLEANUP)
-    SetDetailsPrint none
-    ${LogHeader} "Updating Uninstall Log With Previous Uninstall Log"
-    StrCpy $R0 "$INSTDIR\uninstall\uninstall.log"
-    StrCpy $R1 "$INSTDIR\uninstall\uninstall.bak"
-    GetTempFileName $R2
-    FileOpen $R3 $R2 w
-    ${TextCompareNoDetails} "$R1" "$R0" "SlowDiff" "GetDiff"
-    FileClose $R3
-    ${Unless} ${Errors}
-      ${FileJoin} "$INSTDIR\uninstall\uninstall.log" "$R2" "$INSTDIR\uninstall\uninstall.log"
-    ${EndUnless}
-    ${DeleteFile} "$INSTDIR\uninstall\uninstall.bak"
-    ${DeleteFile} "$R2"
+Function leaveStartMenu
+  ${If} $InstallType == ${INSTALLTYPE_CUSTOM}
+    Call CheckExistingInstall
+  ${EndIf}
+FunctionEnd
+
+Function preSummary
+  ; Setup the summary.ini file for the Custom Summary Page
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "3"
+
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Type   "label"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Text   "$(SUMMARY_INSTALLED_TO)"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Left   "0"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Top    "5"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Bottom "15"
+
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Type   "text"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" state  ""
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Left   "0"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Top    "17"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Bottom "30"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" flags  "READONLY"
+
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Type   "label"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Text   "$(SUMMARY_CLICK)"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Left   "0"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Top    "130"
+  WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Bottom "150"
+
+  ${If} "$TmpVal" == "true"
+    WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Type   "label"
+    WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Text   "$(SUMMARY_REBOOT_REQUIRED_INSTALL)"
+    WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Left   "0"
+    WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Right  "-1"
+    WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Top    "35"
+    WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Bottom "45"
+
+    WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "4"
   ${EndIf}
 
-  Call WriteLogSeparator
-  ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
-  FileWrite $fhInstallLog "${BrandFullName} Installation Finished: $2-$1-$0 $4:$5:$6$\r$\n"
-  FileClose $fhInstallLog
+  !insertmacro MUI_HEADER_TEXT "$(SUMMARY_PAGE_TITLE)" "$(SUMMARY_PAGE_SUBTITLE)"
+
+  ; The Summary custom page has a textbox that will automatically receive
+  ; focus. This sets the focus to the Install button instead.
+  !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "summary.ini"
+  GetDlgItem $0 $HWNDPARENT 1
+  System::Call "user32::SetFocus(i r0, i 0x0007, i,i)i"
+  ${MUI_INSTALLOPTIONS_READ} $1 "summary.ini" "Field 2" "HWND"
+  SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
+  !insertmacro MUI_INSTALLOPTIONS_SHOW
+FunctionEnd
+
+Function leaveSummary
+  ; Try to delete the app executable and if we can't delete it try to find the
+  ; app's message window and prompt the user to close the app. This allows
+  ; running an instance that is located in another directory. If for whatever
+  ; reason there is no message window we will just rename the app's files and
+  ; then remove them on restart.
+  ClearErrors
+  ${DeleteFile} "$INSTDIR\${FileMainEXE}"
+  ${If} ${Errors}
+    ${ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_INSTALL)"
+  ${EndIf}
 FunctionEnd
 
 ; When we add an optional action to the finish page the cancel button is
 ; enabled. This disables it and leaves the finish button as the only choice.
 Function preFinish
+  ${EndInstallLog} "${BrandFullName}"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "cancelenabled" "0"
 FunctionEnd
 
 ################################################################################
 # Initialization Functions
 
 Function .onInit
-  ${GetParameters} $R0
-  ${If} $R0 != ""
-    ClearErrors
-    ${GetOptions} "$R0" "-ms" $R1
-    ${If} ${Errors}
-      ; Default install type
-      StrCpy $InstallType "1"
-      ; Support for specifying an installation configuration file.
-      ClearErrors
-      ${GetOptions} "$R0" "/INI=" $R1
-      ${Unless} ${Errors}
-        ; The configuration file must also exist
-        ${If} ${FileExists} "$R1"
-          SetSilent silent
-          ReadINIStr $0 $R1 "Install" "InstallDirectoryName"
-          ${If} $0 != ""
-            StrCpy $INSTDIR "$PROGRAMFILES\$0"
-          ${Else}
-            ReadINIStr $0 $R1 "Install" "InstallDirectoryPath"
-            ${If} $$0 != ""
-              StrCpy $INSTDIR "$0"
-            ${EndIf}
-          ${EndIf}
+  StrCpy $LANGUAGE 0
+  ${SetBrandNameVars} "$EXEDIR\localized\distribution\setup.ini"
+
+  ${InstallOnInitCommon} "$(WARN_UNSUPPORTED_MSG)"
+
+  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "options.ini"
+  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "shortcuts.ini"
+  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "summary.ini"
+
+  ; Setup the options.ini file for the Custom Options Page
+  WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "5"
 
-          ${If} $INSTDIR == ""
-            ; Check if there is an existing uninstall registry entry for this
-            ; version of the application and if present install into that location
-            ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" "InstallLocation"
-            ${If} $0 == ""
-              StrCpy $INSTDIR "$PROGRAMFILES\${BrandFullName}"
-            ${Else}
-              GetFullPathName $INSTDIR "$0"
-              ${Unless} ${FileExists} "$INSTDIR"
-                StrCpy $INSTDIR "$PROGRAMFILES\${BrandFullName}"
-              ${EndUnless}
-            ${EndIf}
-          ${EndIf}
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Type   "label"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Text   "$(OPTIONS_SUMMARY)"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Left   "0"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Top    "0"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Bottom "10"
+
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Type   "RadioButton"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Text   "$(OPTION_STANDARD_RADIO)"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Left   "15"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Top    "25"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Bottom "35"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" State  "1"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Flags  "GROUP"
+
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Type   "RadioButton"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Text   "$(OPTION_CUSTOM_RADIO)"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Left   "15"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Top    "55"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Bottom "65"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" State  "0"
 
-          ; Quit if we are unable to create the installation directory or we are
-          ; unable to write to a file in the installation directory.
-          ClearErrors
-          ${If} ${FileExists} "$INSTDIR"
-            GetTempFileName $R2 "$INSTDIR"
-            FileOpen $R3 $R2 w
-            FileWrite $R3 "Write Access Test"
-            FileClose $R3
-            Delete $R2
-            ${If} ${Errors}
-              Quit
-            ${EndIf}
-          ${Else}
-            CreateDirectory "$INSTDIR"
-            ${If} ${Errors}
-              Quit
-            ${EndIf}
-          ${EndIf}
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Type   "label"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Text   "$(OPTION_STANDARD_DESC)"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Left   "30"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Top    "37"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Bottom "57"
 
-          ReadINIStr $0 $R1 "Install" "CloseAppNoPrompt"
-          ${If} $0 == "true"
-            ClearErrors
-            ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
-              ${DeleteFile} "$INSTDIR\${FileMainEXE}"
-            ${EndIf}
-            ${If} ${Errors}
-              ClearErrors
-              ${CloseApp} "false" ""
-              ${DeleteFile} "$INSTDIR\${FileMainEXE}"
-            ${EndIf}
-          ${EndIf}
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Type   "label"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Text   "$(OPTION_CUSTOM_DESC)"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Left   "30"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Top    "67"
+  WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Bottom "87"
+
+  ; Setup the shortcuts.ini file for the Custom Shortcuts Page
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Settings" NumFields "4"
+
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Type   "label"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Text   "$(CREATE_ICONS_DESC)"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Left   "0"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Top    "5"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Bottom "15"
 
-          ReadINIStr $0 $R1 "Install" "QuickLaunchShortcut"
-          ${If} $0 == "false"
-            StrCpy $AddQuickLaunchSC "0"
-          ${Else}
-            StrCpy $AddQuickLaunchSC "1"
-          ${EndIf}
-
-          ReadINIStr $0 $R1 "Install" "DesktopShortcut"
-          ${If} $0 == "false"
-            StrCpy $AddDesktopSC "0"
-          ${Else}
-            StrCpy $AddDesktopSC "1"
-          ${EndIf}
-
-          ReadINIStr $0 $R1 "Install" "StartMenuShortcuts"
-          ${If} $0 == "false"
-            StrCpy $AddStartMenuSC "0"
-          ${Else}
-            StrCpy $AddStartMenuSC "1"
-          ${EndIf}
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Type   "checkbox"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Text   "$(ICONS_DESKTOP)"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Left   "15"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Top    "20"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Bottom "30"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" State  "1"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Flags  "GROUP"
 
-          ReadINIStr $0 $R1 "Install" "StartMenuDirectoryName"
-          ${If} $0 != ""
-            StrCpy $StartMenuDir "$0"
-          ${EndIf}
-        ${EndIf}
-      ${EndUnless}
-    ${Else}
-      ; Support for the deprecated -ms command line argument. The new command
-      ; line arguments are not supported when -ms is used.
-      SetSilent silent
-    ${EndIf}
-  ${EndIf}
-  ClearErrors
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Type   "checkbox"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Text   "$(ICONS_STARTMENU)"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Left   "15"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Top    "40"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Bottom "50"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" State  "1"
 
-  StrCpy $LANGUAGE 0
-  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "options.ini"
-  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "components.ini"
-  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "shortcuts.ini"
-  !insertmacro createBasicCustomOptionsINI
-  !insertmacro createComponentsINI
-  !insertmacro createShortcutsINI
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Type   "checkbox"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Text   "$(ICONS_QUICKLAUNCH)"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Left   "15"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Top    "60"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Bottom "70"
+  WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" State  "1"
 
   ; There must always be nonlocalized and localized directories.
-  ${GetSize} "$EXEDIR\nonlocalized\" "/S=0K" $1 $8 $9
-  ${GetSize} "$EXEDIR\localized\" "/S=0K" $2 $8 $9
-  IntOp $0 $1 + $2
-  SectionSetSize 0 $0
+  ${GetSize} "$EXEDIR\nonlocalized\" "/S=0K" $R5 $R7 $R8
+  ${GetSize} "$EXEDIR\localized\" "/S=0K" $R6 $R7 $R8
+  IntOp $R8 $R5 + $R6
+  SectionSetSize ${APP_IDX} $R8
 
-  ${If} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org"
-    ; Set the section size for DOMi.
-    ${GetSize} "$EXEDIR\optional\extensions\inspector@mozilla.org" "/S=0K" $0 $8 $9
-    SectionSetSize 1 $0
-  ${Else}
-    ; Hide DOMi in the components page if it isn't available.
-    SectionSetText 1 ""
-  ${EndIf}
+  ; Initialize $hHeaderBitmap to prevent redundant changing of the bitmap if
+  ; the user clicks the back button
+  StrCpy $hHeaderBitmap ""
 FunctionEnd
+
+Function .onGUIEnd
+  ${OnEndCommon}
+FunctionEnd
new file mode 100644
--- /dev/null
+++ b/calendar/installer/windows/nsis/shared.nsh
@@ -0,0 +1,207 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the Mozilla Installer code.
+#
+# The Initial Developer of the Original Code is Mozilla Foundation
+# Portions created by the Initial Developer are Copyright (C) 2006
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Robert Strong <robert.bugzilla@gmail.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+!macro PostUpdate
+  ; Remove registry entries for non-existent apps and for apps that point to our
+  ; install location in the Software\Mozilla key and uninstall registry entries
+  ; that point to our install location for both HKCU and HKLM.
+  SetShellVarContext current  ; Set SHCTX to the current user (e.g. HKCU)
+  ${RegCleanMain} "Software\Mozilla"
+  ${RegCleanUninstall}
+
+  ClearErrors
+  WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
+  ${If} ${Errors}
+    StrCpy $TmpVal "HKCU" ; used primarily for logging
+  ${Else}
+    DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
+    SetShellVarContext all    ; Set SHCTX to all users (e.g. HKLM)
+    StrCpy $TmpVal "HKLM" ; used primarily for logging
+    ${RegCleanMain} "Software\Mozilla"
+    ${RegCleanUninstall}
+    ${SetUninstallKeys}
+  ${EndIf}
+
+  ; Add Software\Mozilla\ registry entries
+  ${SetAppKeys}
+
+  ; Remove files that may be left behind by the application in the
+  ; VirtualStore directory.
+  ${CleanVirtualStore}
+
+  ; Remove talkback if it is present (remove after bug 386760 is fixed)
+  ${If} ${FileExists} "$INSTDIR\extensions\talkback@mozilla.org\"
+    RmDir /r "$INSTDIR\extensions\talkback@mozilla.org\"
+  ${EndIf}
+!macroend
+!define PostUpdate "!insertmacro PostUpdate"
+
+!macro SetAsDefaultAppUser
+  ; This macro must be defined to use UninstallOnInitCommon in commmon.nsh
+!macroend
+!define SetAsDefaultAppUser "!insertmacro SetAsDefaultAppUser"
+
+!macro SetAsDefaultAppGlobal
+  ; This macro must be defined to use UninstallOnInitCommon in commmon.nsh
+!macroend
+!define SetAsDefaultAppGlobal "!insertmacro SetAsDefaultAppGlobal"
+
+!macro HideShortcuts
+  ; This macro must be defined to use UninstallOnInitCommon in commmon.nsh
+!macroend
+!define HideShortcuts "!insertmacro HideShortcuts"
+
+!macro ShowShortcuts
+  ; This macro must be defined to use UninstallOnInitCommon in commmon.nsh
+!macroend
+!define ShowShortcuts "!insertmacro ShowShortcuts"
+
+!macro SetAppKeys
+  ${GetLongPath} "$INSTDIR" $8
+  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Main"
+  ${WriteRegStr2} $TmpVal "$0" "Install Directory" "$8" 0
+  ${WriteRegStr2} $TmpVal "$0" "PathToExe" "$8\${FileMainEXE}" 0
+  ${WriteRegStr2} $TmpVal "$0" "Program Folder Path" "$SMPROGRAMS\$StartMenuDir" 0
+
+  SetShellVarContext all  ; Set $DESKTOP to All Users
+  ${Unless} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
+    SetShellVarContext current  ; Set $DESKTOP to the current user's desktop
+  ${EndUnless}
+
+  ${If} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
+    ShellLink::GetShortCutArgs "$DESKTOP\${BrandFullName}.lnk"
+    Pop $1
+    ${If} "$1" == ""
+      ShellLink::GetShortCutTarget "$DESKTOP\${BrandFullName}.lnk"
+      Pop $1
+      ${GetLongPath} "$1" $1
+      ${If} "$1" == "$8\${FileMainEXE}"
+        ${WriteRegDWORD2} $TmpVal "$0" "Create Desktop Shortcut" 1 0
+      ${Else}
+        ${WriteRegDWORD2} $TmpVal "$0" "Create Desktop Shortcut" 0 0
+      ${EndIf}
+    ${EndIf}
+  ${EndIf}
+
+  ; XXXrstrong - need a cleaner way to prevent unsetting SHCTX from HKLM when
+  ; trying to find the desktop shortcut.
+  ${If} "$TmpVal" == "HKCU"
+    SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
+  ${Else}
+    SetShellVarContext all     ; Set SHCTX to all users (e.g. HKLM)
+  ${EndIf}
+
+  ${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
+    ShellLink::GetShortCutArgs "$QUICKLAUNCH\${BrandFullName}.lnk"
+    Pop $1
+    ${If} "$1" == ""
+      ShellLink::GetShortCutTarget "$QUICKLAUNCH\${BrandFullName}.lnk"
+      Pop $1
+      ${GetLongPath} "$1" $1
+      ${If} "$1" == "$8\${FileMainEXE}"
+        ${WriteRegDWORD2} $TmpVal "$0" "Create Quick Launch Shortcut" 1 0
+      ${Else}
+        ${WriteRegDWORD2} $TmpVal "$0" "Create Quick Launch Shortcut" 0 0
+      ${EndIf}
+    ${EndIf}
+  ${EndIf}
+  ; XXXrstrong - "Create Start Menu Shortcut" and "Start Menu Folder" are only
+  ; set in the installer and should also be set here for software update.
+
+  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Uninstall"
+  ${WriteRegStr2} $TmpVal "$0" "Uninstall Log Folder" "$8\uninstall" 0
+  ${WriteRegStr2} $TmpVal "$0" "Description" "${BrandFullNameInternal} (${AppVersion})" 0
+
+  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})"
+  ${WriteRegStr2} $TmpVal  "$0" "" "${AppVersion} (${AB_CD})" 0
+
+  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}\bin"
+  ${WriteRegStr2} $TmpVal "$0" "PathToExe" "$8\${FileMainEXE}" 0
+
+  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}\extensions"
+  ${WriteRegStr2} $TmpVal "$0" "Components" "$8\components" 0
+  ${WriteRegStr2} $TmpVal "$0" "Plugins" "$8\plugins" 0
+
+  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}"
+  ${WriteRegStr2} $TmpVal "$0" "GeckoVer" "${GREVersion}" 0
+
+  StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}"
+  ${WriteRegStr2} $TmpVal "$0" "" "${GREVersion}" 0
+  ${WriteRegStr2} $TmpVal "$0" "CurrentVersion" "${AppVersion} (${AB_CD})" 0
+!macroend
+!define SetAppKeys "!insertmacro SetAppKeys"
+
+!macro SetUninstallKeys
+  StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})"
+  ${GetLongPath} "$INSTDIR" $8
+
+  ; Write the uninstall registry keys
+  ${WriteRegStr2} $TmpVal "$0" "Comments" "${BrandFullNameInternal}" 0
+  ${WriteRegStr2} $TmpVal "$0" "DisplayIcon" "$8\${FileMainEXE},0" 0
+  ${WriteRegStr2} $TmpVal "$0" "DisplayName" "${BrandFullNameInternal} (${AppVersion})" 0
+  ${WriteRegStr2} $TmpVal "$0" "DisplayVersion" "${AppVersion} (${AB_CD})" 0
+  ${WriteRegStr2} $TmpVal "$0" "InstallLocation" "$8" 0
+  ${WriteRegStr2} $TmpVal "$0" "Publisher" "Mozilla" 0
+  ${WriteRegStr2} $TmpVal "$0" "UninstallString" "$8\uninstall\helper.exe" 0
+  ${WriteRegStr2} $TmpVal "$0" "URLInfoAbout" "${URLInfoAbout}" 0
+  ${WriteRegStr2} $TmpVal "$0" "URLUpdateInfo" "${URLUpdateInfo}" 0
+  ${WriteRegDWORD2} $TmpVal "$0" "NoModify" 1 0
+  ${WriteRegDWORD2} $TmpVal "$0" "NoRepair" 1 0
+!macroend
+!define SetUninstallKeys "!insertmacro SetUninstallKeys"
+
+; The files to check if they are in use during (un)install so the restart is
+; required message is displayed. All files must be located in the $INSTDIR
+; directory.
+!macro PushFilesToCheck
+  ; The first string to be pushed onto the stack MUST be "end" to indicate
+  ; that there are no more files to check in $INSTDIR and the last string
+  ; should be ${FileMainEXE} so if it is in use the CheckForFilesInUse macro
+  ; returns after the first check.
+  Push "end"
+  Push "AccessibleMarshal.dll"
+  Push "freebl3.dll"
+  Push "nssckbi.dll"
+  Push "nspr4.dll"
+  Push "nssdbm3.dll"
+  Push "sqlite3.dll"
+  Push "xpcom.dll"
+  Push "crashreporter.exe"
+  Push "updater.exe"
+  Push "xpicleanup.exe"
+  Push "${FileMainEXE}"
+!macroend
+!define PushFilesToCheck "!insertmacro PushFilesToCheck"
--- a/calendar/installer/windows/nsis/uninstaller.nsi
+++ b/calendar/installer/windows/nsis/uninstaller.nsi
@@ -29,63 +29,102 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
-# Also requires:
-# ShellLink plugin http://nsis.sourceforge.net/ShellLink_plug-in
+# Required Plugins:
+# AppAssocReg http://nsis.sourceforge.net/Application_Association_Registration_plug-in
+# ShellLink   http://nsis.sourceforge.net/ShellLink_plug-in
+# UAC         http://nsis.sourceforge.net/UAC_plug-in
 
 ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
 !verbose 3
 
 ; 7-Zip provides better compression than the lzma from NSIS so we add the files
 ; uncompressed and use 7-Zip to create a SFX archive of it
 SetDatablockOptimize on
 SetCompress off
 CRCCheck on
 
+RequestExecutionLevel user
+
 !addplugindir ./
 
+; USE_UAC_PLUGIN is temporary until all applications have been updated to use
+; the UAC plugin
+!define USE_UAC_PLUGIN
+
+; prevents compiling of the reg write logging.
+!define NO_LOG
+
 Var TmpVal
 
 ; Other included files may depend upon these includes!
 ; The following includes are provided by NSIS.
 !include FileFunc.nsh
 !include LogicLib.nsh
-!include TextFunc.nsh
+!include MUI.nsh
 !include WinMessages.nsh
+!include WinVer.nsh
 !include WordFunc.nsh
-!include MUI.nsh
 
+!insertmacro GetOptions
 !insertmacro GetParameters
-!insertmacro un.LineFind
-!insertmacro un.TrimNewLines
+!insertmacro GetParent
+
+!insertmacro un.GetParent
 
 ; The following includes are custom.
 !include branding.nsi
 !include defines.nsi
 !include common.nsh
 !include locales.nsi
 !include version.nsh
 
 ; This is named BrandShortName helper because we use this for software update
 ; post update cleanup.
-VIAddVersionKey "FileDescription" "${BrandShortName} Helper"
+VIAddVersionKey "FileDescription"  "${BrandShortName} Helper"
+VIAddVersionKey "OriginalFilename" "helper.exe"
 
+!insertmacro CleanVirtualStore
+!insertmacro GetLongPath
+!insertmacro RegCleanMain
+!insertmacro RegCleanUninstall
+!insertmacro SetBrandNameVars
+!insertmacro UnloadUAC
+!insertmacro WriteRegDWORD2
+!insertmacro WriteRegStr2
+
+!insertmacro un.ChangeMUIHeaderImage
+!insertmacro un.CheckForFilesInUse
+!insertmacro un.CleanUpdatesDir
+!insertmacro un.CleanVirtualStore
+!insertmacro un.GetLongPath
+!insertmacro un.GetSecondInstallPath
+!insertmacro un.ManualCloseAppPrompt
+!insertmacro un.ParseUninstallLog
 !insertmacro un.RegCleanMain
 !insertmacro un.RegCleanUninstall
-!insertmacro un.CloseApp
-!insertmacro un.GetSecondInstallPath
+!insertmacro un.RemoveQuotesFromPath
+!insertmacro un.SetBrandNameVars
+
+!include shared.nsh
+
+; Helper macros for ui callbacks. Insert these after shared.nsh
+!insertmacro OnEndCommon
+!insertmacro UninstallOnInitCommon
+
+!insertmacro un.OnEndCommon
 
 Name "${BrandFullName}"
-OutFile "uninst.exe"
+OutFile "helper.exe"
 InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" "InstallLocation"
 InstallDir "$PROGRAMFILES\${BrandFullName}"
 ShowUnInstDetails nevershow
 
 ################################################################################
 # Modern User Interface - MUI
 
 !define MUI_ABORTWARNING
@@ -102,222 +141,162 @@ ShowUnInstDetails nevershow
 !else
 !define MUI_HEADERIMAGE_BITMAP wizHeader.bmp
 !endif
 
 /**
  * Uninstall Pages
  */
 ; Welcome Page
+!define MUI_PAGE_CUSTOMFUNCTION_PRE un.preWelcome
+!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.leaveWelcome
 !insertmacro MUI_UNPAGE_WELCOME
 
-; Uninstall Confirm Page
-!insertmacro MUI_UNPAGE_CONFIRM
+; Custom Uninstall Confirm Page
+UninstPage custom un.preConfirm un.leaveConfirm
 
 ; Remove Files Page
-!define MUI_PAGE_CUSTOMFUNCTION_PRE un.preInstFiles
 !insertmacro MUI_UNPAGE_INSTFILES
 
 ; Finish Page
+
+; Don't setup the survey controls, functions, etc. when the application has
+; defined NO_UNINSTALL_SURVEY
+!ifndef NO_UNINSTALL_SURVEY
 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.preFinish
 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
 !define MUI_FINISHPAGE_SHOWREADME ""
-
-; Setup the survey controls, functions, etc. except when the application has
-; defined NO_UNINSTALL_SURVEY
-!ifndef NO_UNINSTALL_SURVEY
 !define MUI_FINISHPAGE_SHOWREADME_TEXT $(SURVEY_TEXT)
 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION un.Survey
 !endif
 
 !insertmacro MUI_UNPAGE_FINISH
 
+; Use the default dialog for IDD_VERIFY for a simple Banner
+ChangeUI IDD_VERIFY "${NSISDIR}\Contrib\UIs\default.exe"
+
 ################################################################################
 # Install Sections
 ; Empty section required for the installer to compile as an uninstaller
 Section ""
 SectionEnd
 
 ################################################################################
 # Uninstall Sections
 
 Section "Uninstall"
   SetDetailsPrint textonly
   DetailPrint $(STATUS_UNINSTALL_MAIN)
   SetDetailsPrint none
 
-  ; Remove registry entries for non-existent apps and for apps that point to our
-  ; install location in the Software\Mozilla key and uninstall registry entries
-  ; that point to our install location for both HKCU and HKLM.
-  SetShellVarContext current  ; Sets SHCTX to HKCU
+  ; Delete the app exe to prevent launching the app while we are uninstalling.
+  ClearErrors
+  ${DeleteFile} "$INSTDIR\${FileMainEXE}"
+  ${If} ${Errors}
+    ; If the user closed the application it can take several seconds for it to
+    ; shut down completely. If the application is being used by another user we
+    ; can still delete the files when the system is restarted. 
+    Sleep 5000
+    ${DeleteFile} "$INSTDIR\${FileMainEXE}"
+    ClearErrors
+  ${EndIf}
+
+  SetShellVarContext current  ; Set SHCTX to HKCU
   ${un.RegCleanMain} "Software\Mozilla"
   ${un.RegCleanUninstall}
 
-  SetShellVarContext all  ; Sets SHCTX to HKLM
-  ${un.RegCleanMain} "Software\Mozilla"
-  ${un.RegCleanUninstall}
+  ClearErrors
+  WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
+  ${If} ${Errors}
+    StrCpy $TmpVal "HKCU" ; used primarily for logging
+  ${Else}
+    SetShellVarContext all  ; Set SHCTX to HKLM
+    DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
+    StrCpy $TmpVal "HKLM" ; used primarily for logging
+    ${un.RegCleanMain} "Software\Mozilla"
+    ${un.RegCleanUninstall}
+  ${EndIf}
 
   SetShellVarContext all  ; Set SHCTX to HKLM
   ${un.GetSecondInstallPath} "Software\Mozilla" $R9
   ${If} $R9 == "false"
     SetShellVarContext current  ; Set SHCTX to HKCU
     ${un.GetSecondInstallPath} "Software\Mozilla" $R9
   ${EndIf}
 
-  ; XXXrstrong - Remove registry values for HKLM\Software\Clients\Calendar here.
-  ; See Thunderbird's uninstaller.nsi for an example.
-
   StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
   ${If} $R9 == "false"
     DeleteRegKey HKLM "$0"
     DeleteRegKey HKCU "$0"
   ${Else}
-    ReadRegStr $1 HKLM "$0" ""
-    Push $1
-    ${GetPathFromRegStr}
-    Pop $R0
-    Push $R0
-    ${GetParentDir}
-    Pop $R1
-    ${If} $INSTDIR == $R1
+    ReadRegStr $R1 HKLM "$0" ""
+    ${un.RemoveQuotesFromPath} "$R1" $R1
+    ${un.GetParent} "$R1" $R1
+    ${If} "$INSTDIR" == "$R1"
       WriteRegStr HKLM "$0" "" "$R9"
-      Push $R9
-      ${GetParentDir}
-      Pop $R1
+      ${un.GetParent} "$R9" $R1
       WriteRegStr HKLM "$0" "Path" "$R1"
     ${EndIf}
   ${EndIf}
 
-  ; Remove files. If we don't have a log file skip
-  ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.log"
-    ; Copy the uninstall log file to a temporary file
-    GetTempFileName $TmpVal
-    CopyFiles "$INSTDIR\uninstall\uninstall.log" "$TmpVal"
+  ; Remove directories and files we always control before parsing the uninstall
+  ; log so empty directories can be removed.
+  ${If} ${FileExists} "$INSTDIR\updates"
+    RmDir /r /REBOOTOK "$INSTDIR\updates"
+  ${EndIf}
+  ${If} ${FileExists} "$INSTDIR\defaults\shortcuts"
+    RmDir /r /REBOOTOK "$INSTDIR\defaults\shortcuts"
+  ${EndIf}
+  ${If} ${FileExists} "$INSTDIR\distribution"
+    RmDir /r /REBOOTOK "$INSTDIR\distribution"
+  ${EndIf}
+  ${If} ${FileExists} "$INSTDIR\removed-files"
+    Delete /REBOOTOK "$INSTDIR\removed-files"
+  ${EndIf}
 
-    ; Unregister DLL's
-    ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.UnRegDLLsCallback"
+  ; Remove the updates directory for Vista and above
+  ${un.CleanUpdatesDir} "Mozilla\Sunbird"
 
-    ; Delete files
-    ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.RemoveFilesCallback"
+  ; Remove files that may be left behind by the application in the
+  ; VirtualStore directory.
+  ${un.CleanVirtualStore}
 
-    ; Remove directories we always control
-    RmDir /r "$INSTDIR\uninstall"
-    RmDir /r "$INSTDIR\updates"
-    RmDir /r "$INSTDIR\defaults\shortcuts"
+  ; Parse the uninstall log to unregister dll's and remove all installed
+  ; files / directories this install is responsible for.
+  ${un.ParseUninstallLog}
+
+  ; Remove the uninstall directory that we control
+  RmDir /r /REBOOTOK "$INSTDIR\uninstall"
+
+  ; Remove the installation directory if it is empty
+  ${RemoveDir} "$INSTDIR"
 
-    ; Remove empty directories
-    ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.RemoveDirsCallback"
-
-    ; Delete the temporary uninstall log file
-    ${DeleteFile} "$TmpVal"
-
-    ; Remove the installation directory if it is empty
-    ${RemoveDir} "$INSTDIR"
+  ; If thunderbird.exe was successfully deleted yet we still need to restart to
+  ; remove other files create a dummy thunderbird.exe.moz-delete to prevent the
+  ; installer from allowing an install without restart when it is required
+  ; to complete an uninstall.
+  ${If} ${RebootFlag}
+    ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-delete"
+      FileOpen $0 "$INSTDIR\${FileMainEXE}.moz-delete" w
+      FileWrite $0 "Will be deleted on restart"
+      Delete /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-delete"
+      FileClose $0
+    ${EndUnless}
   ${EndIf}
 
   ; Refresh desktop icons otherwise the start menu internet item won't be
-  ; removed and other ugly things will happen like recreation of the registry
-  ; key by the OS under some conditions.
+  ; removed and other ugly things will happen like recreation of the app's
+  ; clients registry key by the OS under some conditions.
   System::Call "shell32::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)"
 SectionEnd
 
 ################################################################################
 # Helper Functions
 
-Function un.RemoveFilesCallback
-  ${un.TrimNewLines} "$R9" "$R9"
-  StrCpy $R1 "$R9" 5
-  ${If} $R1 == "File:"
-    StrCpy $R9 "$R9" "" 6
-    StrCpy $R0 "$R9" 1
-    ; If the path is relative prepend the install directory
-    ${If} $R0 == "\"
-      StrCpy $R0 "$INSTDIR$R9"
-    ${Else}
-      StrCpy $R0 "$R9"
-    ${EndIf}
-    ${If} ${FileExists} "$R0"
-      ${DeleteFile} "$R0"
-    ${EndIf}
-  ${EndIf}
-  ClearErrors
-  Push 0
-FunctionEnd
-
-; Using locate will leave file handles open to some of the directories which
-; will prevent the deletion of these directories. This parses the uninstall.log
-; and uses the file entries to find / remove empty directories.
-Function un.RemoveDirsCallback
-  ${un.TrimNewLines} "$R9" "$R9"
-  StrCpy $R1 "$R9" 5
-  ${If} $R1 == "File:"
-    StrCpy $R9 "$R9" "" 6
-    StrCpy $R1 "$R9" 1
-    ${If} $R1 == "\"
-      StrCpy $R2 "$INSTDIR"
-      StrCpy $R1 "$INSTDIR$R9"
-    ${Else}
-      StrCpy $R2 ""
-      StrCpy $R1 "$R9"
-    ${EndIf}
-    loop:
-      Push $R1
-      ${GetParentDir}
-      Pop $R0
-      GetFullPathName $R1 "$R0"
-      ; We only try to remove empty directories but the Desktop, StartMenu, and
-      ; QuickLaunch directories can be empty so guard against removing them.
-      ${If} "$R2" != "$INSTDIR"
-        SetShellVarContext all
-        ${If} $R1 == "$DESKTOP"
-        ${OrIf} $R1 == "$STARTMENU"
-          GoTo end
-        ${EndIf}
-        SetShellVarContext current
-        ${If} $R1 == "$QUICKLAUNCH"
-        ${OrIf} $R1 == "$DESKTOP"
-        ${OrIf} $R1 == "$STARTMENU"
-          GoTo end
-        ${EndIf}
-      ${ElseIf} "$R1" == "$INSTDIR"
-        GoTo end
-      ${EndIf}
-      ${If} ${FileExists} "$R1"
-        RmDir "$R1"
-      ${EndIf}
-      ${If} ${Errors}
-      ${OrIf} "$R2" != "$INSTDIR"
-        GoTo end
-      ${EndIf}
-      GoTo loop
-  ${EndIf}
-
-  end:
-    ClearErrors
-    Push 0
-FunctionEnd
-
-Function un.UnRegDLLsCallback
-  ${un.TrimNewLines} "$R9" "$R9"
-  StrCpy $R1 "$R9" 7
-  ${If} $R1 == "DLLReg:"
-    StrCpy $R9 "$R9" "" 8
-    StrCpy $R1 "$R9" 1
-    ${If} $R1 == "\"
-      StrCpy $R1 "$INSTDIR$R9"
-    ${Else}
-      StrCpy $R1 "$R9"
-    ${EndIf}
-    UnRegDLL $R1
-  ${EndIf}
-  ClearErrors
-  Push 0
-FunctionEnd
-
-; Setup the survey controls, functions, etc. except when the application has
+; Don't setup the survey controls, functions, etc. when the application has
 ; defined NO_UNINSTALL_SURVEY
 !ifndef NO_UNINSTALL_SURVEY
 Function un.Survey
   ExecShell "open" "${SurveyURL}"
 FunctionEnd
 !endif
 
 ################################################################################
@@ -330,76 +309,156 @@ FunctionEnd
 !include "customLocale.nsh"
 !verbose pop
 
 ; Set this after the locale files to override it if it is in the locale. Using
 ; " " for BrandingText will hide the "Nullsoft Install System..." branding.
 BrandingText " "
 
 ################################################################################
-# Page pre and leave functions
+# Page pre, show, and leave functions
 
-; Checks if the app being uninstalled is running.
-Function un.preInstFiles
-  ; Try to delete the app executable and if we can't delete it try to close the
-  ; app. This allows running an instance that is located in another directory.
-  ClearErrors
+Function un.preWelcome
+  ${If} ${FileExists} "$INSTDIR\distribution\modern-wizard.bmp"
+    Delete "$PLUGINSDIR\modern-wizard.bmp"
+    CopyFiles /SILENT "$INSTDIR\distribution\modern-wizard.bmp" "$PLUGINSDIR\modern-wizard.bmp"
+  ${EndIf}
+FunctionEnd
+
+Function un.leaveWelcome
   ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
-    ${DeleteFile} "$INSTDIR\${FileMainEXE}"
-  ${EndIf}
-  ${If} ${Errors}
-    ClearErrors
-    ${un.CloseApp} "true" $(WARN_APP_RUNNING_UNINSTALL)
-    ; Delete the app exe to prevent launching the app while we are uninstalling.
-    ${DeleteFile} "$INSTDIR\${FileMainEXE}"
-    ClearErrors
+    Banner::show /NOUNLOAD "$(BANNER_CHECK_EXISTING)"
+
+    ${If} "$TmpVal" == "FoundMessageWindow"
+      Sleep 5000
+    ${EndIf}
+
+    ${PushFilesToCheck}
+
+    ${un.CheckForFilesInUse} $TmpVal
+
+    Banner::destroy
+
+    ${If} "$TmpVal" == "true"
+      StrCpy $TmpVal "FoundMessageWindow"
+      ${un.ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_UNINSTALL)"
+      StrCpy $TmpVal "true"
+    ${EndIf}
   ${EndIf}
 FunctionEnd
 
-; When we add an optional action to the finish page the cancel button is
-; enabled. This disables it and leaves the finish button as the only choice.
-Function un.preFinish
-  !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "cancelenabled" "0"
+Function un.preConfirm
+  ${If} ${FileExists} "$INSTDIR\distribution\modern-header.bmp"
+  ${AndIf} $hHeaderBitmap == ""
+    Delete "$PLUGINSDIR\modern-header.bmp"
+    CopyFiles /SILENT "$INSTDIR\distribution\modern-header.bmp" "$PLUGINSDIR\modern-header.bmp"
+    ${un.ChangeMUIHeaderImage} "$PLUGINSDIR\modern-header.bmp"
+  ${EndIf}
+
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Settings" NumFields "3"
+
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Type   "label"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Text   "$(UN_CONFIRM_UNINSTALLED_FROM)"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Left   "0"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Top    "5"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Bottom "15"
+
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Type   "text"
+  ; The contents of this control must be set as follows in the pre function
+  ; ${MUI_INSTALLOPTIONS_READ} $1 "unconfirm.ini" "Field 2" "HWND"
+  ; SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" State  ""
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Left   "0"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Top    "17"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Bottom "30"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" flags  "READONLY"
+
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Type   "label"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Text   "$(UN_CONFIRM_CLICK)"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Left   "0"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Right  "-1"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Top    "130"
+  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Bottom "150"
+
+  ${If} "$TmpVal" == "true"
+    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Type   "label"
+    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Text   "$(SUMMARY_REBOOT_REQUIRED_UNINSTALL)"
+    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Left   "0"
+    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Right  "-1"
+    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Top    "35"
+    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Bottom "45"
 
-  ; Setup the survey controls, functions, etc. except when the application has
-  ; defined NO_UNINSTALL_SURVEY
-  !ifdef NO_UNINSTALL_SURVEY
-    !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "NumFields" "3"
-  !endif
+    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Settings" NumFields "4"
+  ${EndIf}
+
+  !insertmacro MUI_HEADER_TEXT "$(UN_CONFIRM_PAGE_TITLE)" "$(UN_CONFIRM_PAGE_SUBTITLE)"
+  ; The Summary custom page has a textbox that will automatically receive
+  ; focus. This sets the focus to the Install button instead.
+  !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "unconfirm.ini"
+  GetDlgItem $0 $HWNDPARENT 1
+  System::Call "user32::SetFocus(i r0, i 0x0007, i,i)i"
+  ${MUI_INSTALLOPTIONS_READ} $1 "unconfirm.ini" "Field 2" "HWND"
+  SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
+  !insertmacro MUI_INSTALLOPTIONS_SHOW
 FunctionEnd
 
+Function un.leaveConfirm
+  ; Try to delete the app executable and if we can't delete it try to find the
+  ; app's message window and prompt the user to close the app. This allows
+  ; running an instance that is located in another directory. If for whatever
+  ; reason there is no message window we will just rename the app's files and
+  ; then remove them on restart if they are in use.
+  ClearErrors
+  ${DeleteFile} "$INSTDIR\${FileMainEXE}"
+  ${If} ${Errors}
+    ${un.ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_UNINSTALL)"
+  ${EndIf}
+FunctionEnd
+
+!ifndef NO_UNINSTALL_SURVEY
+Function un.preFinish
+  ; Do not modify the finish page if there is a reboot pending.
+  ${Unless} ${RebootFlag}
+    ; Don't display the option to take a survey on the finish page if the OS is
+    ; Vista or above since the process will be running elevated.
+    ${If} ${AtLeastWinVista}
+      !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "NumFields" "3"
+    ${Else}
+      ; When we add an optional action to the finish page the cancel button
+      ; is enabled. This disables it and leaves the finish button as the
+      ; only choice.
+      !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "cancelenabled" "0"
+    ${EndIf}
+  ${EndUnless}
+FunctionEnd
+!endif
+
 ################################################################################
 # Initialization Functions
 
 Function .onInit
-  GetFullPathName $INSTDIR "$EXEDIR\.."
-  ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}"
-    Abort
-  ${EndUnless}
-  ${GetParameters} $R0
-
-  ; XXXrstrong - Add support for setting program access here (e.g. hide and
-  ; display shortcuts). See Thunderbird's uninstaller.nsi for an example.
-
-  ; If we made it this far then this installer is being used as an uninstaller.
-  WriteUninstaller "$EXEDIR\uninstaller.exe"
-
-  ${If} $R0 == "/S"
-    StrCpy $TmpVal "$\"$EXEDIR\uninstaller.exe$\" /S"
-  ${Else}
-    StrCpy $TmpVal "$\"$EXEDIR\uninstaller.exe$\""
-  ${EndIf}
-
-  ; When the uninstaller is launched it copies itself to the temp directory so
-  ; it won't be in use so it can delete itself.
-  ExecWait $TmpVal
-  ${DeleteFile} "$EXEDIR\uninstaller.exe"
-  SetErrorLevel 0
-  Quit
+  ${UninstallOnInitCommon}
 FunctionEnd
 
 Function un.onInit
   GetFullPathName $INSTDIR "$INSTDIR\.."
+  ${un.GetLongPath} "$INSTDIR" $INSTDIR
   ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}"
     Abort
   ${EndUnless}
+
   StrCpy $LANGUAGE 0
+  ${un.SetBrandNameVars} "$INSTDIR\distribution\setup.ini"
+
+  ; Initialize $hHeaderBitmap to prevent redundant changing of the bitmap if
+  ; the user clicks the back button
+  StrCpy $hHeaderBitmap ""
 FunctionEnd
+
+Function .onGUIEnd
+  ${OnEndCommon}
+FunctionEnd
+
+Function un.onGUIEnd
+  ${un.OnEndCommon}
+FunctionEnd
new file mode 100644
--- /dev/null
+++ b/calendar/installer/windows/nsis/updater_append.ini
@@ -0,0 +1,12 @@
+
+; IMPORTANT: This file should always start with a newline in case a locale
+; provided updater.ini does not end with a newline.
+; Application to launch after an update has been successfully applied. This
+; must be in the same directory or a sub-directory of the directory of the
+; application executable that initiated the software update.
+[PostUpdateWin]
+; ExeRelPath is the path to the PostUpdateWin executable relative to the
+; application executable.
+ExeRelPath=uninstall\helper.exe
+; ExeArg is the argument to pass to the PostUpdateWin exe
+ExeArg=/PostUpdate
--- a/calendar/installer/windows/packages-static
+++ b/calendar/installer/windows/packages-static
@@ -18,17 +18,17 @@ bin\chrome\@AB_CD@.manifest
 bin\chrome\calendar-@AB_CD@.jar
 bin\chrome\calendar-@AB_CD@.manifest
 bin\chrome\sunbird-@AB_CD@.jar
 bin\chrome\sunbird-@AB_CD@.manifest
 bin\defaults\pref\sunbird-l10n.js
 bin\defaults\profile\prefs.js
 bin\defaults\profile\chrome\*
 bin\dictionaries\*
-bin\uninstall\uninst.exe
+bin\uninstall\helper.exe
 bin\updater.ini
 
 [xpcom]
 bin\js3250.dll
 bin\plc4.dll
 bin\plds4.dll
 bin\xpcom.dll
 bin\xpcom_core.dll
--- a/calendar/locales/Makefile.in
+++ b/calendar/locales/Makefile.in
@@ -92,19 +92,23 @@ endif
 
 ifeq (,$(filter-out pref,$(MOZ_EXTENSIONS)))
 DEFINES += -DEXTENSION_PREF
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 tests:
+ifdef MOZ_SUNBIRD
+ifeq ($(OS_ARCH), WINNT)
 ifneq (en-US, $(AB_CD))
-	#@echo "Verifying $(AB_CD) installer variable usage"
-	#@$(PERL) $(MOZ_SRCDIR)/toolkit/mozapps/installer/windows/nsis/check-locales.pl $(LOCALE_SRCDIR)/installer
+	@echo "Verifying $(AB_CD) installer variable usage $(MOZILLA_SRCDIR)"
+	@$(PERL) $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/windows/nsis/check-locales.pl $(LOCALE_SRCDIR)/installer
+endif
+endif
 endif
 
 clobber-%:
 	$(RM) -rf $(DIST)/xpi-stage/locale-$*
 
 libs-%:
 	$(NSINSTALL) -D $(DIST)/install
 	@$(MAKE) -C ../../mozilla/toolkit/locales libs-$* BOTH_MANIFESTS=1
@@ -112,17 +116,17 @@ ifdef MOZ_SUNBIRD
 	@$(MAKE) -C ../sunbird/locales libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref BOTH_MANIFESTS=1
 endif
 	@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref BOTH_MANIFESTS=1
 ifdef MOZ_BRANDING_DIRECTORY
 	@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales AB_CD=$* XPI_NAME=locale-$* BOTH_MANIFESTS=1
 endif
 	@$(MAKE) tests AB_CD=$*
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter cocoa,$(MOZ_WIDGET_TOOLKIT)))
 MOZ_PKG_MAC_DSSTORE=$(_ABS_DIST)/branding/dsstore
 MOZ_PKG_MAC_BACKGROUND=$(_ABS_DIST)/branding/background.png
 MOZ_PKG_MAC_ICON=$(_ABS_DIST)/branding/disk.icns
 MOZ_PKG_MAC_RSRC=$(_ABS_DIST)/branding/license.r
 endif
 
 PACKAGER_NO_LIBS = 1
 include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/packager.mk
@@ -147,44 +151,44 @@ endif
 	cp -r $(DIST)/xpi-stage/locale-$(AB_CD) l10n-stage/localized
 	$(RM) -rf $(DIST)/xpi-stage/calendar-timezones
 	$(MAKE) -C ../timezones libs-$(AB_CD) USE_EXTENSION_MANIFEST=1
 	mv $(DIST)/xpi-stage/calendar-timezones/chrome l10n-stage/nonlocalized/extensions/calendar-timezones@mozilla.org
 	mv $(DIST)/xpi-stage/calendar-timezones/chrome.manifest l10n-stage/nonlocalized/extensions/calendar-timezones@mozilla.org
 	$(MAKE) -C ../installer/windows CONFIG_DIR=l10ngen l10ngen/setup.exe l10ngen/7zSD.sfx
 	cp ../installer/windows/l10ngen/setup.exe l10n-stage
 	$(NSINSTALL) -D l10n-stage/localized/uninstall
-	cp ../installer/windows/l10ngen/uninst.exe l10n-stage/localized/uninstall
+	cp ../installer/windows/l10ngen/helper.exe l10n-stage/localized/uninstall
 	rm -f app.7z
 	cd l10n-stage && \
 	  $(CYGWIN_WRAPPER) 7z a -r -t7z ../app.7z -mx -m0=BCJ2 -m1=LZMA:d24 -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3
 	cat ../installer/windows/l10ngen/7zSD.sfx \
 	    $(topsrcdir)/calendar/installer/windows/app.tag \
 	    app.7z > $(WIN32_INSTALLER_OUT)
 	chmod 0755 $(WIN32_INSTALLER_OUT)
 
 ifeq (WINNT,$(OS_ARCH))
 repackage-win32-installer-%: WIN32_INSTALLER_IN=$(_ABS_DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe
 repackage-win32-installer-%: $(WIN32_INSTALLER_IN) libs-%
 	@$(MAKE) repackage-win32-installer AB_CD=$* WIN32_INSTALLER_IN=$(WIN32_INSTALLER_IN)
 else
 repackage-win32-installer-%: ;
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter cocoa,$(MOZ_WIDGET_TOOLKIT)))
 STAGEDIST = $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/MacOS
 else
 STAGEDIST = $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)
 endif
 
 $(STAGEDIST): AB_CD:=en-US
 $(STAGEDIST): UNPACKAGE=$(ZIP_IN)
 $(STAGEDIST): $(ZIP_IN)
 # only mac needs to remove the parent of STAGEDIST...
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter cocoa,$(MOZ_WIDGET_TOOLKIT)))
 	if test -d $(DIST)/l10n-stage; then \
 	  $(RM) -r -v $(DIST)/l10n-stage; \
 	fi
 else
 # ... and windows doesn't like removing STAGEDIST itself, remove all children
 	if test -d $(DIST)/l10n-stage; then \
 	  find $(STAGEDIST) -maxdepth 1 -print0 | xargs -0 $(RM) -r ; \
 	fi
@@ -225,38 +229,38 @@ unpack: $(STAGEDIST)
 
 repackage-zip: ZIP_OUT="$(_ABS_DIST)/$(PACKAGE)"
 repackage-zip: UNPACKAGE="$(ZIP_IN)"
 repackage-zip:
 	$(MAKE) -C ../timezones libs-$(AB_CD) USE_EXTENSION_MANIFEST=1
 ifeq (WINNT,$(OS_ARCH))
 	$(RM) -r $(STAGEDIST)/uninstall
 	$(NSINSTALL) -D $(STAGEDIST)/uninstall
-	cp ../installer/windows/l10ngen/uninst.exe $(STAGEDIST)/uninstall
+	cp ../installer/windows/l10ngen/helper.exe $(STAGEDIST)/uninstall
 endif
 	cd $(DIST)/xpi-stage/locale-$(AB_CD) && \
 	  tar $(TAR_CREATE_FLAGS) - * | ( cd $(STAGEDIST) && tar -xf - )
 	cd $(DIST)/xpi-stage/calendar-timezones && \
 	  tar $(TAR_CREATE_FLAGS) - * | ( cd $(STAGEDIST)/extensions/calendar-timezones@mozilla.org && tar -xf - )
 ifneq (en,$(AB))
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter cocoa,$(MOZ_WIDGET_TOOLKIT)))
 	mv $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/en.lproj $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/$(AB).lproj
 endif
 endif
 	cd $(DIST)/l10n-stage; \
 	  $(MAKE_PACKAGE)
 ifdef MOZ_MAKE_COMPLETE_MAR
 	$(MAKE) -C $(MOZDEPTH)/tools/update-packaging full-update AB_CD=$(AB_CD) \
 	  MOZ_PKG_PRETTYNAMES=$(MOZ_PKG_PRETTYNAMES) \
 	  PACKAGE_BASE_DIR="$(_ABS_DIST)/l10n-stage" \
 	  DIST="$(_ABS_DIST)"
 endif
 # packaging done, undo l10n stuff
 ifneq (en,$(AB))
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter cocoa,$(MOZ_WIDGET_TOOLKIT)))
 	mv $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/$(AB).lproj $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/en.lproj
 endif
 endif
 	$(MAKE) clobber-zip AB_CD=$(AB_CD)
 	mv -f "$(DIST)/l10n-stage/$(PACKAGE)" "$(DIST)/$(PACKAGE)"
 
 repackage-zip-%: ZIP_IN=$(_ABS_DIST)/$(PACKAGE)
 repackage-zip-%: $(ZIP_IN) $(STAGEDIST) libs-%
--- a/calendar/locales/en-US/installer/custom.properties
+++ b/calendar/locales/en-US/installer/custom.properties
@@ -36,56 +36,68 @@
 
 # LOCALIZATION NOTE:
 
 # This file must be saved as UTF8
 
 # Accesskeys are defined by prefixing the letter that is to be used for the
 # accesskey with an ampersand (e.g. &).
 
-# Don't replace ${BrandShortName}, $(^Name), or $(^NameDA) with a custom string.
+# Do not replace $BrandShortName, $BrandFullName, or $BrandFullNameDA with a
+# custom string and always use the same one as used by the en-US files.
+# $BrandFullNameDA allows the string to contain an ampersand (e.g. DA stands
+# for double ampersand) and prevents the letter following the ampersand from
+# being used as an accesskey.
 
 # You can use \n to create a newline in the string but only when the string
 # from en-US contains a \n.
 
-OPTIONAL_COMPONENTS_TITLE=Choose Optional Components
-OPTIONAL_COMPONENTS_SUBTITLE=Choose which features of $(^NameDA) you want to install.
-OPTIONAL_COMPONENTS_LABEL=Optional Components:
-APP_DESC=Required files for the ${BrandShortName} application
-DOMI_TITLE=DOM Inspector
-DOMI_TEXT=Inspects the structure and properties of a window and its contents.
-QFA_TITLE=Quality Feedback Agent
-QFA_TEXT=Sends information about program crashes to Mozilla.
-OPTIONS=$(^NameDA) &Options
+CONTEXT_OPTIONS=$BrandShortName &Options
+CONTEXT_SAFE_MODE=$BrandShortName &Safe Mode
 SAFE_MODE=Safe Mode
 OPTIONS_PAGE_TITLE=Setup Type
 OPTIONS_PAGE_SUBTITLE=Choose setup options
 SHORTCUTS_PAGE_TITLE=Set Up Shortcuts
 SHORTCUTS_PAGE_SUBTITLE=Create Program Icons
-SURVEY_TEXT=&Tell us what you thought of ${BrandShortName}
-LAUNCH_TEXT=&Launch $(^Name) now
-WARN_APP_RUNNING_INSTALL=$(^Name) must be closed to proceed with the installation.\n\nClick "OK" to exit $(^Name) automatically and continue.
-WARN_APP_RUNNING_UNINSTALL=$(^Name) must be closed to proceed with the uninstall.\n\nClick "OK" to exit $(^Name) automatically and continue.
-CREATE_ICONS_DESC=Create icons for ${BrandShortName}:
+SUMMARY_PAGE_TITLE=Summary
+SUMMARY_PAGE_SUBTITLE=Ready to start installing $BrandShortName
+SUMMARY_INSTALLED_TO=$BrandShortName will be installed to the following location:
+SUMMARY_REBOOT_REQUIRED_INSTALL=A restart of your computer may be required to complete the installation.
+SUMMARY_REBOOT_REQUIRED_UNINSTALL=A restart of your computer may be required to complete the uninstall.
+SUMMARY_CLICK=Click Install to continue.
+SURVEY_TEXT=&Tell us what you thought of $BrandShortName
+LAUNCH_TEXT=&Launch $BrandShortName now
+CREATE_ICONS_DESC=Create icons for $BrandShortName:
 ICONS_DESKTOP=On my &Desktop
 ICONS_STARTMENU=In my &Start Menu Programs folder
 ICONS_QUICKLAUNCH=In my &Quick Launch bar
+WARN_MANUALLY_CLOSE_APP_INSTALL=$BrandShortName must be closed to proceed with the installation.\n\nPlease close $BrandShortName to continue.
+WARN_MANUALLY_CLOSE_APP_UNINSTALL=$BrandShortName must be closed to proceed with the uninstall.\n\nPlease close $BrandShortName to continue.
+WARN_MANUALLY_CLOSE_APP_LAUNCH=$BrandShortName is already running.\n\nPlease close $BrandShortName prior to launching the version you have just installed.
 WARN_WRITE_ACCESS=You don't have access to write to the installation directory.\n\nClick OK to select a different directory.
 WARN_DISK_SPACE=You don't have sufficient disk space to install to this location.\n\nClick OK to select a different location.
+WARN_UNSUPPORTED_MSG=Sorry, $BrandShortName can't be installed. This version of $BrandShortName requires ${MinSupportedVer} or newer.
+WARN_RESTART_REQUIRED_UNINSTALL=Your computer must be restarted to complete a previous uninstall of $BrandShortName. Do you want to reboot now?
+WARN_RESTART_REQUIRED_UPGRADE=Your computer must be restarted to complete a previous upgrade of $BrandShortName. Do you want to reboot now?
+ERROR_CREATE_DIRECTORY_PREFIX=Error creating directory:
+ERROR_CREATE_DIRECTORY_SUFFIX=Click Cancel to stop the installation or\nRetry to try again.
 
-STATUS_INSTALL_APP=Installing ${BrandShortName}...
-STATUS_INSTALL_LANG=Installing Language Files (${AB_CD})...
-STATUS_INSTALL_OPTIONAL=Installing Optional Components...
-STATUS_UNINSTALL_MAIN=Uninstalling ${BrandShortName}...
-STATUS_CLEANUP=A Little Housekeeping...
+UN_CONFIRM_PAGE_TITLE=Uninstall $BrandFullName
+UN_CONFIRM_PAGE_SUBTITLE=Remove $BrandFullName from your computer.
+UN_CONFIRM_UNINSTALLED_FROM=$BrandShortName will be uninstalled from the following location:
+UN_CONFIRM_CLICK=Click Uninstall to continue.
+
+BANNER_CHECK_EXISTING=Checking existing installation…
+
+STATUS_INSTALL_APP=Installing $BrandShortName…
+STATUS_INSTALL_LANG=Installing Language Files (${AB_CD})…
+STATUS_UNINSTALL_MAIN=Uninstalling $BrandShortName…
+STATUS_CLEANUP=A Little Housekeeping…
 
 # _DESC strings support approximately 65 characters per line.
 # One line
 OPTIONS_SUMMARY=Choose the type of setup you prefer, then click Next.
 # One line
-OPTION_STANDARD_DESC=${BrandShortName} will be installed with the most common options.
+OPTION_STANDARD_DESC=$BrandShortName will be installed with the most common options.
 OPTION_STANDARD_RADIO=&Standard
-# One line
-OPTION_COMPLETE_DESC=${BrandShortName} will be installed with all available options.
-OPTION_COMPLETE_RADIO=C&omplete
 # Two lines
 OPTION_CUSTOM_DESC=You may choose individual options to be installed. Recommended for experienced users.
 OPTION_CUSTOM_RADIO=&Custom
--- a/calendar/locales/en-US/installer/mui.properties
+++ b/calendar/locales/en-US/installer/mui.properties
@@ -39,58 +39,59 @@
 
 # LOCALIZATION NOTE:
 
 # This file must be saved as UTF8
 
 # Accesskeys are defined by prefixing the letter that is to be used for the
 # accesskey with an ampersand (e.g. &).
 
-# Do not replace $(^NameDA) or $(^Name) with a custom string.
-
-# Do not change $(^NameDA) to $(^Name) or $(^Name) to $(^NameDA). NameDA allows
-# Name to contain an ampersand (e.g. DA stands for double ampersand) and
-# prevents the letter following the ampersand being used as an accesskey.
+# Do not replace $BrandShortName, $BrandFullName, or $BrandFullNameDA with a
+# custom string and always use the same one as used by the en-US files.
+# $BrandFullNameDA allows the string to contain an ampersand (e.g. DA stands
+# for double ampersand) and prevents the letter following the ampersand from
+# being used as an accesskey.
 
 # You can use \n to create a newline in the string but only when the string
 # from en-US contains a \n.
-MUI_TEXT_WELCOME_INFO_TITLE=Welcome to the $(^NameDA) Setup Wizard
-MUI_TEXT_WELCOME_INFO_TEXT=This wizard will guide you through the installation of $(^NameDA).\n\nIt is recommended that you close all other applications before starting Setup. This will make it possible to update relevant system files without having to reboot your computer.\n\n$_CLICK
+
+MUI_TEXT_WELCOME_INFO_TITLE=Welcome to the $BrandFullNameDA Setup Wizard
+MUI_TEXT_WELCOME_INFO_TEXT=This wizard will guide you through the installation of $BrandFullNameDA.\n\nIt is recommended that you close all other applications before starting Setup. This will make it possible to update relevant system files without having to reboot your computer.\n\n$_CLICK
 MUI_TEXT_LICENSE_TITLE=License Agreement
-MUI_TEXT_LICENSE_SUBTITLE=Please review the license terms before installing $(^NameDA).
+MUI_TEXT_LICENSE_SUBTITLE=Please review the license terms before installing $BrandFullNameDA.
 MUI_INNERTEXT_LICENSE_TOP=Press Page Down to see the rest of the agreement.
-MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS=If you accept the terms of the agreement, select the first option below. You must accept the agreement to install $(^NameDA). $_CLICK
+MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX=If you accept the terms of the agreement, click the check box below. You must accept the agreement to install $BrandFullNameDA. $_CLICK
 MUI_TEXT_COMPONENTS_TITLE=Choose Components
-MUI_TEXT_COMPONENTS_SUBTITLE=Choose which features of $(^NameDA) you want to install.
+MUI_TEXT_COMPONENTS_SUBTITLE=Choose which features of $BrandFullNameDA you want to install.
 MUI_INNERTEXT_COMPONENTS_DESCRIPTION_TITLE=Description
 MUI_INNERTEXT_COMPONENTS_DESCRIPTION_INFO=Position your mouse over a component to see its description.
 MUI_TEXT_DIRECTORY_TITLE=Choose Install Location
-MUI_TEXT_DIRECTORY_SUBTITLE=Choose the folder in which to install $(^NameDA).
+MUI_TEXT_DIRECTORY_SUBTITLE=Choose the folder in which to install $BrandFullNameDA.
 MUI_TEXT_INSTALLING_TITLE=Installing
-MUI_TEXT_INSTALLING_SUBTITLE=Please wait while $(^NameDA) is being installed.
+MUI_TEXT_INSTALLING_SUBTITLE=Please wait while $BrandFullNameDA is being installed.
 MUI_TEXT_FINISH_TITLE=Installation Complete
 MUI_TEXT_FINISH_SUBTITLE=Setup was completed successfully.
 MUI_TEXT_ABORT_TITLE=Installation Aborted
 MUI_TEXT_ABORT_SUBTITLE=Setup was not completed successfully.
 MUI_BUTTONTEXT_FINISH=&Finish
-MUI_TEXT_FINISH_INFO_TITLE=Completing the $(^NameDA) Setup Wizard
-MUI_TEXT_FINISH_INFO_TEXT=$(^NameDA) has been installed on your computer.\n\nClick Finish to close this wizard.
-MUI_TEXT_FINISH_INFO_REBOOT=Your computer must be restarted in order to complete the installation of $(^NameDA). Do you want to reboot now?
+MUI_TEXT_FINISH_INFO_TITLE=Completing the $BrandFullNameDA Setup Wizard
+MUI_TEXT_FINISH_INFO_TEXT=$BrandFullNameDA has been installed on your computer.\n\nClick Finish to close this wizard.
+MUI_TEXT_FINISH_INFO_REBOOT=Your computer must be restarted in order to complete the installation of $BrandFullNameDA. Do you want to reboot now?
 MUI_TEXT_FINISH_REBOOTNOW=Reboot now
 MUI_TEXT_FINISH_REBOOTLATER=I want to manually reboot later
 MUI_TEXT_STARTMENU_TITLE=Choose Start Menu Folder
-MUI_TEXT_STARTMENU_SUBTITLE=Choose a Start Menu folder for the $(^NameDA) shortcuts.
+MUI_TEXT_STARTMENU_SUBTITLE=Choose a Start Menu folder for the $BrandFullNameDA shortcuts.
 MUI_INNERTEXT_STARTMENU_TOP=Select the Start Menu folder in which you would like to create the program's shortcuts. You can also enter a name to create a new folder.
-MUI_TEXT_ABORTWARNING=Are you sure you want to quit $(^Name) Setup?
-MUI_UNTEXT_WELCOME_INFO_TITLE=Welcome to the $(^NameDA) Uninstall Wizard
-MUI_UNTEXT_WELCOME_INFO_TEXT=This wizard will guide you through the uninstallation of $(^NameDA).\n\nBefore starting the uninstallation, make sure $(^NameDA) is not running.\n\n$_CLICK
-MUI_UNTEXT_CONFIRM_TITLE=Uninstall $(^NameDA)
-MUI_UNTEXT_CONFIRM_SUBTITLE=Remove $(^NameDA) from your computer.
+MUI_TEXT_ABORTWARNING=Are you sure you want to quit $BrandFullName Setup?
+MUI_UNTEXT_WELCOME_INFO_TITLE=Welcome to the $BrandFullNameDA Uninstall Wizard
+MUI_UNTEXT_WELCOME_INFO_TEXT=This wizard will guide you through the uninstallation of $BrandFullNameDA.\n\nBefore starting the uninstallation, make sure $BrandFullNameDA is not running.\n\n$_CLICK
+MUI_UNTEXT_CONFIRM_TITLE=Uninstall $BrandFullNameDA
+MUI_UNTEXT_CONFIRM_SUBTITLE=Remove $BrandFullNameDA from your computer.
 MUI_UNTEXT_UNINSTALLING_TITLE=Uninstalling
-MUI_UNTEXT_UNINSTALLING_SUBTITLE=Please wait while $(^NameDA) is being uninstalled.
+MUI_UNTEXT_UNINSTALLING_SUBTITLE=Please wait while $BrandFullNameDA is being uninstalled.
 MUI_UNTEXT_FINISH_TITLE=Uninstallation Complete
 MUI_UNTEXT_FINISH_SUBTITLE=Uninstall was completed successfully.
 MUI_UNTEXT_ABORT_TITLE=Uninstallation Aborted
 MUI_UNTEXT_ABORT_SUBTITLE=Uninstall was not completed successfully.
-MUI_UNTEXT_FINISH_INFO_TITLE=Completing the $(^NameDA) Uninstall Wizard
-MUI_UNTEXT_FINISH_INFO_TEXT=$(^NameDA) has been uninstalled from your computer.\n\nClick Finish to close this wizard.
-MUI_UNTEXT_FINISH_INFO_REBOOT=Your computer must be restarted in order to complete the uninstallation of $(^NameDA). Do you want to reboot now?
-MUI_UNTEXT_ABORTWARNING=Are you sure you want to quit $(^Name) Uninstall?
+MUI_UNTEXT_FINISH_INFO_TITLE=Completing the $BrandFullNameDA Uninstall Wizard
+MUI_UNTEXT_FINISH_INFO_TEXT=$BrandFullNameDA has been uninstalled from your computer.\n\nClick Finish to close this wizard.
+MUI_UNTEXT_FINISH_INFO_REBOOT=Your computer must be restarted in order to complete the uninstallation of $BrandFullNameDA. Do you want to reboot now?
+MUI_UNTEXT_ABORTWARNING=Are you sure you want to quit $BrandFullName Uninstall?
--- a/calendar/locales/en-US/installer/override.properties
+++ b/calendar/locales/en-US/installer/override.properties
@@ -36,55 +36,55 @@
 
 # LOCALIZATION NOTE:
 
 # This file must be saved as UTF8
 
 # Accesskeys are defined by prefixing the letter that is to be used for the
 # accesskey with an ampersand (e.g. &).
 
-# Do not replace $(^NameDA) or $(^Name) with a custom string.
-
-# Do not change $(^NameDA) to $(^Name) or $(^Name) to $(^NameDA). NameDA allows
-# Name to contain an ampersand (e.g. DA stands for double ampersand) and
-# prevents the letter following the ampersand being used as an accesskey.
+# Do not replace $BrandShortName, $BrandFullName, or $BrandFullNameDA with a
+# custom string and always use the same one as used by the en-US files.
+# $BrandFullNameDA allows the string to contain an ampersand (e.g. DA stands
+# for double ampersand) and prevents the letter following the ampersand from
+# being used as an accesskey.
 
 # You can use \n to create a newline in the string but only when the string
 # from en-US contains a \n.
 
 # Strings that require a space at the end should be enclosed with double
 # quotes and the double quotes will be removed. To add quotes to the beginning
 # and end of a strong enclose the add and additional double quote to the
 # beginning and end of the string (e.g. ""This will include quotes"").
 
-SetupCaption=$(^Name) Setup
-UninstallCaption=$(^Name) Uninstall
+SetupCaption=$BrandFullName Setup
+UninstallCaption=$BrandFullName Uninstall
 BackBtn=< &Back
 NextBtn=&Next >
 AcceptBtn=I &accept the terms in the License Agreement
 DontAcceptBtn=I &do not accept the terms in the License Agreement
 InstallBtn=&Install
 UninstallBtn=&Uninstall
 CancelBtn=Cancel
 CloseBtn=&Close
 BrowseBtn=B&rowse...
 ShowDetailsBtn=Show &details
 ClickNext=Click Next to continue.
 ClickInstall=Click Install to start the installation.
 ClickUninstall=Click Uninstall to start the uninstallation.
 Completed=Completed
-LicenseTextRB=Please review the license agreement before installing $(^NameDA). If you accept all terms of the agreement, select the first option below. $_CLICK
+LicenseTextRB=Please review the license agreement before installing $BrandFullNameDA. If you accept all terms of the agreement, select the first option below. $_CLICK
 ComponentsText=Check the components you want to install and uncheck the components you don't want to install. $_CLICK
 ComponentsSubText2_NoInstTypes=Select components to install:
-DirText=Setup will install $(^NameDA) in the following folder. To install in a different folder, click Browse and select another folder. $_CLICK
+DirText=Setup will install $BrandFullNameDA in the following folder. To install in a different folder, click Browse and select another folder. $_CLICK
 DirSubText=Destination Folder
-DirBrowseText=Select the folder to install $(^NameDA) in:
+DirBrowseText=Select the folder to install $BrandFullNameDA in:
 SpaceAvailable="Space available: "
 SpaceRequired="Space required: "
-UninstallingText=$(^NameDA) will be uninstalled from the following folder. $_CLICK
+UninstallingText=$BrandFullNameDA will be uninstalled from the following folder. $_CLICK
 UninstallingSubText=Uninstalling from:
 FileError=Error opening file for writing: \r\n\r\n$0\r\n\r\nClick Abort to stop the installation,\r\nRetry to try again, or\r\nIgnore to skip this file.
 FileError_NoIgnore=Error opening file for writing: \r\n\r\n$0\r\n\r\nClick Retry to try again, or\r\nCancel to stop the installation.
 CantWrite="Can't write: "
 CopyFailed=Copy failed
 CopyTo="Copy to "
 Registering="Registering: "
 Unregistering="Unregistering: "
--- a/calendar/sunbird/locales/Makefile.in
+++ b/calendar/sunbird/locales/Makefile.in
@@ -70,24 +70,16 @@ ifeq ($(OS_ARCH),WINNT)
 	done
 else
 	$(INSTALL) $^ $(FINAL_TARGET)
 endif
 
 ifdef MOZ_UPDATER
 libs:: $(addprefix $(LOCALE_SRCDIR)/,updater/updater.ini)
 ifeq ($(OS_ARCH),WINNT)
-	cat $< $(srcdir)/updater_append.ini | \
+	cat $< $(srcdir)/updater_append.ini $(srcdir)/../../installer/windows/nsis/updater_append.ini | \
 	  sed -e "s/%AB_CD%/$(AB_CD)/" | \
- 	  iconv -f UTF-8 -t $(WIN_INSTALLER_CHARSET) > $(FINAL_TARGET)/updater.ini
-else
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
-	if test ! -d $(FINAL_TARGET)/updater.app/Contents/MacOS; then \
-	  mkdir -p $(FINAL_TARGET)/updater.app/Contents/MacOS; \
-	fi
-	cat $< $(srcdir)/updater_append.ini | \
-	  sed -e "s/%AB_CD%/$(AB_CD)/" > $(FINAL_TARGET)/updater.app/Contents/MacOS/updater.ini
+	  iconv -f UTF-8 -t $(WIN_INSTALLER_CHARSET) > $(FINAL_TARGET)/updater.ini
 else
 	cat $< $(srcdir)/updater_append.ini | \
 	  sed -e "s/%AB_CD%/$(AB_CD)/" > $(FINAL_TARGET)/updater.ini
 endif
 endif
-endif