browser/installer/windows/nsis/stub.nsi

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4
michael@0 5 # Required Plugins:
michael@0 6 # AppAssocReg
michael@0 7 # CertCheck
michael@0 8 # InetBgDL
michael@0 9 # ShellLink
michael@0 10 # UAC
michael@0 11
michael@0 12 ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
michael@0 13 !verbose 3
michael@0 14
michael@0 15 SetDatablockOptimize on
michael@0 16 SetCompress off
michael@0 17 CRCCheck on
michael@0 18
michael@0 19 RequestExecutionLevel user
michael@0 20
michael@0 21 ; The commands inside this ifdef require NSIS 3.0a2 or greater so the ifdef can
michael@0 22 ; be removed after we require NSIS 3.0a2 or greater.
michael@0 23 !ifdef NSIS_PACKEDVERSION
michael@0 24 Unicode true
michael@0 25 ManifestSupportedOS all
michael@0 26 ManifestDPIAware true
michael@0 27 !endif
michael@0 28
michael@0 29 !addplugindir ./
michael@0 30
michael@0 31 Var Dialog
michael@0 32 Var Progressbar
michael@0 33 Var ProgressbarMarqueeIntervalMS
michael@0 34 Var LabelDownloading
michael@0 35 Var LabelInstalling
michael@0 36 Var LabelFreeSpace
michael@0 37 Var CheckboxSetAsDefault
michael@0 38 Var CheckboxShortcutOnBar ; Used for Quicklaunch or Taskbar as appropriate
michael@0 39 Var CheckboxShortcutInStartMenu
michael@0 40 Var CheckboxShortcutOnDesktop
michael@0 41 Var CheckboxSendPing
michael@0 42 Var CheckboxInstallMaintSvc
michael@0 43 Var DirRequest
michael@0 44 Var ButtonBrowse
michael@0 45 Var LabelBlurb1
michael@0 46 Var LabelBlurb2
michael@0 47 Var LabelBlurb3
michael@0 48 Var BitmapBlurb1
michael@0 49 Var BitmapBlurb2
michael@0 50 Var BitmapBlurb3
michael@0 51 Var HwndBitmapBlurb1
michael@0 52 Var HwndBitmapBlurb2
michael@0 53 Var HWndBitmapBlurb3
michael@0 54
michael@0 55 Var FontNormal
michael@0 56 Var FontItalic
michael@0 57 Var FontBlurb
michael@0 58
michael@0 59 Var WasOptionsButtonClicked
michael@0 60 Var CanWriteToInstallDir
michael@0 61 Var HasRequiredSpaceAvailable
michael@0 62 Var IsDownloadFinished
michael@0 63 Var DownloadSizeBytes
michael@0 64 Var HalfOfDownload
michael@0 65 Var DownloadReset
michael@0 66 Var ExistingTopDir
michael@0 67 Var SpaceAvailableBytes
michael@0 68 Var InitialInstallDir
michael@0 69 Var HandleDownload
michael@0 70 Var CanSetAsDefault
michael@0 71 Var InstallCounterStep
michael@0 72 Var InstallStepSize
michael@0 73 Var InstallTotalSteps
michael@0 74 Var TmpVal
michael@0 75
michael@0 76 Var ExitCode
michael@0 77 Var FirefoxLaunchCode
michael@0 78
michael@0 79 ; The first three tick counts are for the start of a phase and equate equate to
michael@0 80 ; the display of individual installer pages.
michael@0 81 Var StartIntroPhaseTickCount
michael@0 82 Var StartOptionsPhaseTickCount
michael@0 83 Var StartDownloadPhaseTickCount
michael@0 84 ; Since the Intro and Options pages can be displayed multiple times the total
michael@0 85 ; seconds spent on each of these pages is reported.
michael@0 86 Var IntroPhaseSeconds
michael@0 87 Var OptionsPhaseSeconds
michael@0 88 ; The tick count for the last download.
michael@0 89 Var StartLastDownloadTickCount
michael@0 90 ; The number of seconds from the start of the download phase until the first
michael@0 91 ; bytes are received. This is only recorded for first request so it is possible
michael@0 92 ; to determine connection issues for the first request.
michael@0 93 Var DownloadFirstTransferSeconds
michael@0 94 ; The last four tick counts are for the end of a phase in the installation page.
michael@0 95 Var EndDownloadPhaseTickCount
michael@0 96 Var EndPreInstallPhaseTickCount
michael@0 97 Var EndInstallPhaseTickCount
michael@0 98 Var EndFinishPhaseTickCount
michael@0 99
michael@0 100 Var InitialInstallRequirementsCode
michael@0 101 Var ExistingProfile
michael@0 102 Var ExistingVersion
michael@0 103 Var ExistingBuildID
michael@0 104 Var DownloadedBytes
michael@0 105 Var DownloadRetryCount
michael@0 106 Var OpenedDownloadPage
michael@0 107 Var DownloadServerIP
michael@0 108
michael@0 109 Var ControlHeightPX
michael@0 110 Var ControlRightPX
michael@0 111
michael@0 112 ; Uncomment the following to prevent pinging the metrics server when testing
michael@0 113 ; the stub installer
michael@0 114 ;!define STUB_DEBUG
michael@0 115
michael@0 116 !define StubURLVersion "v6"
michael@0 117
michael@0 118 ; Successful install exit code
michael@0 119 !define ERR_SUCCESS 0
michael@0 120
michael@0 121 /**
michael@0 122 * The following errors prefixed with ERR_DOWNLOAD apply to the download phase.
michael@0 123 */
michael@0 124 ; The download was cancelled by the user
michael@0 125 !define ERR_DOWNLOAD_CANCEL 10
michael@0 126
michael@0 127 ; Too many attempts to download. The maximum attempts is defined in
michael@0 128 ; DownloadMaxRetries.
michael@0 129 !define ERR_DOWNLOAD_TOO_MANY_RETRIES 11
michael@0 130
michael@0 131 /**
michael@0 132 * The following errors prefixed with ERR_PREINSTALL apply to the pre-install
michael@0 133 * check phase.
michael@0 134 */
michael@0 135 ; Unable to acquire a file handle to the downloaded file
michael@0 136 !define ERR_PREINSTALL_INVALID_HANDLE 20
michael@0 137
michael@0 138 ; The downloaded file's certificate is not trusted by the certificate store.
michael@0 139 !define ERR_PREINSTALL_CERT_UNTRUSTED 21
michael@0 140
michael@0 141 ; The downloaded file's certificate attribute values were incorrect.
michael@0 142 !define ERR_PREINSTALL_CERT_ATTRIBUTES 22
michael@0 143
michael@0 144 ; The downloaded file's certificate is not trusted by the certificate store and
michael@0 145 ; certificate attribute values were incorrect.
michael@0 146 !define ERR_PREINSTALL_CERT_UNTRUSTED_AND_ATTRIBUTES 23
michael@0 147
michael@0 148 /**
michael@0 149 * The following errors prefixed with ERR_INSTALL apply to the install phase.
michael@0 150 */
michael@0 151 ; The installation timed out. The installation timeout is defined by the number
michael@0 152 ; of progress steps defined in InstallTotalSteps and the install timer
michael@0 153 ; interval defined in InstallIntervalMS
michael@0 154 !define ERR_INSTALL_TIMEOUT 30
michael@0 155
michael@0 156 ; Maximum times to retry the download before displaying an error
michael@0 157 !define DownloadMaxRetries 9
michael@0 158
michael@0 159 ; Minimum size expected to download in bytes
michael@0 160 !define DownloadMinSizeBytes 15728640 ; 15 MB
michael@0 161
michael@0 162 ; Maximum size expected to download in bytes
michael@0 163 !define DownloadMaxSizeBytes 36700160 ; 35 MB
michael@0 164
michael@0 165 ; Interval before retrying to download. 3 seconds is used along with 10
michael@0 166 ; attempted downloads (the first attempt along with 9 retries) to give a
michael@0 167 ; minimum of 30 seconds or retrying before giving up.
michael@0 168 !define DownloadRetryIntervalMS 3000
michael@0 169
michael@0 170 ; Interval for the download timer
michael@0 171 !define DownloadIntervalMS 200
michael@0 172
michael@0 173 ; Interval for the install timer
michael@0 174 !define InstallIntervalMS 100
michael@0 175
michael@0 176 ; The first step for the install progress bar. By starting with a large step
michael@0 177 ; immediate feedback is given to the user.
michael@0 178 !define InstallProgressFirstStep 20
michael@0 179
michael@0 180 ; The finish step size to quickly increment the progress bar after the
michael@0 181 ; installation has finished.
michael@0 182 !define InstallProgressFinishStep 40
michael@0 183
michael@0 184 ; Number of steps for the install progress.
michael@0 185 ; This might not be enough when installing on a slow network drive so it will
michael@0 186 ; fallback to downloading the full installer if it reaches this number. The size
michael@0 187 ; of the install progress step is increased when the full installer finishes
michael@0 188 ; instead of waiting.
michael@0 189
michael@0 190 ; Approximately 150 seconds with a 100 millisecond timer and a first step of 20
michael@0 191 ; as defined by InstallProgressFirstStep.
michael@0 192 !define /math InstallCleanTotalSteps ${InstallProgressFirstStep} + 1500
michael@0 193
michael@0 194 ; Approximately 165 seconds (minus 0.2 seconds for each file that is removed)
michael@0 195 ; with a 100 millisecond timer and a first step of 20 as defined by
michael@0 196 ; InstallProgressFirstStep .
michael@0 197 !define /math InstallPaveOverTotalSteps ${InstallProgressFirstStep} + 1800
michael@0 198
michael@0 199 ; On Vista and above attempt to elevate Standard Users in addition to users that
michael@0 200 ; are a member of the Administrators group.
michael@0 201 !define NONADMIN_ELEVATE
michael@0 202
michael@0 203 !define CONFIG_INI "config.ini"
michael@0 204
michael@0 205 !ifndef FILE_SHARE_READ
michael@0 206 !define FILE_SHARE_READ 1
michael@0 207 !endif
michael@0 208 !ifndef GENERIC_READ
michael@0 209 !define GENERIC_READ 0x80000000
michael@0 210 !endif
michael@0 211 !ifndef OPEN_EXISTING
michael@0 212 !define OPEN_EXISTING 3
michael@0 213 !endif
michael@0 214 !ifndef INVALID_HANDLE_VALUE
michael@0 215 !define INVALID_HANDLE_VALUE -1
michael@0 216 !endif
michael@0 217
michael@0 218 !include "nsDialogs.nsh"
michael@0 219 !include "LogicLib.nsh"
michael@0 220 !include "FileFunc.nsh"
michael@0 221 !include "WinVer.nsh"
michael@0 222 !include "WordFunc.nsh"
michael@0 223
michael@0 224 !insertmacro GetParameters
michael@0 225 !insertmacro GetOptions
michael@0 226 !insertmacro StrFilter
michael@0 227
michael@0 228 !include "locales.nsi"
michael@0 229 !include "branding.nsi"
michael@0 230
michael@0 231 !include "defines.nsi"
michael@0 232
michael@0 233 ; Must be included after defines.nsi
michael@0 234 !include "locale-fonts.nsh"
michael@0 235
michael@0 236 ; The OFFICIAL define is a workaround to support different urls for Release and
michael@0 237 ; Beta since they share the same branding when building with other branches that
michael@0 238 ; set the update channel to beta.
michael@0 239 !ifdef OFFICIAL
michael@0 240 !ifdef BETA_UPDATE_CHANNEL
michael@0 241 !undef URLStubDownload
michael@0 242 !define URLStubDownload "http://download.mozilla.org/?os=win&lang=${AB_CD}&product=firefox-beta-latest"
michael@0 243 !undef URLManualDownload
michael@0 244 !define URLManualDownload "https://www.mozilla.org/${AB_CD}/firefox/installer-help/?channel=beta&installer_lang=${AB_CD}"
michael@0 245 !undef Channel
michael@0 246 !define Channel "beta"
michael@0 247 !endif
michael@0 248 !endif
michael@0 249
michael@0 250 !include "common.nsh"
michael@0 251
michael@0 252 !insertmacro ElevateUAC
michael@0 253 !insertmacro GetLongPath
michael@0 254 !insertmacro GetPathFromString
michael@0 255 !insertmacro GetParent
michael@0 256 !insertmacro GetSingleInstallPath
michael@0 257 !insertmacro GetTextWidthHeight
michael@0 258 !insertmacro IsUserAdmin
michael@0 259 !insertmacro OnStubInstallUninstall
michael@0 260 !insertmacro SetBrandNameVars
michael@0 261 !insertmacro UnloadUAC
michael@0 262
michael@0 263 VIAddVersionKey "FileDescription" "${BrandShortName} Stub Installer"
michael@0 264 VIAddVersionKey "OriginalFilename" "setup-stub.exe"
michael@0 265
michael@0 266 Name "$BrandFullName"
michael@0 267 OutFile "setup-stub.exe"
michael@0 268 icon "setup.ico"
michael@0 269 XPStyle on
michael@0 270 BrandingText " "
michael@0 271 ChangeUI all "nsisui.exe"
michael@0 272 !ifdef HAVE_64BIT_OS
michael@0 273 InstallDir "$PROGRAMFILES64\${BrandFullName}\"
michael@0 274 !else
michael@0 275 InstallDir "$PROGRAMFILES32\${BrandFullName}\"
michael@0 276 !endif
michael@0 277
michael@0 278 !ifdef ${AB_CD}_rtl
michael@0 279 LoadLanguageFile "locale-rtl.nlf"
michael@0 280 !else
michael@0 281 LoadLanguageFile "locale.nlf"
michael@0 282 !endif
michael@0 283
michael@0 284 !include "nsisstrings.nlf"
michael@0 285
michael@0 286 !if "${AB_CD}" == "en-US"
michael@0 287 ; Custom strings for en-US. This is done here so they aren't translated.
michael@0 288 !include oneoff_en-US.nsh
michael@0 289 !else
michael@0 290 !define INTRO_BLURB "$(INTRO_BLURB1)"
michael@0 291 !define INSTALL_BLURB1 "$(INSTALL_BLURB1)"
michael@0 292 !define INSTALL_BLURB2 "$(INSTALL_BLURB2)"
michael@0 293 !define INSTALL_BLURB3 "$(INSTALL_BLURB3)"
michael@0 294 !endif
michael@0 295
michael@0 296 Caption "$(WIN_CAPTION)"
michael@0 297
michael@0 298 Page custom createDummy ; Needed to enable the Intro page's back button
michael@0 299 Page custom createIntro leaveIntro ; Introduction page
michael@0 300 Page custom createOptions leaveOptions ; Options page
michael@0 301 Page custom createInstall ; Download / Installation page
michael@0 302
michael@0 303 Function .onInit
michael@0 304 ; Remove the current exe directory from the search order.
michael@0 305 ; This only effects LoadLibrary calls and not implicitly loaded DLLs.
michael@0 306 System::Call 'kernel32::SetDllDirectoryW(w "")'
michael@0 307
michael@0 308 StrCpy $LANGUAGE 0
michael@0 309 ; This macro is used to set the brand name variables but the ini file method
michael@0 310 ; isn't supported for the stub installer.
michael@0 311 ${SetBrandNameVars} "$PLUGINSDIR\ignored.ini"
michael@0 312
michael@0 313 !ifdef HAVE_64BIT_OS
michael@0 314 ; Restrict x64 builds from being installed on x86 and pre Vista
michael@0 315 ${Unless} ${RunningX64}
michael@0 316 ${OrUnless} ${AtLeastWinVista}
michael@0 317 MessageBox MB_OK|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_OS_MSG)"
michael@0 318 Quit
michael@0 319 ${EndUnless}
michael@0 320
michael@0 321 SetRegView 64
michael@0 322 !else
michael@0 323 StrCpy $R8 "0"
michael@0 324 ${If} ${AtMostWin2000}
michael@0 325 StrCpy $R8 "1"
michael@0 326 ${EndIf}
michael@0 327
michael@0 328 ${If} ${IsWinXP}
michael@0 329 ${AndIf} ${AtMostServicePack} 1
michael@0 330 StrCpy $R8 "1"
michael@0 331 ${EndIf}
michael@0 332
michael@0 333 ${If} $R8 == "1"
michael@0 334 ; XXX-rstrong - some systems failed the AtLeastWin2000 test that we
michael@0 335 ; used to use for an unknown reason and likely fail the AtMostWin2000
michael@0 336 ; and possibly the IsWinXP test as well. To work around this also
michael@0 337 ; check if the Windows NT registry Key exists and if it does if the
michael@0 338 ; first char in CurrentVersion is equal to 3 (Windows NT 3.5 and
michael@0 339 ; 3.5.1), 4 (Windows NT 4), or 5 (Windows 2000 and Windows XP).
michael@0 340 StrCpy $R8 ""
michael@0 341 ClearErrors
michael@0 342 ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
michael@0 343 StrCpy $R8 "$R8" 1
michael@0 344 ${If} ${Errors}
michael@0 345 ${OrIf} "$R8" == "3"
michael@0 346 ${OrIf} "$R8" == "4"
michael@0 347 ${OrIf} "$R8" == "5"
michael@0 348 MessageBox MB_OK|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_OS_MSG)"
michael@0 349 Quit
michael@0 350 ${EndIf}
michael@0 351 ${EndUnless}
michael@0 352 !endif
michael@0 353
michael@0 354 ; Require elevation if the user can elevate
michael@0 355 ${ElevateUAC}
michael@0 356
michael@0 357 ; The commands inside this ifndef are needed prior to NSIS 3.0a2 and can be
michael@0 358 ; removed after we require NSIS 3.0a2 or greater.
michael@0 359 !ifndef NSIS_PACKEDVERSION
michael@0 360 ${If} ${AtLeastWinVista}
michael@0 361 System::Call 'user32::SetProcessDPIAware()'
michael@0 362 ${EndIf}
michael@0 363 !endif
michael@0 364
michael@0 365 SetShellVarContext all ; Set SHCTX to HKLM
michael@0 366 ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
michael@0 367
michael@0 368 ${If} "$R9" == "false"
michael@0 369 SetShellVarContext current ; Set SHCTX to HKCU
michael@0 370 ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
michael@0 371 ${EndIf}
michael@0 372
michael@0 373 ${If} "$R9" != "false"
michael@0 374 StrCpy $INSTDIR "$R9"
michael@0 375 ${EndIf}
michael@0 376
michael@0 377 ; Used to determine if the default installation directory was used.
michael@0 378 StrCpy $InitialInstallDir "$INSTDIR"
michael@0 379
michael@0 380 ClearErrors
michael@0 381 WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" \
michael@0 382 "Write Test"
michael@0 383
michael@0 384 ; Only display set as default when there is write access to HKLM and on Win7
michael@0 385 ; and below.
michael@0 386 ${If} ${Errors}
michael@0 387 ${OrIf} ${AtLeastWin8}
michael@0 388 StrCpy $CanSetAsDefault "false"
michael@0 389 StrCpy $CheckboxSetAsDefault "0"
michael@0 390 ${Else}
michael@0 391 DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
michael@0 392 StrCpy $CanSetAsDefault "true"
michael@0 393 ${EndIf}
michael@0 394
michael@0 395 ; The interval in MS used for the progress bars set as marquee.
michael@0 396 ${If} ${AtLeastWinVista}
michael@0 397 StrCpy $ProgressbarMarqueeIntervalMS "10"
michael@0 398 ${Else}
michael@0 399 StrCpy $ProgressbarMarqueeIntervalMS "50"
michael@0 400 ${EndIf}
michael@0 401
michael@0 402 ; Initialize the majority of variables except those that need to be reset
michael@0 403 ; when a page is displayed.
michael@0 404 StrCpy $IntroPhaseSeconds "0"
michael@0 405 StrCpy $OptionsPhaseSeconds "0"
michael@0 406 StrCpy $EndPreInstallPhaseTickCount "0"
michael@0 407 StrCpy $EndInstallPhaseTickCount "0"
michael@0 408 StrCpy $InitialInstallRequirementsCode ""
michael@0 409 StrCpy $IsDownloadFinished ""
michael@0 410 StrCpy $FirefoxLaunchCode "0"
michael@0 411 StrCpy $CheckboxShortcutOnBar "1"
michael@0 412 StrCpy $CheckboxShortcutInStartMenu "1"
michael@0 413 StrCpy $CheckboxShortcutOnDesktop "1"
michael@0 414 StrCpy $CheckboxSendPing "1"
michael@0 415 !ifdef MOZ_MAINTENANCE_SERVICE
michael@0 416 StrCpy $CheckboxInstallMaintSvc "1"
michael@0 417 !else
michael@0 418 StrCpy $CheckboxInstallMaintSvc "0"
michael@0 419 !endif
michael@0 420 StrCpy $WasOptionsButtonClicked "0"
michael@0 421
michael@0 422 StrCpy $0 ""
michael@0 423 !ifdef FONT_FILE1
michael@0 424 ${If} ${FileExists} "$FONTS\${FONT_FILE1}"
michael@0 425 StrCpy $0 "${FONT_NAME1}"
michael@0 426 ${EndIf}
michael@0 427 !endif
michael@0 428
michael@0 429 !ifdef FONT_FILE2
michael@0 430 ${If} $0 == ""
michael@0 431 ${AndIf} ${FileExists} "$FONTS\${FONT_FILE2}"
michael@0 432 StrCpy $0 "${FONT_NAME2}"
michael@0 433 ${EndIf}
michael@0 434 !endif
michael@0 435
michael@0 436 ${If} $0 == ""
michael@0 437 StrCpy $0 "$(^Font)"
michael@0 438 ${EndIf}
michael@0 439
michael@0 440 CreateFont $FontBlurb "$0" "12" "500"
michael@0 441 CreateFont $FontNormal "$0" "11" "500"
michael@0 442 CreateFont $FontItalic "$0" "11" "500" /ITALIC
michael@0 443
michael@0 444 InitPluginsDir
michael@0 445 File /oname=$PLUGINSDIR\bgintro.bmp "bgintro.bmp"
michael@0 446 File /oname=$PLUGINSDIR\appname.bmp "appname.bmp"
michael@0 447 File /oname=$PLUGINSDIR\clock.bmp "clock.bmp"
michael@0 448 File /oname=$PLUGINSDIR\particles.bmp "particles.bmp"
michael@0 449 !ifdef ${AB_CD}_rtl
michael@0 450 ; The horizontally flipped pencil looks better in RTL
michael@0 451 File /oname=$PLUGINSDIR\pencil.bmp "pencil-rtl.bmp"
michael@0 452 !else
michael@0 453 File /oname=$PLUGINSDIR\pencil.bmp "pencil.bmp"
michael@0 454 !endif
michael@0 455 FunctionEnd
michael@0 456
michael@0 457 ; .onGUIInit isn't needed except for RTL locales
michael@0 458 !ifdef ${AB_CD}_rtl
michael@0 459 Function .onGUIInit
michael@0 460 ; Since NSIS RTL support doesn't mirror progress bars use Windows mirroring.
michael@0 461 ${NSD_AddExStyle} $HWNDPARENT ${WS_EX_LAYOUTRTL}
michael@0 462 ${RemoveExStyle} $HWNDPARENT ${WS_EX_RTLREADING}
michael@0 463 ${RemoveExStyle} $HWNDPARENT ${WS_EX_RIGHT}
michael@0 464 ${NSD_AddExStyle} $HWNDPARENT ${WS_EX_LEFT}|${WS_EX_LTRREADING}
michael@0 465 FunctionEnd
michael@0 466 !endif
michael@0 467
michael@0 468 Function .onGUIEnd
michael@0 469 Delete "$PLUGINSDIR\_temp"
michael@0 470 Delete "$PLUGINSDIR\download.exe"
michael@0 471 Delete "$PLUGINSDIR\${CONFIG_INI}"
michael@0 472
michael@0 473 ${UnloadUAC}
michael@0 474 FunctionEnd
michael@0 475
michael@0 476 Function .onUserAbort
michael@0 477 ${NSD_KillTimer} StartDownload
michael@0 478 ${NSD_KillTimer} OnDownload
michael@0 479 ${NSD_KillTimer} CheckInstall
michael@0 480 ${NSD_KillTimer} FinishInstall
michael@0 481 ${NSD_KillTimer} FinishProgressBar
michael@0 482 ${NSD_KillTimer} DisplayDownloadError
michael@0 483
michael@0 484 ${If} "$IsDownloadFinished" != ""
michael@0 485 Call DisplayDownloadError
michael@0 486 ; Aborting the abort will allow SendPing which is called by
michael@0 487 ; DisplayDownloadError to hide the installer window and close the installer
michael@0 488 ; after it sends the metrics ping.
michael@0 489 Abort
michael@0 490 ${EndIf}
michael@0 491 FunctionEnd
michael@0 492
michael@0 493 Function SendPing
michael@0 494 HideWindow
michael@0 495 ; Try to send a ping if a download was attempted
michael@0 496 ${If} $CheckboxSendPing == 1
michael@0 497 ${AndIf} $IsDownloadFinished != ""
michael@0 498 ; Get the tick count for the completion of all phases.
michael@0 499 System::Call "kernel32::GetTickCount()l .s"
michael@0 500 Pop $EndFinishPhaseTickCount
michael@0 501
michael@0 502 ; When the value of $IsDownloadFinished is false the download was started
michael@0 503 ; but didn't finish. In this case the tick count stored in
michael@0 504 ; $EndFinishPhaseTickCount is used to determine how long the download was
michael@0 505 ; in progress.
michael@0 506 ${If} "$IsDownloadFinished" == "false"
michael@0 507 ${OrIf} "$EndDownloadPhaseTickCount" == ""
michael@0 508 StrCpy $EndDownloadPhaseTickCount "$EndFinishPhaseTickCount"
michael@0 509 ; Cancel the download in progress
michael@0 510 InetBgDL::Get /RESET /END
michael@0 511 ${EndIf}
michael@0 512
michael@0 513
michael@0 514 ; When $DownloadFirstTransferSeconds equals an empty string the download
michael@0 515 ; never successfully started so set the value to 0. It will be possible to
michael@0 516 ; determine that the download didn't successfully start from the seconds for
michael@0 517 ; the last download.
michael@0 518 ${If} "$DownloadFirstTransferSeconds" == ""
michael@0 519 StrCpy $DownloadFirstTransferSeconds "0"
michael@0 520 ${EndIf}
michael@0 521
michael@0 522 ; When $StartLastDownloadTickCount equals an empty string the download never
michael@0 523 ; successfully started so set the value to $EndDownloadPhaseTickCount to
michael@0 524 ; compute the correct value.
michael@0 525 ${If} $StartLastDownloadTickCount == ""
michael@0 526 ; This could happen if the download never successfully starts
michael@0 527 StrCpy $StartLastDownloadTickCount "$EndDownloadPhaseTickCount"
michael@0 528 ${EndIf}
michael@0 529
michael@0 530 ; When $EndPreInstallPhaseTickCount equals 0 the installation phase was
michael@0 531 ; never completed so set its value to $EndFinishPhaseTickCount to compute
michael@0 532 ; the correct value.
michael@0 533 ${If} "$EndPreInstallPhaseTickCount" == "0"
michael@0 534 StrCpy $EndPreInstallPhaseTickCount "$EndFinishPhaseTickCount"
michael@0 535 ${EndIf}
michael@0 536
michael@0 537 ; When $EndInstallPhaseTickCount equals 0 the installation phase was never
michael@0 538 ; completed so set its value to $EndFinishPhaseTickCount to compute the
michael@0 539 ; correct value.
michael@0 540 ${If} "$EndInstallPhaseTickCount" == "0"
michael@0 541 StrCpy $EndInstallPhaseTickCount "$EndFinishPhaseTickCount"
michael@0 542 ${EndIf}
michael@0 543
michael@0 544 ; Get the seconds elapsed from the start of the download phase to the end of
michael@0 545 ; the download phase.
michael@0 546 ${GetSecondsElapsed} "$StartDownloadPhaseTickCount" "$EndDownloadPhaseTickCount" $0
michael@0 547
michael@0 548 ; Get the seconds elapsed from the start of the last download to the end of
michael@0 549 ; the last download.
michael@0 550 ${GetSecondsElapsed} "$StartLastDownloadTickCount" "$EndDownloadPhaseTickCount" $1
michael@0 551
michael@0 552 ; Get the seconds elapsed from the end of the download phase to the
michael@0 553 ; completion of the pre-installation check phase.
michael@0 554 ${GetSecondsElapsed} "$EndDownloadPhaseTickCount" "$EndPreInstallPhaseTickCount" $2
michael@0 555
michael@0 556 ; Get the seconds elapsed from the end of the pre-installation check phase
michael@0 557 ; to the completion of the installation phase.
michael@0 558 ${GetSecondsElapsed} "$EndPreInstallPhaseTickCount" "$EndInstallPhaseTickCount" $3
michael@0 559
michael@0 560 ; Get the seconds elapsed from the end of the installation phase to the
michael@0 561 ; completion of all phases.
michael@0 562 ${GetSecondsElapsed} "$EndInstallPhaseTickCount" "$EndFinishPhaseTickCount" $4
michael@0 563
michael@0 564 !ifdef HAVE_64BIT_OS
michael@0 565 StrCpy $R0 "1"
michael@0 566 !else
michael@0 567 StrCpy $R0 "0"
michael@0 568 !endif
michael@0 569
michael@0 570 ${If} ${RunningX64}
michael@0 571 StrCpy $R1 "1"
michael@0 572 ${Else}
michael@0 573 StrCpy $R1 "0"
michael@0 574 ${EndIf}
michael@0 575
michael@0 576 ; Though these values are sometimes incorrect due to bug 444664 it happens
michael@0 577 ; so rarely it isn't worth working around it by reading the registry values.
michael@0 578 ${WinVerGetMajor} $5
michael@0 579 ${WinVerGetMinor} $6
michael@0 580 ${WinVerGetBuild} $7
michael@0 581 ${WinVerGetServicePackLevel} $8
michael@0 582 ${If} ${IsServerOS}
michael@0 583 StrCpy $9 "1"
michael@0 584 ${Else}
michael@0 585 StrCpy $9 "0"
michael@0 586 ${EndIf}
michael@0 587
michael@0 588 ${If} "$ExitCode" == "${ERR_SUCCESS}"
michael@0 589 ReadINIStr $R5 "$INSTDIR\application.ini" "App" "Version"
michael@0 590 ReadINIStr $R6 "$INSTDIR\application.ini" "App" "BuildID"
michael@0 591 ${Else}
michael@0 592 StrCpy $R5 "0"
michael@0 593 StrCpy $R6 "0"
michael@0 594 ${EndIf}
michael@0 595
michael@0 596 ; Whether installed into the default installation directory
michael@0 597 ${GetLongPath} "$INSTDIR" $R7
michael@0 598 ${GetLongPath} "$InitialInstallDir" $R8
michael@0 599 ${If} "$R7" == "$R8"
michael@0 600 StrCpy $R7 "1"
michael@0 601 ${Else}
michael@0 602 StrCpy $R7 "0"
michael@0 603 ${EndIf}
michael@0 604
michael@0 605 ClearErrors
michael@0 606 WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" \
michael@0 607 "Write Test"
michael@0 608 ${If} ${Errors}
michael@0 609 StrCpy $R8 "0"
michael@0 610 ${Else}
michael@0 611 DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
michael@0 612 StrCpy $R8 "1"
michael@0 613 ${EndIf}
michael@0 614
michael@0 615 ${If} "$DownloadServerIP" == ""
michael@0 616 StrCpy $DownloadServerIP "Unknown"
michael@0 617 ${EndIf}
michael@0 618
michael@0 619 StrCpy $R2 ""
michael@0 620 SetShellVarContext current ; Set SHCTX to the current user
michael@0 621 ReadRegStr $R2 HKCU "Software\Classes\http\shell\open\command" ""
michael@0 622 ${If} $R2 != ""
michael@0 623 ${GetPathFromString} "$R2" $R2
michael@0 624 ${GetParent} "$R2" $R3
michael@0 625 ${GetLongPath} "$R3" $R3
michael@0 626 ${If} $R3 == $INSTDIR
michael@0 627 StrCpy $R2 "1" ; This Firefox install is set as default.
michael@0 628 ${Else}
michael@0 629 StrCpy $R2 "$R2" "" -11 # length of firefox.exe
michael@0 630 ${If} "$R2" == "${FileMainEXE}"
michael@0 631 StrCpy $R2 "2" ; Another Firefox install is set as default.
michael@0 632 ${Else}
michael@0 633 StrCpy $R2 "0"
michael@0 634 ${EndIf}
michael@0 635 ${EndIf}
michael@0 636 ${Else}
michael@0 637 StrCpy $R2 "0" ; Firefox is not set as default.
michael@0 638 ${EndIf}
michael@0 639
michael@0 640 ${If} "$R2" == "0"
michael@0 641 ${AndIf} ${AtLeastWinVista}
michael@0 642 ; Check to see if this install location is currently set as the default
michael@0 643 ; browser by Default Programs which is only available on Vista and above.
michael@0 644 ClearErrors
michael@0 645 ReadRegStr $R3 HKLM "Software\RegisteredApplications" "${AppRegName}"
michael@0 646 ${Unless} ${Errors}
michael@0 647 AppAssocReg::QueryAppIsDefaultAll "${AppRegName}" "effective"
michael@0 648 Pop $R3
michael@0 649 ${If} $R3 == "1"
michael@0 650 StrCpy $R3 ""
michael@0 651 ReadRegStr $R2 HKLM "Software\Classes\http\shell\open\command" ""
michael@0 652 ${If} $R2 != ""
michael@0 653 ${GetPathFromString} "$R2" $R2
michael@0 654 ${GetParent} "$R2" $R3
michael@0 655 ${GetLongPath} "$R3" $R3
michael@0 656 ${If} $R3 == $INSTDIR
michael@0 657 StrCpy $R2 "1" ; This Firefox install is set as default.
michael@0 658 ${Else}
michael@0 659 StrCpy $R2 "$R2" "" -11 # length of firefox.exe
michael@0 660 ${If} "$R2" == "${FileMainEXE}"
michael@0 661 StrCpy $R2 "2" ; Another Firefox install is set as default.
michael@0 662 ${Else}
michael@0 663 StrCpy $R2 "0"
michael@0 664 ${EndIf}
michael@0 665 ${EndIf}
michael@0 666 ${Else}
michael@0 667 StrCpy $R2 "0" ; Firefox is not set as default.
michael@0 668 ${EndIf}
michael@0 669 ${EndIf}
michael@0 670 ${EndUnless}
michael@0 671 ${EndIf}
michael@0 672
michael@0 673 ${If} $CanSetAsDefault == "true"
michael@0 674 ${If} $CheckboxSetAsDefault == "1"
michael@0 675 StrCpy $R3 "2"
michael@0 676 ${Else}
michael@0 677 StrCpy $R3 "3"
michael@0 678 ${EndIf}
michael@0 679 ${Else}
michael@0 680 ${If} ${AtLeastWin8}
michael@0 681 StrCpy $R3 "1"
michael@0 682 ${Else}
michael@0 683 StrCpy $R3 "0"
michael@0 684 ${EndIf}
michael@0 685 ${EndIf}
michael@0 686
michael@0 687 !ifdef STUB_DEBUG
michael@0 688 MessageBox MB_OK "${BaseURLStubPing} \
michael@0 689 $\nStub URL Version = ${StubURLVersion}${StubURLVersionAppend} \
michael@0 690 $\nBuild Channel = ${Channel} \
michael@0 691 $\nUpdate Channel = ${UpdateChannel} \
michael@0 692 $\nLocale = ${AB_CD} \
michael@0 693 $\nFirefox x64 = $R0 \
michael@0 694 $\nRunning x64 Windows = $R1 \
michael@0 695 $\nMajor = $5 \
michael@0 696 $\nMinor = $6 \
michael@0 697 $\nBuild = $7 \
michael@0 698 $\nServicePack = $8 \
michael@0 699 $\nIsServer = $9 \
michael@0 700 $\nExit Code = $ExitCode \
michael@0 701 $\nFirefox Launch Code = $FirefoxLaunchCode \
michael@0 702 $\nDownload Retry Count = $DownloadRetryCount \
michael@0 703 $\nDownloaded Bytes = $DownloadedBytes \
michael@0 704 $\nDownload Size Bytes = $DownloadSizeBytes \
michael@0 705 $\nIntroduction Phase Seconds = $IntroPhaseSeconds \
michael@0 706 $\nOptions Phase Seconds = $OptionsPhaseSeconds \
michael@0 707 $\nDownload Phase Seconds = $0 \
michael@0 708 $\nLast Download Seconds = $1 \
michael@0 709 $\nDownload First Transfer Seconds = $DownloadFirstTransferSeconds \
michael@0 710 $\nPreinstall Phase Seconds = $2 \
michael@0 711 $\nInstall Phase Seconds = $3 \
michael@0 712 $\nFinish Phase Seconds = $4 \
michael@0 713 $\nInitial Install Requirements Code = $InitialInstallRequirementsCode \
michael@0 714 $\nOpened Download Page = $OpenedDownloadPage \
michael@0 715 $\nExisting Profile = $ExistingProfile \
michael@0 716 $\nExisting Version = $ExistingVersion \
michael@0 717 $\nExisting Build ID = $ExistingBuildID \
michael@0 718 $\nNew Version = $R5 \
michael@0 719 $\nNew Build ID = $R6 \
michael@0 720 $\nDefault Install Dir = $R7 \
michael@0 721 $\nHas Admin = $R8 \
michael@0 722 $\nDefault Status = $R2 \
michael@0 723 $\nSet As Sefault Status = $R3 \
michael@0 724 $\nDownload Server IP = $DownloadServerIP"
michael@0 725 ; The following will exit the installer
michael@0 726 SetAutoClose true
michael@0 727 StrCpy $R9 "2"
michael@0 728 Call RelativeGotoPage
michael@0 729 !else
michael@0 730 ${NSD_CreateTimer} OnPing ${DownloadIntervalMS}
michael@0 731 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" \
michael@0 732 "$PLUGINSDIR\_temp" /END
michael@0 733 !endif
michael@0 734 ${Else}
michael@0 735 ${If} "$IsDownloadFinished" == "false"
michael@0 736 ; Cancel the download in progress
michael@0 737 InetBgDL::Get /RESET /END
michael@0 738 ${EndIf}
michael@0 739 ; The following will exit the installer
michael@0 740 SetAutoClose true
michael@0 741 StrCpy $R9 "2"
michael@0 742 Call RelativeGotoPage
michael@0 743 ${EndIf}
michael@0 744 FunctionEnd
michael@0 745
michael@0 746 Function createDummy
michael@0 747 FunctionEnd
michael@0 748
michael@0 749 Function createIntro
michael@0 750 nsDialogs::Create /NOUNLOAD 1018
michael@0 751 Pop $Dialog
michael@0 752
michael@0 753 GetFunctionAddress $0 OnBack
michael@0 754 nsDialogs::OnBack /NOUNLOAD $0
michael@0 755
michael@0 756 !ifdef ${AB_CD}_rtl
michael@0 757 ; For RTL align the text with the top of the F in the Firefox bitmap
michael@0 758 StrCpy $0 "${INTRO_BLURB_RTL_TOP_DU}"
michael@0 759 !else
michael@0 760 ; For LTR align the text with the top of the x in the Firefox bitmap
michael@0 761 StrCpy $0 "${INTRO_BLURB_LTR_TOP_DU}"
michael@0 762 !endif
michael@0 763 ${NSD_CreateLabel} ${INTRO_BLURB_EDGE_DU} $0 ${INTRO_BLURB_WIDTH_DU} 76u "${INTRO_BLURB}"
michael@0 764 Pop $0
michael@0 765 SendMessage $0 ${WM_SETFONT} $FontBlurb 0
michael@0 766 SetCtlColors $0 ${INTRO_BLURB_TEXT_COLOR} transparent
michael@0 767
michael@0 768 SetCtlColors $HWNDPARENT ${FOOTER_CONTROL_TEXT_COLOR_NORMAL} ${FOOTER_BKGRD_COLOR}
michael@0 769 GetDlgItem $0 $HWNDPARENT 10 ; Default browser checkbox
michael@0 770 ${If} "$CanSetAsDefault" == "true"
michael@0 771 ; The uxtheme must be disabled on checkboxes in order to override the
michael@0 772 ; system font color.
michael@0 773 System::Call 'uxtheme::SetWindowTheme(i $0 , w " ", w " ")'
michael@0 774 SendMessage $0 ${WM_SETFONT} $FontNormal 0
michael@0 775 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(MAKE_DEFAULT)"
michael@0 776 SendMessage $0 ${BM_SETCHECK} 1 0
michael@0 777 SetCtlColors $0 ${FOOTER_CONTROL_TEXT_COLOR_NORMAL} ${FOOTER_BKGRD_COLOR}
michael@0 778 ${Else}
michael@0 779 ShowWindow $0 ${SW_HIDE}
michael@0 780 ${EndIf}
michael@0 781 GetDlgItem $0 $HWNDPARENT 11
michael@0 782 ShowWindow $0 ${SW_HIDE}
michael@0 783
michael@0 784 ${NSD_CreateBitmap} ${APPNAME_BMP_EDGE_DU} ${APPNAME_BMP_TOP_DU} \
michael@0 785 ${APPNAME_BMP_WIDTH_DU} ${APPNAME_BMP_HEIGHT_DU} ""
michael@0 786 Pop $2
michael@0 787 ${SetStretchedTransparentImage} $2 $PLUGINSDIR\appname.bmp $0
michael@0 788
michael@0 789 ${NSD_CreateBitmap} 0 0 100% 100% ""
michael@0 790 Pop $2
michael@0 791 ${NSD_SetStretchedImage} $2 $PLUGINSDIR\bgintro.bmp $1
michael@0 792
michael@0 793 GetDlgItem $0 $HWNDPARENT 1 ; Install button
michael@0 794 ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
michael@0 795 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(UPGRADE_BUTTON)"
michael@0 796 ${Else}
michael@0 797 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(INSTALL_BUTTON)"
michael@0 798 ${EndIf}
michael@0 799 ${NSD_SetFocus} $0
michael@0 800
michael@0 801 GetDlgItem $0 $HWNDPARENT 2 ; Cancel button
michael@0 802 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(CANCEL_BUTTON)"
michael@0 803
michael@0 804 GetDlgItem $0 $HWNDPARENT 3 ; Back button used for Options
michael@0 805 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(OPTIONS_BUTTON)"
michael@0 806
michael@0 807 System::Call "kernel32::GetTickCount()l .s"
michael@0 808 Pop $StartIntroPhaseTickCount
michael@0 809
michael@0 810 LockWindow off
michael@0 811 nsDialogs::Show
michael@0 812
michael@0 813 ${NSD_FreeImage} $0
michael@0 814 ${NSD_FreeImage} $1
michael@0 815 FunctionEnd
michael@0 816
michael@0 817 Function leaveIntro
michael@0 818 LockWindow on
michael@0 819
michael@0 820 System::Call "kernel32::GetTickCount()l .s"
michael@0 821 Pop $0
michael@0 822 ${GetSecondsElapsed} "$StartIntroPhaseTickCount" "$0" $IntroPhaseSeconds
michael@0 823 ; It is possible for this value to be 0 if the user clicks fast enough so
michael@0 824 ; increment the value by 1 if it is 0.
michael@0 825 ${If} $IntroPhaseSeconds == 0
michael@0 826 IntOp $IntroPhaseSeconds $IntroPhaseSeconds + 1
michael@0 827 ${EndIf}
michael@0 828
michael@0 829 SetShellVarContext all ; Set SHCTX to All Users
michael@0 830 ; If the user doesn't have write access to the installation directory set
michael@0 831 ; the installation directory to a subdirectory of the All Users application
michael@0 832 ; directory and if the user can't write to that location set the installation
michael@0 833 ; directory to a subdirectory of the users local application directory
michael@0 834 ; (e.g. non-roaming).
michael@0 835 Call CanWrite
michael@0 836 ${If} "$CanWriteToInstallDir" == "false"
michael@0 837 StrCpy $INSTDIR "$APPDATA\${BrandFullName}\"
michael@0 838 Call CanWrite
michael@0 839 ${If} "$CanWriteToInstallDir" == "false"
michael@0 840 ; This should never happen but just in case.
michael@0 841 StrCpy $CanWriteToInstallDir "false"
michael@0 842 ${Else}
michael@0 843 StrCpy $INSTDIR "$LOCALAPPDATA\${BrandFullName}\"
michael@0 844 Call CanWrite
michael@0 845 ${EndIf}
michael@0 846 ${EndIf}
michael@0 847
michael@0 848 Call CheckSpace
michael@0 849
michael@0 850 ${If} ${FileExists} "$INSTDIR"
michael@0 851 ; Always display the long path if the path exists.
michael@0 852 ${GetLongPath} "$INSTDIR" $INSTDIR
michael@0 853 ${EndIf}
michael@0 854
michael@0 855 FunctionEnd
michael@0 856
michael@0 857 Function createOptions
michael@0 858 ; Check whether the install requirements are satisfied using the default
michael@0 859 ; values for metrics.
michael@0 860 ${If} "$InitialInstallRequirementsCode" == ""
michael@0 861 ${If} "$CanWriteToInstallDir" != "true"
michael@0 862 ${AndIf} "$HasRequiredSpaceAvailable" != "true"
michael@0 863 StrCpy $InitialInstallRequirementsCode "1"
michael@0 864 ${ElseIf} "$CanWriteToInstallDir" != "true"
michael@0 865 StrCpy $InitialInstallRequirementsCode "2"
michael@0 866 ${ElseIf} "$HasRequiredSpaceAvailable" != "true"
michael@0 867 StrCpy $InitialInstallRequirementsCode "3"
michael@0 868 ${Else}
michael@0 869 StrCpy $InitialInstallRequirementsCode "0"
michael@0 870 ${EndIf}
michael@0 871 ${EndIf}
michael@0 872
michael@0 873 ; Skip the options page unless the Options button was clicked as long as the
michael@0 874 ; installation directory can be written to and there is the minimum required
michael@0 875 ; space available.
michael@0 876 ${If} "$WasOptionsButtonClicked" != "1"
michael@0 877 ${If} "$CanWriteToInstallDir" == "true"
michael@0 878 ${AndIf} "$HasRequiredSpaceAvailable" == "true"
michael@0 879 Abort ; Skip the options page
michael@0 880 ${EndIf}
michael@0 881 ${EndIf}
michael@0 882
michael@0 883 StrCpy $ExistingTopDir ""
michael@0 884
michael@0 885 nsDialogs::Create /NOUNLOAD 1018
michael@0 886 Pop $Dialog
michael@0 887 ; Since the text color for controls is set in this Dialog the foreground and
michael@0 888 ; background colors of the Dialog must also be hardcoded.
michael@0 889 SetCtlColors $Dialog ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 890
michael@0 891 ${NSD_CreateLabel} ${OPTIONS_ITEM_EDGE_DU} 18u ${OPTIONS_ITEM_WIDTH_DU} \
michael@0 892 12u "$(CREATE_SHORTCUTS)"
michael@0 893 Pop $0
michael@0 894 SetCtlColors $0 ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 895 SendMessage $0 ${WM_SETFONT} $FontNormal 0
michael@0 896
michael@0 897 ${If} ${AtLeastWin7}
michael@0 898 StrCpy $0 "$(ADD_SC_TASKBAR)"
michael@0 899 ${Else}
michael@0 900 StrCpy $0 "$(ADD_SC_QUICKLAUNCHBAR)"
michael@0 901 ${EndIf}
michael@0 902 ${NSD_CreateCheckbox} ${OPTIONS_SUBITEM_EDGE_DU} 38u \
michael@0 903 ${OPTIONS_SUBITEM_WIDTH_DU} 12u "$0"
michael@0 904 Pop $CheckboxShortcutOnBar
michael@0 905 ; The uxtheme must be disabled on checkboxes in order to override the system
michael@0 906 ; font color.
michael@0 907 System::Call 'uxtheme::SetWindowTheme(i $CheckboxShortcutOnBar, w " ", w " ")'
michael@0 908 SetCtlColors $CheckboxShortcutOnBar ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 909 SendMessage $CheckboxShortcutOnBar ${WM_SETFONT} $FontNormal 0
michael@0 910 ${NSD_Check} $CheckboxShortcutOnBar
michael@0 911
michael@0 912 ${NSD_CreateCheckbox} ${OPTIONS_SUBITEM_EDGE_DU} 54u ${OPTIONS_SUBITEM_WIDTH_DU} \
michael@0 913 12u "$(ADD_CheckboxShortcutInStartMenu)"
michael@0 914 Pop $CheckboxShortcutInStartMenu
michael@0 915 ; The uxtheme must be disabled on checkboxes in order to override the system
michael@0 916 ; font color.
michael@0 917 System::Call 'uxtheme::SetWindowTheme(i $CheckboxShortcutInStartMenu, w " ", w " ")'
michael@0 918 SetCtlColors $CheckboxShortcutInStartMenu ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 919 SendMessage $CheckboxShortcutInStartMenu ${WM_SETFONT} $FontNormal 0
michael@0 920 ${NSD_Check} $CheckboxShortcutInStartMenu
michael@0 921
michael@0 922 ${NSD_CreateCheckbox} ${OPTIONS_SUBITEM_EDGE_DU} 70u ${OPTIONS_SUBITEM_WIDTH_DU} \
michael@0 923 12u "$(ADD_CheckboxShortcutOnDesktop)"
michael@0 924 Pop $CheckboxShortcutOnDesktop
michael@0 925 ; The uxtheme must be disabled on checkboxes in order to override the system
michael@0 926 ; font color.
michael@0 927 System::Call 'uxtheme::SetWindowTheme(i $CheckboxShortcutOnDesktop, w " ", w " ")'
michael@0 928 SetCtlColors $CheckboxShortcutOnDesktop ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 929 SendMessage $CheckboxShortcutOnDesktop ${WM_SETFONT} $FontNormal 0
michael@0 930 ${NSD_Check} $CheckboxShortcutOnDesktop
michael@0 931
michael@0 932 ${NSD_CreateLabel} ${OPTIONS_ITEM_EDGE_DU} 100u ${OPTIONS_ITEM_WIDTH_DU} \
michael@0 933 12u "$(DEST_FOLDER)"
michael@0 934 Pop $0
michael@0 935 SetCtlColors $0 ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 936 SendMessage $0 ${WM_SETFONT} $FontNormal 0
michael@0 937
michael@0 938 ${NSD_CreateDirRequest} ${OPTIONS_SUBITEM_EDGE_DU} 116u 159u 14u "$INSTDIR"
michael@0 939 Pop $DirRequest
michael@0 940 SetCtlColors $DirRequest ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 941 SendMessage $DirRequest ${WM_SETFONT} $FontNormal 0
michael@0 942 System::Call shlwapi::SHAutoComplete(i $DirRequest, i ${SHACF_FILESYSTEM})
michael@0 943 ${NSD_OnChange} $DirRequest OnChange_DirRequest
michael@0 944
michael@0 945 !ifdef ${AB_CD}_rtl
michael@0 946 ; Remove the RTL styling from the directory request text box
michael@0 947 ${RemoveStyle} $DirRequest ${SS_RIGHT}
michael@0 948 ${RemoveExStyle} $DirRequest ${WS_EX_RIGHT}
michael@0 949 ${RemoveExStyle} $DirRequest ${WS_EX_RTLREADING}
michael@0 950 ${NSD_AddStyle} $DirRequest ${SS_LEFT}
michael@0 951 ${NSD_AddExStyle} $DirRequest ${WS_EX_LTRREADING}|${WS_EX_LEFT}
michael@0 952 !endif
michael@0 953
michael@0 954 ${NSD_CreateBrowseButton} 280u 116u 50u 14u "$(BROWSE_BUTTON)"
michael@0 955 Pop $ButtonBrowse
michael@0 956 SetCtlColors $ButtonBrowse "" ${COMMON_BKGRD_COLOR}
michael@0 957 ${NSD_OnClick} $ButtonBrowse OnClick_ButtonBrowse
michael@0 958
michael@0 959 ; Get the number of pixels from the left of the Dialog to the right side of
michael@0 960 ; the "Space Required:" and "Space Available:" labels prior to setting RTL so
michael@0 961 ; the correct position of the controls can be set by NSIS for RTL locales.
michael@0 962
michael@0 963 ; Get the width and height of both labels and use the tallest for the height
michael@0 964 ; and the widest to calculate where to place the labels after these labels.
michael@0 965 ${GetTextExtent} "$(SPACE_REQUIRED)" $FontItalic $0 $1
michael@0 966 ${GetTextExtent} "$(SPACE_AVAILABLE)" $FontItalic $2 $3
michael@0 967 ${If} $1 > $3
michael@0 968 StrCpy $ControlHeightPX "$1"
michael@0 969 ${Else}
michael@0 970 StrCpy $ControlHeightPX "$3"
michael@0 971 ${EndIf}
michael@0 972
michael@0 973 IntOp $0 $0 + 8 ; Add padding to the control's width
michael@0 974 ; Make both controls the same width as the widest control
michael@0 975 ${NSD_CreateLabelCenter} ${OPTIONS_SUBITEM_EDGE_DU} 134u $0 $ControlHeightPX "$(SPACE_REQUIRED)"
michael@0 976 Pop $5
michael@0 977 SetCtlColors $5 ${COMMON_TEXT_COLOR_FADED} ${COMMON_BKGRD_COLOR}
michael@0 978 SendMessage $5 ${WM_SETFONT} $FontItalic 0
michael@0 979
michael@0 980 IntOp $2 $2 + 8 ; Add padding to the control's width
michael@0 981 ${NSD_CreateLabelCenter} ${OPTIONS_SUBITEM_EDGE_DU} 145u $2 $ControlHeightPX "$(SPACE_AVAILABLE)"
michael@0 982 Pop $6
michael@0 983 SetCtlColors $6 ${COMMON_TEXT_COLOR_FADED} ${COMMON_BKGRD_COLOR}
michael@0 984 SendMessage $6 ${WM_SETFONT} $FontItalic 0
michael@0 985
michael@0 986 ; Use the widest label for aligning the labels next to them
michael@0 987 ${If} $0 > $2
michael@0 988 StrCpy $6 "$5"
michael@0 989 ${EndIf}
michael@0 990 FindWindow $1 "#32770" "" $HWNDPARENT
michael@0 991 ${GetDlgItemEndPX} $6 $ControlRightPX
michael@0 992
michael@0 993 IntOp $ControlRightPX $ControlRightPX + 6
michael@0 994
michael@0 995 ${NSD_CreateLabel} $ControlRightPX 134u 100% $ControlHeightPX \
michael@0 996 "${APPROXIMATE_REQUIRED_SPACE_MB} $(MEGA)$(BYTE)"
michael@0 997 Pop $7
michael@0 998 SetCtlColors $7 ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 999 SendMessage $7 ${WM_SETFONT} $FontNormal 0
michael@0 1000
michael@0 1001 ; Create the free space label with an empty string and update it by calling
michael@0 1002 ; UpdateFreeSpaceLabel
michael@0 1003 ${NSD_CreateLabel} $ControlRightPX 145u 100% $ControlHeightPX " "
michael@0 1004 Pop $LabelFreeSpace
michael@0 1005 SetCtlColors $LabelFreeSpace ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 1006 SendMessage $LabelFreeSpace ${WM_SETFONT} $FontNormal 0
michael@0 1007
michael@0 1008 Call UpdateFreeSpaceLabel
michael@0 1009
michael@0 1010 ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} 168u ${OPTIONS_SUBITEM_WIDTH_DU} \
michael@0 1011 12u "$(SEND_PING)"
michael@0 1012 Pop $CheckboxSendPing
michael@0 1013 ; The uxtheme must be disabled on checkboxes in order to override the system
michael@0 1014 ; font color.
michael@0 1015 System::Call 'uxtheme::SetWindowTheme(i $CheckboxSendPing, w " ", w " ")'
michael@0 1016 SetCtlColors $CheckboxSendPing ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 1017 SendMessage $CheckboxSendPing ${WM_SETFONT} $FontNormal 0
michael@0 1018 ${NSD_Check} $CheckboxSendPing
michael@0 1019
michael@0 1020 !ifdef MOZ_MAINTENANCE_SERVICE
michael@0 1021 ; Only show the maintenance service checkbox if we have write access to HKLM
michael@0 1022 Call IsUserAdmin
michael@0 1023 Pop $0
michael@0 1024 ClearErrors
michael@0 1025 WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" \
michael@0 1026 "Write Test"
michael@0 1027 ${If} ${Errors}
michael@0 1028 ${OrIf} $0 != "true"
michael@0 1029 StrCpy $CheckboxInstallMaintSvc "0"
michael@0 1030 ${Else}
michael@0 1031 DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
michael@0 1032 ; Read the registry instead of using ServicesHelper::IsInstalled so the
michael@0 1033 ; plugin isn't included in the stub installer to lessen its size.
michael@0 1034 ClearErrors
michael@0 1035 ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\services\MozillaMaintenance" "ImagePath"
michael@0 1036 ${If} ${Errors}
michael@0 1037 ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} 184u ${OPTIONS_ITEM_WIDTH_DU} \
michael@0 1038 12u "$(INSTALL_MAINT_SERVICE)"
michael@0 1039 Pop $CheckboxInstallMaintSvc
michael@0 1040 System::Call 'uxtheme::SetWindowTheme(i $CheckboxInstallMaintSvc, w " ", w " ")'
michael@0 1041 SetCtlColors $CheckboxInstallMaintSvc ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 1042 SendMessage $CheckboxInstallMaintSvc ${WM_SETFONT} $FontNormal 0
michael@0 1043 ${NSD_Check} $CheckboxInstallMaintSvc
michael@0 1044 ${EndIf}
michael@0 1045 ${EndIf}
michael@0 1046 !endif
michael@0 1047
michael@0 1048 GetDlgItem $0 $HWNDPARENT 1 ; Install button
michael@0 1049 ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
michael@0 1050 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(UPGRADE_BUTTON)"
michael@0 1051 ${Else}
michael@0 1052 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(INSTALL_BUTTON)"
michael@0 1053 ${EndIf}
michael@0 1054 ${NSD_SetFocus} $0
michael@0 1055
michael@0 1056 GetDlgItem $0 $HWNDPARENT 2 ; Cancel button
michael@0 1057 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(CANCEL_BUTTON)"
michael@0 1058
michael@0 1059 GetDlgItem $0 $HWNDPARENT 3 ; Back button used for Options
michael@0 1060 EnableWindow $0 0
michael@0 1061 ShowWindow $0 ${SW_HIDE}
michael@0 1062
michael@0 1063 ; If the option button was not clicked display the reason for what needs to be
michael@0 1064 ; resolved to continue the installation.
michael@0 1065 ${If} "$WasOptionsButtonClicked" != "1"
michael@0 1066 ${If} "$CanWriteToInstallDir" == "false"
michael@0 1067 MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_WRITE_ACCESS)"
michael@0 1068 ${ElseIf} "$HasRequiredSpaceAvailable" == "false"
michael@0 1069 MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_DISK_SPACE)"
michael@0 1070 ${EndIf}
michael@0 1071 ${EndIf}
michael@0 1072
michael@0 1073 System::Call "kernel32::GetTickCount()l .s"
michael@0 1074 Pop $StartOptionsPhaseTickCount
michael@0 1075
michael@0 1076 LockWindow off
michael@0 1077 nsDialogs::Show
michael@0 1078 FunctionEnd
michael@0 1079
michael@0 1080 Function leaveOptions
michael@0 1081 LockWindow on
michael@0 1082
michael@0 1083 ${GetRoot} "$INSTDIR" $0
michael@0 1084 ${GetLongPath} "$INSTDIR" $INSTDIR
michael@0 1085 ${GetLongPath} "$0" $0
michael@0 1086 ${If} "$INSTDIR" == "$0"
michael@0 1087 LockWindow off
michael@0 1088 MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_ROOT_INSTALL)"
michael@0 1089 Abort ; Stay on the page
michael@0 1090 ${EndIf}
michael@0 1091
michael@0 1092 Call CanWrite
michael@0 1093 ${If} "$CanWriteToInstallDir" == "false"
michael@0 1094 LockWindow off
michael@0 1095 MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_WRITE_ACCESS)"
michael@0 1096 Abort ; Stay on the page
michael@0 1097 ${EndIf}
michael@0 1098
michael@0 1099 Call CheckSpace
michael@0 1100 ${If} "$HasRequiredSpaceAvailable" == "false"
michael@0 1101 LockWindow off
michael@0 1102 MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_DISK_SPACE)"
michael@0 1103 Abort ; Stay on the page
michael@0 1104 ${EndIf}
michael@0 1105
michael@0 1106 System::Call "kernel32::GetTickCount()l .s"
michael@0 1107 Pop $0
michael@0 1108 ${GetSecondsElapsed} "$StartOptionsPhaseTickCount" "$0" $OptionsPhaseSeconds
michael@0 1109 ; It is possible for this value to be 0 if the user clicks fast enough so
michael@0 1110 ; increment the value by 1 if it is 0.
michael@0 1111 ${If} $OptionsPhaseSeconds == 0
michael@0 1112 IntOp $OptionsPhaseSeconds $OptionsPhaseSeconds + 1
michael@0 1113 ${EndIf}
michael@0 1114
michael@0 1115 ${NSD_GetState} $CheckboxShortcutOnBar $CheckboxShortcutOnBar
michael@0 1116 ${NSD_GetState} $CheckboxShortcutInStartMenu $CheckboxShortcutInStartMenu
michael@0 1117 ${NSD_GetState} $CheckboxShortcutOnDesktop $CheckboxShortcutOnDesktop
michael@0 1118 ${NSD_GetState} $CheckboxSendPing $CheckboxSendPing
michael@0 1119 !ifdef MOZ_MAINTENANCE_SERVICE
michael@0 1120 ${NSD_GetState} $CheckboxInstallMaintSvc $CheckboxInstallMaintSvc
michael@0 1121 !endif
michael@0 1122
michael@0 1123 FunctionEnd
michael@0 1124
michael@0 1125 Function createInstall
michael@0 1126 nsDialogs::Create /NOUNLOAD 1018
michael@0 1127 Pop $Dialog
michael@0 1128 ; Since the text color for controls is set in this Dialog the foreground and
michael@0 1129 ; background colors of the Dialog must also be hardcoded.
michael@0 1130 SetCtlColors $Dialog ${COMMON_TEXT_COLOR_NORMAL} ${COMMON_BKGRD_COLOR}
michael@0 1131
michael@0 1132 ${NSD_CreateLabel} 0 0 49u 64u ""
michael@0 1133 Pop $0
michael@0 1134 ${GetDlgItemWidthHeight} $0 $1 $2
michael@0 1135 System::Call 'user32::DestroyWindow(i r0)'
michael@0 1136
michael@0 1137 ${NSD_CreateLabel} 0 0 11u 16u ""
michael@0 1138 Pop $0
michael@0 1139 ${GetDlgItemWidthHeight} $0 $3 $4
michael@0 1140 System::Call 'user32::DestroyWindow(i r0)'
michael@0 1141
michael@0 1142 FindWindow $7 "#32770" "" $HWNDPARENT
michael@0 1143 ${GetDlgItemWidthHeight} $7 $8 $9
michael@0 1144
michael@0 1145 ; Allow a maximum text width of half of the Dialog's width
michael@0 1146 IntOp $R0 $8 / 2
michael@0 1147
michael@0 1148 ${GetTextWidthHeight} "${INSTALL_BLURB1}" $FontBlurb $R0 $5 $6
michael@0 1149 IntOp $R1 $1 + $3
michael@0 1150 IntOp $R1 $R1 + $5
michael@0 1151 IntOp $R1 $8 - $R1
michael@0 1152 IntOp $R1 $R1 / 2
michael@0 1153 ${NSD_CreateBitmap} $R1 ${INSTALL_BLURB_TOP_DU} 49u 64u ""
michael@0 1154 Pop $BitmapBlurb1
michael@0 1155 ${SetStretchedTransparentImage} $BitmapBlurb1 $PLUGINSDIR\clock.bmp $HwndBitmapBlurb1
michael@0 1156 IntOp $R1 $R1 + $1
michael@0 1157 IntOp $R1 $R1 + $3
michael@0 1158 ${NSD_CreateLabel} $R1 ${INSTALL_BLURB_TOP_DU} $5 $6 "${INSTALL_BLURB1}"
michael@0 1159 Pop $LabelBlurb1
michael@0 1160 SendMessage $LabelBlurb1 ${WM_SETFONT} $FontBlurb 0
michael@0 1161 SetCtlColors $LabelBlurb1 ${INSTALL_BLURB_TEXT_COLOR} transparent
michael@0 1162
michael@0 1163 ${GetTextWidthHeight} "${INSTALL_BLURB2}" $FontBlurb $R0 $5 $6
michael@0 1164 IntOp $R1 $1 + $3
michael@0 1165 IntOp $R1 $R1 + $5
michael@0 1166 IntOp $R1 $8 - $R1
michael@0 1167 IntOp $R1 $R1 / 2
michael@0 1168 ${NSD_CreateBitmap} $R1 ${INSTALL_BLURB_TOP_DU} 49u 64u ""
michael@0 1169 Pop $BitmapBlurb2
michael@0 1170 ${SetStretchedTransparentImage} $BitmapBlurb2 $PLUGINSDIR\particles.bmp $HwndBitmapBlurb2
michael@0 1171 IntOp $R1 $R1 + $1
michael@0 1172 IntOp $R1 $R1 + $3
michael@0 1173 ${NSD_CreateLabel} $R1 ${INSTALL_BLURB_TOP_DU} $5 $6 "${INSTALL_BLURB2}"
michael@0 1174 Pop $LabelBlurb2
michael@0 1175 SendMessage $LabelBlurb2 ${WM_SETFONT} $FontBlurb 0
michael@0 1176 SetCtlColors $LabelBlurb2 ${INSTALL_BLURB_TEXT_COLOR} transparent
michael@0 1177 ShowWindow $BitmapBlurb2 ${SW_HIDE}
michael@0 1178 ShowWindow $LabelBlurb2 ${SW_HIDE}
michael@0 1179
michael@0 1180 ${GetTextWidthHeight} "${INSTALL_BLURB3}" $FontBlurb $R0 $5 $6
michael@0 1181 IntOp $R1 $1 + $3
michael@0 1182 IntOp $R1 $R1 + $5
michael@0 1183 IntOp $R1 $8 - $R1
michael@0 1184 IntOp $R1 $R1 / 2
michael@0 1185 ${NSD_CreateBitmap} $R1 ${INSTALL_BLURB_TOP_DU} 49u 64u ""
michael@0 1186 Pop $BitmapBlurb3
michael@0 1187 ${SetStretchedTransparentImage} $BitmapBlurb3 $PLUGINSDIR\pencil.bmp $HWndBitmapBlurb3
michael@0 1188 IntOp $R1 $R1 + $1
michael@0 1189 IntOp $R1 $R1 + $3
michael@0 1190 ${NSD_CreateLabel} $R1 ${INSTALL_BLURB_TOP_DU} $5 $6 "${INSTALL_BLURB3}"
michael@0 1191 Pop $LabelBlurb3
michael@0 1192 SendMessage $LabelBlurb3 ${WM_SETFONT} $FontBlurb 0
michael@0 1193 SetCtlColors $LabelBlurb3 ${INSTALL_BLURB_TEXT_COLOR} transparent
michael@0 1194 ShowWindow $BitmapBlurb3 ${SW_HIDE}
michael@0 1195 ShowWindow $LabelBlurb3 ${SW_HIDE}
michael@0 1196
michael@0 1197 ${NSD_CreateProgressBar} 103u 166u 241u 9u ""
michael@0 1198 Pop $Progressbar
michael@0 1199 ${NSD_AddStyle} $Progressbar ${PBS_MARQUEE}
michael@0 1200 SendMessage $Progressbar ${PBM_SETMARQUEE} 1 \
michael@0 1201 $ProgressbarMarqueeIntervalMS ; start=1|stop=0 interval(ms)=+N
michael@0 1202
michael@0 1203 ${NSD_CreateLabelCenter} 103u 180u 241u 20u "$(DOWNLOADING_LABEL)"
michael@0 1204 Pop $LabelDownloading
michael@0 1205 SendMessage $LabelDownloading ${WM_SETFONT} $FontNormal 0
michael@0 1206 SetCtlColors $LabelDownloading ${INSTALL_PROGRESS_TEXT_COLOR_NORMAL} transparent
michael@0 1207
michael@0 1208 ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
michael@0 1209 ${NSD_CreateLabelCenter} 103u 180u 241u 20u "$(UPGRADING_LABEL)"
michael@0 1210 ${Else}
michael@0 1211 ${NSD_CreateLabelCenter} 103u 180u 241u 20u "$(INSTALLING_LABEL)"
michael@0 1212 ${EndIf}
michael@0 1213 Pop $LabelInstalling
michael@0 1214 SendMessage $LabelInstalling ${WM_SETFONT} $FontNormal 0
michael@0 1215 SetCtlColors $LabelInstalling ${INSTALL_PROGRESS_TEXT_COLOR_NORMAL} transparent
michael@0 1216 ShowWindow $LabelInstalling ${SW_HIDE}
michael@0 1217
michael@0 1218 ${NSD_CreateBitmap} ${APPNAME_BMP_EDGE_DU} ${APPNAME_BMP_TOP_DU} \
michael@0 1219 ${APPNAME_BMP_WIDTH_DU} ${APPNAME_BMP_HEIGHT_DU} ""
michael@0 1220 Pop $2
michael@0 1221 ${SetStretchedTransparentImage} $2 $PLUGINSDIR\appname.bmp $0
michael@0 1222
michael@0 1223 GetDlgItem $0 $HWNDPARENT 1 ; Install button
michael@0 1224 EnableWindow $0 0
michael@0 1225 ShowWindow $0 ${SW_HIDE}
michael@0 1226
michael@0 1227 GetDlgItem $0 $HWNDPARENT 3 ; Back button used for Options
michael@0 1228 EnableWindow $0 0
michael@0 1229 ShowWindow $0 ${SW_HIDE}
michael@0 1230
michael@0 1231 GetDlgItem $0 $HWNDPARENT 2 ; Cancel button
michael@0 1232 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(CANCEL_BUTTON)"
michael@0 1233 ; Focus the Cancel button otherwise it isn't possible to tab to it since it is
michael@0 1234 ; the only control that can be tabbed to.
michael@0 1235 ${NSD_SetFocus} $0
michael@0 1236 ; Kill the Cancel button's focus so pressing enter won't cancel the install.
michael@0 1237 SendMessage $0 ${WM_KILLFOCUS} 0 0
michael@0 1238
michael@0 1239 ${If} "$CanSetAsDefault" == "true"
michael@0 1240 GetDlgItem $0 $HWNDPARENT 10 ; Default browser checkbox
michael@0 1241 SendMessage $0 ${BM_GETCHECK} 0 0 $CheckboxSetAsDefault
michael@0 1242 EnableWindow $0 0
michael@0 1243 ShowWindow $0 ${SW_HIDE}
michael@0 1244 ${EndIf}
michael@0 1245
michael@0 1246 GetDlgItem $0 $HWNDPARENT 11
michael@0 1247 ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
michael@0 1248 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(ONE_MOMENT_UPGRADE)"
michael@0 1249 ${Else}
michael@0 1250 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(ONE_MOMENT_INSTALL)"
michael@0 1251 ${EndIf}
michael@0 1252 SendMessage $0 ${WM_SETFONT} $FontNormal 0
michael@0 1253 SetCtlColors $0 ${FOOTER_CONTROL_TEXT_COLOR_FADED} ${FOOTER_BKGRD_COLOR}
michael@0 1254 ShowWindow $0 ${SW_SHOW}
michael@0 1255
michael@0 1256 ; Set $DownloadReset to true so the first download tick count is measured.
michael@0 1257 StrCpy $DownloadReset "true"
michael@0 1258 StrCpy $IsDownloadFinished "false"
michael@0 1259 StrCpy $DownloadRetryCount "0"
michael@0 1260 StrCpy $DownloadedBytes "0"
michael@0 1261 StrCpy $StartLastDownloadTickCount ""
michael@0 1262 StrCpy $EndDownloadPhaseTickCount ""
michael@0 1263 StrCpy $DownloadFirstTransferSeconds ""
michael@0 1264 StrCpy $ExitCode "${ERR_DOWNLOAD_CANCEL}"
michael@0 1265 StrCpy $OpenedDownloadPage "0"
michael@0 1266
michael@0 1267 ClearErrors
michael@0 1268 ReadINIStr $ExistingVersion "$INSTDIR\application.ini" "App" "Version"
michael@0 1269 ${If} ${Errors}
michael@0 1270 StrCpy $ExistingVersion "0"
michael@0 1271 ${EndIf}
michael@0 1272
michael@0 1273 ClearErrors
michael@0 1274 ReadINIStr $ExistingBuildID "$INSTDIR\application.ini" "App" "BuildID"
michael@0 1275 ${If} ${Errors}
michael@0 1276 StrCpy $ExistingBuildID "0"
michael@0 1277 ${EndIf}
michael@0 1278
michael@0 1279 ${If} ${FileExists} "$LOCALAPPDATA\Mozilla\Firefox"
michael@0 1280 StrCpy $ExistingProfile "1"
michael@0 1281 ${Else}
michael@0 1282 StrCpy $ExistingProfile "0"
michael@0 1283 ${EndIf}
michael@0 1284
michael@0 1285 StrCpy $DownloadServerIP ""
michael@0 1286
michael@0 1287 System::Call "kernel32::GetTickCount()l .s"
michael@0 1288 Pop $StartDownloadPhaseTickCount
michael@0 1289
michael@0 1290 ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.log"
michael@0 1291 StrCpy $InstallTotalSteps ${InstallPaveOverTotalSteps}
michael@0 1292 ${Else}
michael@0 1293 StrCpy $InstallTotalSteps ${InstallCleanTotalSteps}
michael@0 1294 ${EndIf}
michael@0 1295
michael@0 1296 ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS}
michael@0 1297
michael@0 1298 LockWindow off
michael@0 1299 nsDialogs::Show
michael@0 1300
michael@0 1301 ${NSD_FreeImage} $0
michael@0 1302 ${NSD_FreeImage} $HwndBitmapBlurb1
michael@0 1303 ${NSD_FreeImage} $HwndBitmapBlurb2
michael@0 1304 ${NSD_FreeImage} $HWndBitmapBlurb3
michael@0 1305 FunctionEnd
michael@0 1306
michael@0 1307 Function StartDownload
michael@0 1308 ${NSD_KillTimer} StartDownload
michael@0 1309 InetBgDL::Get "${URLStubDownload}${URLStubDownloadAppend}" "$PLUGINSDIR\download.exe" \
michael@0 1310 /CONNECTTIMEOUT 120 /RECEIVETIMEOUT 120 /END
michael@0 1311 StrCpy $4 ""
michael@0 1312 ${NSD_CreateTimer} OnDownload ${DownloadIntervalMS}
michael@0 1313 ${If} ${FileExists} "$INSTDIR\${TO_BE_DELETED}"
michael@0 1314 RmDir /r "$INSTDIR\${TO_BE_DELETED}"
michael@0 1315 ${EndIf}
michael@0 1316 FunctionEnd
michael@0 1317
michael@0 1318 Function OnDownload
michael@0 1319 InetBgDL::GetStats
michael@0 1320 # $0 = HTTP status code, 0=Completed
michael@0 1321 # $1 = Completed files
michael@0 1322 # $2 = Remaining files
michael@0 1323 # $3 = Number of downloaded bytes for the current file
michael@0 1324 # $4 = Size of current file (Empty string if the size is unknown)
michael@0 1325 # /RESET must be used if status $0 > 299 (e.g. failure)
michael@0 1326 # When status is $0 =< 299 it is handled by InetBgDL
michael@0 1327 StrCpy $DownloadServerIP "$5"
michael@0 1328 ${If} $0 > 299
michael@0 1329 ${NSD_KillTimer} OnDownload
michael@0 1330 IntOp $DownloadRetryCount $DownloadRetryCount + 1
michael@0 1331 ${If} "$DownloadReset" != "true"
michael@0 1332 StrCpy $DownloadedBytes "0"
michael@0 1333 ${NSD_AddStyle} $Progressbar ${PBS_MARQUEE}
michael@0 1334 SendMessage $Progressbar ${PBM_SETMARQUEE} 1 \
michael@0 1335 $ProgressbarMarqueeIntervalMS ; start=1|stop=0 interval(ms)=+N
michael@0 1336 ${EndIf}
michael@0 1337 InetBgDL::Get /RESET /END
michael@0 1338 StrCpy $DownloadSizeBytes ""
michael@0 1339 StrCpy $DownloadReset "true"
michael@0 1340
michael@0 1341 ${If} $DownloadRetryCount >= ${DownloadMaxRetries}
michael@0 1342 StrCpy $ExitCode "${ERR_DOWNLOAD_TOO_MANY_RETRIES}"
michael@0 1343 ; Use a timer so the UI has a chance to update
michael@0 1344 ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
michael@0 1345 ${Else}
michael@0 1346 ${NSD_CreateTimer} StartDownload ${DownloadRetryIntervalMS}
michael@0 1347 ${EndIf}
michael@0 1348 Return
michael@0 1349 ${EndIf}
michael@0 1350
michael@0 1351 ${If} "$DownloadReset" == "true"
michael@0 1352 System::Call "kernel32::GetTickCount()l .s"
michael@0 1353 Pop $StartLastDownloadTickCount
michael@0 1354 StrCpy $DownloadReset "false"
michael@0 1355 ; The seconds elapsed from the start of the download phase until the first
michael@0 1356 ; bytes are received are only recorded for the first request so it is
michael@0 1357 ; possible to determine connection issues for the first request.
michael@0 1358 ${If} "$DownloadFirstTransferSeconds" == ""
michael@0 1359 ; Get the seconds elapsed from the start of the download phase until the
michael@0 1360 ; first bytes are received.
michael@0 1361 ${GetSecondsElapsed} "$StartDownloadPhaseTickCount" "$StartLastDownloadTickCount" $DownloadFirstTransferSeconds
michael@0 1362 ${EndIf}
michael@0 1363 ${EndIf}
michael@0 1364
michael@0 1365 ${If} "$DownloadSizeBytes" == ""
michael@0 1366 ${AndIf} "$4" != ""
michael@0 1367 ; Handle the case where the size of the file to be downloaded is less than
michael@0 1368 ; the minimum expected size or greater than the maximum expected size at the
michael@0 1369 ; beginning of the download.
michael@0 1370 ${If} $4 < ${DownloadMinSizeBytes}
michael@0 1371 ${OrIf} $4 > ${DownloadMaxSizeBytes}
michael@0 1372 ${NSD_KillTimer} OnDownload
michael@0 1373 InetBgDL::Get /RESET /END
michael@0 1374 StrCpy $DownloadReset "true"
michael@0 1375
michael@0 1376 ${If} $DownloadRetryCount >= ${DownloadMaxRetries}
michael@0 1377 ; Use a timer so the UI has a chance to update
michael@0 1378 ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
michael@0 1379 ${Else}
michael@0 1380 ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS}
michael@0 1381 ${EndIf}
michael@0 1382 Return
michael@0 1383 ${EndIf}
michael@0 1384
michael@0 1385 StrCpy $DownloadSizeBytes "$4"
michael@0 1386 System::Int64Op $4 / 2
michael@0 1387 Pop $HalfOfDownload
michael@0 1388 System::Int64Op $HalfOfDownload / $InstallTotalSteps
michael@0 1389 Pop $InstallStepSize
michael@0 1390 SendMessage $Progressbar ${PBM_SETMARQUEE} 0 0 ; start=1|stop=0 interval(ms)=+N
michael@0 1391 ${RemoveStyle} $Progressbar ${PBS_MARQUEE}
michael@0 1392 System::Int64Op $HalfOfDownload + $DownloadSizeBytes
michael@0 1393 Pop $R9
michael@0 1394 SendMessage $Progressbar ${PBM_SETRANGE32} 0 $R9
michael@0 1395 ${EndIf}
michael@0 1396
michael@0 1397 ; Don't update the status until after the download starts
michael@0 1398 ${If} $2 != 0
michael@0 1399 ${AndIf} "$4" == ""
michael@0 1400 Return
michael@0 1401 ${EndIf}
michael@0 1402
michael@0 1403 ; Handle the case where the downloaded size is greater than the maximum
michael@0 1404 ; expected size during the download.
michael@0 1405 ${If} $DownloadedBytes > ${DownloadMaxSizeBytes}
michael@0 1406 InetBgDL::Get /RESET /END
michael@0 1407 StrCpy $DownloadReset "true"
michael@0 1408
michael@0 1409 ${If} $DownloadRetryCount >= ${DownloadMaxRetries}
michael@0 1410 ; Use a timer so the UI has a chance to update
michael@0 1411 ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
michael@0 1412 ${Else}
michael@0 1413 ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS}
michael@0 1414 ${EndIf}
michael@0 1415 Return
michael@0 1416 ${EndIf}
michael@0 1417
michael@0 1418 ${If} $IsDownloadFinished != "true"
michael@0 1419 ${If} $2 == 0
michael@0 1420 ${NSD_KillTimer} OnDownload
michael@0 1421 StrCpy $IsDownloadFinished "true"
michael@0 1422 ; The first step of the install progress bar is determined by the
michael@0 1423 ; InstallProgressFirstStep define and provides the user with immediate
michael@0 1424 ; feedback.
michael@0 1425 StrCpy $InstallCounterStep "${InstallProgressFirstStep}"
michael@0 1426 System::Call "kernel32::GetTickCount()l .s"
michael@0 1427 Pop $EndDownloadPhaseTickCount
michael@0 1428
michael@0 1429 StrCpy $DownloadedBytes "$DownloadSizeBytes"
michael@0 1430
michael@0 1431 ; When a download has finished handle the case where the downloaded size
michael@0 1432 ; is less than the minimum expected size or greater than the maximum
michael@0 1433 ; expected size during the download.
michael@0 1434 ${If} $DownloadedBytes < ${DownloadMinSizeBytes}
michael@0 1435 ${OrIf} $DownloadedBytes > ${DownloadMaxSizeBytes}
michael@0 1436 InetBgDL::Get /RESET /END
michael@0 1437 StrCpy $DownloadReset "true"
michael@0 1438
michael@0 1439 ${If} $DownloadRetryCount >= ${DownloadMaxRetries}
michael@0 1440 ; Use a timer so the UI has a chance to update
michael@0 1441 ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
michael@0 1442 ${Else}
michael@0 1443 ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS}
michael@0 1444 ${EndIf}
michael@0 1445 Return
michael@0 1446 ${EndIf}
michael@0 1447
michael@0 1448 LockWindow on
michael@0 1449 ; Update the progress bars first in the UI change so they take affect
michael@0 1450 ; before other UI changes.
michael@0 1451 SendMessage $Progressbar ${PBM_SETPOS} $DownloadSizeBytes 0
michael@0 1452 System::Int64Op $InstallStepSize * ${InstallProgressFirstStep}
michael@0 1453 Pop $R9
michael@0 1454 SendMessage $Progressbar ${PBM_SETSTEP} $R9 0
michael@0 1455 SendMessage $Progressbar ${PBM_STEPIT} 0 0
michael@0 1456 SendMessage $Progressbar ${PBM_SETSTEP} $InstallStepSize 0
michael@0 1457 ShowWindow $LabelDownloading ${SW_HIDE}
michael@0 1458 ShowWindow $LabelInstalling ${SW_SHOW}
michael@0 1459 ShowWindow $LabelBlurb2 ${SW_HIDE}
michael@0 1460 ShowWindow $BitmapBlurb2 ${SW_HIDE}
michael@0 1461 ShowWindow $LabelBlurb3 ${SW_SHOW}
michael@0 1462 ShowWindow $BitmapBlurb3 ${SW_SHOW}
michael@0 1463 ; Disable the Cancel button during the install
michael@0 1464 GetDlgItem $5 $HWNDPARENT 2
michael@0 1465 EnableWindow $5 0
michael@0 1466 LockWindow off
michael@0 1467
michael@0 1468 ; Open a handle to prevent modification of the full installer
michael@0 1469 StrCpy $R9 "${INVALID_HANDLE_VALUE}"
michael@0 1470 System::Call 'kernel32::CreateFileW(w "$PLUGINSDIR\download.exe", \
michael@0 1471 i ${GENERIC_READ}, \
michael@0 1472 i ${FILE_SHARE_READ}, i 0, \
michael@0 1473 i ${OPEN_EXISTING}, i 0, i 0) i .R9'
michael@0 1474 StrCpy $HandleDownload "$R9"
michael@0 1475
michael@0 1476 ${If} $HandleDownload == ${INVALID_HANDLE_VALUE}
michael@0 1477 StrCpy $ExitCode "${ERR_PREINSTALL_INVALID_HANDLE}"
michael@0 1478 StrCpy $0 "0"
michael@0 1479 StrCpy $1 "0"
michael@0 1480 ${Else}
michael@0 1481 CertCheck::VerifyCertTrust "$PLUGINSDIR\download.exe"
michael@0 1482 Pop $0
michael@0 1483 CertCheck::VerifyCertNameIssuer "$PLUGINSDIR\download.exe" \
michael@0 1484 "${CertNameDownload}" "${CertIssuerDownload}"
michael@0 1485 Pop $1
michael@0 1486 ${If} $0 == 0
michael@0 1487 ${AndIf} $1 == 0
michael@0 1488 StrCpy $ExitCode "${ERR_PREINSTALL_CERT_UNTRUSTED_AND_ATTRIBUTES}"
michael@0 1489 ${ElseIf} $0 == 0
michael@0 1490 StrCpy $ExitCode "${ERR_PREINSTALL_CERT_UNTRUSTED}"
michael@0 1491 ${ElseIf} $1 == 0
michael@0 1492 StrCpy $ExitCode "${ERR_PREINSTALL_CERT_ATTRIBUTES}"
michael@0 1493 ${EndIf}
michael@0 1494 ${EndIf}
michael@0 1495
michael@0 1496 System::Call "kernel32::GetTickCount()l .s"
michael@0 1497 Pop $EndPreInstallPhaseTickCount
michael@0 1498
michael@0 1499 ${If} $0 == 0
michael@0 1500 ${OrIf} $1 == 0
michael@0 1501 ; Use a timer so the UI has a chance to update
michael@0 1502 ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
michael@0 1503 Return
michael@0 1504 ${EndIf}
michael@0 1505
michael@0 1506 ; Instead of extracting the files we use the downloaded installer to
michael@0 1507 ; install in case it needs to perform operations that the stub doesn't
michael@0 1508 ; know about.
michael@0 1509 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "InstallDirectoryPath" "$INSTDIR"
michael@0 1510 ; Don't create the QuickLaunch or Taskbar shortcut from the launched installer
michael@0 1511 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "QuickLaunchShortcut" "false"
michael@0 1512 ${If} $CheckboxShortcutOnDesktop == 1
michael@0 1513 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "DesktopShortcut" "true"
michael@0 1514 ${Else}
michael@0 1515 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "DesktopShortcut" "false"
michael@0 1516 ${EndIf}
michael@0 1517
michael@0 1518 ${If} $CheckboxShortcutInStartMenu == 1
michael@0 1519 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "StartMenuShortcuts" "true"
michael@0 1520 ${Else}
michael@0 1521 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "StartMenuShortcuts" "false"
michael@0 1522 ${EndIf}
michael@0 1523
michael@0 1524 !ifdef MOZ_MAINTENANCE_SERVICE
michael@0 1525 ${If} $CheckboxInstallMaintSvc == 1
michael@0 1526 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "MaintenanceService" "true"
michael@0 1527 ${Else}
michael@0 1528 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "MaintenanceService" "false"
michael@0 1529 ${EndIf}
michael@0 1530 !else
michael@0 1531 WriteINIStr "$PLUGINSDIR\${CONFIG_INI}" "Install" "MaintenanceService" "false"
michael@0 1532 !endif
michael@0 1533
michael@0 1534 ; Write migrated to the shortcuts.ini file to prevent the installer
michael@0 1535 ; from creating a taskbar shortcut (Bug 791613).
michael@0 1536 ${GetShortcutsLogPath} $0
michael@0 1537 Delete "$0"
michael@0 1538 ; Workaround to prevent pinning to the taskbar.
michael@0 1539 ${If} $CheckboxShortcutOnBar == 0
michael@0 1540 WriteIniStr "$0" "TASKBAR" "Migrated" "true"
michael@0 1541 ${EndIf}
michael@0 1542
michael@0 1543 ${OnStubInstallUninstall} $Progressbar $InstallCounterStep
michael@0 1544
michael@0 1545 ; Delete the install.log and let the full installer create it. When the
michael@0 1546 ; installer closes it we can detect that it has completed.
michael@0 1547 Delete "$INSTDIR\install.log"
michael@0 1548
michael@0 1549 ; Delete firefox.exe.moz-upgrade if it exists since it being present will
michael@0 1550 ; require an OS restart for the full installer.
michael@0 1551 Delete "$INSTDIR\${FileMainEXE}.moz-upgrade"
michael@0 1552
michael@0 1553 System::Call "kernel32::GetTickCount()l .s"
michael@0 1554 Pop $EndPreInstallPhaseTickCount
michael@0 1555
michael@0 1556 Exec "$\"$PLUGINSDIR\download.exe$\" /INI=$PLUGINSDIR\${CONFIG_INI}"
michael@0 1557 ${NSD_CreateTimer} CheckInstall ${InstallIntervalMS}
michael@0 1558 ${Else}
michael@0 1559 ${If} $HalfOfDownload != "true"
michael@0 1560 ${AndIf} $3 > $HalfOfDownload
michael@0 1561 StrCpy $HalfOfDownload "true"
michael@0 1562 LockWindow on
michael@0 1563 ShowWindow $LabelBlurb1 ${SW_HIDE}
michael@0 1564 ShowWindow $BitmapBlurb1 ${SW_HIDE}
michael@0 1565 ShowWindow $LabelBlurb2 ${SW_SHOW}
michael@0 1566 ShowWindow $BitmapBlurb2 ${SW_SHOW}
michael@0 1567 LockWindow off
michael@0 1568 ${EndIf}
michael@0 1569 StrCpy $DownloadedBytes "$3"
michael@0 1570 SendMessage $Progressbar ${PBM_SETPOS} $3 0
michael@0 1571 ${EndIf}
michael@0 1572 ${EndIf}
michael@0 1573 FunctionEnd
michael@0 1574
michael@0 1575 Function OnPing
michael@0 1576 InetBgDL::GetStats
michael@0 1577 # $0 = HTTP status code, 0=Completed
michael@0 1578 # $1 = Completed files
michael@0 1579 # $2 = Remaining files
michael@0 1580 # $3 = Number of downloaded bytes for the current file
michael@0 1581 # $4 = Size of current file (Empty string if the size is unknown)
michael@0 1582 # /RESET must be used if status $0 > 299 (e.g. failure)
michael@0 1583 # When status is $0 =< 299 it is handled by InetBgDL
michael@0 1584 ${If} $2 == 0
michael@0 1585 ${OrIf} $0 > 299
michael@0 1586 ${NSD_KillTimer} OnPing
michael@0 1587 ${If} $0 > 299
michael@0 1588 InetBgDL::Get /RESET /END
michael@0 1589 ${EndIf}
michael@0 1590 ; The following will exit the installer
michael@0 1591 SetAutoClose true
michael@0 1592 StrCpy $R9 "2"
michael@0 1593 Call RelativeGotoPage
michael@0 1594 ${EndIf}
michael@0 1595 FunctionEnd
michael@0 1596
michael@0 1597 Function CheckInstall
michael@0 1598 IntOp $InstallCounterStep $InstallCounterStep + 1
michael@0 1599 ${If} $InstallCounterStep >= $InstallTotalSteps
michael@0 1600 ${NSD_KillTimer} CheckInstall
michael@0 1601 ; Close the handle that prevents modification of the full installer
michael@0 1602 System::Call 'kernel32::CloseHandle(i $HandleDownload)'
michael@0 1603 StrCpy $ExitCode "${ERR_INSTALL_TIMEOUT}"
michael@0 1604 ; Use a timer so the UI has a chance to update
michael@0 1605 ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
michael@0 1606 Return
michael@0 1607 ${EndIf}
michael@0 1608
michael@0 1609 SendMessage $Progressbar ${PBM_STEPIT} 0 0
michael@0 1610
michael@0 1611 ${If} ${FileExists} "$INSTDIR\install.log"
michael@0 1612 Delete "$INSTDIR\install.tmp"
michael@0 1613 CopyFiles /SILENT "$INSTDIR\install.log" "$INSTDIR\install.tmp"
michael@0 1614
michael@0 1615 ; The unfocus and refocus that happens approximately here is caused by the
michael@0 1616 ; installer calling SHChangeNotify to refresh the shortcut icons.
michael@0 1617
michael@0 1618 ; When the full installer completes the installation the install.log will no
michael@0 1619 ; longer be in use.
michael@0 1620 ClearErrors
michael@0 1621 Delete "$INSTDIR\install.log"
michael@0 1622 ${Unless} ${Errors}
michael@0 1623 ${NSD_KillTimer} CheckInstall
michael@0 1624 ; Close the handle that prevents modification of the full installer
michael@0 1625 System::Call 'kernel32::CloseHandle(i $HandleDownload)'
michael@0 1626 Rename "$INSTDIR\install.tmp" "$INSTDIR\install.log"
michael@0 1627 Delete "$PLUGINSDIR\download.exe"
michael@0 1628 Delete "$PLUGINSDIR\${CONFIG_INI}"
michael@0 1629 System::Call "kernel32::GetTickCount()l .s"
michael@0 1630 Pop $EndInstallPhaseTickCount
michael@0 1631 System::Int64Op $InstallStepSize * ${InstallProgressFinishStep}
michael@0 1632 Pop $InstallStepSize
michael@0 1633 SendMessage $Progressbar ${PBM_SETSTEP} $InstallStepSize 0
michael@0 1634 ${NSD_CreateTimer} FinishInstall ${InstallIntervalMS}
michael@0 1635 ${EndUnless}
michael@0 1636 ${EndIf}
michael@0 1637 FunctionEnd
michael@0 1638
michael@0 1639 Function FinishInstall
michael@0 1640 ; The full installer has completed but the progress bar still needs to finish
michael@0 1641 ; so increase the size of the step.
michael@0 1642 IntOp $InstallCounterStep $InstallCounterStep + ${InstallProgressFinishStep}
michael@0 1643 ${If} $InstallTotalSteps < $InstallCounterStep
michael@0 1644 StrCpy $InstallCounterStep "$InstallTotalSteps"
michael@0 1645 ${EndIf}
michael@0 1646
michael@0 1647 ${If} $InstallTotalSteps != $InstallCounterStep
michael@0 1648 SendMessage $Progressbar ${PBM_STEPIT} 0 0
michael@0 1649 Return
michael@0 1650 ${EndIf}
michael@0 1651
michael@0 1652 ${NSD_KillTimer} FinishInstall
michael@0 1653
michael@0 1654 SendMessage $Progressbar ${PBM_GETRANGE} 0 0 $R9
michael@0 1655 SendMessage $Progressbar ${PBM_SETPOS} $R9 0
michael@0 1656
michael@0 1657 ${If} "$CheckboxSetAsDefault" == "1"
michael@0 1658 ${GetParameters} $0
michael@0 1659 ClearErrors
michael@0 1660 ${GetOptions} "$0" "/UAC:" $0
michael@0 1661 ${If} ${Errors} ; Not elevated
michael@0 1662 Call ExecSetAsDefaultAppUser
michael@0 1663 ${Else} ; Elevated - execute the function in the unelevated process
michael@0 1664 GetFunctionAddress $0 ExecSetAsDefaultAppUser
michael@0 1665 UAC::ExecCodeSegment $0
michael@0 1666 ${EndIf}
michael@0 1667 ${EndIf}
michael@0 1668
michael@0 1669 ${If} $CheckboxShortcutOnBar == 1
michael@0 1670 ${If} ${AtMostWinVista}
michael@0 1671 ClearErrors
michael@0 1672 ${GetParameters} $0
michael@0 1673 ClearErrors
michael@0 1674 ${GetOptions} "$0" "/UAC:" $0
michael@0 1675 ${If} ${Errors}
michael@0 1676 Call AddQuickLaunchShortcut
michael@0 1677 ${Else}
michael@0 1678 GetFunctionAddress $0 AddQuickLaunchShortcut
michael@0 1679 UAC::ExecCodeSegment $0
michael@0 1680 ${EndIf}
michael@0 1681 ${EndIf}
michael@0 1682 ${EndIf}
michael@0 1683
michael@0 1684 ${If} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-upgrade"
michael@0 1685 Delete "$INSTDIR\${FileMainEXE}"
michael@0 1686 Rename "$INSTDIR\${FileMainEXE}.moz-upgrade" "$INSTDIR\${FileMainEXE}"
michael@0 1687 ${EndIf}
michael@0 1688
michael@0 1689 StrCpy $ExitCode "${ERR_SUCCESS}"
michael@0 1690
michael@0 1691 StrCpy $InstallCounterStep 0
michael@0 1692 ${NSD_CreateTimer} FinishProgressBar ${InstallIntervalMS}
michael@0 1693 FunctionEnd
michael@0 1694
michael@0 1695 Function FinishProgressBar
michael@0 1696 IntOp $InstallCounterStep $InstallCounterStep + 1
michael@0 1697
michael@0 1698 ${If} $InstallCounterStep < 10
michael@0 1699 Return
michael@0 1700 ${EndIf}
michael@0 1701
michael@0 1702 ${NSD_KillTimer} FinishProgressBar
michael@0 1703
michael@0 1704 Call LaunchApp
michael@0 1705
michael@0 1706 Call SendPing
michael@0 1707 FunctionEnd
michael@0 1708
michael@0 1709 Function OnBack
michael@0 1710 StrCpy $WasOptionsButtonClicked "1"
michael@0 1711 StrCpy $R9 "1" ; Goto the next page
michael@0 1712 Call RelativeGotoPage
michael@0 1713 ; The call to Abort prevents NSIS from trying to move to the previous or the
michael@0 1714 ; next page.
michael@0 1715 Abort
michael@0 1716 FunctionEnd
michael@0 1717
michael@0 1718 Function RelativeGotoPage
michael@0 1719 IntCmp $R9 0 0 Move Move
michael@0 1720 StrCmp $R9 "X" 0 Move
michael@0 1721 StrCpy $R9 "120"
michael@0 1722
michael@0 1723 Move:
michael@0 1724 SendMessage $HWNDPARENT "0x408" "$R9" ""
michael@0 1725 FunctionEnd
michael@0 1726
michael@0 1727 Function UpdateFreeSpaceLabel
michael@0 1728 ; Only update when $ExistingTopDir isn't set
michael@0 1729 ${If} "$ExistingTopDir" != ""
michael@0 1730 StrLen $5 "$ExistingTopDir"
michael@0 1731 StrLen $6 "$INSTDIR"
michael@0 1732 ${If} $5 <= $6
michael@0 1733 StrCpy $7 "$INSTDIR" $5
michael@0 1734 ${If} "$7" == "$ExistingTopDir"
michael@0 1735 Return
michael@0 1736 ${EndIf}
michael@0 1737 ${EndIf}
michael@0 1738 ${EndIf}
michael@0 1739
michael@0 1740 Call CheckSpace
michael@0 1741
michael@0 1742 StrCpy $0 "$SpaceAvailableBytes"
michael@0 1743
michael@0 1744 StrCpy $1 "$(BYTE)"
michael@0 1745
michael@0 1746 ${If} $0 > 1024
michael@0 1747 ${OrIf} $0 < 0
michael@0 1748 ; Multiply by 10 so it is possible to display a decimal in the size
michael@0 1749 System::Int64Op $0 * 10
michael@0 1750 Pop $0
michael@0 1751 System::Int64Op $0 / 1024
michael@0 1752 Pop $0
michael@0 1753 StrCpy $1 "$(KILO)$(BYTE)"
michael@0 1754 ${If} $0 > 10240
michael@0 1755 ${OrIf} $0 < 0
michael@0 1756 System::Int64Op $0 / 1024
michael@0 1757 Pop $0
michael@0 1758 StrCpy $1 "$(MEGA)$(BYTE)"
michael@0 1759 ${If} $0 > 10240
michael@0 1760 ${OrIf} $0 < 0
michael@0 1761 System::Int64Op $0 / 1024
michael@0 1762 Pop $0
michael@0 1763 StrCpy $1 "$(GIGA)$(BYTE)"
michael@0 1764 ${EndIf}
michael@0 1765 ${EndIf}
michael@0 1766 StrLen $3 "$0"
michael@0 1767 ${If} $3 > 1
michael@0 1768 StrCpy $2 "$0" -1 ; All characters except the last one
michael@0 1769 StrCpy $0 "$0" "" -1 ; The last character
michael@0 1770 ${If} "$0" == "0"
michael@0 1771 StrCpy $0 "$2" ; Don't display the decimal if it is 0
michael@0 1772 ${Else}
michael@0 1773 StrCpy $0 "$2.$0"
michael@0 1774 ${EndIf}
michael@0 1775 ${ElseIf} $3 == 1
michael@0 1776 StrCpy $0 "0.$0"
michael@0 1777 ${Else}
michael@0 1778 ; This should never happen
michael@0 1779 System::Int64Op $0 / 10
michael@0 1780 Pop $0
michael@0 1781 ${EndIf}
michael@0 1782 ${EndIf}
michael@0 1783
michael@0 1784 SendMessage $LabelFreeSpace ${WM_SETTEXT} 0 "STR:$0 $1"
michael@0 1785
michael@0 1786 FunctionEnd
michael@0 1787
michael@0 1788 Function OnChange_DirRequest
michael@0 1789 Pop $0
michael@0 1790 System::Call 'user32::GetWindowTextW(i $DirRequest, w .r0, i ${NSIS_MAX_STRLEN})'
michael@0 1791 StrCpy $1 "$0" 1 ; the first character
michael@0 1792 ${If} "$1" == "$\""
michael@0 1793 StrCpy $1 "$0" "" -1 ; the last character
michael@0 1794 ${If} "$1" == "$\""
michael@0 1795 StrCpy $0 "$0" "" 1 ; all but the first character
michael@0 1796 StrCpy $0 "$0" -1 ; all but the last character
michael@0 1797 ${EndIf}
michael@0 1798 ${EndIf}
michael@0 1799
michael@0 1800 StrCpy $INSTDIR "$0"
michael@0 1801 Call UpdateFreeSpaceLabel
michael@0 1802
michael@0 1803 GetDlgItem $0 $HWNDPARENT 1 ; Install button
michael@0 1804 ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
michael@0 1805 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(UPGRADE_BUTTON)"
michael@0 1806 ${Else}
michael@0 1807 SendMessage $0 ${WM_SETTEXT} 0 "STR:$(INSTALL_BUTTON)"
michael@0 1808 ${EndIf}
michael@0 1809 FunctionEnd
michael@0 1810
michael@0 1811 Function OnClick_ButtonBrowse
michael@0 1812 StrCpy $0 "$INSTDIR"
michael@0 1813 nsDialogs::SelectFolderDialog /NOUNLOAD "$(SELECT_FOLDER_TEXT)" $0
michael@0 1814 Pop $0
michael@0 1815 ${If} $0 == "error" ; returns 'error' if 'cancel' was pressed?
michael@0 1816 Return
michael@0 1817 ${EndIf}
michael@0 1818
michael@0 1819 ${If} $0 != ""
michael@0 1820 StrCpy $INSTDIR "$0"
michael@0 1821 System::Call 'user32::SetWindowTextW(i $DirRequest, w "$INSTDIR")'
michael@0 1822 ${EndIf}
michael@0 1823 FunctionEnd
michael@0 1824
michael@0 1825 Function CheckSpace
michael@0 1826 ${If} "$ExistingTopDir" != ""
michael@0 1827 StrLen $0 "$ExistingTopDir"
michael@0 1828 StrLen $1 "$INSTDIR"
michael@0 1829 ${If} $0 <= $1
michael@0 1830 StrCpy $2 "$INSTDIR" $3
michael@0 1831 ${If} "$2" == "$ExistingTopDir"
michael@0 1832 Return
michael@0 1833 ${EndIf}
michael@0 1834 ${EndIf}
michael@0 1835 ${EndIf}
michael@0 1836
michael@0 1837 StrCpy $ExistingTopDir "$INSTDIR"
michael@0 1838 ${DoUntil} ${FileExists} "$ExistingTopDir"
michael@0 1839 ${GetParent} "$ExistingTopDir" $ExistingTopDir
michael@0 1840 ${If} "$ExistingTopDir" == ""
michael@0 1841 StrCpy $SpaceAvailableBytes "0"
michael@0 1842 StrCpy $HasRequiredSpaceAvailable "false"
michael@0 1843 Return
michael@0 1844 ${EndIf}
michael@0 1845 ${Loop}
michael@0 1846
michael@0 1847 ${GetLongPath} "$ExistingTopDir" $ExistingTopDir
michael@0 1848
michael@0 1849 ; GetDiskFreeSpaceExW requires a backslash.
michael@0 1850 StrCpy $0 "$ExistingTopDir" "" -1 ; the last character
michael@0 1851 ${If} "$0" != "\"
michael@0 1852 StrCpy $0 "\"
michael@0 1853 ${Else}
michael@0 1854 StrCpy $0 ""
michael@0 1855 ${EndIf}
michael@0 1856
michael@0 1857 System::Call 'kernel32::GetDiskFreeSpaceExW(w, *l, *l, *l) i("$ExistingTopDir$0", .r1, .r2, .r3) .'
michael@0 1858 StrCpy $SpaceAvailableBytes "$1"
michael@0 1859
michael@0 1860 System::Int64Op $SpaceAvailableBytes / 1048576
michael@0 1861 Pop $1
michael@0 1862 System::Int64Op $1 > ${APPROXIMATE_REQUIRED_SPACE_MB}
michael@0 1863 Pop $1
michael@0 1864 ${If} $1 == 1
michael@0 1865 StrCpy $HasRequiredSpaceAvailable "true"
michael@0 1866 ${Else}
michael@0 1867 StrCpy $HasRequiredSpaceAvailable "false"
michael@0 1868 ${EndIf}
michael@0 1869 FunctionEnd
michael@0 1870
michael@0 1871 Function CanWrite
michael@0 1872 StrCpy $CanWriteToInstallDir "false"
michael@0 1873
michael@0 1874 StrCpy $0 "$INSTDIR"
michael@0 1875 ; Use the existing directory when it exists
michael@0 1876 ${Unless} ${FileExists} "$INSTDIR"
michael@0 1877 ; Get the topmost directory that exists for new installs
michael@0 1878 ${DoUntil} ${FileExists} "$0"
michael@0 1879 ${GetParent} "$0" $0
michael@0 1880 ${If} "$0" == ""
michael@0 1881 Return
michael@0 1882 ${EndIf}
michael@0 1883 ${Loop}
michael@0 1884 ${EndUnless}
michael@0 1885
michael@0 1886 GetTempFileName $2 "$0"
michael@0 1887 Delete $2
michael@0 1888 CreateDirectory "$2"
michael@0 1889 ${If} ${FileExists} "$2"
michael@0 1890 ${If} ${FileExists} "$INSTDIR"
michael@0 1891 GetTempFileName $3 "$INSTDIR"
michael@0 1892 ${Else}
michael@0 1893 GetTempFileName $3 "$2"
michael@0 1894 ${EndIf}
michael@0 1895 ${If} ${FileExists} "$3"
michael@0 1896 Delete "$3"
michael@0 1897 StrCpy $CanWriteToInstallDir "true"
michael@0 1898 ${EndIf}
michael@0 1899 RmDir "$2"
michael@0 1900 ${EndIf}
michael@0 1901 FunctionEnd
michael@0 1902
michael@0 1903 Function AddQuickLaunchShortcut
michael@0 1904 CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}"
michael@0 1905 ${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
michael@0 1906 ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandFullName}.lnk" \
michael@0 1907 "$INSTDIR"
michael@0 1908 ${EndIf}
michael@0 1909 FunctionEnd
michael@0 1910
michael@0 1911 Function ExecSetAsDefaultAppUser
michael@0 1912 ; Using the helper.exe lessens the stub installer size.
michael@0 1913 ; This could ask for elevatation when the user doesn't install as admin.
michael@0 1914 Exec "$\"$INSTDIR\uninstall\helper.exe$\" /SetAsDefaultAppUser"
michael@0 1915 FunctionEnd
michael@0 1916
michael@0 1917 Function LaunchApp
michael@0 1918 FindWindow $0 "${WindowClass}"
michael@0 1919 ${If} $0 <> 0 ; integer comparison
michael@0 1920 StrCpy $FirefoxLaunchCode "1"
michael@0 1921 MessageBox MB_OK|MB_ICONQUESTION "$(WARN_MANUALLY_CLOSE_APP_LAUNCH)"
michael@0 1922 Return
michael@0 1923 ${EndIf}
michael@0 1924
michael@0 1925 StrCpy $FirefoxLaunchCode "2"
michael@0 1926
michael@0 1927 ; Set the current working directory to the installation directory
michael@0 1928 SetOutPath "$INSTDIR"
michael@0 1929 ClearErrors
michael@0 1930 ${GetParameters} $0
michael@0 1931 ${GetOptions} "$0" "/UAC:" $1
michael@0 1932 ${If} ${Errors}
michael@0 1933 Exec "$\"$INSTDIR\${FileMainEXE}$\""
michael@0 1934 ${Else}
michael@0 1935 GetFunctionAddress $0 LaunchAppFromElevatedProcess
michael@0 1936 UAC::ExecCodeSegment $0
michael@0 1937 ${EndIf}
michael@0 1938 FunctionEnd
michael@0 1939
michael@0 1940 Function LaunchAppFromElevatedProcess
michael@0 1941 ; Find the installation directory when launching using GetFunctionAddress
michael@0 1942 ; from an elevated installer since $INSTDIR will not be set in this installer
michael@0 1943 ${StrFilter} "${FileMainEXE}" "+" "" "" $R9
michael@0 1944 ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
michael@0 1945 ${GetPathFromString} "$0" $0
michael@0 1946 ; Set the current working directory to the installation directory
michael@0 1947 ${GetParent} "$0" $1
michael@0 1948 SetOutPath "$1"
michael@0 1949 Exec "$\"$0$\""
michael@0 1950 FunctionEnd
michael@0 1951
michael@0 1952 Function DisplayDownloadError
michael@0 1953 ${NSD_KillTimer} DisplayDownloadError
michael@0 1954 MessageBox MB_OKCANCEL|MB_ICONSTOP "$(ERROR_DOWNLOAD)" IDCANCEL +2 IDOK +1
michael@0 1955 StrCpy $OpenedDownloadPage "1" ; Already initialized to 0
michael@0 1956
michael@0 1957 ${If} "$OpenedDownloadPage" == "1"
michael@0 1958 ClearErrors
michael@0 1959 ${GetParameters} $0
michael@0 1960 ${GetOptions} "$0" "/UAC:" $1
michael@0 1961 ${If} ${Errors}
michael@0 1962 Call OpenManualDownloadURL
michael@0 1963 ${Else}
michael@0 1964 GetFunctionAddress $0 OpenManualDownloadURL
michael@0 1965 UAC::ExecCodeSegment $0
michael@0 1966 ${EndIf}
michael@0 1967 ${EndIf}
michael@0 1968
michael@0 1969 Call SendPing
michael@0 1970 FunctionEnd
michael@0 1971
michael@0 1972 Function OpenManualDownloadURL
michael@0 1973 ExecShell "open" "${URLManualDownload}${URLManualDownloadAppend}"
michael@0 1974 FunctionEnd
michael@0 1975
michael@0 1976 Section
michael@0 1977 SectionEnd

mercurial