1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/installer/windows/nsis/stub.nsi Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1977 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +# Required Plugins: 1.9 +# AppAssocReg 1.10 +# CertCheck 1.11 +# InetBgDL 1.12 +# ShellLink 1.13 +# UAC 1.14 + 1.15 +; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs 1.16 +!verbose 3 1.17 + 1.18 +SetDatablockOptimize on 1.19 +SetCompress off 1.20 +CRCCheck on 1.21 + 1.22 +RequestExecutionLevel user 1.23 + 1.24 +; The commands inside this ifdef require NSIS 3.0a2 or greater so the ifdef can 1.25 +; be removed after we require NSIS 3.0a2 or greater. 1.26 +!ifdef NSIS_PACKEDVERSION 1.27 + Unicode true 1.28 + ManifestSupportedOS all 1.29 + ManifestDPIAware true 1.30 +!endif 1.31 + 1.32 +!addplugindir ./ 1.33 + 1.34 +Var Dialog 1.35 +Var Progressbar 1.36 +Var ProgressbarMarqueeIntervalMS 1.37 +Var LabelDownloading 1.38 +Var LabelInstalling 1.39 +Var LabelFreeSpace 1.40 +Var CheckboxSetAsDefault 1.41 +Var CheckboxShortcutOnBar ; Used for Quicklaunch or Taskbar as appropriate 1.42 +Var CheckboxShortcutInStartMenu 1.43 +Var CheckboxShortcutOnDesktop 1.44 +Var CheckboxSendPing 1.45 +Var CheckboxInstallMaintSvc 1.46 +Var DirRequest 1.47 +Var ButtonBrowse 1.48 +Var LabelBlurb1 1.49 +Var LabelBlurb2 1.50 +Var LabelBlurb3 1.51 +Var BitmapBlurb1 1.52 +Var BitmapBlurb2 1.53 +Var BitmapBlurb3 1.54 +Var HwndBitmapBlurb1 1.55 +Var HwndBitmapBlurb2 1.56 +Var HWndBitmapBlurb3 1.57 + 1.58 +Var FontNormal 1.59 +Var FontItalic 1.60 +Var FontBlurb 1.61 + 1.62 +Var WasOptionsButtonClicked 1.63 +Var CanWriteToInstallDir 1.64 +Var HasRequiredSpaceAvailable 1.65 +Var IsDownloadFinished 1.66 +Var DownloadSizeBytes 1.67 +Var HalfOfDownload 1.68 +Var DownloadReset 1.69 +Var ExistingTopDir 1.70 +Var SpaceAvailableBytes 1.71 +Var InitialInstallDir 1.72 +Var HandleDownload 1.73 +Var CanSetAsDefault 1.74 +Var InstallCounterStep 1.75 +Var InstallStepSize 1.76 +Var InstallTotalSteps 1.77 +Var TmpVal 1.78 + 1.79 +Var ExitCode 1.80 +Var FirefoxLaunchCode 1.81 + 1.82 +; The first three tick counts are for the start of a phase and equate equate to 1.83 +; the display of individual installer pages. 1.84 +Var StartIntroPhaseTickCount 1.85 +Var StartOptionsPhaseTickCount 1.86 +Var StartDownloadPhaseTickCount 1.87 +; Since the Intro and Options pages can be displayed multiple times the total 1.88 +; seconds spent on each of these pages is reported. 1.89 +Var IntroPhaseSeconds 1.90 +Var OptionsPhaseSeconds 1.91 +; The tick count for the last download. 1.92 +Var StartLastDownloadTickCount 1.93 +; The number of seconds from the start of the download phase until the first 1.94 +; bytes are received. This is only recorded for first request so it is possible 1.95 +; to determine connection issues for the first request. 1.96 +Var DownloadFirstTransferSeconds 1.97 +; The last four tick counts are for the end of a phase in the installation page. 1.98 +Var EndDownloadPhaseTickCount 1.99 +Var EndPreInstallPhaseTickCount 1.100 +Var EndInstallPhaseTickCount 1.101 +Var EndFinishPhaseTickCount 1.102 + 1.103 +Var InitialInstallRequirementsCode 1.104 +Var ExistingProfile 1.105 +Var ExistingVersion 1.106 +Var ExistingBuildID 1.107 +Var DownloadedBytes 1.108 +Var DownloadRetryCount 1.109 +Var OpenedDownloadPage 1.110 +Var DownloadServerIP 1.111 + 1.112 +Var ControlHeightPX 1.113 +Var ControlRightPX 1.114 + 1.115 +; Uncomment the following to prevent pinging the metrics server when testing 1.116 +; the stub installer 1.117 +;!define STUB_DEBUG 1.118 + 1.119 +!define StubURLVersion "v6" 1.120 + 1.121 +; Successful install exit code 1.122 +!define ERR_SUCCESS 0 1.123 + 1.124 +/** 1.125 + * The following errors prefixed with ERR_DOWNLOAD apply to the download phase. 1.126 + */ 1.127 +; The download was cancelled by the user 1.128 +!define ERR_DOWNLOAD_CANCEL 10 1.129 + 1.130 +; Too many attempts to download. The maximum attempts is defined in 1.131 +; DownloadMaxRetries. 1.132 +!define ERR_DOWNLOAD_TOO_MANY_RETRIES 11 1.133 + 1.134 +/** 1.135 + * The following errors prefixed with ERR_PREINSTALL apply to the pre-install 1.136 + * check phase. 1.137 + */ 1.138 +; Unable to acquire a file handle to the downloaded file 1.139 +!define ERR_PREINSTALL_INVALID_HANDLE 20 1.140 + 1.141 +; The downloaded file's certificate is not trusted by the certificate store. 1.142 +!define ERR_PREINSTALL_CERT_UNTRUSTED 21 1.143 + 1.144 +; The downloaded file's certificate attribute values were incorrect. 1.145 +!define ERR_PREINSTALL_CERT_ATTRIBUTES 22 1.146 + 1.147 +; The downloaded file's certificate is not trusted by the certificate store and 1.148 +; certificate attribute values were incorrect. 1.149 +!define ERR_PREINSTALL_CERT_UNTRUSTED_AND_ATTRIBUTES 23 1.150 + 1.151 +/** 1.152 + * The following errors prefixed with ERR_INSTALL apply to the install phase. 1.153 + */ 1.154 +; The installation timed out. The installation timeout is defined by the number 1.155 +; of progress steps defined in InstallTotalSteps and the install timer 1.156 +; interval defined in InstallIntervalMS 1.157 +!define ERR_INSTALL_TIMEOUT 30 1.158 + 1.159 +; Maximum times to retry the download before displaying an error 1.160 +!define DownloadMaxRetries 9 1.161 + 1.162 +; Minimum size expected to download in bytes 1.163 +!define DownloadMinSizeBytes 15728640 ; 15 MB 1.164 + 1.165 +; Maximum size expected to download in bytes 1.166 +!define DownloadMaxSizeBytes 36700160 ; 35 MB 1.167 + 1.168 +; Interval before retrying to download. 3 seconds is used along with 10 1.169 +; attempted downloads (the first attempt along with 9 retries) to give a 1.170 +; minimum of 30 seconds or retrying before giving up. 1.171 +!define DownloadRetryIntervalMS 3000 1.172 + 1.173 +; Interval for the download timer 1.174 +!define DownloadIntervalMS 200 1.175 + 1.176 +; Interval for the install timer 1.177 +!define InstallIntervalMS 100 1.178 + 1.179 +; The first step for the install progress bar. By starting with a large step 1.180 +; immediate feedback is given to the user. 1.181 +!define InstallProgressFirstStep 20 1.182 + 1.183 +; The finish step size to quickly increment the progress bar after the 1.184 +; installation has finished. 1.185 +!define InstallProgressFinishStep 40 1.186 + 1.187 +; Number of steps for the install progress. 1.188 +; This might not be enough when installing on a slow network drive so it will 1.189 +; fallback to downloading the full installer if it reaches this number. The size 1.190 +; of the install progress step is increased when the full installer finishes 1.191 +; instead of waiting. 1.192 + 1.193 +; Approximately 150 seconds with a 100 millisecond timer and a first step of 20 1.194 +; as defined by InstallProgressFirstStep. 1.195 +!define /math InstallCleanTotalSteps ${InstallProgressFirstStep} + 1500 1.196 + 1.197 +; Approximately 165 seconds (minus 0.2 seconds for each file that is removed) 1.198 +; with a 100 millisecond timer and a first step of 20 as defined by 1.199 +; InstallProgressFirstStep . 1.200 +!define /math InstallPaveOverTotalSteps ${InstallProgressFirstStep} + 1800 1.201 + 1.202 +; On Vista and above attempt to elevate Standard Users in addition to users that 1.203 +; are a member of the Administrators group. 1.204 +!define NONADMIN_ELEVATE 1.205 + 1.206 +!define CONFIG_INI "config.ini" 1.207 + 1.208 +!ifndef FILE_SHARE_READ 1.209 + !define FILE_SHARE_READ 1 1.210 +!endif 1.211 +!ifndef GENERIC_READ 1.212 + !define GENERIC_READ 0x80000000 1.213 +!endif 1.214 +!ifndef OPEN_EXISTING 1.215 + !define OPEN_EXISTING 3 1.216 +!endif 1.217 +!ifndef INVALID_HANDLE_VALUE 1.218 + !define INVALID_HANDLE_VALUE -1 1.219 +!endif 1.220 + 1.221 +!include "nsDialogs.nsh" 1.222 +!include "LogicLib.nsh" 1.223 +!include "FileFunc.nsh" 1.224 +!include "WinVer.nsh" 1.225 +!include "WordFunc.nsh" 1.226 + 1.227 +!insertmacro GetParameters 1.228 +!insertmacro GetOptions 1.229 +!insertmacro StrFilter 1.230 + 1.231 +!include "locales.nsi" 1.232 +!include "branding.nsi" 1.233 + 1.234 +!include "defines.nsi" 1.235 + 1.236 +; Must be included after defines.nsi 1.237 +!include "locale-fonts.nsh" 1.238 + 1.239 +; The OFFICIAL define is a workaround to support different urls for Release and 1.240 +; Beta since they share the same branding when building with other branches that 1.241 +; set the update channel to beta. 1.242 +!ifdef OFFICIAL 1.243 +!ifdef BETA_UPDATE_CHANNEL 1.244 +!undef URLStubDownload 1.245 +!define URLStubDownload "http://download.mozilla.org/?os=win&lang=${AB_CD}&product=firefox-beta-latest" 1.246 +!undef URLManualDownload 1.247 +!define URLManualDownload "https://www.mozilla.org/${AB_CD}/firefox/installer-help/?channel=beta&installer_lang=${AB_CD}" 1.248 +!undef Channel 1.249 +!define Channel "beta" 1.250 +!endif 1.251 +!endif 1.252 + 1.253 +!include "common.nsh" 1.254 + 1.255 +!insertmacro ElevateUAC 1.256 +!insertmacro GetLongPath 1.257 +!insertmacro GetPathFromString 1.258 +!insertmacro GetParent 1.259 +!insertmacro GetSingleInstallPath 1.260 +!insertmacro GetTextWidthHeight 1.261 +!insertmacro IsUserAdmin 1.262 +!insertmacro OnStubInstallUninstall 1.263 +!insertmacro SetBrandNameVars 1.264 +!insertmacro UnloadUAC 1.265 + 1.266 +VIAddVersionKey "FileDescription" "${BrandShortName} Stub Installer" 1.267 +VIAddVersionKey "OriginalFilename" "setup-stub.exe" 1.268 + 1.269 +Name "$BrandFullName" 1.270 +OutFile "setup-stub.exe" 1.271 +icon "setup.ico" 1.272 +XPStyle on 1.273 +BrandingText " " 1.274 +ChangeUI all "nsisui.exe" 1.275 +!ifdef HAVE_64BIT_OS 1.276 + InstallDir "$PROGRAMFILES64\${BrandFullName}\" 1.277 +!else 1.278 + InstallDir "$PROGRAMFILES32\${BrandFullName}\" 1.279 +!endif 1.280 + 1.281 +!ifdef ${AB_CD}_rtl 1.282 + LoadLanguageFile "locale-rtl.nlf" 1.283 +!else 1.284 + LoadLanguageFile "locale.nlf" 1.285 +!endif 1.286 + 1.287 +!include "nsisstrings.nlf" 1.288 + 1.289 +!if "${AB_CD}" == "en-US" 1.290 + ; Custom strings for en-US. This is done here so they aren't translated. 1.291 + !include oneoff_en-US.nsh 1.292 +!else 1.293 + !define INTRO_BLURB "$(INTRO_BLURB1)" 1.294 + !define INSTALL_BLURB1 "$(INSTALL_BLURB1)" 1.295 + !define INSTALL_BLURB2 "$(INSTALL_BLURB2)" 1.296 + !define INSTALL_BLURB3 "$(INSTALL_BLURB3)" 1.297 +!endif 1.298 + 1.299 +Caption "$(WIN_CAPTION)" 1.300 + 1.301 +Page custom createDummy ; Needed to enable the Intro page's back button 1.302 +Page custom createIntro leaveIntro ; Introduction page 1.303 +Page custom createOptions leaveOptions ; Options page 1.304 +Page custom createInstall ; Download / Installation page 1.305 + 1.306 +Function .onInit 1.307 + ; Remove the current exe directory from the search order. 1.308 + ; This only effects LoadLibrary calls and not implicitly loaded DLLs. 1.309 + System::Call 'kernel32::SetDllDirectoryW(w "")' 1.310 + 1.311 + StrCpy $LANGUAGE 0 1.312 + ; This macro is used to set the brand name variables but the ini file method 1.313 + ; isn't supported for the stub installer. 1.314 + ${SetBrandNameVars} "$PLUGINSDIR\ignored.ini" 1.315 + 1.316 +!ifdef HAVE_64BIT_OS 1.317 + ; Restrict x64 builds from being installed on x86 and pre Vista 1.318 + ${Unless} ${RunningX64} 1.319 + ${OrUnless} ${AtLeastWinVista} 1.320 + MessageBox MB_OK|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_OS_MSG)" 1.321 + Quit 1.322 + ${EndUnless} 1.323 + 1.324 + SetRegView 64 1.325 +!else 1.326 + StrCpy $R8 "0" 1.327 + ${If} ${AtMostWin2000} 1.328 + StrCpy $R8 "1" 1.329 + ${EndIf} 1.330 + 1.331 + ${If} ${IsWinXP} 1.332 + ${AndIf} ${AtMostServicePack} 1 1.333 + StrCpy $R8 "1" 1.334 + ${EndIf} 1.335 + 1.336 + ${If} $R8 == "1" 1.337 + ; XXX-rstrong - some systems failed the AtLeastWin2000 test that we 1.338 + ; used to use for an unknown reason and likely fail the AtMostWin2000 1.339 + ; and possibly the IsWinXP test as well. To work around this also 1.340 + ; check if the Windows NT registry Key exists and if it does if the 1.341 + ; first char in CurrentVersion is equal to 3 (Windows NT 3.5 and 1.342 + ; 3.5.1), 4 (Windows NT 4), or 5 (Windows 2000 and Windows XP). 1.343 + StrCpy $R8 "" 1.344 + ClearErrors 1.345 + ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion" 1.346 + StrCpy $R8 "$R8" 1 1.347 + ${If} ${Errors} 1.348 + ${OrIf} "$R8" == "3" 1.349 + ${OrIf} "$R8" == "4" 1.350 + ${OrIf} "$R8" == "5" 1.351 + MessageBox MB_OK|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_OS_MSG)" 1.352 + Quit 1.353 + ${EndIf} 1.354 + ${EndUnless} 1.355 +!endif 1.356 + 1.357 + ; Require elevation if the user can elevate 1.358 + ${ElevateUAC} 1.359 + 1.360 +; The commands inside this ifndef are needed prior to NSIS 3.0a2 and can be 1.361 +; removed after we require NSIS 3.0a2 or greater. 1.362 +!ifndef NSIS_PACKEDVERSION 1.363 + ${If} ${AtLeastWinVista} 1.364 + System::Call 'user32::SetProcessDPIAware()' 1.365 + ${EndIf} 1.366 +!endif 1.367 + 1.368 + SetShellVarContext all ; Set SHCTX to HKLM 1.369 + ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9 1.370 + 1.371 + ${If} "$R9" == "false" 1.372 + SetShellVarContext current ; Set SHCTX to HKCU 1.373 + ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9 1.374 + ${EndIf} 1.375 + 1.376 + ${If} "$R9" != "false" 1.377 + StrCpy $INSTDIR "$R9" 1.378 + ${EndIf} 1.379 + 1.380 + ; Used to determine if the default installation directory was used. 1.381 + StrCpy $InitialInstallDir "$INSTDIR" 1.382 + 1.383 + ClearErrors 1.384 + WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" \ 1.385 + "Write Test" 1.386 + 1.387 + ; Only display set as default when there is write access to HKLM and on Win7 1.388 + ; and below. 1.389 + ${If} ${Errors} 1.390 + ${OrIf} ${AtLeastWin8} 1.391 + StrCpy $CanSetAsDefault "false" 1.392 + StrCpy $CheckboxSetAsDefault "0" 1.393 + ${Else} 1.394 + DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" 1.395 + StrCpy $CanSetAsDefault "true" 1.396 + ${EndIf} 1.397 + 1.398 + ; The interval in MS used for the progress bars set as marquee. 1.399 + ${If} ${AtLeastWinVista} 1.400 + StrCpy $ProgressbarMarqueeIntervalMS "10" 1.401 + ${Else} 1.402 + StrCpy $ProgressbarMarqueeIntervalMS "50" 1.403 + ${EndIf} 1.404 + 1.405 + ; Initialize the majority of variables except those that need to be reset 1.406 + ; when a page is displayed. 1.407 + StrCpy $IntroPhaseSeconds "0" 1.408 + StrCpy $OptionsPhaseSeconds "0" 1.409 + StrCpy $EndPreInstallPhaseTickCount "0" 1.410 + StrCpy $EndInstallPhaseTickCount "0" 1.411 + StrCpy $InitialInstallRequirementsCode "" 1.412 + StrCpy $IsDownloadFinished "" 1.413 + StrCpy $FirefoxLaunchCode "0" 1.414 + StrCpy $CheckboxShortcutOnBar "1" 1.415 + StrCpy $CheckboxShortcutInStartMenu "1" 1.416 + StrCpy $CheckboxShortcutOnDesktop "1" 1.417 + StrCpy $CheckboxSendPing "1" 1.418 +!ifdef MOZ_MAINTENANCE_SERVICE 1.419 + StrCpy $CheckboxInstallMaintSvc "1" 1.420 +!else 1.421 + StrCpy $CheckboxInstallMaintSvc "0" 1.422 +!endif 1.423 + StrCpy $WasOptionsButtonClicked "0" 1.424 + 1.425 + StrCpy $0 "" 1.426 +!ifdef FONT_FILE1 1.427 + ${If} ${FileExists} "$FONTS\${FONT_FILE1}" 1.428 + StrCpy $0 "${FONT_NAME1}" 1.429 + ${EndIf} 1.430 +!endif 1.431 + 1.432 +!ifdef FONT_FILE2 1.433 + ${If} $0 == "" 1.434 + ${AndIf} ${FileExists} "$FONTS\${FONT_FILE2}" 1.435 + StrCpy $0 "${FONT_NAME2}" 1.436 + ${EndIf} 1.437 +!endif 1.438 + 1.439 + ${If} $0 == "" 1.440 + StrCpy $0 "$(^Font)" 1.441 + ${EndIf} 1.442 + 1.443 + CreateFont $FontBlurb "$0" "12" "500" 1.444 + CreateFont $FontNormal "$0" "11" "500" 1.445 + CreateFont $FontItalic "$0" "11" "500" /ITALIC 1.446 + 1.447 + InitPluginsDir 1.448 + File /oname=$PLUGINSDIR\bgintro.bmp "bgintro.bmp" 1.449 + File /oname=$PLUGINSDIR\appname.bmp "appname.bmp" 1.450 + File /oname=$PLUGINSDIR\clock.bmp "clock.bmp" 1.451 + File /oname=$PLUGINSDIR\particles.bmp "particles.bmp" 1.452 +!ifdef ${AB_CD}_rtl 1.453 + ; The horizontally flipped pencil looks better in RTL 1.454 + File /oname=$PLUGINSDIR\pencil.bmp "pencil-rtl.bmp" 1.455 +!else 1.456 + File /oname=$PLUGINSDIR\pencil.bmp "pencil.bmp" 1.457 +!endif 1.458 +FunctionEnd 1.459 + 1.460 +; .onGUIInit isn't needed except for RTL locales 1.461 +!ifdef ${AB_CD}_rtl 1.462 +Function .onGUIInit 1.463 + ; Since NSIS RTL support doesn't mirror progress bars use Windows mirroring. 1.464 + ${NSD_AddExStyle} $HWNDPARENT ${WS_EX_LAYOUTRTL} 1.465 + ${RemoveExStyle} $HWNDPARENT ${WS_EX_RTLREADING} 1.466 + ${RemoveExStyle} $HWNDPARENT ${WS_EX_RIGHT} 1.467 + ${NSD_AddExStyle} $HWNDPARENT ${WS_EX_LEFT}|${WS_EX_LTRREADING} 1.468 +FunctionEnd 1.469 +!endif 1.470 + 1.471 +Function .onGUIEnd 1.472 + Delete "$PLUGINSDIR\_temp" 1.473 + Delete "$PLUGINSDIR\download.exe" 1.474 + Delete "$PLUGINSDIR\${CONFIG_INI}" 1.475 + 1.476 + ${UnloadUAC} 1.477 +FunctionEnd 1.478 + 1.479 +Function .onUserAbort 1.480 + ${NSD_KillTimer} StartDownload 1.481 + ${NSD_KillTimer} OnDownload 1.482 + ${NSD_KillTimer} CheckInstall 1.483 + ${NSD_KillTimer} FinishInstall 1.484 + ${NSD_KillTimer} FinishProgressBar 1.485 + ${NSD_KillTimer} DisplayDownloadError 1.486 + 1.487 + ${If} "$IsDownloadFinished" != "" 1.488 + Call DisplayDownloadError 1.489 + ; Aborting the abort will allow SendPing which is called by 1.490 + ; DisplayDownloadError to hide the installer window and close the installer 1.491 + ; after it sends the metrics ping. 1.492 + Abort 1.493 + ${EndIf} 1.494 +FunctionEnd 1.495 + 1.496 +Function SendPing 1.497 + HideWindow 1.498 + ; Try to send a ping if a download was attempted 1.499 + ${If} $CheckboxSendPing == 1 1.500 + ${AndIf} $IsDownloadFinished != "" 1.501 + ; Get the tick count for the completion of all phases. 1.502 + System::Call "kernel32::GetTickCount()l .s" 1.503 + Pop $EndFinishPhaseTickCount 1.504 + 1.505 + ; When the value of $IsDownloadFinished is false the download was started 1.506 + ; but didn't finish. In this case the tick count stored in 1.507 + ; $EndFinishPhaseTickCount is used to determine how long the download was 1.508 + ; in progress. 1.509 + ${If} "$IsDownloadFinished" == "false" 1.510 + ${OrIf} "$EndDownloadPhaseTickCount" == "" 1.511 + StrCpy $EndDownloadPhaseTickCount "$EndFinishPhaseTickCount" 1.512 + ; Cancel the download in progress 1.513 + InetBgDL::Get /RESET /END 1.514 + ${EndIf} 1.515 + 1.516 + 1.517 + ; When $DownloadFirstTransferSeconds equals an empty string the download 1.518 + ; never successfully started so set the value to 0. It will be possible to 1.519 + ; determine that the download didn't successfully start from the seconds for 1.520 + ; the last download. 1.521 + ${If} "$DownloadFirstTransferSeconds" == "" 1.522 + StrCpy $DownloadFirstTransferSeconds "0" 1.523 + ${EndIf} 1.524 + 1.525 + ; When $StartLastDownloadTickCount equals an empty string the download never 1.526 + ; successfully started so set the value to $EndDownloadPhaseTickCount to 1.527 + ; compute the correct value. 1.528 + ${If} $StartLastDownloadTickCount == "" 1.529 + ; This could happen if the download never successfully starts 1.530 + StrCpy $StartLastDownloadTickCount "$EndDownloadPhaseTickCount" 1.531 + ${EndIf} 1.532 + 1.533 + ; When $EndPreInstallPhaseTickCount equals 0 the installation phase was 1.534 + ; never completed so set its value to $EndFinishPhaseTickCount to compute 1.535 + ; the correct value. 1.536 + ${If} "$EndPreInstallPhaseTickCount" == "0" 1.537 + StrCpy $EndPreInstallPhaseTickCount "$EndFinishPhaseTickCount" 1.538 + ${EndIf} 1.539 + 1.540 + ; When $EndInstallPhaseTickCount equals 0 the installation phase was never 1.541 + ; completed so set its value to $EndFinishPhaseTickCount to compute the 1.542 + ; correct value. 1.543 + ${If} "$EndInstallPhaseTickCount" == "0" 1.544 + StrCpy $EndInstallPhaseTickCount "$EndFinishPhaseTickCount" 1.545 + ${EndIf} 1.546 + 1.547 + ; Get the seconds elapsed from the start of the download phase to the end of 1.548 + ; the download phase. 1.549 + ${GetSecondsElapsed} "$StartDownloadPhaseTickCount" "$EndDownloadPhaseTickCount" $0 1.550 + 1.551 + ; Get the seconds elapsed from the start of the last download to the end of 1.552 + ; the last download. 1.553 + ${GetSecondsElapsed} "$StartLastDownloadTickCount" "$EndDownloadPhaseTickCount" $1 1.554 + 1.555 + ; Get the seconds elapsed from the end of the download phase to the 1.556 + ; completion of the pre-installation check phase. 1.557 + ${GetSecondsElapsed} "$EndDownloadPhaseTickCount" "$EndPreInstallPhaseTickCount" $2 1.558 + 1.559 + ; Get the seconds elapsed from the end of the pre-installation check phase 1.560 + ; to the completion of the installation phase. 1.561 + ${GetSecondsElapsed} "$EndPreInstallPhaseTickCount" "$EndInstallPhaseTickCount" $3 1.562 + 1.563 + ; Get the seconds elapsed from the end of the installation phase to the 1.564 + ; completion of all phases. 1.565 + ${GetSecondsElapsed} "$EndInstallPhaseTickCount" "$EndFinishPhaseTickCount" $4 1.566 + 1.567 +!ifdef HAVE_64BIT_OS 1.568 + StrCpy $R0 "1" 1.569 +!else 1.570 + StrCpy $R0 "0" 1.571 +!endif 1.572 + 1.573 + ${If} ${RunningX64} 1.574 + StrCpy $R1 "1" 1.575 + ${Else} 1.576 + StrCpy $R1 "0" 1.577 + ${EndIf} 1.578 + 1.579 + ; Though these values are sometimes incorrect due to bug 444664 it happens 1.580 + ; so rarely it isn't worth working around it by reading the registry values. 1.581 + ${WinVerGetMajor} $5 1.582 + ${WinVerGetMinor} $6 1.583 + ${WinVerGetBuild} $7 1.584 + ${WinVerGetServicePackLevel} $8 1.585 + ${If} ${IsServerOS} 1.586 + StrCpy $9 "1" 1.587 + ${Else} 1.588 + StrCpy $9 "0" 1.589 + ${EndIf} 1.590 + 1.591 + ${If} "$ExitCode" == "${ERR_SUCCESS}" 1.592 + ReadINIStr $R5 "$INSTDIR\application.ini" "App" "Version" 1.593 + ReadINIStr $R6 "$INSTDIR\application.ini" "App" "BuildID" 1.594 + ${Else} 1.595 + StrCpy $R5 "0" 1.596 + StrCpy $R6 "0" 1.597 + ${EndIf} 1.598 + 1.599 + ; Whether installed into the default installation directory 1.600 + ${GetLongPath} "$INSTDIR" $R7 1.601 + ${GetLongPath} "$InitialInstallDir" $R8 1.602 + ${If} "$R7" == "$R8" 1.603 + StrCpy $R7 "1" 1.604 + ${Else} 1.605 + StrCpy $R7 "0" 1.606 + ${EndIf} 1.607 + 1.608 + ClearErrors 1.609 + WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" \ 1.610 + "Write Test" 1.611 + ${If} ${Errors} 1.612 + StrCpy $R8 "0" 1.613 + ${Else} 1.614 + DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" 1.615 + StrCpy $R8 "1" 1.616 + ${EndIf} 1.617 + 1.618 + ${If} "$DownloadServerIP" == "" 1.619 + StrCpy $DownloadServerIP "Unknown" 1.620 + ${EndIf} 1.621 + 1.622 + StrCpy $R2 "" 1.623 + SetShellVarContext current ; Set SHCTX to the current user 1.624 + ReadRegStr $R2 HKCU "Software\Classes\http\shell\open\command" "" 1.625 + ${If} $R2 != "" 1.626 + ${GetPathFromString} "$R2" $R2 1.627 + ${GetParent} "$R2" $R3 1.628 + ${GetLongPath} "$R3" $R3 1.629 + ${If} $R3 == $INSTDIR 1.630 + StrCpy $R2 "1" ; This Firefox install is set as default. 1.631 + ${Else} 1.632 + StrCpy $R2 "$R2" "" -11 # length of firefox.exe 1.633 + ${If} "$R2" == "${FileMainEXE}" 1.634 + StrCpy $R2 "2" ; Another Firefox install is set as default. 1.635 + ${Else} 1.636 + StrCpy $R2 "0" 1.637 + ${EndIf} 1.638 + ${EndIf} 1.639 + ${Else} 1.640 + StrCpy $R2 "0" ; Firefox is not set as default. 1.641 + ${EndIf} 1.642 + 1.643 + ${If} "$R2" == "0" 1.644 + ${AndIf} ${AtLeastWinVista} 1.645 + ; Check to see if this install location is currently set as the default 1.646 + ; browser by Default Programs which is only available on Vista and above. 1.647 + ClearErrors 1.648 + ReadRegStr $R3 HKLM "Software\RegisteredApplications" "${AppRegName}" 1.649 + ${Unless} ${Errors} 1.650 + AppAssocReg::QueryAppIsDefaultAll "${AppRegName}" "effective" 1.651 + Pop $R3 1.652 + ${If} $R3 == "1" 1.653 + StrCpy $R3 "" 1.654 + ReadRegStr $R2 HKLM "Software\Classes\http\shell\open\command" "" 1.655 + ${If} $R2 != "" 1.656 + ${GetPathFromString} "$R2" $R2 1.657 + ${GetParent} "$R2" $R3 1.658 + ${GetLongPath} "$R3" $R3 1.659 + ${If} $R3 == $INSTDIR 1.660 + StrCpy $R2 "1" ; This Firefox install is set as default. 1.661 + ${Else} 1.662 + StrCpy $R2 "$R2" "" -11 # length of firefox.exe 1.663 + ${If} "$R2" == "${FileMainEXE}" 1.664 + StrCpy $R2 "2" ; Another Firefox install is set as default. 1.665 + ${Else} 1.666 + StrCpy $R2 "0" 1.667 + ${EndIf} 1.668 + ${EndIf} 1.669 + ${Else} 1.670 + StrCpy $R2 "0" ; Firefox is not set as default. 1.671 + ${EndIf} 1.672 + ${EndIf} 1.673 + ${EndUnless} 1.674 + ${EndIf} 1.675 + 1.676 + ${If} $CanSetAsDefault == "true" 1.677 + ${If} $CheckboxSetAsDefault == "1" 1.678 + StrCpy $R3 "2" 1.679 + ${Else} 1.680 + StrCpy $R3 "3" 1.681 + ${EndIf} 1.682 + ${Else} 1.683 + ${If} ${AtLeastWin8} 1.684 + StrCpy $R3 "1" 1.685 + ${Else} 1.686 + StrCpy $R3 "0" 1.687 + ${EndIf} 1.688 + ${EndIf} 1.689 + 1.690 +!ifdef STUB_DEBUG 1.691 + MessageBox MB_OK "${BaseURLStubPing} \ 1.692 + $\nStub URL Version = ${StubURLVersion}${StubURLVersionAppend} \ 1.693 + $\nBuild Channel = ${Channel} \ 1.694 + $\nUpdate Channel = ${UpdateChannel} \ 1.695 + $\nLocale = ${AB_CD} \ 1.696 + $\nFirefox x64 = $R0 \ 1.697 + $\nRunning x64 Windows = $R1 \ 1.698 + $\nMajor = $5 \ 1.699 + $\nMinor = $6 \ 1.700 + $\nBuild = $7 \ 1.701 + $\nServicePack = $8 \ 1.702 + $\nIsServer = $9 \ 1.703 + $\nExit Code = $ExitCode \ 1.704 + $\nFirefox Launch Code = $FirefoxLaunchCode \ 1.705 + $\nDownload Retry Count = $DownloadRetryCount \ 1.706 + $\nDownloaded Bytes = $DownloadedBytes \ 1.707 + $\nDownload Size Bytes = $DownloadSizeBytes \ 1.708 + $\nIntroduction Phase Seconds = $IntroPhaseSeconds \ 1.709 + $\nOptions Phase Seconds = $OptionsPhaseSeconds \ 1.710 + $\nDownload Phase Seconds = $0 \ 1.711 + $\nLast Download Seconds = $1 \ 1.712 + $\nDownload First Transfer Seconds = $DownloadFirstTransferSeconds \ 1.713 + $\nPreinstall Phase Seconds = $2 \ 1.714 + $\nInstall Phase Seconds = $3 \ 1.715 + $\nFinish Phase Seconds = $4 \ 1.716 + $\nInitial Install Requirements Code = $InitialInstallRequirementsCode \ 1.717 + $\nOpened Download Page = $OpenedDownloadPage \ 1.718 + $\nExisting Profile = $ExistingProfile \ 1.719 + $\nExisting Version = $ExistingVersion \ 1.720 + $\nExisting Build ID = $ExistingBuildID \ 1.721 + $\nNew Version = $R5 \ 1.722 + $\nNew Build ID = $R6 \ 1.723 + $\nDefault Install Dir = $R7 \ 1.724 + $\nHas Admin = $R8 \ 1.725 + $\nDefault Status = $R2 \ 1.726 + $\nSet As Sefault Status = $R3 \ 1.727 + $\nDownload Server IP = $DownloadServerIP" 1.728 + ; The following will exit the installer 1.729 + SetAutoClose true 1.730 + StrCpy $R9 "2" 1.731 + Call RelativeGotoPage 1.732 +!else 1.733 + ${NSD_CreateTimer} OnPing ${DownloadIntervalMS} 1.734 + InetBgDL::Get "${BaseURLStubPing}/${StubURLVersion}${StubURLVersionAppend}/${Channel}/${UpdateChannel}/${AB_CD}/$R0/$R1/$5/$6/$7/$8/$9/$ExitCode/$FirefoxLaunchCode/$DownloadRetryCount/$DownloadedBytes/$DownloadSizeBytes/$IntroPhaseSeconds/$OptionsPhaseSeconds/$0/$1/$DownloadFirstTransferSeconds/$2/$3/$4/$InitialInstallRequirementsCode/$OpenedDownloadPage/$ExistingProfile/$ExistingVersion/$ExistingBuildID/$R5/$R6/$R7/$R8/$R2/$R3/$DownloadServerIP" \ 1.735 + "$PLUGINSDIR\_temp" /END 1.736 +!endif 1.737 + ${Else} 1.738 + ${If} "$IsDownloadFinished" == "false" 1.739 + ; Cancel the download in progress 1.740 + InetBgDL::Get /RESET /END 1.741 + ${EndIf} 1.742 + ; The following will exit the installer 1.743 + SetAutoClose true 1.744 + StrCpy $R9 "2" 1.745 + Call RelativeGotoPage 1.746 + ${EndIf} 1.747 +FunctionEnd 1.748 + 1.749 +Function createDummy 1.750 +FunctionEnd 1.751 + 1.752 +Function createIntro 1.753 + nsDialogs::Create /NOUNLOAD 1018 1.754 + Pop $Dialog 1.755 + 1.756 + GetFunctionAddress $0 OnBack 1.757 + nsDialogs::OnBack /NOUNLOAD $0 1.758 + 1.759 +!ifdef ${AB_CD}_rtl 1.760 + ; For RTL align the text with the top of the F in the Firefox bitmap 1.761 + StrCpy $0 "${INTRO_BLURB_RTL_TOP_DU}" 1.762 +!else 1.763 + ; For LTR align the text with the top of the x in the Firefox bitmap 1.764 + StrCpy $0 "${INTRO_BLURB_LTR_TOP_DU}" 1.765 +!endif 1.766 + ${NSD_CreateLabel} ${INTRO_BLURB_EDGE_DU} $0 ${INTRO_BLURB_WIDTH_DU} 76u "${INTRO_BLURB}" 1.767 + Pop $0 1.768 + SendMessage $0 ${WM_SETFONT} $FontBlurb 0 1.769 + SetCtlColors $0 ${INTRO_BLURB_TEXT_COLOR} transparent 1.770 + 1.771 + SetCtlColors $HWNDPARENT ${FOOTER_CONTROL_TEXT_COLOR_NORMAL} ${FOOTER_BKGRD_COLOR} 1.772 + GetDlgItem $0 $HWNDPARENT 10 ; Default browser checkbox 1.773 + ${If} "$CanSetAsDefault" == "true" 1.774 + ; The uxtheme must be disabled on checkboxes in order to override the 1.775 + ; system font color. 1.776 + System::Call 'uxtheme::SetWindowTheme(i $0 , w " ", w " ")' 1.777 + SendMessage $0 ${WM_SETFONT} $FontNormal 0 1.778 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(MAKE_DEFAULT)" 1.779 + SendMessage $0 ${BM_SETCHECK} 1 0 1.780 + SetCtlColors $0 ${FOOTER_CONTROL_TEXT_COLOR_NORMAL} ${FOOTER_BKGRD_COLOR} 1.781 + ${Else} 1.782 + ShowWindow $0 ${SW_HIDE} 1.783 + ${EndIf} 1.784 + GetDlgItem $0 $HWNDPARENT 11 1.785 + ShowWindow $0 ${SW_HIDE} 1.786 + 1.787 + ${NSD_CreateBitmap} ${APPNAME_BMP_EDGE_DU} ${APPNAME_BMP_TOP_DU} \ 1.788 + ${APPNAME_BMP_WIDTH_DU} ${APPNAME_BMP_HEIGHT_DU} "" 1.789 + Pop $2 1.790 + ${SetStretchedTransparentImage} $2 $PLUGINSDIR\appname.bmp $0 1.791 + 1.792 + ${NSD_CreateBitmap} 0 0 100% 100% "" 1.793 + Pop $2 1.794 + ${NSD_SetStretchedImage} $2 $PLUGINSDIR\bgintro.bmp $1 1.795 + 1.796 + GetDlgItem $0 $HWNDPARENT 1 ; Install button 1.797 + ${If} ${FileExists} "$INSTDIR\${FileMainEXE}" 1.798 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(UPGRADE_BUTTON)" 1.799 + ${Else} 1.800 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(INSTALL_BUTTON)" 1.801 + ${EndIf} 1.802 + ${NSD_SetFocus} $0 1.803 + 1.804 + GetDlgItem $0 $HWNDPARENT 2 ; Cancel button 1.805 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(CANCEL_BUTTON)" 1.806 + 1.807 + GetDlgItem $0 $HWNDPARENT 3 ; Back button used for Options 1.808 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(OPTIONS_BUTTON)" 1.809 + 1.810 + System::Call "kernel32::GetTickCount()l .s" 1.811 + Pop $StartIntroPhaseTickCount 1.812 + 1.813 + LockWindow off 1.814 + nsDialogs::Show 1.815 + 1.816 + ${NSD_FreeImage} $0 1.817 + ${NSD_FreeImage} $1 1.818 +FunctionEnd 1.819 + 1.820 +Function leaveIntro 1.821 + LockWindow on 1.822 + 1.823 + System::Call "kernel32::GetTickCount()l .s" 1.824 + Pop $0 1.825 + ${GetSecondsElapsed} "$StartIntroPhaseTickCount" "$0" $IntroPhaseSeconds 1.826 + ; It is possible for this value to be 0 if the user clicks fast enough so 1.827 + ; increment the value by 1 if it is 0. 1.828 + ${If} $IntroPhaseSeconds == 0 1.829 + IntOp $IntroPhaseSeconds $IntroPhaseSeconds + 1 1.830 + ${EndIf} 1.831 + 1.832 + SetShellVarContext all ; Set SHCTX to All Users 1.833 + ; If the user doesn't have write access to the installation directory set 1.834 + ; the installation directory to a subdirectory of the All Users application 1.835 + ; directory and if the user can't write to that location set the installation 1.836 + ; directory to a subdirectory of the users local application directory 1.837 + ; (e.g. non-roaming). 1.838 + Call CanWrite 1.839 + ${If} "$CanWriteToInstallDir" == "false" 1.840 + StrCpy $INSTDIR "$APPDATA\${BrandFullName}\" 1.841 + Call CanWrite 1.842 + ${If} "$CanWriteToInstallDir" == "false" 1.843 + ; This should never happen but just in case. 1.844 + StrCpy $CanWriteToInstallDir "false" 1.845 + ${Else} 1.846 + StrCpy $INSTDIR "$LOCALAPPDATA\${BrandFullName}\" 1.847 + Call CanWrite 1.848 + ${EndIf} 1.849 + ${EndIf} 1.850 + 1.851 + Call CheckSpace 1.852 + 1.853 + ${If} ${FileExists} "$INSTDIR" 1.854 + ; Always display the long path if the path exists. 1.855 + ${GetLongPath} "$INSTDIR" $INSTDIR 1.856 + ${EndIf} 1.857 + 1.858 +FunctionEnd 1.859 + 1.860 +Function createOptions 1.861 + ; Check whether the install requirements are satisfied using the default 1.862 + ; values for metrics. 1.863 + ${If} "$InitialInstallRequirementsCode" == "" 1.864 + ${If} "$CanWriteToInstallDir" != "true" 1.865 + ${AndIf} "$HasRequiredSpaceAvailable" != "true" 1.866 + StrCpy $InitialInstallRequirementsCode "1" 1.867 + ${ElseIf} "$CanWriteToInstallDir" != "true" 1.868 + StrCpy $InitialInstallRequirementsCode "2" 1.869 + ${ElseIf} "$HasRequiredSpaceAvailable" != "true" 1.870 + StrCpy $InitialInstallRequirementsCode "3" 1.871 + ${Else} 1.872 + StrCpy $InitialInstallRequirementsCode "0" 1.873 + ${EndIf} 1.874 + ${EndIf} 1.875 + 1.876 + ; Skip the options page unless the Options button was clicked as long as the 1.877 + ; installation directory can be written to and there is the minimum required 1.878 + ; space available. 1.879 + ${If} "$WasOptionsButtonClicked" != "1" 1.880 + ${If} "$CanWriteToInstallDir" == "true" 1.881 + ${AndIf} "$HasRequiredSpaceAvailable" == "true" 1.882 + Abort ; Skip the options page 1.883 + ${EndIf} 1.884 + ${EndIf} 1.885 + 1.886 + StrCpy $ExistingTopDir "" 1.887 + 1.888 + nsDialogs::Create /NOUNLOAD 1018 1.889 + Pop $Dialog 1.890 + ; Since the text color for controls is set in this Dialog the foreground and 1.891 + ; background colors of the Dialog must also be hardcoded. 1.892 + SetCtlColors $Dialog ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.893 + 1.894 + ${NSD_CreateLabel} ${OPTIONS_ITEM_EDGE_DU} 18u ${OPTIONS_ITEM_WIDTH_DU} \ 1.895 + 12u "$(CREATE_SHORTCUTS)" 1.896 + Pop $0 1.897 + SetCtlColors $0 ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.898 + SendMessage $0 ${WM_SETFONT} $FontNormal 0 1.899 + 1.900 + ${If} ${AtLeastWin7} 1.901 + StrCpy $0 "$(ADD_SC_TASKBAR)" 1.902 + ${Else} 1.903 + StrCpy $0 "$(ADD_SC_QUICKLAUNCHBAR)" 1.904 + ${EndIf} 1.905 + ${NSD_CreateCheckbox} ${OPTIONS_SUBITEM_EDGE_DU} 38u \ 1.906 + ${OPTIONS_SUBITEM_WIDTH_DU} 12u "$0" 1.907 + Pop $CheckboxShortcutOnBar 1.908 + ; The uxtheme must be disabled on checkboxes in order to override the system 1.909 + ; font color. 1.910 + System::Call 'uxtheme::SetWindowTheme(i $CheckboxShortcutOnBar, w " ", w " ")' 1.911 + SetCtlColors $CheckboxShortcutOnBar ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.912 + SendMessage $CheckboxShortcutOnBar ${WM_SETFONT} $FontNormal 0 1.913 + ${NSD_Check} $CheckboxShortcutOnBar 1.914 + 1.915 + ${NSD_CreateCheckbox} ${OPTIONS_SUBITEM_EDGE_DU} 54u ${OPTIONS_SUBITEM_WIDTH_DU} \ 1.916 + 12u "$(ADD_CheckboxShortcutInStartMenu)" 1.917 + Pop $CheckboxShortcutInStartMenu 1.918 + ; The uxtheme must be disabled on checkboxes in order to override the system 1.919 + ; font color. 1.920 + System::Call 'uxtheme::SetWindowTheme(i $CheckboxShortcutInStartMenu, w " ", w " ")' 1.921 + SetCtlColors $CheckboxShortcutInStartMenu ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.922 + SendMessage $CheckboxShortcutInStartMenu ${WM_SETFONT} $FontNormal 0 1.923 + ${NSD_Check} $CheckboxShortcutInStartMenu 1.924 + 1.925 + ${NSD_CreateCheckbox} ${OPTIONS_SUBITEM_EDGE_DU} 70u ${OPTIONS_SUBITEM_WIDTH_DU} \ 1.926 + 12u "$(ADD_CheckboxShortcutOnDesktop)" 1.927 + Pop $CheckboxShortcutOnDesktop 1.928 + ; The uxtheme must be disabled on checkboxes in order to override the system 1.929 + ; font color. 1.930 + System::Call 'uxtheme::SetWindowTheme(i $CheckboxShortcutOnDesktop, w " ", w " ")' 1.931 + SetCtlColors $CheckboxShortcutOnDesktop ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.932 + SendMessage $CheckboxShortcutOnDesktop ${WM_SETFONT} $FontNormal 0 1.933 + ${NSD_Check} $CheckboxShortcutOnDesktop 1.934 + 1.935 + ${NSD_CreateLabel} ${OPTIONS_ITEM_EDGE_DU} 100u ${OPTIONS_ITEM_WIDTH_DU} \ 1.936 + 12u "$(DEST_FOLDER)" 1.937 + Pop $0 1.938 + SetCtlColors $0 ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.939 + SendMessage $0 ${WM_SETFONT} $FontNormal 0 1.940 + 1.941 + ${NSD_CreateDirRequest} ${OPTIONS_SUBITEM_EDGE_DU} 116u 159u 14u "$INSTDIR" 1.942 + Pop $DirRequest 1.943 + SetCtlColors $DirRequest ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.944 + SendMessage $DirRequest ${WM_SETFONT} $FontNormal 0 1.945 + System::Call shlwapi::SHAutoComplete(i $DirRequest, i ${SHACF_FILESYSTEM}) 1.946 + ${NSD_OnChange} $DirRequest OnChange_DirRequest 1.947 + 1.948 +!ifdef ${AB_CD}_rtl 1.949 + ; Remove the RTL styling from the directory request text box 1.950 + ${RemoveStyle} $DirRequest ${SS_RIGHT} 1.951 + ${RemoveExStyle} $DirRequest ${WS_EX_RIGHT} 1.952 + ${RemoveExStyle} $DirRequest ${WS_EX_RTLREADING} 1.953 + ${NSD_AddStyle} $DirRequest ${SS_LEFT} 1.954 + ${NSD_AddExStyle} $DirRequest ${WS_EX_LTRREADING}|${WS_EX_LEFT} 1.955 +!endif 1.956 + 1.957 + ${NSD_CreateBrowseButton} 280u 116u 50u 14u "$(BROWSE_BUTTON)" 1.958 + Pop $ButtonBrowse 1.959 + SetCtlColors $ButtonBrowse "" ${COMMON_BKGRD_COLOR} 1.960 + ${NSD_OnClick} $ButtonBrowse OnClick_ButtonBrowse 1.961 + 1.962 + ; Get the number of pixels from the left of the Dialog to the right side of 1.963 + ; the "Space Required:" and "Space Available:" labels prior to setting RTL so 1.964 + ; the correct position of the controls can be set by NSIS for RTL locales. 1.965 + 1.966 + ; Get the width and height of both labels and use the tallest for the height 1.967 + ; and the widest to calculate where to place the labels after these labels. 1.968 + ${GetTextExtent} "$(SPACE_REQUIRED)" $FontItalic $0 $1 1.969 + ${GetTextExtent} "$(SPACE_AVAILABLE)" $FontItalic $2 $3 1.970 + ${If} $1 > $3 1.971 + StrCpy $ControlHeightPX "$1" 1.972 + ${Else} 1.973 + StrCpy $ControlHeightPX "$3" 1.974 + ${EndIf} 1.975 + 1.976 + IntOp $0 $0 + 8 ; Add padding to the control's width 1.977 + ; Make both controls the same width as the widest control 1.978 + ${NSD_CreateLabelCenter} ${OPTIONS_SUBITEM_EDGE_DU} 134u $0 $ControlHeightPX "$(SPACE_REQUIRED)" 1.979 + Pop $5 1.980 + SetCtlColors $5 ${COMMON_TEXT_COLOR_FADED} ${COMMON_BKGRD_COLOR} 1.981 + SendMessage $5 ${WM_SETFONT} $FontItalic 0 1.982 + 1.983 + IntOp $2 $2 + 8 ; Add padding to the control's width 1.984 + ${NSD_CreateLabelCenter} ${OPTIONS_SUBITEM_EDGE_DU} 145u $2 $ControlHeightPX "$(SPACE_AVAILABLE)" 1.985 + Pop $6 1.986 + SetCtlColors $6 ${COMMON_TEXT_COLOR_FADED} ${COMMON_BKGRD_COLOR} 1.987 + SendMessage $6 ${WM_SETFONT} $FontItalic 0 1.988 + 1.989 + ; Use the widest label for aligning the labels next to them 1.990 + ${If} $0 > $2 1.991 + StrCpy $6 "$5" 1.992 + ${EndIf} 1.993 + FindWindow $1 "#32770" "" $HWNDPARENT 1.994 + ${GetDlgItemEndPX} $6 $ControlRightPX 1.995 + 1.996 + IntOp $ControlRightPX $ControlRightPX + 6 1.997 + 1.998 + ${NSD_CreateLabel} $ControlRightPX 134u 100% $ControlHeightPX \ 1.999 + "${APPROXIMATE_REQUIRED_SPACE_MB} $(MEGA)$(BYTE)" 1.1000 + Pop $7 1.1001 + SetCtlColors $7 ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.1002 + SendMessage $7 ${WM_SETFONT} $FontNormal 0 1.1003 + 1.1004 + ; Create the free space label with an empty string and update it by calling 1.1005 + ; UpdateFreeSpaceLabel 1.1006 + ${NSD_CreateLabel} $ControlRightPX 145u 100% $ControlHeightPX " " 1.1007 + Pop $LabelFreeSpace 1.1008 + SetCtlColors $LabelFreeSpace ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.1009 + SendMessage $LabelFreeSpace ${WM_SETFONT} $FontNormal 0 1.1010 + 1.1011 + Call UpdateFreeSpaceLabel 1.1012 + 1.1013 + ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} 168u ${OPTIONS_SUBITEM_WIDTH_DU} \ 1.1014 + 12u "$(SEND_PING)" 1.1015 + Pop $CheckboxSendPing 1.1016 + ; The uxtheme must be disabled on checkboxes in order to override the system 1.1017 + ; font color. 1.1018 + System::Call 'uxtheme::SetWindowTheme(i $CheckboxSendPing, w " ", w " ")' 1.1019 + SetCtlColors $CheckboxSendPing ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.1020 + SendMessage $CheckboxSendPing ${WM_SETFONT} $FontNormal 0 1.1021 + ${NSD_Check} $CheckboxSendPing 1.1022 + 1.1023 +!ifdef MOZ_MAINTENANCE_SERVICE 1.1024 + ; Only show the maintenance service checkbox if we have write access to HKLM 1.1025 + Call IsUserAdmin 1.1026 + Pop $0 1.1027 + ClearErrors 1.1028 + WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" \ 1.1029 + "Write Test" 1.1030 + ${If} ${Errors} 1.1031 + ${OrIf} $0 != "true" 1.1032 + StrCpy $CheckboxInstallMaintSvc "0" 1.1033 + ${Else} 1.1034 + DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" 1.1035 + ; Read the registry instead of using ServicesHelper::IsInstalled so the 1.1036 + ; plugin isn't included in the stub installer to lessen its size. 1.1037 + ClearErrors 1.1038 + ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\services\MozillaMaintenance" "ImagePath" 1.1039 + ${If} ${Errors} 1.1040 + ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} 184u ${OPTIONS_ITEM_WIDTH_DU} \ 1.1041 + 12u "$(INSTALL_MAINT_SERVICE)" 1.1042 + Pop $CheckboxInstallMaintSvc 1.1043 + System::Call 'uxtheme::SetWindowTheme(i $CheckboxInstallMaintSvc, w " ", w " ")' 1.1044 + SetCtlColors $CheckboxInstallMaintSvc ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.1045 + SendMessage $CheckboxInstallMaintSvc ${WM_SETFONT} $FontNormal 0 1.1046 + ${NSD_Check} $CheckboxInstallMaintSvc 1.1047 + ${EndIf} 1.1048 + ${EndIf} 1.1049 +!endif 1.1050 + 1.1051 + GetDlgItem $0 $HWNDPARENT 1 ; Install button 1.1052 + ${If} ${FileExists} "$INSTDIR\${FileMainEXE}" 1.1053 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(UPGRADE_BUTTON)" 1.1054 + ${Else} 1.1055 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(INSTALL_BUTTON)" 1.1056 + ${EndIf} 1.1057 + ${NSD_SetFocus} $0 1.1058 + 1.1059 + GetDlgItem $0 $HWNDPARENT 2 ; Cancel button 1.1060 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(CANCEL_BUTTON)" 1.1061 + 1.1062 + GetDlgItem $0 $HWNDPARENT 3 ; Back button used for Options 1.1063 + EnableWindow $0 0 1.1064 + ShowWindow $0 ${SW_HIDE} 1.1065 + 1.1066 + ; If the option button was not clicked display the reason for what needs to be 1.1067 + ; resolved to continue the installation. 1.1068 + ${If} "$WasOptionsButtonClicked" != "1" 1.1069 + ${If} "$CanWriteToInstallDir" == "false" 1.1070 + MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_WRITE_ACCESS)" 1.1071 + ${ElseIf} "$HasRequiredSpaceAvailable" == "false" 1.1072 + MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_DISK_SPACE)" 1.1073 + ${EndIf} 1.1074 + ${EndIf} 1.1075 + 1.1076 + System::Call "kernel32::GetTickCount()l .s" 1.1077 + Pop $StartOptionsPhaseTickCount 1.1078 + 1.1079 + LockWindow off 1.1080 + nsDialogs::Show 1.1081 +FunctionEnd 1.1082 + 1.1083 +Function leaveOptions 1.1084 + LockWindow on 1.1085 + 1.1086 + ${GetRoot} "$INSTDIR" $0 1.1087 + ${GetLongPath} "$INSTDIR" $INSTDIR 1.1088 + ${GetLongPath} "$0" $0 1.1089 + ${If} "$INSTDIR" == "$0" 1.1090 + LockWindow off 1.1091 + MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_ROOT_INSTALL)" 1.1092 + Abort ; Stay on the page 1.1093 + ${EndIf} 1.1094 + 1.1095 + Call CanWrite 1.1096 + ${If} "$CanWriteToInstallDir" == "false" 1.1097 + LockWindow off 1.1098 + MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_WRITE_ACCESS)" 1.1099 + Abort ; Stay on the page 1.1100 + ${EndIf} 1.1101 + 1.1102 + Call CheckSpace 1.1103 + ${If} "$HasRequiredSpaceAvailable" == "false" 1.1104 + LockWindow off 1.1105 + MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_DISK_SPACE)" 1.1106 + Abort ; Stay on the page 1.1107 + ${EndIf} 1.1108 + 1.1109 + System::Call "kernel32::GetTickCount()l .s" 1.1110 + Pop $0 1.1111 + ${GetSecondsElapsed} "$StartOptionsPhaseTickCount" "$0" $OptionsPhaseSeconds 1.1112 + ; It is possible for this value to be 0 if the user clicks fast enough so 1.1113 + ; increment the value by 1 if it is 0. 1.1114 + ${If} $OptionsPhaseSeconds == 0 1.1115 + IntOp $OptionsPhaseSeconds $OptionsPhaseSeconds + 1 1.1116 + ${EndIf} 1.1117 + 1.1118 + ${NSD_GetState} $CheckboxShortcutOnBar $CheckboxShortcutOnBar 1.1119 + ${NSD_GetState} $CheckboxShortcutInStartMenu $CheckboxShortcutInStartMenu 1.1120 + ${NSD_GetState} $CheckboxShortcutOnDesktop $CheckboxShortcutOnDesktop 1.1121 + ${NSD_GetState} $CheckboxSendPing $CheckboxSendPing 1.1122 +!ifdef MOZ_MAINTENANCE_SERVICE 1.1123 + ${NSD_GetState} $CheckboxInstallMaintSvc $CheckboxInstallMaintSvc 1.1124 +!endif 1.1125 + 1.1126 +FunctionEnd 1.1127 + 1.1128 +Function createInstall 1.1129 + nsDialogs::Create /NOUNLOAD 1018 1.1130 + Pop $Dialog 1.1131 + ; Since the text color for controls is set in this Dialog the foreground and 1.1132 + ; background colors of the Dialog must also be hardcoded. 1.1133 + SetCtlColors $Dialog ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR} 1.1134 + 1.1135 + ${NSD_CreateLabel} 0 0 49u 64u "" 1.1136 + Pop $0 1.1137 + ${GetDlgItemWidthHeight} $0 $1 $2 1.1138 + System::Call 'user32::DestroyWindow(i r0)' 1.1139 + 1.1140 + ${NSD_CreateLabel} 0 0 11u 16u "" 1.1141 + Pop $0 1.1142 + ${GetDlgItemWidthHeight} $0 $3 $4 1.1143 + System::Call 'user32::DestroyWindow(i r0)' 1.1144 + 1.1145 + FindWindow $7 "#32770" "" $HWNDPARENT 1.1146 + ${GetDlgItemWidthHeight} $7 $8 $9 1.1147 + 1.1148 + ; Allow a maximum text width of half of the Dialog's width 1.1149 + IntOp $R0 $8 / 2 1.1150 + 1.1151 + ${GetTextWidthHeight} "${INSTALL_BLURB1}" $FontBlurb $R0 $5 $6 1.1152 + IntOp $R1 $1 + $3 1.1153 + IntOp $R1 $R1 + $5 1.1154 + IntOp $R1 $8 - $R1 1.1155 + IntOp $R1 $R1 / 2 1.1156 + ${NSD_CreateBitmap} $R1 ${INSTALL_BLURB_TOP_DU} 49u 64u "" 1.1157 + Pop $BitmapBlurb1 1.1158 + ${SetStretchedTransparentImage} $BitmapBlurb1 $PLUGINSDIR\clock.bmp $HwndBitmapBlurb1 1.1159 + IntOp $R1 $R1 + $1 1.1160 + IntOp $R1 $R1 + $3 1.1161 + ${NSD_CreateLabel} $R1 ${INSTALL_BLURB_TOP_DU} $5 $6 "${INSTALL_BLURB1}" 1.1162 + Pop $LabelBlurb1 1.1163 + SendMessage $LabelBlurb1 ${WM_SETFONT} $FontBlurb 0 1.1164 + SetCtlColors $LabelBlurb1 ${INSTALL_BLURB_TEXT_COLOR} transparent 1.1165 + 1.1166 + ${GetTextWidthHeight} "${INSTALL_BLURB2}" $FontBlurb $R0 $5 $6 1.1167 + IntOp $R1 $1 + $3 1.1168 + IntOp $R1 $R1 + $5 1.1169 + IntOp $R1 $8 - $R1 1.1170 + IntOp $R1 $R1 / 2 1.1171 + ${NSD_CreateBitmap} $R1 ${INSTALL_BLURB_TOP_DU} 49u 64u "" 1.1172 + Pop $BitmapBlurb2 1.1173 + ${SetStretchedTransparentImage} $BitmapBlurb2 $PLUGINSDIR\particles.bmp $HwndBitmapBlurb2 1.1174 + IntOp $R1 $R1 + $1 1.1175 + IntOp $R1 $R1 + $3 1.1176 + ${NSD_CreateLabel} $R1 ${INSTALL_BLURB_TOP_DU} $5 $6 "${INSTALL_BLURB2}" 1.1177 + Pop $LabelBlurb2 1.1178 + SendMessage $LabelBlurb2 ${WM_SETFONT} $FontBlurb 0 1.1179 + SetCtlColors $LabelBlurb2 ${INSTALL_BLURB_TEXT_COLOR} transparent 1.1180 + ShowWindow $BitmapBlurb2 ${SW_HIDE} 1.1181 + ShowWindow $LabelBlurb2 ${SW_HIDE} 1.1182 + 1.1183 + ${GetTextWidthHeight} "${INSTALL_BLURB3}" $FontBlurb $R0 $5 $6 1.1184 + IntOp $R1 $1 + $3 1.1185 + IntOp $R1 $R1 + $5 1.1186 + IntOp $R1 $8 - $R1 1.1187 + IntOp $R1 $R1 / 2 1.1188 + ${NSD_CreateBitmap} $R1 ${INSTALL_BLURB_TOP_DU} 49u 64u "" 1.1189 + Pop $BitmapBlurb3 1.1190 + ${SetStretchedTransparentImage} $BitmapBlurb3 $PLUGINSDIR\pencil.bmp $HWndBitmapBlurb3 1.1191 + IntOp $R1 $R1 + $1 1.1192 + IntOp $R1 $R1 + $3 1.1193 + ${NSD_CreateLabel} $R1 ${INSTALL_BLURB_TOP_DU} $5 $6 "${INSTALL_BLURB3}" 1.1194 + Pop $LabelBlurb3 1.1195 + SendMessage $LabelBlurb3 ${WM_SETFONT} $FontBlurb 0 1.1196 + SetCtlColors $LabelBlurb3 ${INSTALL_BLURB_TEXT_COLOR} transparent 1.1197 + ShowWindow $BitmapBlurb3 ${SW_HIDE} 1.1198 + ShowWindow $LabelBlurb3 ${SW_HIDE} 1.1199 + 1.1200 + ${NSD_CreateProgressBar} 103u 166u 241u 9u "" 1.1201 + Pop $Progressbar 1.1202 + ${NSD_AddStyle} $Progressbar ${PBS_MARQUEE} 1.1203 + SendMessage $Progressbar ${PBM_SETMARQUEE} 1 \ 1.1204 + $ProgressbarMarqueeIntervalMS ; start=1|stop=0 interval(ms)=+N 1.1205 + 1.1206 + ${NSD_CreateLabelCenter} 103u 180u 241u 20u "$(DOWNLOADING_LABEL)" 1.1207 + Pop $LabelDownloading 1.1208 + SendMessage $LabelDownloading ${WM_SETFONT} $FontNormal 0 1.1209 + SetCtlColors $LabelDownloading ${INSTALL_PROGRESS_TEXT_COLOR_NORMAL} transparent 1.1210 + 1.1211 + ${If} ${FileExists} "$INSTDIR\${FileMainEXE}" 1.1212 + ${NSD_CreateLabelCenter} 103u 180u 241u 20u "$(UPGRADING_LABEL)" 1.1213 + ${Else} 1.1214 + ${NSD_CreateLabelCenter} 103u 180u 241u 20u "$(INSTALLING_LABEL)" 1.1215 + ${EndIf} 1.1216 + Pop $LabelInstalling 1.1217 + SendMessage $LabelInstalling ${WM_SETFONT} $FontNormal 0 1.1218 + SetCtlColors $LabelInstalling ${INSTALL_PROGRESS_TEXT_COLOR_NORMAL} transparent 1.1219 + ShowWindow $LabelInstalling ${SW_HIDE} 1.1220 + 1.1221 + ${NSD_CreateBitmap} ${APPNAME_BMP_EDGE_DU} ${APPNAME_BMP_TOP_DU} \ 1.1222 + ${APPNAME_BMP_WIDTH_DU} ${APPNAME_BMP_HEIGHT_DU} "" 1.1223 + Pop $2 1.1224 + ${SetStretchedTransparentImage} $2 $PLUGINSDIR\appname.bmp $0 1.1225 + 1.1226 + GetDlgItem $0 $HWNDPARENT 1 ; Install button 1.1227 + EnableWindow $0 0 1.1228 + ShowWindow $0 ${SW_HIDE} 1.1229 + 1.1230 + GetDlgItem $0 $HWNDPARENT 3 ; Back button used for Options 1.1231 + EnableWindow $0 0 1.1232 + ShowWindow $0 ${SW_HIDE} 1.1233 + 1.1234 + GetDlgItem $0 $HWNDPARENT 2 ; Cancel button 1.1235 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(CANCEL_BUTTON)" 1.1236 + ; Focus the Cancel button otherwise it isn't possible to tab to it since it is 1.1237 + ; the only control that can be tabbed to. 1.1238 + ${NSD_SetFocus} $0 1.1239 + ; Kill the Cancel button's focus so pressing enter won't cancel the install. 1.1240 + SendMessage $0 ${WM_KILLFOCUS} 0 0 1.1241 + 1.1242 + ${If} "$CanSetAsDefault" == "true" 1.1243 + GetDlgItem $0 $HWNDPARENT 10 ; Default browser checkbox 1.1244 + SendMessage $0 ${BM_GETCHECK} 0 0 $CheckboxSetAsDefault 1.1245 + EnableWindow $0 0 1.1246 + ShowWindow $0 ${SW_HIDE} 1.1247 + ${EndIf} 1.1248 + 1.1249 + GetDlgItem $0 $HWNDPARENT 11 1.1250 + ${If} ${FileExists} "$INSTDIR\${FileMainEXE}" 1.1251 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(ONE_MOMENT_UPGRADE)" 1.1252 + ${Else} 1.1253 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(ONE_MOMENT_INSTALL)" 1.1254 + ${EndIf} 1.1255 + SendMessage $0 ${WM_SETFONT} $FontNormal 0 1.1256 + SetCtlColors $0 ${FOOTER_CONTROL_TEXT_COLOR_FADED} ${FOOTER_BKGRD_COLOR} 1.1257 + ShowWindow $0 ${SW_SHOW} 1.1258 + 1.1259 + ; Set $DownloadReset to true so the first download tick count is measured. 1.1260 + StrCpy $DownloadReset "true" 1.1261 + StrCpy $IsDownloadFinished "false" 1.1262 + StrCpy $DownloadRetryCount "0" 1.1263 + StrCpy $DownloadedBytes "0" 1.1264 + StrCpy $StartLastDownloadTickCount "" 1.1265 + StrCpy $EndDownloadPhaseTickCount "" 1.1266 + StrCpy $DownloadFirstTransferSeconds "" 1.1267 + StrCpy $ExitCode "${ERR_DOWNLOAD_CANCEL}" 1.1268 + StrCpy $OpenedDownloadPage "0" 1.1269 + 1.1270 + ClearErrors 1.1271 + ReadINIStr $ExistingVersion "$INSTDIR\application.ini" "App" "Version" 1.1272 + ${If} ${Errors} 1.1273 + StrCpy $ExistingVersion "0" 1.1274 + ${EndIf} 1.1275 + 1.1276 + ClearErrors 1.1277 + ReadINIStr $ExistingBuildID "$INSTDIR\application.ini" "App" "BuildID" 1.1278 + ${If} ${Errors} 1.1279 + StrCpy $ExistingBuildID "0" 1.1280 + ${EndIf} 1.1281 + 1.1282 + ${If} ${FileExists} "$LOCALAPPDATA\Mozilla\Firefox" 1.1283 + StrCpy $ExistingProfile "1" 1.1284 + ${Else} 1.1285 + StrCpy $ExistingProfile "0" 1.1286 + ${EndIf} 1.1287 + 1.1288 + StrCpy $DownloadServerIP "" 1.1289 + 1.1290 + System::Call "kernel32::GetTickCount()l .s" 1.1291 + Pop $StartDownloadPhaseTickCount 1.1292 + 1.1293 + ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.log" 1.1294 + StrCpy $InstallTotalSteps ${InstallPaveOverTotalSteps} 1.1295 + ${Else} 1.1296 + StrCpy $InstallTotalSteps ${InstallCleanTotalSteps} 1.1297 + ${EndIf} 1.1298 + 1.1299 + ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS} 1.1300 + 1.1301 + LockWindow off 1.1302 + nsDialogs::Show 1.1303 + 1.1304 + ${NSD_FreeImage} $0 1.1305 + ${NSD_FreeImage} $HwndBitmapBlurb1 1.1306 + ${NSD_FreeImage} $HwndBitmapBlurb2 1.1307 + ${NSD_FreeImage} $HWndBitmapBlurb3 1.1308 +FunctionEnd 1.1309 + 1.1310 +Function StartDownload 1.1311 + ${NSD_KillTimer} StartDownload 1.1312 + InetBgDL::Get "${URLStubDownload}${URLStubDownloadAppend}" "$PLUGINSDIR\download.exe" \ 1.1313 + /CONNECTTIMEOUT 120 /RECEIVETIMEOUT 120 /END 1.1314 + StrCpy $4 "" 1.1315 + ${NSD_CreateTimer} OnDownload ${DownloadIntervalMS} 1.1316 + ${If} ${FileExists} "$INSTDIR\${TO_BE_DELETED}" 1.1317 + RmDir /r "$INSTDIR\${TO_BE_DELETED}" 1.1318 + ${EndIf} 1.1319 +FunctionEnd 1.1320 + 1.1321 +Function OnDownload 1.1322 + InetBgDL::GetStats 1.1323 + # $0 = HTTP status code, 0=Completed 1.1324 + # $1 = Completed files 1.1325 + # $2 = Remaining files 1.1326 + # $3 = Number of downloaded bytes for the current file 1.1327 + # $4 = Size of current file (Empty string if the size is unknown) 1.1328 + # /RESET must be used if status $0 > 299 (e.g. failure) 1.1329 + # When status is $0 =< 299 it is handled by InetBgDL 1.1330 + StrCpy $DownloadServerIP "$5" 1.1331 + ${If} $0 > 299 1.1332 + ${NSD_KillTimer} OnDownload 1.1333 + IntOp $DownloadRetryCount $DownloadRetryCount + 1 1.1334 + ${If} "$DownloadReset" != "true" 1.1335 + StrCpy $DownloadedBytes "0" 1.1336 + ${NSD_AddStyle} $Progressbar ${PBS_MARQUEE} 1.1337 + SendMessage $Progressbar ${PBM_SETMARQUEE} 1 \ 1.1338 + $ProgressbarMarqueeIntervalMS ; start=1|stop=0 interval(ms)=+N 1.1339 + ${EndIf} 1.1340 + InetBgDL::Get /RESET /END 1.1341 + StrCpy $DownloadSizeBytes "" 1.1342 + StrCpy $DownloadReset "true" 1.1343 + 1.1344 + ${If} $DownloadRetryCount >= ${DownloadMaxRetries} 1.1345 + StrCpy $ExitCode "${ERR_DOWNLOAD_TOO_MANY_RETRIES}" 1.1346 + ; Use a timer so the UI has a chance to update 1.1347 + ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS} 1.1348 + ${Else} 1.1349 + ${NSD_CreateTimer} StartDownload ${DownloadRetryIntervalMS} 1.1350 + ${EndIf} 1.1351 + Return 1.1352 + ${EndIf} 1.1353 + 1.1354 + ${If} "$DownloadReset" == "true" 1.1355 + System::Call "kernel32::GetTickCount()l .s" 1.1356 + Pop $StartLastDownloadTickCount 1.1357 + StrCpy $DownloadReset "false" 1.1358 + ; The seconds elapsed from the start of the download phase until the first 1.1359 + ; bytes are received are only recorded for the first request so it is 1.1360 + ; possible to determine connection issues for the first request. 1.1361 + ${If} "$DownloadFirstTransferSeconds" == "" 1.1362 + ; Get the seconds elapsed from the start of the download phase until the 1.1363 + ; first bytes are received. 1.1364 + ${GetSecondsElapsed} "$StartDownloadPhaseTickCount" "$StartLastDownloadTickCount" $DownloadFirstTransferSeconds 1.1365 + ${EndIf} 1.1366 + ${EndIf} 1.1367 + 1.1368 + ${If} "$DownloadSizeBytes" == "" 1.1369 + ${AndIf} "$4" != "" 1.1370 + ; Handle the case where the size of the file to be downloaded is less than 1.1371 + ; the minimum expected size or greater than the maximum expected size at the 1.1372 + ; beginning of the download. 1.1373 + ${If} $4 < ${DownloadMinSizeBytes} 1.1374 + ${OrIf} $4 > ${DownloadMaxSizeBytes} 1.1375 + ${NSD_KillTimer} OnDownload 1.1376 + InetBgDL::Get /RESET /END 1.1377 + StrCpy $DownloadReset "true" 1.1378 + 1.1379 + ${If} $DownloadRetryCount >= ${DownloadMaxRetries} 1.1380 + ; Use a timer so the UI has a chance to update 1.1381 + ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS} 1.1382 + ${Else} 1.1383 + ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS} 1.1384 + ${EndIf} 1.1385 + Return 1.1386 + ${EndIf} 1.1387 + 1.1388 + StrCpy $DownloadSizeBytes "$4" 1.1389 + System::Int64Op $4 / 2 1.1390 + Pop $HalfOfDownload 1.1391 + System::Int64Op $HalfOfDownload / $InstallTotalSteps 1.1392 + Pop $InstallStepSize 1.1393 + SendMessage $Progressbar ${PBM_SETMARQUEE} 0 0 ; start=1|stop=0 interval(ms)=+N 1.1394 + ${RemoveStyle} $Progressbar ${PBS_MARQUEE} 1.1395 + System::Int64Op $HalfOfDownload + $DownloadSizeBytes 1.1396 + Pop $R9 1.1397 + SendMessage $Progressbar ${PBM_SETRANGE32} 0 $R9 1.1398 + ${EndIf} 1.1399 + 1.1400 + ; Don't update the status until after the download starts 1.1401 + ${If} $2 != 0 1.1402 + ${AndIf} "$4" == "" 1.1403 + Return 1.1404 + ${EndIf} 1.1405 + 1.1406 + ; Handle the case where the downloaded size is greater than the maximum 1.1407 + ; expected size during the download. 1.1408 + ${If} $DownloadedBytes > ${DownloadMaxSizeBytes} 1.1409 + InetBgDL::Get /RESET /END 1.1410 + StrCpy $DownloadReset "true" 1.1411 + 1.1412 + ${If} $DownloadRetryCount >= ${DownloadMaxRetries} 1.1413 + ; Use a timer so the UI has a chance to update 1.1414 + ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS} 1.1415 + ${Else} 1.1416 + ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS} 1.1417 + ${EndIf} 1.1418 + Return 1.1419 + ${EndIf} 1.1420 + 1.1421 + ${If} $IsDownloadFinished != "true" 1.1422 + ${If} $2 == 0 1.1423 + ${NSD_KillTimer} OnDownload 1.1424 + StrCpy $IsDownloadFinished "true" 1.1425 + ; The first step of the install progress bar is determined by the 1.1426 + ; InstallProgressFirstStep define and provides the user with immediate 1.1427 + ; feedback. 1.1428 + StrCpy $InstallCounterStep "${InstallProgressFirstStep}" 1.1429 + System::Call "kernel32::GetTickCount()l .s" 1.1430 + Pop $EndDownloadPhaseTickCount 1.1431 + 1.1432 + StrCpy $DownloadedBytes "$DownloadSizeBytes" 1.1433 + 1.1434 + ; When a download has finished handle the case where the downloaded size 1.1435 + ; is less than the minimum expected size or greater than the maximum 1.1436 + ; expected size during the download. 1.1437 + ${If} $DownloadedBytes < ${DownloadMinSizeBytes} 1.1438 + ${OrIf} $DownloadedBytes > ${DownloadMaxSizeBytes} 1.1439 + InetBgDL::Get /RESET /END 1.1440 + StrCpy $DownloadReset "true" 1.1441 + 1.1442 + ${If} $DownloadRetryCount >= ${DownloadMaxRetries} 1.1443 + ; Use a timer so the UI has a chance to update 1.1444 + ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS} 1.1445 + ${Else} 1.1446 + ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS} 1.1447 + ${EndIf} 1.1448 + Return 1.1449 + ${EndIf} 1.1450 + 1.1451 + LockWindow on 1.1452 + ; Update the progress bars first in the UI change so they take affect 1.1453 + ; before other UI changes. 1.1454 + SendMessage $Progressbar ${PBM_SETPOS} $DownloadSizeBytes 0 1.1455 + System::Int64Op $InstallStepSize * ${InstallProgressFirstStep} 1.1456 + Pop $R9 1.1457 + SendMessage $Progressbar ${PBM_SETSTEP} $R9 0 1.1458 + SendMessage $Progressbar ${PBM_STEPIT} 0 0 1.1459 + SendMessage $Progressbar ${PBM_SETSTEP} $InstallStepSize 0 1.1460 + ShowWindow $LabelDownloading ${SW_HIDE} 1.1461 + ShowWindow $LabelInstalling ${SW_SHOW} 1.1462 + ShowWindow $LabelBlurb2 ${SW_HIDE} 1.1463 + ShowWindow $BitmapBlurb2 ${SW_HIDE} 1.1464 + ShowWindow $LabelBlurb3 ${SW_SHOW} 1.1465 + ShowWindow $BitmapBlurb3 ${SW_SHOW} 1.1466 + ; Disable the Cancel button during the install 1.1467 + GetDlgItem $5 $HWNDPARENT 2 1.1468 + EnableWindow $5 0 1.1469 + LockWindow off 1.1470 + 1.1471 + ; Open a handle to prevent modification of the full installer 1.1472 + StrCpy $R9 "${INVALID_HANDLE_VALUE}" 1.1473 + System::Call 'kernel32::CreateFileW(w "$PLUGINSDIR\download.exe", \ 1.1474 + i ${GENERIC_READ}, \ 1.1475 + i ${FILE_SHARE_READ}, i 0, \ 1.1476 + i ${OPEN_EXISTING}, i 0, i 0) i .R9' 1.1477 + StrCpy $HandleDownload "$R9" 1.1478 + 1.1479 + ${If} $HandleDownload == ${INVALID_HANDLE_VALUE} 1.1480 + StrCpy $ExitCode "${ERR_PREINSTALL_INVALID_HANDLE}" 1.1481 + StrCpy $0 "0" 1.1482 + StrCpy $1 "0" 1.1483 + ${Else} 1.1484 + CertCheck::VerifyCertTrust "$PLUGINSDIR\download.exe" 1.1485 + Pop $0 1.1486 + CertCheck::VerifyCertNameIssuer "$PLUGINSDIR\download.exe" \ 1.1487 + "${CertNameDownload}" "${CertIssuerDownload}" 1.1488 + Pop $1 1.1489 + ${If} $0 == 0 1.1490 + ${AndIf} $1 == 0 1.1491 + StrCpy $ExitCode "${ERR_PREINSTALL_CERT_UNTRUSTED_AND_ATTRIBUTES}" 1.1492 + ${ElseIf} $0 == 0 1.1493 + StrCpy $ExitCode "${ERR_PREINSTALL_CERT_UNTRUSTED}" 1.1494 + ${ElseIf} $1 == 0 1.1495 + StrCpy $ExitCode "${ERR_PREINSTALL_CERT_ATTRIBUTES}" 1.1496 + ${EndIf} 1.1497 + ${EndIf} 1.1498 + 1.1499 + System::Call "kernel32::GetTickCount()l .s" 1.1500 + Pop $EndPreInstallPhaseTickCount 1.1501 + 1.1502 + ${If} $0 == 0 1.1503 + ${OrIf} $1 == 0 1.1504 + ; Use a timer so the UI has a chance to update 1.1505 + ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS} 1.1506 + Return 1.1507 + ${EndIf} 1.1508 + 1.1509 + ; Instead of extracting the files we use the downloaded installer to 1.1510 + ; install in case it needs to perform operations that the stub doesn't 1.1511 + ; know about. 1.1512 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "InstallDirectoryPath" "$INSTDIR" 1.1513 + ; Don't create the QuickLaunch or Taskbar shortcut from the launched installer 1.1514 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "QuickLaunchShortcut" "false" 1.1515 + ${If} $CheckboxShortcutOnDesktop == 1 1.1516 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "DesktopShortcut" "true" 1.1517 + ${Else} 1.1518 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "DesktopShortcut" "false" 1.1519 + ${EndIf} 1.1520 + 1.1521 + ${If} $CheckboxShortcutInStartMenu == 1 1.1522 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "StartMenuShortcuts" "true" 1.1523 + ${Else} 1.1524 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "StartMenuShortcuts" "false" 1.1525 + ${EndIf} 1.1526 + 1.1527 +!ifdef MOZ_MAINTENANCE_SERVICE 1.1528 + ${If} $CheckboxInstallMaintSvc == 1 1.1529 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "MaintenanceService" "true" 1.1530 + ${Else} 1.1531 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "MaintenanceService" "false" 1.1532 + ${EndIf} 1.1533 +!else 1.1534 + WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "MaintenanceService" "false" 1.1535 +!endif 1.1536 + 1.1537 + ; Write migrated to the shortcuts.ini file to prevent the installer 1.1538 + ; from creating a taskbar shortcut (Bug 791613). 1.1539 + ${GetShortcutsLogPath} $0 1.1540 + Delete "$0" 1.1541 + ; Workaround to prevent pinning to the taskbar. 1.1542 + ${If} $CheckboxShortcutOnBar == 0 1.1543 + WriteIniStr "$0" "TASKBAR" "Migrated" "true" 1.1544 + ${EndIf} 1.1545 + 1.1546 + ${OnStubInstallUninstall} $Progressbar $InstallCounterStep 1.1547 + 1.1548 + ; Delete the install.log and let the full installer create it. When the 1.1549 + ; installer closes it we can detect that it has completed. 1.1550 + Delete "$INSTDIR\install.log" 1.1551 + 1.1552 + ; Delete firefox.exe.moz-upgrade if it exists since it being present will 1.1553 + ; require an OS restart for the full installer. 1.1554 + Delete "$INSTDIR\${FileMainEXE}.moz-upgrade" 1.1555 + 1.1556 + System::Call "kernel32::GetTickCount()l .s" 1.1557 + Pop $EndPreInstallPhaseTickCount 1.1558 + 1.1559 + Exec "$\"$PLUGINSDIR\download.exe$\" /INI=$PLUGINSDIR\${CONFIG_INI}" 1.1560 + ${NSD_CreateTimer} CheckInstall ${InstallIntervalMS} 1.1561 + ${Else} 1.1562 + ${If} $HalfOfDownload != "true" 1.1563 + ${AndIf} $3 > $HalfOfDownload 1.1564 + StrCpy $HalfOfDownload "true" 1.1565 + LockWindow on 1.1566 + ShowWindow $LabelBlurb1 ${SW_HIDE} 1.1567 + ShowWindow $BitmapBlurb1 ${SW_HIDE} 1.1568 + ShowWindow $LabelBlurb2 ${SW_SHOW} 1.1569 + ShowWindow $BitmapBlurb2 ${SW_SHOW} 1.1570 + LockWindow off 1.1571 + ${EndIf} 1.1572 + StrCpy $DownloadedBytes "$3" 1.1573 + SendMessage $Progressbar ${PBM_SETPOS} $3 0 1.1574 + ${EndIf} 1.1575 + ${EndIf} 1.1576 +FunctionEnd 1.1577 + 1.1578 +Function OnPing 1.1579 + InetBgDL::GetStats 1.1580 + # $0 = HTTP status code, 0=Completed 1.1581 + # $1 = Completed files 1.1582 + # $2 = Remaining files 1.1583 + # $3 = Number of downloaded bytes for the current file 1.1584 + # $4 = Size of current file (Empty string if the size is unknown) 1.1585 + # /RESET must be used if status $0 > 299 (e.g. failure) 1.1586 + # When status is $0 =< 299 it is handled by InetBgDL 1.1587 + ${If} $2 == 0 1.1588 + ${OrIf} $0 > 299 1.1589 + ${NSD_KillTimer} OnPing 1.1590 + ${If} $0 > 299 1.1591 + InetBgDL::Get /RESET /END 1.1592 + ${EndIf} 1.1593 + ; The following will exit the installer 1.1594 + SetAutoClose true 1.1595 + StrCpy $R9 "2" 1.1596 + Call RelativeGotoPage 1.1597 + ${EndIf} 1.1598 +FunctionEnd 1.1599 + 1.1600 +Function CheckInstall 1.1601 + IntOp $InstallCounterStep $InstallCounterStep + 1 1.1602 + ${If} $InstallCounterStep >= $InstallTotalSteps 1.1603 + ${NSD_KillTimer} CheckInstall 1.1604 + ; Close the handle that prevents modification of the full installer 1.1605 + System::Call 'kernel32::CloseHandle(i $HandleDownload)' 1.1606 + StrCpy $ExitCode "${ERR_INSTALL_TIMEOUT}" 1.1607 + ; Use a timer so the UI has a chance to update 1.1608 + ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS} 1.1609 + Return 1.1610 + ${EndIf} 1.1611 + 1.1612 + SendMessage $Progressbar ${PBM_STEPIT} 0 0 1.1613 + 1.1614 + ${If} ${FileExists} "$INSTDIR\install.log" 1.1615 + Delete "$INSTDIR\install.tmp" 1.1616 + CopyFiles /SILENT "$INSTDIR\install.log" "$INSTDIR\install.tmp" 1.1617 + 1.1618 + ; The unfocus and refocus that happens approximately here is caused by the 1.1619 + ; installer calling SHChangeNotify to refresh the shortcut icons. 1.1620 + 1.1621 + ; When the full installer completes the installation the install.log will no 1.1622 + ; longer be in use. 1.1623 + ClearErrors 1.1624 + Delete "$INSTDIR\install.log" 1.1625 + ${Unless} ${Errors} 1.1626 + ${NSD_KillTimer} CheckInstall 1.1627 + ; Close the handle that prevents modification of the full installer 1.1628 + System::Call 'kernel32::CloseHandle(i $HandleDownload)' 1.1629 + Rename "$INSTDIR\install.tmp" "$INSTDIR\install.log" 1.1630 + Delete "$PLUGINSDIR\download.exe" 1.1631 + Delete "$PLUGINSDIR\${CONFIG_INI}" 1.1632 + System::Call "kernel32::GetTickCount()l .s" 1.1633 + Pop $EndInstallPhaseTickCount 1.1634 + System::Int64Op $InstallStepSize * ${InstallProgressFinishStep} 1.1635 + Pop $InstallStepSize 1.1636 + SendMessage $Progressbar ${PBM_SETSTEP} $InstallStepSize 0 1.1637 + ${NSD_CreateTimer} FinishInstall ${InstallIntervalMS} 1.1638 + ${EndUnless} 1.1639 + ${EndIf} 1.1640 +FunctionEnd 1.1641 + 1.1642 +Function FinishInstall 1.1643 + ; The full installer has completed but the progress bar still needs to finish 1.1644 + ; so increase the size of the step. 1.1645 + IntOp $InstallCounterStep $InstallCounterStep + ${InstallProgressFinishStep} 1.1646 + ${If} $InstallTotalSteps < $InstallCounterStep 1.1647 + StrCpy $InstallCounterStep "$InstallTotalSteps" 1.1648 + ${EndIf} 1.1649 + 1.1650 + ${If} $InstallTotalSteps != $InstallCounterStep 1.1651 + SendMessage $Progressbar ${PBM_STEPIT} 0 0 1.1652 + Return 1.1653 + ${EndIf} 1.1654 + 1.1655 + ${NSD_KillTimer} FinishInstall 1.1656 + 1.1657 + SendMessage $Progressbar ${PBM_GETRANGE} 0 0 $R9 1.1658 + SendMessage $Progressbar ${PBM_SETPOS} $R9 0 1.1659 + 1.1660 + ${If} "$CheckboxSetAsDefault" == "1" 1.1661 + ${GetParameters} $0 1.1662 + ClearErrors 1.1663 + ${GetOptions} "$0" "/UAC:" $0 1.1664 + ${If} ${Errors} ; Not elevated 1.1665 + Call ExecSetAsDefaultAppUser 1.1666 + ${Else} ; Elevated - execute the function in the unelevated process 1.1667 + GetFunctionAddress $0 ExecSetAsDefaultAppUser 1.1668 + UAC::ExecCodeSegment $0 1.1669 + ${EndIf} 1.1670 + ${EndIf} 1.1671 + 1.1672 + ${If} $CheckboxShortcutOnBar == 1 1.1673 + ${If} ${AtMostWinVista} 1.1674 + ClearErrors 1.1675 + ${GetParameters} $0 1.1676 + ClearErrors 1.1677 + ${GetOptions} "$0" "/UAC:" $0 1.1678 + ${If} ${Errors} 1.1679 + Call AddQuickLaunchShortcut 1.1680 + ${Else} 1.1681 + GetFunctionAddress $0 AddQuickLaunchShortcut 1.1682 + UAC::ExecCodeSegment $0 1.1683 + ${EndIf} 1.1684 + ${EndIf} 1.1685 + ${EndIf} 1.1686 + 1.1687 + ${If} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-upgrade" 1.1688 + Delete "$INSTDIR\${FileMainEXE}" 1.1689 + Rename "$INSTDIR\${FileMainEXE}.moz-upgrade" "$INSTDIR\${FileMainEXE}" 1.1690 + ${EndIf} 1.1691 + 1.1692 + StrCpy $ExitCode "${ERR_SUCCESS}" 1.1693 + 1.1694 + StrCpy $InstallCounterStep 0 1.1695 + ${NSD_CreateTimer} FinishProgressBar ${InstallIntervalMS} 1.1696 +FunctionEnd 1.1697 + 1.1698 +Function FinishProgressBar 1.1699 + IntOp $InstallCounterStep $InstallCounterStep + 1 1.1700 + 1.1701 + ${If} $InstallCounterStep < 10 1.1702 + Return 1.1703 + ${EndIf} 1.1704 + 1.1705 + ${NSD_KillTimer} FinishProgressBar 1.1706 + 1.1707 + Call LaunchApp 1.1708 + 1.1709 + Call SendPing 1.1710 +FunctionEnd 1.1711 + 1.1712 +Function OnBack 1.1713 + StrCpy $WasOptionsButtonClicked "1" 1.1714 + StrCpy $R9 "1" ; Goto the next page 1.1715 + Call RelativeGotoPage 1.1716 + ; The call to Abort prevents NSIS from trying to move to the previous or the 1.1717 + ; next page. 1.1718 + Abort 1.1719 +FunctionEnd 1.1720 + 1.1721 +Function RelativeGotoPage 1.1722 + IntCmp $R9 0 0 Move Move 1.1723 + StrCmp $R9 "X" 0 Move 1.1724 + StrCpy $R9 "120" 1.1725 + 1.1726 + Move: 1.1727 + SendMessage $HWNDPARENT "0x408" "$R9" "" 1.1728 +FunctionEnd 1.1729 + 1.1730 +Function UpdateFreeSpaceLabel 1.1731 + ; Only update when $ExistingTopDir isn't set 1.1732 + ${If} "$ExistingTopDir" != "" 1.1733 + StrLen $5 "$ExistingTopDir" 1.1734 + StrLen $6 "$INSTDIR" 1.1735 + ${If} $5 <= $6 1.1736 + StrCpy $7 "$INSTDIR" $5 1.1737 + ${If} "$7" == "$ExistingTopDir" 1.1738 + Return 1.1739 + ${EndIf} 1.1740 + ${EndIf} 1.1741 + ${EndIf} 1.1742 + 1.1743 + Call CheckSpace 1.1744 + 1.1745 + StrCpy $0 "$SpaceAvailableBytes" 1.1746 + 1.1747 + StrCpy $1 "$(BYTE)" 1.1748 + 1.1749 + ${If} $0 > 1024 1.1750 + ${OrIf} $0 < 0 1.1751 + ; Multiply by 10 so it is possible to display a decimal in the size 1.1752 + System::Int64Op $0 * 10 1.1753 + Pop $0 1.1754 + System::Int64Op $0 / 1024 1.1755 + Pop $0 1.1756 + StrCpy $1 "$(KILO)$(BYTE)" 1.1757 + ${If} $0 > 10240 1.1758 + ${OrIf} $0 < 0 1.1759 + System::Int64Op $0 / 1024 1.1760 + Pop $0 1.1761 + StrCpy $1 "$(MEGA)$(BYTE)" 1.1762 + ${If} $0 > 10240 1.1763 + ${OrIf} $0 < 0 1.1764 + System::Int64Op $0 / 1024 1.1765 + Pop $0 1.1766 + StrCpy $1 "$(GIGA)$(BYTE)" 1.1767 + ${EndIf} 1.1768 + ${EndIf} 1.1769 + StrLen $3 "$0" 1.1770 + ${If} $3 > 1 1.1771 + StrCpy $2 "$0" -1 ; All characters except the last one 1.1772 + StrCpy $0 "$0" "" -1 ; The last character 1.1773 + ${If} "$0" == "0" 1.1774 + StrCpy $0 "$2" ; Don't display the decimal if it is 0 1.1775 + ${Else} 1.1776 + StrCpy $0 "$2.$0" 1.1777 + ${EndIf} 1.1778 + ${ElseIf} $3 == 1 1.1779 + StrCpy $0 "0.$0" 1.1780 + ${Else} 1.1781 + ; This should never happen 1.1782 + System::Int64Op $0 / 10 1.1783 + Pop $0 1.1784 + ${EndIf} 1.1785 + ${EndIf} 1.1786 + 1.1787 + SendMessage $LabelFreeSpace ${WM_SETTEXT} 0 "STR:$0 $1" 1.1788 + 1.1789 +FunctionEnd 1.1790 + 1.1791 +Function OnChange_DirRequest 1.1792 + Pop $0 1.1793 + System::Call 'user32::GetWindowTextW(i $DirRequest, w .r0, i ${NSIS_MAX_STRLEN})' 1.1794 + StrCpy $1 "$0" 1 ; the first character 1.1795 + ${If} "$1" == "$\"" 1.1796 + StrCpy $1 "$0" "" -1 ; the last character 1.1797 + ${If} "$1" == "$\"" 1.1798 + StrCpy $0 "$0" "" 1 ; all but the first character 1.1799 + StrCpy $0 "$0" -1 ; all but the last character 1.1800 + ${EndIf} 1.1801 + ${EndIf} 1.1802 + 1.1803 + StrCpy $INSTDIR "$0" 1.1804 + Call UpdateFreeSpaceLabel 1.1805 + 1.1806 + GetDlgItem $0 $HWNDPARENT 1 ; Install button 1.1807 + ${If} ${FileExists} "$INSTDIR\${FileMainEXE}" 1.1808 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(UPGRADE_BUTTON)" 1.1809 + ${Else} 1.1810 + SendMessage $0 ${WM_SETTEXT} 0 "STR:$(INSTALL_BUTTON)" 1.1811 + ${EndIf} 1.1812 +FunctionEnd 1.1813 + 1.1814 +Function OnClick_ButtonBrowse 1.1815 + StrCpy $0 "$INSTDIR" 1.1816 + nsDialogs::SelectFolderDialog /NOUNLOAD "$(SELECT_FOLDER_TEXT)" $0 1.1817 + Pop $0 1.1818 + ${If} $0 == "error" ; returns 'error' if 'cancel' was pressed? 1.1819 + Return 1.1820 + ${EndIf} 1.1821 + 1.1822 + ${If} $0 != "" 1.1823 + StrCpy $INSTDIR "$0" 1.1824 + System::Call 'user32::SetWindowTextW(i $DirRequest, w "$INSTDIR")' 1.1825 + ${EndIf} 1.1826 +FunctionEnd 1.1827 + 1.1828 +Function CheckSpace 1.1829 + ${If} "$ExistingTopDir" != "" 1.1830 + StrLen $0 "$ExistingTopDir" 1.1831 + StrLen $1 "$INSTDIR" 1.1832 + ${If} $0 <= $1 1.1833 + StrCpy $2 "$INSTDIR" $3 1.1834 + ${If} "$2" == "$ExistingTopDir" 1.1835 + Return 1.1836 + ${EndIf} 1.1837 + ${EndIf} 1.1838 + ${EndIf} 1.1839 + 1.1840 + StrCpy $ExistingTopDir "$INSTDIR" 1.1841 + ${DoUntil} ${FileExists} "$ExistingTopDir" 1.1842 + ${GetParent} "$ExistingTopDir" $ExistingTopDir 1.1843 + ${If} "$ExistingTopDir" == "" 1.1844 + StrCpy $SpaceAvailableBytes "0" 1.1845 + StrCpy $HasRequiredSpaceAvailable "false" 1.1846 + Return 1.1847 + ${EndIf} 1.1848 + ${Loop} 1.1849 + 1.1850 + ${GetLongPath} "$ExistingTopDir" $ExistingTopDir 1.1851 + 1.1852 + ; GetDiskFreeSpaceExW requires a backslash. 1.1853 + StrCpy $0 "$ExistingTopDir" "" -1 ; the last character 1.1854 + ${If} "$0" != "\" 1.1855 + StrCpy $0 "\" 1.1856 + ${Else} 1.1857 + StrCpy $0 "" 1.1858 + ${EndIf} 1.1859 + 1.1860 + System::Call 'kernel32::GetDiskFreeSpaceExW(w, *l, *l, *l) i("$ExistingTopDir$0", .r1, .r2, .r3) .' 1.1861 + StrCpy $SpaceAvailableBytes "$1" 1.1862 + 1.1863 + System::Int64Op $SpaceAvailableBytes / 1048576 1.1864 + Pop $1 1.1865 + System::Int64Op $1 > ${APPROXIMATE_REQUIRED_SPACE_MB} 1.1866 + Pop $1 1.1867 + ${If} $1 == 1 1.1868 + StrCpy $HasRequiredSpaceAvailable "true" 1.1869 + ${Else} 1.1870 + StrCpy $HasRequiredSpaceAvailable "false" 1.1871 + ${EndIf} 1.1872 +FunctionEnd 1.1873 + 1.1874 +Function CanWrite 1.1875 + StrCpy $CanWriteToInstallDir "false" 1.1876 + 1.1877 + StrCpy $0 "$INSTDIR" 1.1878 + ; Use the existing directory when it exists 1.1879 + ${Unless} ${FileExists} "$INSTDIR" 1.1880 + ; Get the topmost directory that exists for new installs 1.1881 + ${DoUntil} ${FileExists} "$0" 1.1882 + ${GetParent} "$0" $0 1.1883 + ${If} "$0" == "" 1.1884 + Return 1.1885 + ${EndIf} 1.1886 + ${Loop} 1.1887 + ${EndUnless} 1.1888 + 1.1889 + GetTempFileName $2 "$0" 1.1890 + Delete $2 1.1891 + CreateDirectory "$2" 1.1892 + ${If} ${FileExists} "$2" 1.1893 + ${If} ${FileExists} "$INSTDIR" 1.1894 + GetTempFileName $3 "$INSTDIR" 1.1895 + ${Else} 1.1896 + GetTempFileName $3 "$2" 1.1897 + ${EndIf} 1.1898 + ${If} ${FileExists} "$3" 1.1899 + Delete "$3" 1.1900 + StrCpy $CanWriteToInstallDir "true" 1.1901 + ${EndIf} 1.1902 + RmDir "$2" 1.1903 + ${EndIf} 1.1904 +FunctionEnd 1.1905 + 1.1906 +Function AddQuickLaunchShortcut 1.1907 + CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" 1.1908 + ${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk" 1.1909 + ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandFullName}.lnk" \ 1.1910 + "$INSTDIR" 1.1911 + ${EndIf} 1.1912 +FunctionEnd 1.1913 + 1.1914 +Function ExecSetAsDefaultAppUser 1.1915 + ; Using the helper.exe lessens the stub installer size. 1.1916 + ; This could ask for elevatation when the user doesn't install as admin. 1.1917 + Exec "$\"$INSTDIR\uninstall\helper.exe$\" /SetAsDefaultAppUser" 1.1918 +FunctionEnd 1.1919 + 1.1920 +Function LaunchApp 1.1921 + FindWindow $0 "${WindowClass}" 1.1922 + ${If} $0 <> 0 ; integer comparison 1.1923 + StrCpy $FirefoxLaunchCode "1" 1.1924 + MessageBox MB_OK|MB_ICONQUESTION "$(WARN_MANUALLY_CLOSE_APP_LAUNCH)" 1.1925 + Return 1.1926 + ${EndIf} 1.1927 + 1.1928 + StrCpy $FirefoxLaunchCode "2" 1.1929 + 1.1930 + ; Set the current working directory to the installation directory 1.1931 + SetOutPath "$INSTDIR" 1.1932 + ClearErrors 1.1933 + ${GetParameters} $0 1.1934 + ${GetOptions} "$0" "/UAC:" $1 1.1935 + ${If} ${Errors} 1.1936 + Exec "$\"$INSTDIR\${FileMainEXE}$\"" 1.1937 + ${Else} 1.1938 + GetFunctionAddress $0 LaunchAppFromElevatedProcess 1.1939 + UAC::ExecCodeSegment $0 1.1940 + ${EndIf} 1.1941 +FunctionEnd 1.1942 + 1.1943 +Function LaunchAppFromElevatedProcess 1.1944 + ; Find the installation directory when launching using GetFunctionAddress 1.1945 + ; from an elevated installer since $INSTDIR will not be set in this installer 1.1946 + ${StrFilter} "${FileMainEXE}" "+" "" "" $R9 1.1947 + ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" "" 1.1948 + ${GetPathFromString} "$0" $0 1.1949 + ; Set the current working directory to the installation directory 1.1950 + ${GetParent} "$0" $1 1.1951 + SetOutPath "$1" 1.1952 + Exec "$\"$0$\"" 1.1953 +FunctionEnd 1.1954 + 1.1955 +Function DisplayDownloadError 1.1956 + ${NSD_KillTimer} DisplayDownloadError 1.1957 + MessageBox MB_OKCANCEL|MB_ICONSTOP "$(ERROR_DOWNLOAD)" IDCANCEL +2 IDOK +1 1.1958 + StrCpy $OpenedDownloadPage "1" ; Already initialized to 0 1.1959 + 1.1960 + ${If} "$OpenedDownloadPage" == "1" 1.1961 + ClearErrors 1.1962 + ${GetParameters} $0 1.1963 + ${GetOptions} "$0" "/UAC:" $1 1.1964 + ${If} ${Errors} 1.1965 + Call OpenManualDownloadURL 1.1966 + ${Else} 1.1967 + GetFunctionAddress $0 OpenManualDownloadURL 1.1968 + UAC::ExecCodeSegment $0 1.1969 + ${EndIf} 1.1970 + ${EndIf} 1.1971 + 1.1972 + Call SendPing 1.1973 +FunctionEnd 1.1974 + 1.1975 +Function OpenManualDownloadURL 1.1976 + ExecShell "open" "${URLManualDownload}${URLManualDownloadAppend}" 1.1977 +FunctionEnd 1.1978 + 1.1979 +Section 1.1980 +SectionEnd