Revision control

Copy as Markdown

Other Tools

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Also requires:
; 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
Unicode true
ManifestSupportedOS all
ManifestDPIAware true
!addplugindir ./
; 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 MUI.nsh
!include WinMessages.nsh
!include WinVer.nsh
!include WordFunc.nsh
!insertmacro GetSize
!insertmacro GetOptions
!insertmacro GetParameters
!insertmacro GetParent
!insertmacro StrFilter
!insertmacro WordFind
!insertmacro un.GetParent
; The following includes are custom.
!include branding.nsi
!include defines.nsi
!include common.nsh
!include locales.nsi
; This is named BrandShortName helper because we use this for software update
; post update cleanup.
VIAddVersionKey "FileDescription" "${BrandShortName} Helper"
VIAddVersionKey "OriginalFilename" "helper.exe"
; Most commonly used macros for managing shortcuts
!insertmacro _LoggingShortcutsCommon
!insertmacro AddDisabledDDEHandlerValues
!insertmacro AddHandlerValues
!insertmacro CheckIfRegistryKeyExists
!insertmacro CleanMaintenanceServiceLogs
!insertmacro CleanVirtualStore
!insertmacro FindSMProgramsDir
!insertmacro GetLongPath
!insertmacro GetPathFromString
!insertmacro InitHashAppModelId
!insertmacro IsHandlerForInstallDir
!insertmacro RegCleanMain
!insertmacro RegCleanUninstall
!insertmacro SetBrandNameVars
!insertmacro UnloadUAC
!insertmacro UpdateShortcutAppModelIDs
!insertmacro WordReplace
!insertmacro WriteRegDWORD2
!insertmacro WriteRegStr2
!insertmacro un.ChangeMUIHeaderImage
!insertmacro un.CheckForFilesInUse
!insertmacro un.CleanMaintenanceServiceLogs
!insertmacro un.CleanVirtualStore
!insertmacro un.DeleteShortcuts
!insertmacro un.GetLongPath
!insertmacro un.GetSecondInstallPath
!insertmacro un.InitHashAppModelId
!insertmacro un.ManualCloseAppPrompt
!insertmacro un.ParseUninstallLog
!insertmacro un.RegCleanAppHandler
!insertmacro un.RegCleanFileHandler
!insertmacro un.RegCleanMain
!insertmacro un.RegCleanProtocolHandler
!insertmacro un.RegCleanUninstall
!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
!insertmacro un.UninstallUnOnInitCommon
Name "${BrandFullName}"
OutFile "helper.exe"
!ifdef HAVE_64BIT_BUILD
InstallDir "$PROGRAMFILES64\${BrandFullName}\"
!else
InstallDir "$PROGRAMFILES32\${BrandFullName}\"
!endif
ShowUnInstDetails nevershow
################################################################################
# Modern User Interface - MUI
!define MUI_ABORTWARNING
!define MUI_ICON setup.ico
!define MUI_UNICON setup.ico
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_UNWELCOMEFINISHPAGE_BITMAP wizWatermark.bmp
; Use a right to left header image when the language is right to left
!ifdef ${AB_CD}_rtl
!define MUI_HEADERIMAGE_BITMAP_RTL wizHeaderRTL.bmp
!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
UninstPage custom un.preConfirm un.leaveConfirm
; Remove Files Page
!insertmacro MUI_UNPAGE_INSTFILES
!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
; 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}
${un.DeleteShortcuts}
; setup the application model id registration value
${un.InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
; Unregister resources associated with Win7 taskbar jump lists.
${If} "$AppUserModelID" != ""
ApplicationID::UninstallJumpLists "$AppUserModelID"
${EndIf}
; Remove the updates directory for Vista and above
${un.CleanMaintenanceServiceLogs} "Mozilla\SeaMonkey"
; Remove any app model id's stored in the registry for this install path
DeleteRegValue HKCU "Software\Mozilla\${AppName}\TaskBarIDs" "$INSTDIR"
DeleteRegValue HKLM "Software\Mozilla\${AppName}\TaskBarIDs" "$INSTDIR"
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}
${un.DeleteShortcuts}
${EndIf}
${un.RegCleanAppHandler} "SeaMonkeyURL"
${un.RegCleanAppHandler} "SeaMonkeyHTML"
${un.RegCleanAppHandler} "SeaMonkeyMAIL"
${un.RegCleanAppHandler} "SeaMonkeyNEWS"
${un.RegCleanAppHandler} "SeaMonkeyEML"
${un.RegCleanProtocolHandler} "http"
${un.RegCleanProtocolHandler} "https"
${un.RegCleanProtocolHandler} "ftp"
${un.RegCleanProtocolHandler} "mailto"
${un.RegCleanProtocolHandler} "news"
${un.RegCleanProtocolHandler} "nntp"
${un.RegCleanProtocolHandler} "snews"
ClearErrors
ReadRegStr $R9 HKCR "SeaMonkeyEML" ""
; Don't clean up the file handlers if the SeaMonkeyEML key still exists since
; there could be a second installation that may be the default file handler
${If} ${Errors}
${un.RegCleanFileHandler} ".eml" "SeaMonkeyEML"
${EndIf}
ClearErrors
ReadRegStr $R9 HKCR "SeaMonkeyHTML" ""
; Don't clean up the file handlers if the SeaMonkeyHTML key still exists since
; there could be a second installation that may be the default file handler
${If} ${Errors}
${un.RegCleanFileHandler} ".htm" "SeaMonkeyHTML"
${un.RegCleanFileHandler} ".html" "SeaMonkeyHTML"
${un.RegCleanFileHandler} ".shtml" "SeaMonkeyHTML"
${un.RegCleanFileHandler} ".webm" "SeaMonkeyHTML"
${un.RegCleanFileHandler} ".xht" "SeaMonkeyHTML"
${un.RegCleanFileHandler} ".xhtml" "SeaMonkeyHTML"
${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}
StrCpy $0 "Software\Clients\StartMenuInternet\${FileMainEXE}\shell\open\command"
ReadRegStr $R1 HKLM "$0" ""
${un.RemoveQuotesFromPath} "$R1" $R1
${un.GetParent} "$R1" $R1
; Only remove the StartMenuInternet key if it refers to this install location.
; The StartMenuInternet registry key is independent of the default browser
; settings. The XPInstall base un-installer always removes this key if it is
; uninstalling the default browser and it will always replace the keys when
; installing even if there is another install of SeaMonkey that is set as the
; default browser. Now the key is always updated on install but it is only
; removed if it refers to this install location.
${If} "$INSTDIR" == "$R1"
DeleteRegKey HKLM "Software\Clients\StartMenuInternet\${FileMainEXE}"
DeleteRegValue HKLM "Software\RegisteredApplications" "${AppRegName}"
${EndIf}
StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\shell\open\command"
ReadRegStr $R1 HKLM "$0" ""
${un.RemoveQuotesFromPath} "$R1" $R1
${un.GetParent} "$R1" $R1
; Only remove the Clients\Mail and Clients\News key if it refers to this
; install location. The Clients\Mail & Clients\News keys are independent
; of the default app for the OS settings. The XPInstall base un-installer
; always removes these keys if it is uninstalling the default app and it
; will always replace the keys when installing even if there is another
; install of SeaMonkey that is set as the default app. Now the keys are always
; updated on install but are only removed if they refer to this install
; location.
${If} "$INSTDIR" == "$R1"
DeleteRegKey HKLM "Software\Clients\Mail\${BrandFullNameInternal}"
DeleteRegKey HKLM "Software\Clients\News\${BrandFullNameInternal}"
DeleteRegValue HKLM "Software\RegisteredApplications" "${AppRegNameMail}"
DeleteRegValue HKLM "Software\RegisteredApplications" "${AppRegNameNews}"
${EndIf}
StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
${If} $R9 == "false"
DeleteRegKey HKLM "$0"
DeleteRegKey HKCU "$0"
StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\${FileMainEXE}"
DeleteRegKey HKLM "$0"
DeleteRegKey HKCU "$0"
StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\plugin-container.exe"
DeleteRegKey HKLM "$0"
DeleteRegKey HKCU "$0"
${Else}
ReadRegStr $R1 HKLM "$0" ""
${un.RemoveQuotesFromPath} "$R1" $R1
${un.GetParent} "$R1" $R1
${If} "$INSTDIR" == "$R1"
WriteRegStr HKLM "$0" "" "$R9"
${un.GetParent} "$R9" $R1
WriteRegStr HKLM "$0" "Path" "$R1"
${EndIf}
${EndIf}
; 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}
; Application update won't add these files to the uninstall log so delete
; them if they still exist.
${If} ${FileExists} "$INSTDIR\MapiProxy_InUse.dll"
Delete /REBOOTOK "$INSTDIR\MapiProxy_InUse.dll"
${EndIf}
${If} ${FileExists} "$INSTDIR\mozMapi32_InUse.dll"
Delete /REBOOTOK "$INSTDIR\mozMapi32_InUse.dll"
${EndIf}
; Remove files that may be left behind by the application in the
; VirtualStore directory.
${un.CleanVirtualStore}
; Only unregister the dll if the registration points to this installation
ReadRegStr $R1 HKCR "CLSID\{0D68D6D0-D93D-4D08-A30D-F00DD1F45B24}\InProcServer32" ""
${If} "$INSTDIR\AccessibleMarshal.dll" == "$R1"
${UnregisterDLL} "$INSTDIR\AccessibleMarshal.dll"
${EndIf}
${If} ${FileExists} "$INSTDIR\AccessibleHandler.dll"
${UnregisterDLL} "$INSTDIR\AccessibleHandler.dll"
${EndIf}
; 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"
; If seamonkey.exe was successfully deleted yet we still need to restart to
; remove other files create a dummy seamonkey.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 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
################################################################################
# Language
!insertmacro MOZ_MUI_LANGUAGE 'baseLocale'
!verbose push
!verbose 3
!include "overrideLocale.nsh"
!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, show, and leave functions
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}"
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
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"
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
################################################################################
# Initialization Functions
Function .onInit
; We need this set up for most of the helper.exe operations.
!ifdef AppName
${InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
!endif
${UninstallOnInitCommon}
FunctionEnd
Function un.onInit
StrCpy $LANGUAGE 0
${un.UninstallUnOnInitCommon}
!insertmacro InitInstallOptionsFile "unconfirm.ini"
FunctionEnd
Function .onGUIEnd
${OnEndCommon}
FunctionEnd
Function un.onGUIEnd
${un.OnEndCommon}
FunctionEnd