toolkit/mozapps/installer/windows/nsis/common.nsh

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
-rwxr-xr-x

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
michael@0 6 ################################################################################
michael@0 7 # Helper defines and macros for toolkit applications
michael@0 8
michael@0 9 /**
michael@0 10 * Avoid creating macros / functions that overwrite registers (see the
michael@0 11 * GetLongPath macro for one way to avoid this)!
michael@0 12 *
michael@0 13 * Before using the registers exchange the passed in params and save existing
michael@0 14 * register values to the stack.
michael@0 15 *
michael@0 16 * Exch $R9 ; exhange the original $R9 with the top of the stack
michael@0 17 * Exch 1 ; exchange the top of the stack with 1 below the top of the stack
michael@0 18 * Exch $R8 ; exchange the original $R8 with the top of the stack
michael@0 19 * Exch 2 ; exchange the top of the stack with 2 below the top of the stack
michael@0 20 * Exch $R7 ; exchange the original $R7 with the top of the stack
michael@0 21 * Push $R6 ; push the original $R6 onto the top of the stack
michael@0 22 * Push $R5 ; push the original $R5 onto the top of the stack
michael@0 23 * Push $R4 ; push the original $R4 onto the top of the stack
michael@0 24 *
michael@0 25 * <do stuff>
michael@0 26 *
michael@0 27 * ; Restore the values.
michael@0 28 * Pop $R4 ; restore the value for $R4 from the top of the stack
michael@0 29 * Pop $R5 ; restore the value for $R5 from the top of the stack
michael@0 30 * Pop $R6 ; restore the value for $R6 from the top of the stack
michael@0 31 * Exch $R7 ; exchange the new $R7 value with the top of the stack
michael@0 32 * Exch 2 ; exchange the top of the stack with 2 below the top of the stack
michael@0 33 * Exch $R8 ; exchange the new $R8 value with the top of the stack
michael@0 34 * Exch 1 ; exchange the top of the stack with 2 below the top of the stack
michael@0 35 * Exch $R9 ; exchange the new $R9 value with the top of the stack
michael@0 36 *
michael@0 37 *
michael@0 38 * When inserting macros in common.nsh from another macro in common.nsh that
michael@0 39 * can be used from the uninstaller _MOZFUNC_UN will be undefined when it is
michael@0 40 * inserted. Use the following to redefine _MOZFUNC_UN with its original value
michael@0 41 * (see the RegCleanMain macro for an example).
michael@0 42 *
michael@0 43 * !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 44 * !insertmacro ${_MOZFUNC_UN_TMP}FileJoin
michael@0 45 * !insertmacro ${_MOZFUNC_UN_TMP}LineFind
michael@0 46 * !insertmacro ${_MOZFUNC_UN_TMP}TextCompareNoDetails
michael@0 47 * !insertmacro ${_MOZFUNC_UN_TMP}TrimNewLines
michael@0 48 * !undef _MOZFUNC_UN
michael@0 49 * !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 50 * !undef _MOZFUNC_UN_TMP
michael@0 51 */
michael@0 52
michael@0 53 ; When including a file provided by NSIS check if its verbose macro is defined
michael@0 54 ; to prevent loading the file a second time.
michael@0 55 !ifmacrondef TEXTFUNC_VERBOSE
michael@0 56 !include TextFunc.nsh
michael@0 57 !endif
michael@0 58
michael@0 59 !ifmacrondef FILEFUNC_VERBOSE
michael@0 60 !include FileFunc.nsh
michael@0 61 !endif
michael@0 62
michael@0 63 !ifmacrondef LOGICLIB_VERBOSITY
michael@0 64 !include LogicLib.nsh
michael@0 65 !endif
michael@0 66
michael@0 67 !ifndef WINMESSAGES_INCLUDED
michael@0 68 !include WinMessages.nsh
michael@0 69 !endif
michael@0 70
michael@0 71 ; When including WinVer.nsh check if ___WINVER__NSH___ is defined to prevent
michael@0 72 ; loading the file a second time.
michael@0 73 !ifndef ___WINVER__NSH___
michael@0 74 !include WinVer.nsh
michael@0 75 !endif
michael@0 76
michael@0 77 !include x64.nsh
michael@0 78
michael@0 79 ; NSIS provided macros that we have overridden.
michael@0 80 !include overrides.nsh
michael@0 81
michael@0 82 !define SHORTCUTS_LOG "shortcuts_log.ini"
michael@0 83 !define TO_BE_DELETED "tobedeleted"
michael@0 84
michael@0 85 ; !define SHCNF_DWORD 0x0003
michael@0 86 ; !define SHCNF_FLUSH 0x1000
michael@0 87 !ifndef SHCNF_DWORDFLUSH
michael@0 88 !define SHCNF_DWORDFLUSH 0x1003
michael@0 89 !endif
michael@0 90 !ifndef SHCNE_ASSOCCHANGED
michael@0 91 !define SHCNE_ASSOCCHANGED 0x08000000
michael@0 92 !endif
michael@0 93
michael@0 94 ################################################################################
michael@0 95 # Macros for debugging
michael@0 96
michael@0 97 /**
michael@0 98 * The following two macros assist with verifying that a macro doesn't
michael@0 99 * overwrite any registers.
michael@0 100 *
michael@0 101 * Usage:
michael@0 102 * ${debugSetRegisters}
michael@0 103 * <do stuff>
michael@0 104 * ${debugDisplayRegisters}
michael@0 105 */
michael@0 106
michael@0 107 /**
michael@0 108 * Sets all register values to their name to assist with verifying that a macro
michael@0 109 * doesn't overwrite any registers.
michael@0 110 */
michael@0 111 !macro debugSetRegisters
michael@0 112 StrCpy $0 "$$0"
michael@0 113 StrCpy $1 "$$1"
michael@0 114 StrCpy $2 "$$2"
michael@0 115 StrCpy $3 "$$3"
michael@0 116 StrCpy $4 "$$4"
michael@0 117 StrCpy $5 "$$5"
michael@0 118 StrCpy $6 "$$6"
michael@0 119 StrCpy $7 "$$7"
michael@0 120 StrCpy $8 "$$8"
michael@0 121 StrCpy $9 "$$9"
michael@0 122 StrCpy $R0 "$$R0"
michael@0 123 StrCpy $R1 "$$R1"
michael@0 124 StrCpy $R2 "$$R2"
michael@0 125 StrCpy $R3 "$$R3"
michael@0 126 StrCpy $R4 "$$R4"
michael@0 127 StrCpy $R5 "$$R5"
michael@0 128 StrCpy $R6 "$$R6"
michael@0 129 StrCpy $R7 "$$R7"
michael@0 130 StrCpy $R8 "$$R8"
michael@0 131 StrCpy $R9 "$$R9"
michael@0 132 !macroend
michael@0 133 !define debugSetRegisters "!insertmacro debugSetRegisters"
michael@0 134
michael@0 135 /**
michael@0 136 * Displays all register values to assist with verifying that a macro doesn't
michael@0 137 * overwrite any registers.
michael@0 138 */
michael@0 139 !macro debugDisplayRegisters
michael@0 140 MessageBox MB_OK \
michael@0 141 "Register Values:$\n\
michael@0 142 $$0 = $0$\n$$1 = $1$\n$$2 = $2$\n$$3 = $3$\n$$4 = $4$\n\
michael@0 143 $$5 = $5$\n$$6 = $6$\n$$7 = $7$\n$$8 = $8$\n$$9 = $9$\n\
michael@0 144 $$R0 = $R0$\n$$R1 = $R1$\n$$R2 = $R2$\n$$R3 = $R3$\n$$R4 = $R4$\n\
michael@0 145 $$R5 = $R5$\n$$R6 = $R6$\n$$R7 = $R7$\n$$R8 = $R8$\n$$R9 = $R9"
michael@0 146 !macroend
michael@0 147 !define debugDisplayRegisters "!insertmacro debugDisplayRegisters"
michael@0 148
michael@0 149
michael@0 150 ################################################################################
michael@0 151 # Modern User Interface (MUI) override macros
michael@0 152
michael@0 153 ; Removed macros in nsis 2.33u (ported from nsis 2.22)
michael@0 154 ; MUI_LANGUAGEFILE_DEFINE
michael@0 155 ; MUI_LANGUAGEFILE_LANGSTRING_PAGE
michael@0 156 ; MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE
michael@0 157 ; MUI_LANGUAGEFILE_LANGSTRING_DEFINE
michael@0 158 ; MUI_LANGUAGEFILE_UNLANGSTRING_PAGE
michael@0 159
michael@0 160 !macro MOZ_MUI_LANGUAGEFILE_DEFINE DEFINE NAME
michael@0 161
michael@0 162 !ifndef "${DEFINE}"
michael@0 163 !define "${DEFINE}" "${${NAME}}"
michael@0 164 !endif
michael@0 165 !undef "${NAME}"
michael@0 166
michael@0 167 !macroend
michael@0 168
michael@0 169 !macro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE PAGE NAME
michael@0 170
michael@0 171 !ifdef MUI_${PAGE}PAGE
michael@0 172 LangString "${NAME}" 0 "${${NAME}}"
michael@0 173 !undef "${NAME}"
michael@0 174 !else
michael@0 175 !undef "${NAME}"
michael@0 176 !endif
michael@0 177
michael@0 178 !macroend
michael@0 179
michael@0 180 !macro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE PAGE NAME
michael@0 181
michael@0 182 !ifdef MUI_${PAGE}PAGE | MUI_UN${PAGE}PAGE
michael@0 183 LangString "${NAME}" 0 "${${NAME}}"
michael@0 184 !undef "${NAME}"
michael@0 185 !else
michael@0 186 !undef "${NAME}"
michael@0 187 !endif
michael@0 188
michael@0 189 !macroend
michael@0 190
michael@0 191 !macro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE DEFINE NAME
michael@0 192
michael@0 193 !ifdef "${DEFINE}"
michael@0 194 LangString "${NAME}" 0 "${${NAME}}"
michael@0 195 !endif
michael@0 196 !undef "${NAME}"
michael@0 197
michael@0 198 !macroend
michael@0 199
michael@0 200 !macro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE PAGE NAME
michael@0 201
michael@0 202 !ifdef MUI_UNINSTALLER
michael@0 203 !ifdef MUI_UN${PAGE}PAGE
michael@0 204 LangString "${NAME}" 0 "${${NAME}}"
michael@0 205 !undef "${NAME}"
michael@0 206 !else
michael@0 207 !undef "${NAME}"
michael@0 208 !endif
michael@0 209 !else
michael@0 210 !undef "${NAME}"
michael@0 211 !endif
michael@0 212
michael@0 213 !macroend
michael@0 214
michael@0 215 ; Modified version of the following MUI macros to support Mozilla localization.
michael@0 216 ; MUI_LANGUAGE
michael@0 217 ; MUI_LANGUAGEFILE_BEGIN
michael@0 218 ; MOZ_MUI_LANGUAGEFILE_END
michael@0 219 ; See <NSIS App Dir>/Contrib/Modern UI/System.nsh for more information
michael@0 220 !define MUI_INSTALLOPTIONS_READ "!insertmacro MUI_INSTALLOPTIONS_READ"
michael@0 221
michael@0 222 !macro MOZ_MUI_LANGUAGE LANGUAGE
michael@0 223 !verbose push
michael@0 224 !verbose ${MUI_VERBOSE}
michael@0 225 !include "${LANGUAGE}.nsh"
michael@0 226 !verbose pop
michael@0 227 !macroend
michael@0 228
michael@0 229 !macro MOZ_MUI_LANGUAGEFILE_BEGIN LANGUAGE
michael@0 230 !insertmacro MUI_INSERT
michael@0 231 !ifndef "MUI_LANGUAGEFILE_${LANGUAGE}_USED"
michael@0 232 !define "MUI_LANGUAGEFILE_${LANGUAGE}_USED"
michael@0 233 LoadLanguageFile "${LANGUAGE}.nlf"
michael@0 234 !else
michael@0 235 !error "Modern UI language file ${LANGUAGE} included twice!"
michael@0 236 !endif
michael@0 237 !macroend
michael@0 238
michael@0 239 ; Custom version of MUI_LANGUAGEFILE_END. The macro to add the default MUI
michael@0 240 ; strings and the macros for several strings that are part of the NSIS MUI and
michael@0 241 ; not in our locale files have been commented out.
michael@0 242 !macro MOZ_MUI_LANGUAGEFILE_END
michael@0 243
michael@0 244 # !include "${NSISDIR}\Contrib\Modern UI\Language files\Default.nsh"
michael@0 245 !ifdef MUI_LANGUAGEFILE_DEFAULT_USED
michael@0 246 !undef MUI_LANGUAGEFILE_DEFAULT_USED
michael@0 247 !warning "${LANGUAGE} Modern UI language file version doesn't match. Using default English texts for missing strings."
michael@0 248 !endif
michael@0 249
michael@0 250 !insertmacro MOZ_MUI_LANGUAGEFILE_DEFINE "MUI_${LANGUAGE}_LANGNAME" "MUI_LANGNAME"
michael@0 251
michael@0 252 !ifndef MUI_LANGDLL_PUSHLIST
michael@0 253 !define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} "
michael@0 254 !else
michael@0 255 !ifdef MUI_LANGDLL_PUSHLIST_TEMP
michael@0 256 !undef MUI_LANGDLL_PUSHLIST_TEMP
michael@0 257 !endif
michael@0 258 !define MUI_LANGDLL_PUSHLIST_TEMP "${MUI_LANGDLL_PUSHLIST}"
michael@0 259 !undef MUI_LANGDLL_PUSHLIST
michael@0 260 !define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} ${MUI_LANGDLL_PUSHLIST_TEMP}"
michael@0 261 !endif
michael@0 262
michael@0 263 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE WELCOME "MUI_TEXT_WELCOME_INFO_TITLE"
michael@0 264 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE WELCOME "MUI_TEXT_WELCOME_INFO_TEXT"
michael@0 265
michael@0 266 !ifdef MUI_TEXT_LICENSE_TITLE
michael@0 267 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_TEXT_LICENSE_TITLE"
michael@0 268 !endif
michael@0 269 !ifdef MUI_TEXT_LICENSE_SUBTITLE
michael@0 270 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_TEXT_LICENSE_SUBTITLE"
michael@0 271 !endif
michael@0 272 !ifdef MUI_INNERTEXT_LICENSE_TOP
michael@0 273 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_TOP"
michael@0 274 !endif
michael@0 275
michael@0 276 # !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM"
michael@0 277
michael@0 278 !ifdef MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX
michael@0 279 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX"
michael@0 280 !endif
michael@0 281
michael@0 282 !ifdef MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS
michael@0 283 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS"
michael@0 284 !endif
michael@0 285
michael@0 286 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE COMPONENTS "MUI_TEXT_COMPONENTS_TITLE"
michael@0 287 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE COMPONENTS "MUI_TEXT_COMPONENTS_SUBTITLE"
michael@0 288 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE COMPONENTS "MUI_INNERTEXT_COMPONENTS_DESCRIPTION_TITLE"
michael@0 289 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE COMPONENTS "MUI_INNERTEXT_COMPONENTS_DESCRIPTION_INFO"
michael@0 290
michael@0 291 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE DIRECTORY "MUI_TEXT_DIRECTORY_TITLE"
michael@0 292 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE DIRECTORY "MUI_TEXT_DIRECTORY_SUBTITLE"
michael@0 293
michael@0 294 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_TEXT_STARTMENU_TITLE"
michael@0 295 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_TEXT_STARTMENU_SUBTITLE"
michael@0 296 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_INNERTEXT_STARTMENU_TOP"
michael@0 297 # !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_INNERTEXT_STARTMENU_CHECKBOX"
michael@0 298
michael@0 299 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_INSTALLING_TITLE"
michael@0 300 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_INSTALLING_SUBTITLE"
michael@0 301
michael@0 302 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_FINISH_TITLE"
michael@0 303 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_FINISH_SUBTITLE"
michael@0 304
michael@0 305 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_ABORT_TITLE"
michael@0 306 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_ABORT_SUBTITLE"
michael@0 307
michael@0 308 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_BUTTONTEXT_FINISH"
michael@0 309 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_TITLE"
michael@0 310 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_TEXT"
michael@0 311 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_REBOOT"
michael@0 312 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_REBOOTNOW"
michael@0 313 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_REBOOTLATER"
michael@0 314 # !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_RUN"
michael@0 315 # !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_SHOWREADME"
michael@0 316
michael@0 317 ; Support for using the existing MUI_TEXT_ABORTWARNING string
michael@0 318 !ifdef MOZ_MUI_CUSTOM_ABORT
michael@0 319 LangString MOZ_MUI_TEXT_ABORTWARNING 0 "${MUI_TEXT_ABORTWARNING}"
michael@0 320 !endif
michael@0 321
michael@0 322 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE MUI_ABORTWARNING "MUI_TEXT_ABORTWARNING"
michael@0 323
michael@0 324
michael@0 325 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE WELCOME "MUI_UNTEXT_WELCOME_INFO_TITLE"
michael@0 326 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE WELCOME "MUI_UNTEXT_WELCOME_INFO_TEXT"
michael@0 327
michael@0 328 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE CONFIRM "MUI_UNTEXT_CONFIRM_TITLE"
michael@0 329 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE CONFIRM "MUI_UNTEXT_CONFIRM_SUBTITLE"
michael@0 330
michael@0 331 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNTEXT_LICENSE_TITLE"
michael@0 332 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNTEXT_LICENSE_SUBTITLE"
michael@0 333
michael@0 334 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM"
michael@0 335 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM_CHECKBOX"
michael@0 336 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS"
michael@0 337
michael@0 338 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE COMPONENTS "MUI_UNTEXT_COMPONENTS_TITLE"
michael@0 339 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE COMPONENTS "MUI_UNTEXT_COMPONENTS_SUBTITLE"
michael@0 340
michael@0 341 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE DIRECTORY "MUI_UNTEXT_DIRECTORY_TITLE"
michael@0 342 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE DIRECTORY "MUI_UNTEXT_DIRECTORY_SUBTITLE"
michael@0 343
michael@0 344 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_UNINSTALLING_TITLE"
michael@0 345 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_UNINSTALLING_SUBTITLE"
michael@0 346
michael@0 347 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_FINISH_TITLE"
michael@0 348 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_FINISH_SUBTITLE"
michael@0 349
michael@0 350 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_ABORT_TITLE"
michael@0 351 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_ABORT_SUBTITLE"
michael@0 352
michael@0 353 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_TITLE"
michael@0 354 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_TEXT"
michael@0 355 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_REBOOT"
michael@0 356
michael@0 357 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE MUI_UNABORTWARNING "MUI_UNTEXT_ABORTWARNING"
michael@0 358
michael@0 359 !ifndef MUI_LANGDLL_LANGUAGES
michael@0 360 !define MUI_LANGDLL_LANGUAGES "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' "
michael@0 361 !define MUI_LANGDLL_LANGUAGES_CP "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' '${LANG_${LANGUAGE}_CP}' "
michael@0 362 !else
michael@0 363 !ifdef MUI_LANGDLL_LANGUAGES_TEMP
michael@0 364 !undef MUI_LANGDLL_LANGUAGES_TEMP
michael@0 365 !endif
michael@0 366 !define MUI_LANGDLL_LANGUAGES_TEMP "${MUI_LANGDLL_LANGUAGES}"
michael@0 367 !undef MUI_LANGDLL_LANGUAGES
michael@0 368
michael@0 369 !ifdef MUI_LANGDLL_LANGUAGES_CP_TEMP
michael@0 370 !undef MUI_LANGDLL_LANGUAGES_CP_TEMP
michael@0 371 !endif
michael@0 372 !define MUI_LANGDLL_LANGUAGES_CP_TEMP "${MUI_LANGDLL_LANGUAGES_CP}"
michael@0 373 !undef MUI_LANGDLL_LANGUAGES_CP
michael@0 374
michael@0 375 !define MUI_LANGDLL_LANGUAGES "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' ${MUI_LANGDLL_LANGUAGES_TEMP}"
michael@0 376 !define MUI_LANGDLL_LANGUAGES_CP "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' '${LANG_${LANGUAGE}_CP}' ${MUI_LANGDLL_LANGUAGES_CP_TEMP}"
michael@0 377 !endif
michael@0 378
michael@0 379 !macroend
michael@0 380
michael@0 381 /**
michael@0 382 * Creates an InstallOptions file with a UTF-16LE BOM and adds the RTL value
michael@0 383 * to the Settings section.
michael@0 384 *
michael@0 385 * @param _FILE
michael@0 386 * The name of the file to be created in $PLUGINSDIR.
michael@0 387 */
michael@0 388 !macro InitInstallOptionsFile _FILE
michael@0 389 Push $R9
michael@0 390
michael@0 391 FileOpen $R9 "$PLUGINSDIR\${_FILE}" w
michael@0 392 FileWriteWord $R9 "65279"
michael@0 393 FileClose $R9
michael@0 394 WriteIniStr "$PLUGINSDIR\${_FILE}" "Settings" "RTL" "$(^RTL)"
michael@0 395
michael@0 396 Pop $R9
michael@0 397 !macroend
michael@0 398
michael@0 399
michael@0 400 ################################################################################
michael@0 401 # Macros for handling files in use
michael@0 402
michael@0 403 /**
michael@0 404 * Checks for files in use in the $INSTDIR directory. To check files in
michael@0 405 * sub-directories this macro would need to be rewritten to create
michael@0 406 * sub-directories in the temporary directory used to backup the files that are
michael@0 407 * checked.
michael@0 408 *
michael@0 409 * Example usage:
michael@0 410 *
michael@0 411 * ; The first string to be pushed onto the stack MUST be "end" to indicate
michael@0 412 * ; that there are no more files in the $INSTDIR directory to check.
michael@0 413 * Push "end"
michael@0 414 * Push "freebl3.dll"
michael@0 415 * ; The last file pushed should be the app's main exe so if it is in use this
michael@0 416 * ; macro will return after the first check.
michael@0 417 * Push "${FileMainEXE}"
michael@0 418 * ${CheckForFilesInUse} $R9
michael@0 419 *
michael@0 420 * !IMPORTANT - this macro uses the $R7, $R8, and $R9 registers and makes no
michael@0 421 * attempt to restore their original values.
michael@0 422 *
michael@0 423 * @return _RESULT
michael@0 424 * false if all of the files popped from the stack are not in use.
michael@0 425 * True if any of the files popped from the stack are in use.
michael@0 426 * $R7 = Temporary backup directory where the files will be copied to.
michael@0 427 * $R8 = value popped from the stack. This will either be a file name for a file
michael@0 428 * in the $INSTDIR directory or "end" to indicate that there are no
michael@0 429 * additional files to check.
michael@0 430 * $R9 = _RESULT
michael@0 431 */
michael@0 432 !macro CheckForFilesInUse
michael@0 433
michael@0 434 !ifndef ${_MOZFUNC_UN}CheckForFilesInUse
michael@0 435 !verbose push
michael@0 436 !verbose ${_MOZFUNC_VERBOSE}
michael@0 437 !define ${_MOZFUNC_UN}CheckForFilesInUse "!insertmacro ${_MOZFUNC_UN}CheckForFilesInUseCall"
michael@0 438
michael@0 439 Function ${_MOZFUNC_UN}CheckForFilesInUse
michael@0 440 ; Create a temporary backup directory.
michael@0 441 GetTempFileName $R7 "$INSTDIR"
michael@0 442 Delete "$R7"
michael@0 443 SetOutPath "$R7"
michael@0 444 StrCpy $R9 "false"
michael@0 445
michael@0 446 Pop $R8
michael@0 447 ${While} $R8 != "end"
michael@0 448 ${Unless} ${FileExists} "$INSTDIR\$R8"
michael@0 449 Pop $R8 ; get next file to check before continuing
michael@0 450 ${Continue}
michael@0 451 ${EndUnless}
michael@0 452
michael@0 453 ClearErrors
michael@0 454 CopyFiles /SILENT "$INSTDIR\$R8" "$R7\$R8" ; try to copy
michael@0 455 ${If} ${Errors}
michael@0 456 ; File is in use
michael@0 457 StrCpy $R9 "true"
michael@0 458 ${Break}
michael@0 459 ${EndIf}
michael@0 460
michael@0 461 Delete "$INSTDIR\$R8" ; delete original
michael@0 462 ${If} ${Errors}
michael@0 463 ; File is in use
michael@0 464 StrCpy $R9 "true"
michael@0 465 Delete "$R7\$R8" ; delete temp copy
michael@0 466 ${Break}
michael@0 467 ${EndIf}
michael@0 468
michael@0 469 Pop $R8 ; get next file to check
michael@0 470 ${EndWhile}
michael@0 471
michael@0 472 ; clear stack
michael@0 473 ${While} $R8 != "end"
michael@0 474 Pop $R8
michael@0 475 ${EndWhile}
michael@0 476
michael@0 477 ; restore everything
michael@0 478 SetOutPath "$INSTDIR"
michael@0 479 CopyFiles /SILENT "$R7\*" "$INSTDIR\"
michael@0 480 RmDir /r "$R7"
michael@0 481 SetOutPath "$EXEDIR"
michael@0 482 ClearErrors
michael@0 483
michael@0 484 Push $R9
michael@0 485 FunctionEnd
michael@0 486
michael@0 487 !verbose pop
michael@0 488 !endif
michael@0 489 !macroend
michael@0 490
michael@0 491 !macro CheckForFilesInUseCall _RESULT
michael@0 492 !verbose push
michael@0 493 !verbose ${_MOZFUNC_VERBOSE}
michael@0 494 Call CheckForFilesInUse
michael@0 495 Pop ${_RESULT}
michael@0 496 !verbose pop
michael@0 497 !macroend
michael@0 498
michael@0 499 !macro un.CheckForFilesInUseCall _RESULT
michael@0 500 !verbose push
michael@0 501 !verbose ${_MOZFUNC_VERBOSE}
michael@0 502 Call un.CheckForFilesInUse
michael@0 503 Pop ${_RESULT}
michael@0 504 !verbose pop
michael@0 505 !macroend
michael@0 506
michael@0 507 !macro un.CheckForFilesInUse
michael@0 508 !ifndef un.CheckForFilesInUse
michael@0 509 !verbose push
michael@0 510 !verbose ${_MOZFUNC_VERBOSE}
michael@0 511 !undef _MOZFUNC_UN
michael@0 512 !define _MOZFUNC_UN "un."
michael@0 513
michael@0 514 !insertmacro CheckForFilesInUse
michael@0 515
michael@0 516 !undef _MOZFUNC_UN
michael@0 517 !define _MOZFUNC_UN
michael@0 518 !verbose pop
michael@0 519 !endif
michael@0 520 !macroend
michael@0 521
michael@0 522 /**
michael@0 523 * The macros below will automatically prepend un. to the function names when
michael@0 524 * they are defined (e.g. !define un.RegCleanMain).
michael@0 525 */
michael@0 526 !verbose push
michael@0 527 !verbose 3
michael@0 528 !ifndef _MOZFUNC_VERBOSE
michael@0 529 !define _MOZFUNC_VERBOSE 3
michael@0 530 !endif
michael@0 531 !verbose ${_MOZFUNC_VERBOSE}
michael@0 532 !define MOZFUNC_VERBOSE "!insertmacro MOZFUNC_VERBOSE"
michael@0 533 !define _MOZFUNC_UN
michael@0 534 !define _MOZFUNC_S
michael@0 535 !verbose pop
michael@0 536
michael@0 537 !macro MOZFUNC_VERBOSE _VERBOSE
michael@0 538 !verbose push
michael@0 539 !verbose 3
michael@0 540 !undef _MOZFUNC_VERBOSE
michael@0 541 !define _MOZFUNC_VERBOSE ${_VERBOSE}
michael@0 542 !verbose pop
michael@0 543 !macroend
michael@0 544
michael@0 545 /**
michael@0 546 * Displays a MessageBox and then calls abort to prevent continuing to the
michael@0 547 * next page when the specified Window Class is found.
michael@0 548 *
michael@0 549 * @param _WINDOW_CLASS
michael@0 550 * The Window Class to search for with FindWindow.
michael@0 551 * @param _MSG
michael@0 552 * The message text to display in the message box.
michael@0 553 *
michael@0 554 * $R7 = return value from FindWindow
michael@0 555 * $R8 = _WINDOW_CLASS
michael@0 556 * $R9 = _MSG
michael@0 557 */
michael@0 558 !macro ManualCloseAppPrompt
michael@0 559
michael@0 560 !ifndef ${_MOZFUNC_UN}ManualCloseAppPrompt
michael@0 561 !verbose push
michael@0 562 !verbose ${_MOZFUNC_VERBOSE}
michael@0 563 !define ${_MOZFUNC_UN}ManualCloseAppPrompt "!insertmacro ${_MOZFUNC_UN}ManualCloseAppPromptCall"
michael@0 564
michael@0 565 Function ${_MOZFUNC_UN}ManualCloseAppPrompt
michael@0 566 Exch $R9
michael@0 567 Exch 1
michael@0 568 Exch $R8
michael@0 569 Push $R7
michael@0 570
michael@0 571 FindWindow $R7 "$R8"
michael@0 572 ${If} $R7 <> 0 ; integer comparison
michael@0 573 MessageBox MB_OK|MB_ICONQUESTION "$R9"
michael@0 574 Abort
michael@0 575 ${EndIf}
michael@0 576
michael@0 577 Pop $R7
michael@0 578 Exch $R8
michael@0 579 Exch 1
michael@0 580 Exch $R9
michael@0 581 FunctionEnd
michael@0 582
michael@0 583 !verbose pop
michael@0 584 !endif
michael@0 585 !macroend
michael@0 586
michael@0 587 !macro ManualCloseAppPromptCall _WINDOW_CLASS _MSG
michael@0 588 !verbose push
michael@0 589 !verbose ${_MOZFUNC_VERBOSE}
michael@0 590 Push "${_WINDOW_CLASS}"
michael@0 591 Push "${_MSG}"
michael@0 592 Call ManualCloseAppPrompt
michael@0 593 !verbose pop
michael@0 594 !macroend
michael@0 595
michael@0 596 !macro un.ManualCloseAppPromptCall _WINDOW_CLASS _MSG
michael@0 597 !verbose push
michael@0 598 !verbose ${_MOZFUNC_VERBOSE}
michael@0 599 Push "${_WINDOW_CLASS}"
michael@0 600 Push "${_MSG}"
michael@0 601 Call un.ManualCloseAppPrompt
michael@0 602 !verbose pop
michael@0 603 !macroend
michael@0 604
michael@0 605 !macro un.ManualCloseAppPrompt
michael@0 606 !ifndef un.ManualCloseAppPrompt
michael@0 607 !verbose push
michael@0 608 !verbose ${_MOZFUNC_VERBOSE}
michael@0 609 !undef _MOZFUNC_UN
michael@0 610 !define _MOZFUNC_UN "un."
michael@0 611
michael@0 612 !insertmacro ManualCloseAppPrompt
michael@0 613
michael@0 614 !undef _MOZFUNC_UN
michael@0 615 !define _MOZFUNC_UN
michael@0 616 !verbose pop
michael@0 617 !endif
michael@0 618 !macroend
michael@0 619
michael@0 620
michael@0 621 ################################################################################
michael@0 622 # Macros for working with the registry
michael@0 623
michael@0 624 /**
michael@0 625 * Writes a registry string using SHCTX and the supplied params and logs the
michael@0 626 * action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
michael@0 627 *
michael@0 628 * Define NO_LOG to prevent all logging when calling this from the uninstaller.
michael@0 629 *
michael@0 630 * @param _ROOT
michael@0 631 * The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
michael@0 632 * This will only be used for logging.
michael@0 633 * @param _KEY
michael@0 634 * The subkey in relation to the key root.
michael@0 635 * @param _NAME
michael@0 636 * The key value name to write to.
michael@0 637 * @param _STR
michael@0 638 * The string to write to the key value name.
michael@0 639 * @param _LOG_UNINSTALL
michael@0 640 * 0 = don't add to uninstall log, 1 = add to uninstall log.
michael@0 641 *
michael@0 642 * $R5 = _ROOT
michael@0 643 * $R6 = _KEY
michael@0 644 * $R7 = _NAME
michael@0 645 * $R8 = _STR
michael@0 646 * $R9 = _LOG_UNINSTALL
michael@0 647 */
michael@0 648 !macro WriteRegStr2
michael@0 649
michael@0 650 !ifndef ${_MOZFUNC_UN}WriteRegStr2
michael@0 651 !verbose push
michael@0 652 !verbose ${_MOZFUNC_VERBOSE}
michael@0 653 !define ${_MOZFUNC_UN}WriteRegStr2 "!insertmacro ${_MOZFUNC_UN}WriteRegStr2Call"
michael@0 654
michael@0 655 Function ${_MOZFUNC_UN}WriteRegStr2
michael@0 656 Exch $R9
michael@0 657 Exch 1
michael@0 658 Exch $R8
michael@0 659 Exch 2
michael@0 660 Exch $R7
michael@0 661 Exch 3
michael@0 662 Exch $R6
michael@0 663 Exch 4
michael@0 664 Exch $R5
michael@0 665
michael@0 666 ClearErrors
michael@0 667 WriteRegStr SHCTX "$R6" "$R7" "$R8"
michael@0 668
michael@0 669 !ifndef NO_LOG
michael@0 670 ${If} ${Errors}
michael@0 671 ${LogMsg} "** ERROR Adding Registry String: $R5 | $R6 | $R7 | $R8 **"
michael@0 672 ${Else}
michael@0 673 ${If} $R9 == 1 ; add to the uninstall log?
michael@0 674 ${LogUninstall} "RegVal: $R5 | $R6 | $R7"
michael@0 675 ${EndIf}
michael@0 676 ${LogMsg} "Added Registry String: $R5 | $R6 | $R7 | $R8"
michael@0 677 ${EndIf}
michael@0 678 !endif
michael@0 679
michael@0 680 Exch $R5
michael@0 681 Exch 4
michael@0 682 Exch $R6
michael@0 683 Exch 3
michael@0 684 Exch $R7
michael@0 685 Exch 2
michael@0 686 Exch $R8
michael@0 687 Exch 1
michael@0 688 Exch $R9
michael@0 689 FunctionEnd
michael@0 690
michael@0 691 !verbose pop
michael@0 692 !endif
michael@0 693 !macroend
michael@0 694
michael@0 695 !macro WriteRegStr2Call _ROOT _KEY _NAME _STR _LOG_UNINSTALL
michael@0 696 !verbose push
michael@0 697 !verbose ${_MOZFUNC_VERBOSE}
michael@0 698 Push "${_ROOT}"
michael@0 699 Push "${_KEY}"
michael@0 700 Push "${_NAME}"
michael@0 701 Push "${_STR}"
michael@0 702 Push "${_LOG_UNINSTALL}"
michael@0 703 Call WriteRegStr2
michael@0 704 !verbose pop
michael@0 705 !macroend
michael@0 706
michael@0 707 !macro un.WriteRegStr2Call _ROOT _KEY _NAME _STR _LOG_UNINSTALL
michael@0 708 !verbose push
michael@0 709 !verbose ${_MOZFUNC_VERBOSE}
michael@0 710 Push "${_ROOT}"
michael@0 711 Push "${_KEY}"
michael@0 712 Push "${_NAME}"
michael@0 713 Push "${_STR}"
michael@0 714 Push "${_LOG_UNINSTALL}"
michael@0 715 Call un.WriteRegStr2
michael@0 716 !verbose pop
michael@0 717 !macroend
michael@0 718
michael@0 719 !macro un.WriteRegStr2
michael@0 720 !ifndef un.WriteRegStr2
michael@0 721 !verbose push
michael@0 722 !verbose ${_MOZFUNC_VERBOSE}
michael@0 723 !undef _MOZFUNC_UN
michael@0 724 !define _MOZFUNC_UN "un."
michael@0 725
michael@0 726 !insertmacro WriteRegStr2
michael@0 727
michael@0 728 !undef _MOZFUNC_UN
michael@0 729 !define _MOZFUNC_UN
michael@0 730 !verbose pop
michael@0 731 !endif
michael@0 732 !macroend
michael@0 733
michael@0 734 /**
michael@0 735 * Writes a registry dword using SHCTX and the supplied params and logs the
michael@0 736 * action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
michael@0 737 *
michael@0 738 * Define NO_LOG to prevent all logging when calling this from the uninstaller.
michael@0 739 *
michael@0 740 * @param _ROOT
michael@0 741 * The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
michael@0 742 * This will only be used for logging.
michael@0 743 * @param _KEY
michael@0 744 * The subkey in relation to the key root.
michael@0 745 * @param _NAME
michael@0 746 * The key value name to write to.
michael@0 747 * @param _DWORD
michael@0 748 * The dword to write to the key value name.
michael@0 749 * @param _LOG_UNINSTALL
michael@0 750 * 0 = don't add to uninstall log, 1 = add to uninstall log.
michael@0 751 *
michael@0 752 * $R5 = _ROOT
michael@0 753 * $R6 = _KEY
michael@0 754 * $R7 = _NAME
michael@0 755 * $R8 = _DWORD
michael@0 756 * $R9 = _LOG_UNINSTALL
michael@0 757 */
michael@0 758 !macro WriteRegDWORD2
michael@0 759
michael@0 760 !ifndef ${_MOZFUNC_UN}WriteRegDWORD2
michael@0 761 !verbose push
michael@0 762 !verbose ${_MOZFUNC_VERBOSE}
michael@0 763 !define ${_MOZFUNC_UN}WriteRegDWORD2 "!insertmacro ${_MOZFUNC_UN}WriteRegDWORD2Call"
michael@0 764
michael@0 765 Function ${_MOZFUNC_UN}WriteRegDWORD2
michael@0 766 Exch $R9
michael@0 767 Exch 1
michael@0 768 Exch $R8
michael@0 769 Exch 2
michael@0 770 Exch $R7
michael@0 771 Exch 3
michael@0 772 Exch $R6
michael@0 773 Exch 4
michael@0 774 Exch $R5
michael@0 775
michael@0 776 ClearErrors
michael@0 777 WriteRegDWORD SHCTX "$R6" "$R7" "$R8"
michael@0 778
michael@0 779 !ifndef NO_LOG
michael@0 780 ${If} ${Errors}
michael@0 781 ${LogMsg} "** ERROR Adding Registry DWord: $R5 | $R6 | $R7 | $R8 **"
michael@0 782 ${Else}
michael@0 783 ${If} $R9 == 1 ; add to the uninstall log?
michael@0 784 ${LogUninstall} "RegVal: $R5 | $R6 | $R7"
michael@0 785 ${EndIf}
michael@0 786 ${LogMsg} "Added Registry DWord: $R5 | $R6 | $R7 | $R8"
michael@0 787 ${EndIf}
michael@0 788 !endif
michael@0 789
michael@0 790 Exch $R5
michael@0 791 Exch 4
michael@0 792 Exch $R6
michael@0 793 Exch 3
michael@0 794 Exch $R7
michael@0 795 Exch 2
michael@0 796 Exch $R8
michael@0 797 Exch 1
michael@0 798 Exch $R9
michael@0 799 FunctionEnd
michael@0 800
michael@0 801 !verbose pop
michael@0 802 !endif
michael@0 803 !macroend
michael@0 804
michael@0 805 !macro WriteRegDWORD2Call _ROOT _KEY _NAME _DWORD _LOG_UNINSTALL
michael@0 806 !verbose push
michael@0 807 !verbose ${_MOZFUNC_VERBOSE}
michael@0 808 Push "${_ROOT}"
michael@0 809 Push "${_KEY}"
michael@0 810 Push "${_NAME}"
michael@0 811 Push "${_DWORD}"
michael@0 812 Push "${_LOG_UNINSTALL}"
michael@0 813 Call WriteRegDWORD2
michael@0 814 !verbose pop
michael@0 815 !macroend
michael@0 816
michael@0 817 !macro un.WriteRegDWORD2Call _ROOT _KEY _NAME _DWORD _LOG_UNINSTALL
michael@0 818 !verbose push
michael@0 819 !verbose ${_MOZFUNC_VERBOSE}
michael@0 820 Push "${_ROOT}"
michael@0 821 Push "${_KEY}"
michael@0 822 Push "${_NAME}"
michael@0 823 Push "${_DWORD}"
michael@0 824 Push "${_LOG_UNINSTALL}"
michael@0 825 Call un.WriteRegDWORD2
michael@0 826 !verbose pop
michael@0 827 !macroend
michael@0 828
michael@0 829 !macro un.WriteRegDWORD2
michael@0 830 !ifndef un.WriteRegDWORD2
michael@0 831 !verbose push
michael@0 832 !verbose ${_MOZFUNC_VERBOSE}
michael@0 833 !undef _MOZFUNC_UN
michael@0 834 !define _MOZFUNC_UN "un."
michael@0 835
michael@0 836 !insertmacro WriteRegDWORD2
michael@0 837
michael@0 838 !undef _MOZFUNC_UN
michael@0 839 !define _MOZFUNC_UN
michael@0 840 !verbose pop
michael@0 841 !endif
michael@0 842 !macroend
michael@0 843
michael@0 844 /**
michael@0 845 * Writes a registry string to HKCR using the supplied params and logs the
michael@0 846 * action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
michael@0 847 *
michael@0 848 * Define NO_LOG to prevent all logging when calling this from the uninstaller.
michael@0 849 *
michael@0 850 * @param _ROOT
michael@0 851 * The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
michael@0 852 * This will only be used for logging.
michael@0 853 * @param _KEY
michael@0 854 * The subkey in relation to the key root.
michael@0 855 * @param _NAME
michael@0 856 * The key value name to write to.
michael@0 857 * @param _STR
michael@0 858 * The string to write to the key value name.
michael@0 859 * @param _LOG_UNINSTALL
michael@0 860 * 0 = don't add to uninstall log, 1 = add to uninstall log.
michael@0 861 *
michael@0 862 * $R5 = _ROOT
michael@0 863 * $R6 = _KEY
michael@0 864 * $R7 = _NAME
michael@0 865 * $R8 = _STR
michael@0 866 * $R9 = _LOG_UNINSTALL
michael@0 867 */
michael@0 868 !macro WriteRegStrHKCR
michael@0 869
michael@0 870 !ifndef ${_MOZFUNC_UN}WriteRegStrHKCR
michael@0 871 !verbose push
michael@0 872 !verbose ${_MOZFUNC_VERBOSE}
michael@0 873 !define ${_MOZFUNC_UN}WriteRegStrHKCR "!insertmacro ${_MOZFUNC_UN}WriteRegStrHKCRCall"
michael@0 874
michael@0 875 Function ${_MOZFUNC_UN}WriteRegStrHKCR
michael@0 876 Exch $R9
michael@0 877 Exch 1
michael@0 878 Exch $R8
michael@0 879 Exch 2
michael@0 880 Exch $R7
michael@0 881 Exch 3
michael@0 882 Exch $R6
michael@0 883 Exch 4
michael@0 884 Exch $R5
michael@0 885
michael@0 886 ClearErrors
michael@0 887 WriteRegStr HKCR "$R6" "$R7" "$R8"
michael@0 888
michael@0 889 !ifndef NO_LOG
michael@0 890 ${If} ${Errors}
michael@0 891 ${LogMsg} "** ERROR Adding Registry String: $R5 | $R6 | $R7 | $R8 **"
michael@0 892 ${Else}
michael@0 893 ${If} $R9 == 1 ; add to the uninstall log?
michael@0 894 ${LogUninstall} "RegVal: $R5 | $R6 | $R7"
michael@0 895 ${EndIf}
michael@0 896 ${LogMsg} "Added Registry String: $R5 | $R6 | $R7 | $R8"
michael@0 897 ${EndIf}
michael@0 898 !endif
michael@0 899
michael@0 900 Exch $R5
michael@0 901 Exch 4
michael@0 902 Exch $R6
michael@0 903 Exch 3
michael@0 904 Exch $R7
michael@0 905 Exch 2
michael@0 906 Exch $R8
michael@0 907 Exch 1
michael@0 908 Exch $R9
michael@0 909 FunctionEnd
michael@0 910
michael@0 911 !verbose pop
michael@0 912 !endif
michael@0 913 !macroend
michael@0 914
michael@0 915 !macro WriteRegStrHKCRCall _ROOT _KEY _NAME _STR _LOG_UNINSTALL
michael@0 916 !verbose push
michael@0 917 !verbose ${_MOZFUNC_VERBOSE}
michael@0 918 Push "${_ROOT}"
michael@0 919 Push "${_KEY}"
michael@0 920 Push "${_NAME}"
michael@0 921 Push "${_STR}"
michael@0 922 Push "${_LOG_UNINSTALL}"
michael@0 923 Call WriteRegStrHKCR
michael@0 924 !verbose pop
michael@0 925 !macroend
michael@0 926
michael@0 927 !macro un.WriteRegStrHKCRCall _ROOT _KEY _NAME _STR _LOG_UNINSTALL
michael@0 928 !verbose push
michael@0 929 !verbose ${_MOZFUNC_VERBOSE}
michael@0 930 Push "${_ROOT}"
michael@0 931 Push "${_KEY}"
michael@0 932 Push "${_NAME}"
michael@0 933 Push "${_STR}"
michael@0 934 Push "${_LOG_UNINSTALL}"
michael@0 935 Call un.WriteRegStrHKCR
michael@0 936 !verbose pop
michael@0 937 !macroend
michael@0 938
michael@0 939 !macro un.WriteRegStrHKCR
michael@0 940 !ifndef un.WriteRegStrHKCR
michael@0 941 !verbose push
michael@0 942 !verbose ${_MOZFUNC_VERBOSE}
michael@0 943 !undef _MOZFUNC_UN
michael@0 944 !define _MOZFUNC_UN "un."
michael@0 945
michael@0 946 !insertmacro WriteRegStrHKCR
michael@0 947
michael@0 948 !undef _MOZFUNC_UN
michael@0 949 !define _MOZFUNC_UN
michael@0 950 !verbose pop
michael@0 951 !endif
michael@0 952 !macroend
michael@0 953
michael@0 954 !ifndef KEY_SET_VALUE
michael@0 955 !define KEY_SET_VALUE 0x0002
michael@0 956 !endif
michael@0 957 !ifndef KEY_WOW64_64KEY
michael@0 958 !define KEY_WOW64_64KEY 0x0100
michael@0 959 !endif
michael@0 960 !ifndef HAVE_64BIT_OS
michael@0 961 !define CREATE_KEY_SAM ${KEY_SET_VALUE}
michael@0 962 !else
michael@0 963 !define CREATE_KEY_SAM ${KEY_SET_VALUE}|${KEY_WOW64_64KEY}
michael@0 964 !endif
michael@0 965
michael@0 966 /**
michael@0 967 * Creates a registry key. This will log the actions to the install and
michael@0 968 * uninstall logs. Alternatively you can set a registry value to create the key
michael@0 969 * and then delete the value.
michael@0 970 *
michael@0 971 * Define NO_LOG to prevent all logging when calling this from the uninstaller.
michael@0 972 *
michael@0 973 * @param _ROOT
michael@0 974 * The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
michael@0 975 * @param _KEY
michael@0 976 * The subkey in relation to the key root.
michael@0 977 * @param _LOG_UNINSTALL
michael@0 978 * 0 = don't add to uninstall log, 1 = add to uninstall log.
michael@0 979 *
michael@0 980 * $R4 = [out] handle to newly created registry key. If this is not a key
michael@0 981 * located in one of the predefined registry keys this must be closed
michael@0 982 * with RegCloseKey (this should not be needed unless someone decides to
michael@0 983 * do something extremely squirrelly with NSIS).
michael@0 984 * $R5 = return value from RegCreateKeyExW (represented by R5 in the system call).
michael@0 985 * $R6 = [in] hKey passed to RegCreateKeyExW.
michael@0 986 * $R7 = _ROOT
michael@0 987 * $R8 = _KEY
michael@0 988 * $R9 = _LOG_UNINSTALL
michael@0 989 */
michael@0 990 !macro CreateRegKey
michael@0 991
michael@0 992 !ifndef ${_MOZFUNC_UN}CreateRegKey
michael@0 993 !verbose push
michael@0 994 !verbose ${_MOZFUNC_VERBOSE}
michael@0 995 !define ${_MOZFUNC_UN}CreateRegKey "!insertmacro ${_MOZFUNC_UN}CreateRegKeyCall"
michael@0 996
michael@0 997 Function ${_MOZFUNC_UN}CreateRegKey
michael@0 998 Exch $R9
michael@0 999 Exch 1
michael@0 1000 Exch $R8
michael@0 1001 Exch 2
michael@0 1002 Exch $R7
michael@0 1003 Push $R6
michael@0 1004 Push $R5
michael@0 1005 Push $R4
michael@0 1006
michael@0 1007 StrCmp $R7 "HKCR" +1 +2
michael@0 1008 StrCpy $R6 "0x80000000"
michael@0 1009 StrCmp $R7 "HKCU" +1 +2
michael@0 1010 StrCpy $R6 "0x80000001"
michael@0 1011 StrCmp $R7 "HKLM" +1 +2
michael@0 1012 StrCpy $R6 "0x80000002"
michael@0 1013
michael@0 1014 ; see definition of RegCreateKey
michael@0 1015 System::Call "Advapi32::RegCreateKeyExW(i R6, w R8, i 0, i 0, i 0,\
michael@0 1016 i ${CREATE_KEY_SAM}, i 0, *i .R4,\
michael@0 1017 i 0) i .R5"
michael@0 1018
michael@0 1019 !ifndef NO_LOG
michael@0 1020 ; if $R5 is not 0 then there was an error creating the registry key.
michael@0 1021 ${If} $R5 <> 0
michael@0 1022 ${LogMsg} "** ERROR Adding Registry Key: $R7 | $R8 **"
michael@0 1023 ${Else}
michael@0 1024 ${If} $R9 == 1 ; add to the uninstall log?
michael@0 1025 ${LogUninstall} "RegKey: $R7 | $R8"
michael@0 1026 ${EndIf}
michael@0 1027 ${LogMsg} "Added Registry Key: $R7 | $R8"
michael@0 1028 ${EndIf}
michael@0 1029 !endif
michael@0 1030
michael@0 1031 StrCmp $R5 0 +1 +2
michael@0 1032 System::Call "Advapi32::RegCloseKey(iR4)"
michael@0 1033
michael@0 1034 Pop $R4
michael@0 1035 Pop $R5
michael@0 1036 Pop $R6
michael@0 1037 Exch $R7
michael@0 1038 Exch 2
michael@0 1039 Exch $R8
michael@0 1040 Exch 1
michael@0 1041 Exch $R9
michael@0 1042 FunctionEnd
michael@0 1043
michael@0 1044 !verbose pop
michael@0 1045 !endif
michael@0 1046 !macroend
michael@0 1047
michael@0 1048 !macro CreateRegKeyCall _ROOT _KEY _LOG_UNINSTALL
michael@0 1049 !verbose push
michael@0 1050 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1051 Push "${_ROOT}"
michael@0 1052 Push "${_KEY}"
michael@0 1053 Push "${_LOG_UNINSTALL}"
michael@0 1054 Call CreateRegKey
michael@0 1055 !verbose pop
michael@0 1056 !macroend
michael@0 1057
michael@0 1058 !macro un.CreateRegKeyCall _ROOT _KEY _LOG_UNINSTALL
michael@0 1059 !verbose push
michael@0 1060 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1061 Push "${_ROOT}"
michael@0 1062 Push "${_KEY}"
michael@0 1063 Push "${_LOG_UNINSTALL}"
michael@0 1064 Call un.CreateRegKey
michael@0 1065 !verbose pop
michael@0 1066 !macroend
michael@0 1067
michael@0 1068 !macro un.CreateRegKey
michael@0 1069 !ifndef un.CreateRegKey
michael@0 1070 !verbose push
michael@0 1071 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1072 !undef _MOZFUNC_UN
michael@0 1073 !define _MOZFUNC_UN "un."
michael@0 1074
michael@0 1075 !insertmacro CreateRegKey
michael@0 1076
michael@0 1077 !undef _MOZFUNC_UN
michael@0 1078 !define _MOZFUNC_UN
michael@0 1079 !verbose pop
michael@0 1080 !endif
michael@0 1081 !macroend
michael@0 1082
michael@0 1083 /**
michael@0 1084 * Helper for checking for the existence of a registry key.
michael@0 1085 * SHCTX is the root key to search.
michael@0 1086 *
michael@0 1087 * @param _MAIN_KEY
michael@0 1088 * Sub key to iterate for the key in question
michael@0 1089 * @param _KEY
michael@0 1090 * Key name to search for
michael@0 1091 * @return _RESULT
michael@0 1092 * 'true' / 'false' result
michael@0 1093 */
michael@0 1094 !macro CheckIfRegistryKeyExists
michael@0 1095 !ifndef CheckIfRegistryKeyExists
michael@0 1096 !verbose push
michael@0 1097 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1098 !define CheckIfRegistryKeyExists "!insertmacro CheckIfRegistryKeyExistsCall"
michael@0 1099
michael@0 1100 Function CheckIfRegistryKeyExists
michael@0 1101 ; stack: main key, key
michael@0 1102 Exch $R9 ; main key, stack: old R9, key
michael@0 1103 Exch 1 ; stack: key, old R9
michael@0 1104 Exch $R8 ; key, stack: old R8, old R9
michael@0 1105 Push $R7
michael@0 1106 Push $R6
michael@0 1107 Push $R5
michael@0 1108
michael@0 1109 StrCpy $R5 "false"
michael@0 1110 StrCpy $R7 "0" # loop index
michael@0 1111 ${Do}
michael@0 1112 EnumRegKey $R6 SHCTX "$R9" "$R7"
michael@0 1113 ${If} "$R6" == "$R8"
michael@0 1114 StrCpy $R5 "true"
michael@0 1115 ${Break}
michael@0 1116 ${EndIf}
michael@0 1117 IntOp $R7 $R7 + 1
michael@0 1118 ${LoopWhile} $R6 != ""
michael@0 1119 ClearErrors
michael@0 1120
michael@0 1121 StrCpy $R9 $R5
michael@0 1122
michael@0 1123 Pop $R5
michael@0 1124 Pop $R6
michael@0 1125 Pop $R7 ; stack: old R8, old R9
michael@0 1126 Pop $R8 ; stack: old R9
michael@0 1127 Exch $R9 ; stack: result
michael@0 1128 FunctionEnd
michael@0 1129
michael@0 1130 !verbose pop
michael@0 1131 !endif
michael@0 1132 !macroend
michael@0 1133
michael@0 1134 !macro CheckIfRegistryKeyExistsCall _MAIN_KEY _KEY _RESULT
michael@0 1135 !verbose push
michael@0 1136 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1137 Push "${_KEY}"
michael@0 1138 Push "${_MAIN_KEY}"
michael@0 1139 Call CheckIfRegistryKeyExists
michael@0 1140 Pop ${_RESULT}
michael@0 1141 !verbose pop
michael@0 1142 !macroend
michael@0 1143
michael@0 1144 ################################################################################
michael@0 1145 # Macros for adding file and protocol handlers
michael@0 1146
michael@0 1147 /**
michael@0 1148 * Writes common registry values for a handler using SHCTX.
michael@0 1149 *
michael@0 1150 * @param _KEY
michael@0 1151 * The subkey in relation to the key root.
michael@0 1152 * @param _VALOPEN
michael@0 1153 * The path and args to launch the application.
michael@0 1154 * @param _VALICON
michael@0 1155 * The path to the binary that contains the icon group for the default icon
michael@0 1156 * followed by a comma and either the icon group's resource index or the icon
michael@0 1157 * group's resource id prefixed with a minus sign
michael@0 1158 * @param _DISPNAME
michael@0 1159 * The display name for the handler. If emtpy no value will be set.
michael@0 1160 * @param _ISPROTOCOL
michael@0 1161 * Sets protocol handler specific registry values when "true".
michael@0 1162 * Deletes protocol handler specific registry values when "delete".
michael@0 1163 * Otherwise doesn't touch handler specific registry values.
michael@0 1164 * @param _ISDDE
michael@0 1165 * Sets DDE specific registry values when "true".
michael@0 1166 *
michael@0 1167 * $R3 = string value of the current registry key path.
michael@0 1168 * $R4 = _KEY
michael@0 1169 * $R5 = _VALOPEN
michael@0 1170 * $R6 = _VALICON
michael@0 1171 * $R7 = _DISPNAME
michael@0 1172 * $R8 = _ISPROTOCOL
michael@0 1173 * $R9 = _ISDDE
michael@0 1174 */
michael@0 1175 !macro AddHandlerValues
michael@0 1176
michael@0 1177 !ifndef ${_MOZFUNC_UN}AddHandlerValues
michael@0 1178 !verbose push
michael@0 1179 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1180 !define ${_MOZFUNC_UN}AddHandlerValues "!insertmacro ${_MOZFUNC_UN}AddHandlerValuesCall"
michael@0 1181
michael@0 1182 Function ${_MOZFUNC_UN}AddHandlerValues
michael@0 1183 Exch $R9
michael@0 1184 Exch 1
michael@0 1185 Exch $R8
michael@0 1186 Exch 2
michael@0 1187 Exch $R7
michael@0 1188 Exch 3
michael@0 1189 Exch $R6
michael@0 1190 Exch 4
michael@0 1191 Exch $R5
michael@0 1192 Exch 5
michael@0 1193 Exch $R4
michael@0 1194 Push $R3
michael@0 1195
michael@0 1196 StrCmp "$R7" "" +6 +1
michael@0 1197 ReadRegStr $R3 SHCTX "$R4" "FriendlyTypeName"
michael@0 1198
michael@0 1199 StrCmp "$R3" "" +1 +3
michael@0 1200 WriteRegStr SHCTX "$R4" "" "$R7"
michael@0 1201 WriteRegStr SHCTX "$R4" "FriendlyTypeName" "$R7"
michael@0 1202
michael@0 1203 StrCmp "$R8" "true" +1 +2
michael@0 1204 WriteRegStr SHCTX "$R4" "URL Protocol" ""
michael@0 1205 StrCmp "$R8" "delete" +1 +2
michael@0 1206 DeleteRegValue SHCTX "$R4" "URL Protocol"
michael@0 1207 StrCpy $R3 ""
michael@0 1208 ReadRegDWord $R3 SHCTX "$R4" "EditFlags"
michael@0 1209 StrCmp $R3 "" +1 +3 ; Only add EditFlags if a value doesn't exist
michael@0 1210 DeleteRegValue SHCTX "$R4" "EditFlags"
michael@0 1211 WriteRegDWord SHCTX "$R4" "EditFlags" 0x00000002
michael@0 1212
michael@0 1213 StrCmp "$R6" "" +2 +1
michael@0 1214 WriteRegStr SHCTX "$R4\DefaultIcon" "" "$R6"
michael@0 1215
michael@0 1216 StrCmp "$R5" "" +2 +1
michael@0 1217 WriteRegStr SHCTX "$R4\shell\open\command" "" "$R5"
michael@0 1218
michael@0 1219 !ifdef DDEApplication
michael@0 1220 StrCmp "$R9" "true" +1 +11
michael@0 1221 WriteRegStr SHCTX "$R4\shell\open\ddeexec" "" "$\"%1$\",,0,0,,,,"
michael@0 1222 WriteRegStr SHCTX "$R4\shell\open\ddeexec" "NoActivateHandler" ""
michael@0 1223 WriteRegStr SHCTX "$R4\shell\open\ddeexec\Application" "" "${DDEApplication}"
michael@0 1224 WriteRegStr SHCTX "$R4\shell\open\ddeexec\Topic" "" "WWW_OpenURL"
michael@0 1225 ; The ifexec key may have been added by another application so try to
michael@0 1226 ; delete it to prevent it from breaking this app's shell integration.
michael@0 1227 ; Also, IE 6 and below doesn't remove this key when it sets itself as the
michael@0 1228 ; default handler and if this key exists IE's shell integration breaks.
michael@0 1229 DeleteRegKey HKLM "$R4\shell\open\ddeexec\ifexec"
michael@0 1230 DeleteRegKey HKCU "$R4\shell\open\ddeexec\ifexec"
michael@0 1231 !endif
michael@0 1232
michael@0 1233 ClearErrors
michael@0 1234
michael@0 1235 Pop $R3
michael@0 1236 Exch $R4
michael@0 1237 Exch 5
michael@0 1238 Exch $R5
michael@0 1239 Exch 4
michael@0 1240 Exch $R6
michael@0 1241 Exch 3
michael@0 1242 Exch $R7
michael@0 1243 Exch 2
michael@0 1244 Exch $R8
michael@0 1245 Exch 1
michael@0 1246 Exch $R9
michael@0 1247 FunctionEnd
michael@0 1248
michael@0 1249 !verbose pop
michael@0 1250 !endif
michael@0 1251 !macroend
michael@0 1252
michael@0 1253 !macro AddHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _ISDDE
michael@0 1254 !verbose push
michael@0 1255 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1256 Push "${_KEY}"
michael@0 1257 Push "${_VALOPEN}"
michael@0 1258 Push "${_VALICON}"
michael@0 1259 Push "${_DISPNAME}"
michael@0 1260 Push "${_ISPROTOCOL}"
michael@0 1261 Push "${_ISDDE}"
michael@0 1262 Call AddHandlerValues
michael@0 1263 !verbose pop
michael@0 1264 !macroend
michael@0 1265
michael@0 1266 !macro un.AddHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _ISDDE
michael@0 1267 !verbose push
michael@0 1268 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1269 Push "${_KEY}"
michael@0 1270 Push "${_VALOPEN}"
michael@0 1271 Push "${_VALICON}"
michael@0 1272 Push "${_DISPNAME}"
michael@0 1273 Push "${_ISPROTOCOL}"
michael@0 1274 Push "${_ISDDE}"
michael@0 1275 Call un.AddHandlerValues
michael@0 1276 !verbose pop
michael@0 1277 !macroend
michael@0 1278
michael@0 1279 !macro un.AddHandlerValues
michael@0 1280 !ifndef un.AddHandlerValues
michael@0 1281 !verbose push
michael@0 1282 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1283 !undef _MOZFUNC_UN
michael@0 1284 !define _MOZFUNC_UN "un."
michael@0 1285
michael@0 1286 !insertmacro AddHandlerValues
michael@0 1287
michael@0 1288 !undef _MOZFUNC_UN
michael@0 1289 !define _MOZFUNC_UN
michael@0 1290 !verbose pop
michael@0 1291 !endif
michael@0 1292 !macroend
michael@0 1293
michael@0 1294 /**
michael@0 1295 * Writes common registry values for a handler that uses DDE using SHCTX.
michael@0 1296 *
michael@0 1297 * @param _KEY
michael@0 1298 * The key name in relation to the HKCR root. SOFTWARE\Classes is
michael@0 1299 * prefixed to this value when using SHCTX.
michael@0 1300 * @param _VALOPEN
michael@0 1301 * The path and args to launch the application.
michael@0 1302 * @param _VALICON
michael@0 1303 * The path to the binary that contains the icon group for the default icon
michael@0 1304 * followed by a comma and either the icon group's resource index or the icon
michael@0 1305 * group's resource id prefixed with a minus sign
michael@0 1306 * @param _DISPNAME
michael@0 1307 * The display name for the handler. If emtpy no value will be set.
michael@0 1308 * @param _ISPROTOCOL
michael@0 1309 * Sets protocol handler specific registry values when "true".
michael@0 1310 * Deletes protocol handler specific registry values when "delete".
michael@0 1311 * Otherwise doesn't touch handler specific registry values.
michael@0 1312 * @param _DDE_APPNAME
michael@0 1313 * Sets DDE specific registry values when not an empty string.
michael@0 1314 *
michael@0 1315 * $R0 = storage for SOFTWARE\Classes
michael@0 1316 * $R1 = string value of the current registry key path.
michael@0 1317 * $R2 = _KEY
michael@0 1318 * $R3 = _VALOPEN
michael@0 1319 * $R4 = _VALICON
michael@0 1320 * $R5 = _DISPNAME
michael@0 1321 * $R6 = _ISPROTOCOL
michael@0 1322 * $R7 = _DDE_APPNAME
michael@0 1323 * $R8 = _DDE_DEFAULT
michael@0 1324 * $R9 = _DDE_TOPIC
michael@0 1325 */
michael@0 1326 !macro AddDDEHandlerValues
michael@0 1327
michael@0 1328 !ifndef ${_MOZFUNC_UN}AddDDEHandlerValues
michael@0 1329 !verbose push
michael@0 1330 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1331 !define ${_MOZFUNC_UN}AddDDEHandlerValues "!insertmacro ${_MOZFUNC_UN}AddDDEHandlerValuesCall"
michael@0 1332
michael@0 1333 Function ${_MOZFUNC_UN}AddDDEHandlerValues
michael@0 1334 Exch $R9
michael@0 1335 Exch 1
michael@0 1336 Exch $R8
michael@0 1337 Exch 2
michael@0 1338 Exch $R7
michael@0 1339 Exch 3
michael@0 1340 Exch $R6
michael@0 1341 Exch 4
michael@0 1342 Exch $R5
michael@0 1343 Exch 5
michael@0 1344 Exch $R4
michael@0 1345 Exch 6
michael@0 1346 Exch $R3
michael@0 1347 Exch 7
michael@0 1348 Exch $R2
michael@0 1349 Push $R1
michael@0 1350 Push $R0
michael@0 1351
michael@0 1352 StrCpy $R0 "SOFTWARE\Classes"
michael@0 1353 StrCmp "$R5" "" +6 +1
michael@0 1354 ReadRegStr $R1 SHCTX "$R2" "FriendlyTypeName"
michael@0 1355
michael@0 1356 StrCmp "$R1" "" +1 +3
michael@0 1357 WriteRegStr SHCTX "$R0\$R2" "" "$R5"
michael@0 1358 WriteRegStr SHCTX "$R0\$R2" "FriendlyTypeName" "$R5"
michael@0 1359
michael@0 1360 StrCmp "$R6" "true" +1 +2
michael@0 1361 WriteRegStr SHCTX "$R0\$R2" "URL Protocol" ""
michael@0 1362 StrCmp "$R6" "delete" +1 +2
michael@0 1363 DeleteRegValue SHCTX "$R0\$R2" "URL Protocol"
michael@0 1364 StrCpy $R1 ""
michael@0 1365 ReadRegDWord $R1 SHCTX "$R0\$R2" "EditFlags"
michael@0 1366 StrCmp $R1 "" +1 +3 ; Only add EditFlags if a value doesn't exist
michael@0 1367 DeleteRegValue SHCTX "$R0\$R2" "EditFlags"
michael@0 1368 WriteRegDWord SHCTX "$R0\$R2" "EditFlags" 0x00000002
michael@0 1369
michael@0 1370 StrCmp "$R4" "" +2 +1
michael@0 1371 WriteRegStr SHCTX "$R0\$R2\DefaultIcon" "" "$R4"
michael@0 1372
michael@0 1373 WriteRegStr SHCTX "$R0\$R2\shell" "" "open"
michael@0 1374 WriteRegStr SHCTX "$R0\$R2\shell\open\command" "" "$R3"
michael@0 1375
michael@0 1376 WriteRegStr SHCTX "$R0\$R2\shell\open\ddeexec" "" "$R8"
michael@0 1377 WriteRegStr SHCTX "$R0\$R2\shell\open\ddeexec" "NoActivateHandler" ""
michael@0 1378 WriteRegStr SHCTX "$R0\$R2\shell\open\ddeexec\Application" "" "$R7"
michael@0 1379 WriteRegStr SHCTX "$R0\$R2\shell\open\ddeexec\Topic" "" "$R9"
michael@0 1380
michael@0 1381 ; The ifexec key may have been added by another application so try to
michael@0 1382 ; delete it to prevent it from breaking this app's shell integration.
michael@0 1383 ; Also, IE 6 and below doesn't remove this key when it sets itself as the
michael@0 1384 ; default handler and if this key exists IE's shell integration breaks.
michael@0 1385 DeleteRegKey HKLM "$R0\$R2\shell\open\ddeexec\ifexec"
michael@0 1386 DeleteRegKey HKCU "$R0\$R2\shell\open\ddeexec\ifexec"
michael@0 1387 ClearErrors
michael@0 1388
michael@0 1389 Pop $R0
michael@0 1390 Pop $R1
michael@0 1391 Exch $R2
michael@0 1392 Exch 7
michael@0 1393 Exch $R3
michael@0 1394 Exch 6
michael@0 1395 Exch $R4
michael@0 1396 Exch 5
michael@0 1397 Exch $R5
michael@0 1398 Exch 4
michael@0 1399 Exch $R6
michael@0 1400 Exch 3
michael@0 1401 Exch $R7
michael@0 1402 Exch 2
michael@0 1403 Exch $R8
michael@0 1404 Exch 1
michael@0 1405 Exch $R9
michael@0 1406 FunctionEnd
michael@0 1407
michael@0 1408 !verbose pop
michael@0 1409 !endif
michael@0 1410 !macroend
michael@0 1411
michael@0 1412 !macro AddDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _DDE_APPNAME _DDE_DEFAULT _DDE_TOPIC
michael@0 1413 !verbose push
michael@0 1414 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1415 Push "${_KEY}"
michael@0 1416 Push "${_VALOPEN}"
michael@0 1417 Push "${_VALICON}"
michael@0 1418 Push "${_DISPNAME}"
michael@0 1419 Push "${_ISPROTOCOL}"
michael@0 1420 Push "${_DDE_APPNAME}"
michael@0 1421 Push "${_DDE_DEFAULT}"
michael@0 1422 Push "${_DDE_TOPIC}"
michael@0 1423 Call AddDDEHandlerValues
michael@0 1424 !verbose pop
michael@0 1425 !macroend
michael@0 1426
michael@0 1427 !macro un.AddDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _DDE_APPNAME _DDE_DEFAULT _DDE_TOPIC
michael@0 1428 !verbose push
michael@0 1429 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1430 Push "${_KEY}"
michael@0 1431 Push "${_VALOPEN}"
michael@0 1432 Push "${_VALICON}"
michael@0 1433 Push "${_DISPNAME}"
michael@0 1434 Push "${_ISPROTOCOL}"
michael@0 1435 Push "${_DDE_APPNAME}"
michael@0 1436 Push "${_DDE_DEFAULT}"
michael@0 1437 Push "${_DDE_TOPIC}"
michael@0 1438 Call un.AddDDEHandlerValues
michael@0 1439 !verbose pop
michael@0 1440 !macroend
michael@0 1441
michael@0 1442 !macro un.AddDDEHandlerValues
michael@0 1443 !ifndef un.AddDDEHandlerValues
michael@0 1444 !verbose push
michael@0 1445 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1446 !undef _MOZFUNC_UN
michael@0 1447 !define _MOZFUNC_UN "un."
michael@0 1448
michael@0 1449 !insertmacro AddDDEHandlerValues
michael@0 1450
michael@0 1451 !undef _MOZFUNC_UN
michael@0 1452 !define _MOZFUNC_UN
michael@0 1453 !verbose pop
michael@0 1454 !endif
michael@0 1455 !macroend
michael@0 1456
michael@0 1457 /**
michael@0 1458 * Writes common registry values for a handler that DOES NOT use DDE using SHCTX.
michael@0 1459 *
michael@0 1460 * @param _KEY
michael@0 1461 * The key name in relation to the HKCR root. SOFTWARE\Classes is
michael@0 1462 * prefixed to this value when using SHCTX.
michael@0 1463 * @param _VALOPEN
michael@0 1464 * The path and args to launch the application.
michael@0 1465 * @param _VALICON
michael@0 1466 * The path to the binary that contains the icon group for the default icon
michael@0 1467 * followed by a comma and either the icon group's resource index or the icon
michael@0 1468 * group's resource id prefixed with a minus sign
michael@0 1469 * @param _DISPNAME
michael@0 1470 * The display name for the handler. If emtpy no value will be set.
michael@0 1471 * @param _ISPROTOCOL
michael@0 1472 * Sets protocol handler specific registry values when "true".
michael@0 1473 * Deletes protocol handler specific registry values when "delete".
michael@0 1474 * Otherwise doesn't touch handler specific registry values.
michael@0 1475 *
michael@0 1476 * $R3 = storage for SOFTWARE\Classes
michael@0 1477 * $R4 = string value of the current registry key path.
michael@0 1478 * $R5 = _KEY
michael@0 1479 * $R6 = _VALOPEN
michael@0 1480 * $R7 = _VALICON
michael@0 1481 * $R8 = _DISPNAME
michael@0 1482 * $R9 = _ISPROTOCOL
michael@0 1483 */
michael@0 1484 !macro AddDisabledDDEHandlerValues
michael@0 1485
michael@0 1486 !ifndef ${_MOZFUNC_UN}AddDisabledDDEHandlerValues
michael@0 1487 !verbose push
michael@0 1488 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1489 !define ${_MOZFUNC_UN}AddDisabledDDEHandlerValues "!insertmacro ${_MOZFUNC_UN}AddDisabledDDEHandlerValuesCall"
michael@0 1490
michael@0 1491 Function ${_MOZFUNC_UN}AddDisabledDDEHandlerValues
michael@0 1492 Exch $R9 ; _ISPROTOCOL
michael@0 1493 Exch 1
michael@0 1494 Exch $R8 ; FriendlyTypeName
michael@0 1495 Exch 2
michael@0 1496 Exch $R7 ; icon index
michael@0 1497 Exch 3
michael@0 1498 Exch $R6 ; shell\open\command
michael@0 1499 Exch 4
michael@0 1500 Exch $R5 ; reg key
michael@0 1501 Push $R4 ;
michael@0 1502 Push $R3 ; base reg class
michael@0 1503
michael@0 1504 StrCpy $R3 "SOFTWARE\Classes"
michael@0 1505 StrCmp "$R8" "" +6 +1
michael@0 1506 ReadRegStr $R4 SHCTX "$R5" "FriendlyTypeName"
michael@0 1507
michael@0 1508 StrCmp "$R4" "" +1 +3
michael@0 1509 WriteRegStr SHCTX "$R3\$R5" "" "$R8"
michael@0 1510 WriteRegStr SHCTX "$R3\$R5" "FriendlyTypeName" "$R8"
michael@0 1511
michael@0 1512 StrCmp "$R9" "true" +1 +2
michael@0 1513 WriteRegStr SHCTX "$R3\$R5" "URL Protocol" ""
michael@0 1514 StrCmp "$R9" "delete" +1 +2
michael@0 1515 DeleteRegValue SHCTX "$R3\$R5" "URL Protocol"
michael@0 1516 StrCpy $R4 ""
michael@0 1517 ReadRegDWord $R4 SHCTX "$R3\$R5" "EditFlags"
michael@0 1518 StrCmp $R4 "" +1 +3 ; Only add EditFlags if a value doesn't exist
michael@0 1519 DeleteRegValue SHCTX "$R3\$R5" "EditFlags"
michael@0 1520 WriteRegDWord SHCTX "$R3\$R5" "EditFlags" 0x00000002
michael@0 1521
michael@0 1522 StrCmp "$R7" "" +2 +1
michael@0 1523 WriteRegStr SHCTX "$R3\$R5\DefaultIcon" "" "$R7"
michael@0 1524
michael@0 1525 ; Main command handler for the app
michael@0 1526 WriteRegStr SHCTX "$R3\$R5\shell" "" "open"
michael@0 1527 WriteRegStr SHCTX "$R3\$R5\shell\open\command" "" "$R6"
michael@0 1528
michael@0 1529 ; Drop support for DDE (bug 491947), and remove old dde entries if
michael@0 1530 ; they exist.
michael@0 1531 ;
michael@0 1532 ; Note, changes in SHCTX should propegate to hkey classes root when
michael@0 1533 ; current user or local machine entries are written. Windows will also
michael@0 1534 ; attempt to propegate entries when a handler is used. CR entries are a
michael@0 1535 ; combination of LM and CU, with CU taking priority.
michael@0 1536 ;
michael@0 1537 ; To disable dde, an empty shell/ddeexec key must be created in current
michael@0 1538 ; user or local machine. Unfortunately, settings have various different
michael@0 1539 ; behaviors depending on the windows version. The following code attempts
michael@0 1540 ; to address these differences.
michael@0 1541 ;
michael@0 1542 ; On XP (no SP, SP1, SP2), Vista: An empty default string
michael@0 1543 ; must be set under ddeexec. Empty strings propagate to CR.
michael@0 1544 ;
michael@0 1545 ; Win7: IE does not configure ddeexec, so issues with left over ddeexec keys
michael@0 1546 ; in LM are reduced. We configure an empty ddeexec key with an empty default
michael@0 1547 ; string in CU to be sure.
michael@0 1548 ;
michael@0 1549 DeleteRegKey SHCTX "SOFTWARE\Classes\$R5\shell\open\ddeexec"
michael@0 1550 WriteRegStr SHCTX "SOFTWARE\Classes\$R5\shell\open\ddeexec" "" ""
michael@0 1551
michael@0 1552 ClearErrors
michael@0 1553
michael@0 1554 Pop $R3
michael@0 1555 Pop $R4
michael@0 1556 Exch $R5
michael@0 1557 Exch 4
michael@0 1558 Exch $R6
michael@0 1559 Exch 3
michael@0 1560 Exch $R7
michael@0 1561 Exch 2
michael@0 1562 Exch $R8
michael@0 1563 Exch 1
michael@0 1564 Exch $R9
michael@0 1565 FunctionEnd
michael@0 1566
michael@0 1567 !verbose pop
michael@0 1568 !endif
michael@0 1569 !macroend
michael@0 1570
michael@0 1571 !macro AddDisabledDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL
michael@0 1572 !verbose push
michael@0 1573 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1574 Push "${_KEY}"
michael@0 1575 Push "${_VALOPEN}"
michael@0 1576 Push "${_VALICON}"
michael@0 1577 Push "${_DISPNAME}"
michael@0 1578 Push "${_ISPROTOCOL}"
michael@0 1579 Call AddDisabledDDEHandlerValues
michael@0 1580 !verbose pop
michael@0 1581 !macroend
michael@0 1582
michael@0 1583 !macro un.AddDisabledDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL
michael@0 1584 !verbose push
michael@0 1585 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1586 Push "${_KEY}"
michael@0 1587 Push "${_VALOPEN}"
michael@0 1588 Push "${_VALICON}"
michael@0 1589 Push "${_DISPNAME}"
michael@0 1590 Push "${_ISPROTOCOL}"
michael@0 1591 Call un.AddDisabledDDEHandlerValues
michael@0 1592 !verbose pop
michael@0 1593 !macroend
michael@0 1594
michael@0 1595 !macro un.AddDisabledDDEHandlerValues
michael@0 1596 !ifndef un.AddDisabledDDEHandlerValues
michael@0 1597 !verbose push
michael@0 1598 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1599 !undef _MOZFUNC_UN
michael@0 1600 !define _MOZFUNC_UN "un."
michael@0 1601
michael@0 1602 !insertmacro AddDisabledDDEHandlerValues
michael@0 1603
michael@0 1604 !undef _MOZFUNC_UN
michael@0 1605 !define _MOZFUNC_UN
michael@0 1606 !verbose pop
michael@0 1607 !endif
michael@0 1608 !macroend
michael@0 1609
michael@0 1610
michael@0 1611 ################################################################################
michael@0 1612 # Macros for handling DLL registration
michael@0 1613
michael@0 1614 !macro RegisterDLL DLL
michael@0 1615
michael@0 1616 ; The x64 regsvr32.exe registers x86 DLL's properly on Windows Vista and above
michael@0 1617 ; (not on Windows XP http://support.microsoft.com/kb/282747) so just use it
michael@0 1618 ; when installing on an x64 systems even when installing an x86 application.
michael@0 1619 ${If} ${RunningX64}
michael@0 1620 ${DisableX64FSRedirection}
michael@0 1621 ExecWait '"$SYSDIR\regsvr32.exe" /s "${DLL}"'
michael@0 1622 ${EnableX64FSRedirection}
michael@0 1623 ${Else}
michael@0 1624 RegDLL "${DLL}"
michael@0 1625 ${EndIf}
michael@0 1626
michael@0 1627 !macroend
michael@0 1628
michael@0 1629 !macro UnregisterDLL DLL
michael@0 1630
michael@0 1631 ; The x64 regsvr32.exe registers x86 DLL's properly on Windows Vista and above
michael@0 1632 ; (not on Windows XP http://support.microsoft.com/kb/282747) so just use it
michael@0 1633 ; when installing on an x64 systems even when installing an x86 application.
michael@0 1634 ${If} ${RunningX64}
michael@0 1635 ${DisableX64FSRedirection}
michael@0 1636 ExecWait '"$SYSDIR\regsvr32.exe" /s /u "${DLL}"'
michael@0 1637 ${EnableX64FSRedirection}
michael@0 1638 ${Else}
michael@0 1639 UnRegDLL "${DLL}"
michael@0 1640 ${EndIf}
michael@0 1641
michael@0 1642 !macroend
michael@0 1643
michael@0 1644 !define RegisterDLL `!insertmacro RegisterDLL`
michael@0 1645 !define UnregisterDLL `!insertmacro UnregisterDLL`
michael@0 1646
michael@0 1647
michael@0 1648 ################################################################################
michael@0 1649 # Macros for retrieving existing install paths
michael@0 1650
michael@0 1651 /**
michael@0 1652 * Finds a second installation of the application so we can make informed
michael@0 1653 * decisions about registry operations. This uses SHCTX to determine the
michael@0 1654 * registry hive so you must call SetShellVarContext first.
michael@0 1655 *
michael@0 1656 * @param _KEY
michael@0 1657 * The registry subkey (typically this will be Software\Mozilla).
michael@0 1658 * @return _RESULT
michael@0 1659 * false if a second install isn't found, path to the main exe if a
michael@0 1660 * second install is found.
michael@0 1661 *
michael@0 1662 * $R3 = stores the long path to $INSTDIR
michael@0 1663 * $R4 = counter for the outer loop's EnumRegKey
michael@0 1664 * $R5 = return value from ReadRegStr and RemoveQuotesFromPath
michael@0 1665 * $R6 = return value from GetParent
michael@0 1666 * $R7 = return value from the loop's EnumRegKey
michael@0 1667 * $R8 = storage for _KEY
michael@0 1668 * $R9 = _KEY and _RESULT
michael@0 1669 */
michael@0 1670 !macro GetSecondInstallPath
michael@0 1671
michael@0 1672 !ifndef ${_MOZFUNC_UN}GetSecondInstallPath
michael@0 1673 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 1674 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 1675 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
michael@0 1676 !insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
michael@0 1677 !undef _MOZFUNC_UN
michael@0 1678 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 1679 !undef _MOZFUNC_UN_TMP
michael@0 1680
michael@0 1681 !verbose push
michael@0 1682 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1683 !define ${_MOZFUNC_UN}GetSecondInstallPath "!insertmacro ${_MOZFUNC_UN}GetSecondInstallPathCall"
michael@0 1684
michael@0 1685 Function ${_MOZFUNC_UN}GetSecondInstallPath
michael@0 1686 Exch $R9
michael@0 1687 Push $R8
michael@0 1688 Push $R7
michael@0 1689 Push $R6
michael@0 1690 Push $R5
michael@0 1691 Push $R4
michael@0 1692 Push $R3
michael@0 1693
michael@0 1694 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R3
michael@0 1695
michael@0 1696 StrCpy $R4 0 ; set the counter for the loop to 0
michael@0 1697 StrCpy $R8 "$R9" ; Registry key path to search
michael@0 1698 StrCpy $R9 "false" ; default return value
michael@0 1699
michael@0 1700 loop:
michael@0 1701 EnumRegKey $R7 SHCTX $R8 $R4
michael@0 1702 StrCmp $R7 "" end +1 ; if empty there are no more keys to enumerate
michael@0 1703 IntOp $R4 $R4 + 1 ; increment the loop's counter
michael@0 1704 ClearErrors
michael@0 1705 ReadRegStr $R5 SHCTX "$R8\$R7\bin" "PathToExe"
michael@0 1706 IfErrors loop
michael@0 1707
michael@0 1708 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R5
michael@0 1709
michael@0 1710 IfFileExists "$R5" +1 loop
michael@0 1711 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
michael@0 1712 ${${_MOZFUNC_UN}GetParent} "$R5" $R6
michael@0 1713 StrCmp "$R6" "$R3" loop +1
michael@0 1714 StrCmp "$R6\${FileMainEXE}" "$R5" +1 loop
michael@0 1715 StrCpy $R9 "$R5"
michael@0 1716
michael@0 1717 end:
michael@0 1718 ClearErrors
michael@0 1719
michael@0 1720 Pop $R3
michael@0 1721 Pop $R4
michael@0 1722 Pop $R5
michael@0 1723 Pop $R6
michael@0 1724 Pop $R7
michael@0 1725 Pop $R8
michael@0 1726 Exch $R9
michael@0 1727 FunctionEnd
michael@0 1728
michael@0 1729 !verbose pop
michael@0 1730 !endif
michael@0 1731 !macroend
michael@0 1732
michael@0 1733 !macro GetSecondInstallPathCall _KEY _RESULT
michael@0 1734 !verbose push
michael@0 1735 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1736 Push "${_KEY}"
michael@0 1737 Call GetSecondInstallPath
michael@0 1738 Pop ${_RESULT}
michael@0 1739 !verbose pop
michael@0 1740 !macroend
michael@0 1741
michael@0 1742 !macro un.GetSecondInstallPathCall _KEY _RESULT
michael@0 1743 !verbose push
michael@0 1744 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1745 Push "${_KEY}"
michael@0 1746 Call un.GetSecondInstallPath
michael@0 1747 Pop ${_RESULT}
michael@0 1748 !verbose pop
michael@0 1749 !macroend
michael@0 1750
michael@0 1751 !macro un.GetSecondInstallPath
michael@0 1752 !ifndef un.GetSecondInstallPath
michael@0 1753 !verbose push
michael@0 1754 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1755 !undef _MOZFUNC_UN
michael@0 1756 !define _MOZFUNC_UN "un."
michael@0 1757
michael@0 1758 !insertmacro GetSecondInstallPath
michael@0 1759
michael@0 1760 !undef _MOZFUNC_UN
michael@0 1761 !define _MOZFUNC_UN
michael@0 1762 !verbose pop
michael@0 1763 !endif
michael@0 1764 !macroend
michael@0 1765
michael@0 1766 /**
michael@0 1767 * Finds an existing installation path for the application based on the
michael@0 1768 * application's executable name so we can default to using this path for the
michael@0 1769 * install. If there is zero or more than one installation of the application
michael@0 1770 * then we default to the default installation path. This uses SHCTX to
michael@0 1771 * determine the registry hive to read from so you must call SetShellVarContext
michael@0 1772 * first.
michael@0 1773 *
michael@0 1774 * @param _KEY
michael@0 1775 * The registry subkey (typically this will be Software\Mozilla\App Name).
michael@0 1776 * @return _RESULT
michael@0 1777 * false if a single install location for this app name isn't found,
michael@0 1778 * path to the install directory if a single install location is found.
michael@0 1779 *
michael@0 1780 * $R5 = counter for the loop's EnumRegKey
michael@0 1781 * $R6 = return value from EnumRegKey
michael@0 1782 * $R7 = return value from ReadRegStr
michael@0 1783 * $R8 = storage for _KEY
michael@0 1784 * $R9 = _KEY and _RESULT
michael@0 1785 */
michael@0 1786 !macro GetSingleInstallPath
michael@0 1787
michael@0 1788 !ifndef ${_MOZFUNC_UN}GetSingleInstallPath
michael@0 1789 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 1790 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 1791 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
michael@0 1792 !insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
michael@0 1793 !undef _MOZFUNC_UN
michael@0 1794 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 1795 !undef _MOZFUNC_UN_TMP
michael@0 1796
michael@0 1797 !verbose push
michael@0 1798 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1799 !define ${_MOZFUNC_UN}GetSingleInstallPath "!insertmacro ${_MOZFUNC_UN}GetSingleInstallPathCall"
michael@0 1800
michael@0 1801 Function ${_MOZFUNC_UN}GetSingleInstallPath
michael@0 1802 Exch $R9
michael@0 1803 Push $R8
michael@0 1804 Push $R7
michael@0 1805 Push $R6
michael@0 1806 Push $R5
michael@0 1807
michael@0 1808 StrCpy $R8 $R9
michael@0 1809 StrCpy $R9 "false"
michael@0 1810 StrCpy $R5 0 ; set the counter for the loop to 0
michael@0 1811
michael@0 1812 loop:
michael@0 1813 ClearErrors
michael@0 1814 EnumRegKey $R6 SHCTX $R8 $R5
michael@0 1815 IfErrors cleanup
michael@0 1816 StrCmp $R6 "" cleanup +1 ; if empty there are no more keys to enumerate
michael@0 1817 IntOp $R5 $R5 + 1 ; increment the loop's counter
michael@0 1818 ClearErrors
michael@0 1819 ReadRegStr $R7 SHCTX "$R8\$R6\Main" "PathToExe"
michael@0 1820 IfErrors loop
michael@0 1821 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R7" $R7
michael@0 1822 GetFullPathName $R7 "$R7"
michael@0 1823 IfErrors loop
michael@0 1824
michael@0 1825 StrCmp "$R9" "false" +1 +3
michael@0 1826 StrCpy $R9 "$R7"
michael@0 1827 GoTo Loop
michael@0 1828
michael@0 1829 StrCpy $R9 "false"
michael@0 1830
michael@0 1831 cleanup:
michael@0 1832 StrCmp $R9 "false" end +1
michael@0 1833 ${${_MOZFUNC_UN}GetLongPath} "$R9" $R9
michael@0 1834 ${${_MOZFUNC_UN}GetParent} "$R9" $R9
michael@0 1835
michael@0 1836 end:
michael@0 1837 ClearErrors
michael@0 1838
michael@0 1839 Pop $R5
michael@0 1840 Pop $R6
michael@0 1841 Pop $R7
michael@0 1842 Pop $R8
michael@0 1843 Exch $R9
michael@0 1844 FunctionEnd
michael@0 1845
michael@0 1846 !verbose pop
michael@0 1847 !endif
michael@0 1848 !macroend
michael@0 1849
michael@0 1850 !macro GetSingleInstallPathCall _KEY _RESULT
michael@0 1851 !verbose push
michael@0 1852 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1853 Push "${_KEY}"
michael@0 1854 Call GetSingleInstallPath
michael@0 1855 Pop ${_RESULT}
michael@0 1856 !verbose pop
michael@0 1857 !macroend
michael@0 1858
michael@0 1859 !macro un.GetSingleInstallPathCall _KEY _RESULT
michael@0 1860 !verbose push
michael@0 1861 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1862 Push "${_KEY}"
michael@0 1863 Call un.GetSingleInstallPath
michael@0 1864 Pop ${_RESULT}
michael@0 1865 !verbose pop
michael@0 1866 !macroend
michael@0 1867
michael@0 1868 !macro un.GetSingleInstallPath
michael@0 1869 !ifndef un.GetSingleInstallPath
michael@0 1870 !verbose push
michael@0 1871 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1872 !undef _MOZFUNC_UN
michael@0 1873 !define _MOZFUNC_UN "un."
michael@0 1874
michael@0 1875 !insertmacro GetSingleInstallPath
michael@0 1876
michael@0 1877 !undef _MOZFUNC_UN
michael@0 1878 !define _MOZFUNC_UN
michael@0 1879 !verbose pop
michael@0 1880 !endif
michael@0 1881 !macroend
michael@0 1882
michael@0 1883
michael@0 1884 ################################################################################
michael@0 1885 # Macros for working with the file system
michael@0 1886
michael@0 1887 /**
michael@0 1888 * Attempts to delete a file if it exists. This will fail if the file is in use.
michael@0 1889 *
michael@0 1890 * @param _FILE
michael@0 1891 * The path to the file that is to be deleted.
michael@0 1892 */
michael@0 1893 !macro DeleteFile _FILE
michael@0 1894 ${If} ${FileExists} "${_FILE}"
michael@0 1895 Delete "${_FILE}"
michael@0 1896 ${EndIf}
michael@0 1897 !macroend
michael@0 1898 !define DeleteFile "!insertmacro DeleteFile"
michael@0 1899
michael@0 1900 /**
michael@0 1901 * Removes a directory if it exists and is empty.
michael@0 1902 *
michael@0 1903 * @param _DIR
michael@0 1904 * The path to the directory that is to be removed.
michael@0 1905 */
michael@0 1906 !macro RemoveDir _DIR
michael@0 1907 ${If} ${FileExists} "${_DIR}"
michael@0 1908 RmDir "${_DIR}"
michael@0 1909 ${EndIf}
michael@0 1910 !macroend
michael@0 1911 !define RemoveDir "!insertmacro RemoveDir"
michael@0 1912
michael@0 1913 /**
michael@0 1914 * Checks whether it is possible to create and delete a directory and a file in
michael@0 1915 * the install directory. Creation and deletion of files and directories are
michael@0 1916 * checked since a user may have rights for one and not the other. If creation
michael@0 1917 * and deletion of a file and a directory are successful this macro will return
michael@0 1918 * true... if not, this it return false.
michael@0 1919 *
michael@0 1920 * @return _RESULT
michael@0 1921 * true if files and directories can be created and deleted in the
michael@0 1922 * install directory otherwise false.
michael@0 1923 *
michael@0 1924 * $R8 = temporary filename in the installation directory returned from
michael@0 1925 * GetTempFileName.
michael@0 1926 * $R9 = _RESULT
michael@0 1927 */
michael@0 1928 !macro CanWriteToInstallDir
michael@0 1929
michael@0 1930 !ifndef ${_MOZFUNC_UN}CanWriteToInstallDir
michael@0 1931 !verbose push
michael@0 1932 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1933 !define ${_MOZFUNC_UN}CanWriteToInstallDir "!insertmacro ${_MOZFUNC_UN}CanWriteToInstallDirCall"
michael@0 1934
michael@0 1935 Function ${_MOZFUNC_UN}CanWriteToInstallDir
michael@0 1936 Push $R9
michael@0 1937 Push $R8
michael@0 1938
michael@0 1939 StrCpy $R9 "true"
michael@0 1940
michael@0 1941 ; IfFileExists returns false for $INSTDIR when $INSTDIR is the root of a
michael@0 1942 ; UNC path so always try to create $INSTDIR
michael@0 1943 CreateDirectory "$INSTDIR\"
michael@0 1944 GetTempFileName $R8 "$INSTDIR\"
michael@0 1945
michael@0 1946 ${Unless} ${FileExists} $R8 ; Can files be created?
michael@0 1947 StrCpy $R9 "false"
michael@0 1948 Goto done
michael@0 1949 ${EndUnless}
michael@0 1950
michael@0 1951 Delete $R8
michael@0 1952 ${If} ${FileExists} $R8 ; Can files be deleted?
michael@0 1953 StrCpy $R9 "false"
michael@0 1954 Goto done
michael@0 1955 ${EndIf}
michael@0 1956
michael@0 1957 CreateDirectory $R8
michael@0 1958 ${Unless} ${FileExists} $R8 ; Can directories be created?
michael@0 1959 StrCpy $R9 "false"
michael@0 1960 Goto done
michael@0 1961 ${EndUnless}
michael@0 1962
michael@0 1963 RmDir $R8
michael@0 1964 ${If} ${FileExists} $R8 ; Can directories be deleted?
michael@0 1965 StrCpy $R9 "false"
michael@0 1966 Goto done
michael@0 1967 ${EndIf}
michael@0 1968
michael@0 1969 done:
michael@0 1970
michael@0 1971 RmDir "$INSTDIR\" ; Only remove $INSTDIR if it is empty
michael@0 1972 ClearErrors
michael@0 1973
michael@0 1974 Pop $R8
michael@0 1975 Exch $R9
michael@0 1976 FunctionEnd
michael@0 1977
michael@0 1978 !verbose pop
michael@0 1979 !endif
michael@0 1980 !macroend
michael@0 1981
michael@0 1982 !macro CanWriteToInstallDirCall _RESULT
michael@0 1983 !verbose push
michael@0 1984 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1985 Call CanWriteToInstallDir
michael@0 1986 Pop ${_RESULT}
michael@0 1987 !verbose pop
michael@0 1988 !macroend
michael@0 1989
michael@0 1990 !macro un.CanWriteToInstallDirCall _RESULT
michael@0 1991 !verbose push
michael@0 1992 !verbose ${_MOZFUNC_VERBOSE}
michael@0 1993 Call un.CanWriteToInstallDir
michael@0 1994 Pop ${_RESULT}
michael@0 1995 !verbose pop
michael@0 1996 !macroend
michael@0 1997
michael@0 1998 !macro un.CanWriteToInstallDir
michael@0 1999 !ifndef un.CanWriteToInstallDir
michael@0 2000 !verbose push
michael@0 2001 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2002 !undef _MOZFUNC_UN
michael@0 2003 !define _MOZFUNC_UN "un."
michael@0 2004
michael@0 2005 !insertmacro CanWriteToInstallDir
michael@0 2006
michael@0 2007 !undef _MOZFUNC_UN
michael@0 2008 !define _MOZFUNC_UN
michael@0 2009 !verbose pop
michael@0 2010 !endif
michael@0 2011 !macroend
michael@0 2012
michael@0 2013 /**
michael@0 2014 * Checks whether there is sufficient free space available for the installation
michael@0 2015 * directory using GetDiskFreeSpaceExW which respects disk quotas. This macro
michael@0 2016 * will calculate the size of all sections that are selected, compare that with
michael@0 2017 * the free space available, and if there is sufficient free space it will
michael@0 2018 * return true... if not, it will return false.
michael@0 2019 *
michael@0 2020 * @return _RESULT
michael@0 2021 * "true" if there is sufficient free space otherwise "false".
michael@0 2022 *
michael@0 2023 * $R5 = return value from SectionGetSize
michael@0 2024 * $R6 = return value from SectionGetFlags
michael@0 2025 * return value from an 'and' comparison of SectionGetFlags (1=selected)
michael@0 2026 * return value for lpFreeBytesAvailable from GetDiskFreeSpaceExW
michael@0 2027 * return value for System::Int64Op $R6 / 1024
michael@0 2028 * return value for System::Int64Op $R6 > $R8
michael@0 2029 * $R7 = the counter for enumerating the sections
michael@0 2030 * the temporary file name for the directory created under $INSTDIR passed
michael@0 2031 * to GetDiskFreeSpaceExW.
michael@0 2032 * $R8 = sum in KB of all selected sections
michael@0 2033 * $R9 = _RESULT
michael@0 2034 */
michael@0 2035 !macro CheckDiskSpace
michael@0 2036
michael@0 2037 !ifndef ${_MOZFUNC_UN}CheckDiskSpace
michael@0 2038 !verbose push
michael@0 2039 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2040 !define ${_MOZFUNC_UN}CheckDiskSpace "!insertmacro ${_MOZFUNC_UN}CheckDiskSpaceCall"
michael@0 2041
michael@0 2042 Function ${_MOZFUNC_UN}CheckDiskSpace
michael@0 2043 Push $R9
michael@0 2044 Push $R8
michael@0 2045 Push $R7
michael@0 2046 Push $R6
michael@0 2047 Push $R5
michael@0 2048
michael@0 2049 ClearErrors
michael@0 2050
michael@0 2051 StrCpy $R9 "true" ; default return value
michael@0 2052 StrCpy $R8 "0" ; sum in KB of all selected sections
michael@0 2053 StrCpy $R7 "0" ; counter for enumerating sections
michael@0 2054
michael@0 2055 ; Enumerate the sections and sum up the sizes of the sections that are
michael@0 2056 ; selected.
michael@0 2057 SectionGetFlags $R7 $R6
michael@0 2058 IfErrors +7 +1
michael@0 2059 IntOp $R6 ${SF_SELECTED} & $R6
michael@0 2060 IntCmp $R6 0 +3 +1 +1
michael@0 2061 SectionGetSize $R7 $R5
michael@0 2062 IntOp $R8 $R8 + $R5
michael@0 2063 IntOp $R7 $R7 + 1
michael@0 2064 GoTo -7
michael@0 2065
michael@0 2066 ; The directory passed to GetDiskFreeSpaceExW must exist for the call to
michael@0 2067 ; succeed. Since the CanWriteToInstallDir macro is called prior to this
michael@0 2068 ; macro the call to CreateDirectory will always succeed.
michael@0 2069
michael@0 2070 ; IfFileExists returns false for $INSTDIR when $INSTDIR is the root of a
michael@0 2071 ; UNC path so always try to create $INSTDIR
michael@0 2072 CreateDirectory "$INSTDIR\"
michael@0 2073 GetTempFileName $R7 "$INSTDIR\"
michael@0 2074 Delete "$R7"
michael@0 2075 CreateDirectory "$R7"
michael@0 2076
michael@0 2077 System::Call 'kernel32::GetDiskFreeSpaceExW(w, *l, *l, *l) i(R7, .R6, ., .) .'
michael@0 2078
michael@0 2079 ; Convert to KB for comparison with $R8 which is in KB
michael@0 2080 System::Int64Op $R6 / 1024
michael@0 2081 Pop $R6
michael@0 2082
michael@0 2083 System::Int64Op $R6 > $R8
michael@0 2084 Pop $R6
michael@0 2085
michael@0 2086 IntCmp $R6 1 end +1 +1
michael@0 2087 StrCpy $R9 "false"
michael@0 2088
michael@0 2089 end:
michael@0 2090 RmDir "$R7"
michael@0 2091 RmDir "$INSTDIR\" ; Only remove $INSTDIR if it is empty
michael@0 2092
michael@0 2093 ClearErrors
michael@0 2094
michael@0 2095 Pop $R5
michael@0 2096 Pop $R6
michael@0 2097 Pop $R7
michael@0 2098 Pop $R8
michael@0 2099 Exch $R9
michael@0 2100 FunctionEnd
michael@0 2101
michael@0 2102 !verbose pop
michael@0 2103 !endif
michael@0 2104 !macroend
michael@0 2105
michael@0 2106 !macro CheckDiskSpaceCall _RESULT
michael@0 2107 !verbose push
michael@0 2108 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2109 Call CheckDiskSpace
michael@0 2110 Pop ${_RESULT}
michael@0 2111 !verbose pop
michael@0 2112 !macroend
michael@0 2113
michael@0 2114 !macro un.CheckDiskSpaceCall _RESULT
michael@0 2115 !verbose push
michael@0 2116 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2117 Call un.CheckDiskSpace
michael@0 2118 Pop ${_RESULT}
michael@0 2119 !verbose pop
michael@0 2120 !macroend
michael@0 2121
michael@0 2122 !macro un.CheckDiskSpace
michael@0 2123 !ifndef un.CheckDiskSpace
michael@0 2124 !verbose push
michael@0 2125 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2126 !undef _MOZFUNC_UN
michael@0 2127 !define _MOZFUNC_UN "un."
michael@0 2128
michael@0 2129 !insertmacro CheckDiskSpace
michael@0 2130
michael@0 2131 !undef _MOZFUNC_UN
michael@0 2132 !define _MOZFUNC_UN
michael@0 2133 !verbose pop
michael@0 2134 !endif
michael@0 2135 !macroend
michael@0 2136
michael@0 2137 /**
michael@0 2138 * Returns the path found within a passed in string. The path is quoted or not
michael@0 2139 * with the exception of an unquoted non 8dot3 path without arguments that is
michael@0 2140 * also not a DefaultIcon path, is a 8dot3 path or not, has command line
michael@0 2141 * arguments, or is a registry DefaultIcon path (e.g. <path to binary>,# where #
michael@0 2142 * is the icon's resuorce id). The string does not need to be a valid path or
michael@0 2143 * exist. It is up to the caller to pass in a string of one of the forms noted
michael@0 2144 * above and to verify existence if necessary.
michael@0 2145 *
michael@0 2146 * Examples:
michael@0 2147 * In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE -flag "%1"
michael@0 2148 * In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE,0
michael@0 2149 * In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE
michael@0 2150 * In: "C:\PROGRA~1\MOZILL~1\FIREFOX.EXE"
michael@0 2151 * In: "C:\PROGRA~1\MOZILL~1\FIREFOX.EXE" -flag "%1"
michael@0 2152 * Out: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE
michael@0 2153 *
michael@0 2154 * In: "C:\Program Files\Mozilla Firefox\firefox.exe" -flag "%1"
michael@0 2155 * In: C:\Program Files\Mozilla Firefox\firefox.exe,0
michael@0 2156 * In: "C:\Program Files\Mozilla Firefox\firefox.exe"
michael@0 2157 * Out: C:\Program Files\Mozilla Firefox\firefox.exe
michael@0 2158 *
michael@0 2159 * @param _IN_PATH
michael@0 2160 * The string containing the path.
michael@0 2161 * @param _OUT_PATH
michael@0 2162 * The register to store the path to.
michael@0 2163 *
michael@0 2164 * $R7 = counter for the outer loop's EnumRegKey
michael@0 2165 * $R8 = return value from ReadRegStr
michael@0 2166 * $R9 = _IN_PATH and _OUT_PATH
michael@0 2167 */
michael@0 2168 !macro GetPathFromString
michael@0 2169
michael@0 2170 !ifndef ${_MOZFUNC_UN}GetPathFromString
michael@0 2171 !verbose push
michael@0 2172 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2173 !define ${_MOZFUNC_UN}GetPathFromString "!insertmacro ${_MOZFUNC_UN}GetPathFromStringCall"
michael@0 2174
michael@0 2175 Function ${_MOZFUNC_UN}GetPathFromString
michael@0 2176 Exch $R9
michael@0 2177 Push $R8
michael@0 2178 Push $R7
michael@0 2179
michael@0 2180 StrCpy $R7 0 ; Set the counter to 0.
michael@0 2181
michael@0 2182 ; Handle quoted paths with arguments.
michael@0 2183 StrCpy $R8 $R9 1 ; Copy the first char.
michael@0 2184 StrCmp $R8 '"' +2 +1 ; Is it a "?
michael@0 2185 StrCmp $R8 "'" +1 +9 ; Is it a '?
michael@0 2186 StrCpy $R9 $R9 "" 1 ; Remove the first char.
michael@0 2187 IntOp $R7 $R7 + 1 ; Increment the counter.
michael@0 2188 StrCpy $R8 $R9 1 $R7 ; Starting from the counter copy the next char.
michael@0 2189 StrCmp $R8 "" end +1 ; Are there no more chars?
michael@0 2190 StrCmp $R8 '"' +2 +1 ; Is it a " char?
michael@0 2191 StrCmp $R8 "'" +1 -4 ; Is it a ' char?
michael@0 2192 StrCpy $R9 $R9 $R7 ; Copy chars up to the counter.
michael@0 2193 GoTo end
michael@0 2194
michael@0 2195 ; Handle DefaultIcon paths. DefaultIcon paths are not quoted and end with
michael@0 2196 ; a , and a number.
michael@0 2197 IntOp $R7 $R7 - 1 ; Decrement the counter.
michael@0 2198 StrCpy $R8 $R9 1 $R7 ; Copy one char from the end minus the counter.
michael@0 2199 StrCmp $R8 '' +4 +1 ; Are there no more chars?
michael@0 2200 StrCmp $R8 ',' +1 -3 ; Is it a , char?
michael@0 2201 StrCpy $R9 $R9 $R7 ; Copy chars up to the end minus the counter.
michael@0 2202 GoTo end
michael@0 2203
michael@0 2204 ; Handle unquoted paths with arguments. An unquoted path with arguments
michael@0 2205 ; must be an 8dot3 path.
michael@0 2206 StrCpy $R7 -1 ; Set the counter to -1 so it will start at 0.
michael@0 2207 IntOp $R7 $R7 + 1 ; Increment the counter.
michael@0 2208 StrCpy $R8 $R9 1 $R7 ; Starting from the counter copy the next char.
michael@0 2209 StrCmp $R8 "" end +1 ; Are there no more chars?
michael@0 2210 StrCmp $R8 " " +1 -3 ; Is it a space char?
michael@0 2211 StrCpy $R9 $R9 $R7 ; Copy chars up to the counter.
michael@0 2212
michael@0 2213 end:
michael@0 2214 ClearErrors
michael@0 2215
michael@0 2216 Pop $R7
michael@0 2217 Pop $R8
michael@0 2218 Exch $R9
michael@0 2219 FunctionEnd
michael@0 2220
michael@0 2221 !verbose pop
michael@0 2222 !endif
michael@0 2223 !macroend
michael@0 2224
michael@0 2225 !macro GetPathFromStringCall _IN_PATH _OUT_PATH
michael@0 2226 !verbose push
michael@0 2227 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2228 Push "${_IN_PATH}"
michael@0 2229 Call GetPathFromString
michael@0 2230 Pop ${_OUT_PATH}
michael@0 2231 !verbose pop
michael@0 2232 !macroend
michael@0 2233
michael@0 2234 !macro un.GetPathFromStringCall _IN_PATH _OUT_PATH
michael@0 2235 !verbose push
michael@0 2236 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2237 Push "${_IN_PATH}"
michael@0 2238 Call un.GetPathFromString
michael@0 2239 Pop ${_OUT_PATH}
michael@0 2240 !verbose pop
michael@0 2241 !macroend
michael@0 2242
michael@0 2243 !macro un.GetPathFromString
michael@0 2244 !ifndef un.GetPathFromString
michael@0 2245 !verbose push
michael@0 2246 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2247 !undef _MOZFUNC_UN
michael@0 2248 !define _MOZFUNC_UN "un."
michael@0 2249
michael@0 2250 !insertmacro GetPathFromString
michael@0 2251
michael@0 2252 !undef _MOZFUNC_UN
michael@0 2253 !define _MOZFUNC_UN
michael@0 2254 !verbose pop
michael@0 2255 !endif
michael@0 2256 !macroend
michael@0 2257
michael@0 2258 /**
michael@0 2259 * Removes the quotes from each end of a string if present.
michael@0 2260 *
michael@0 2261 * @param _IN_PATH
michael@0 2262 * The string containing the path.
michael@0 2263 * @param _OUT_PATH
michael@0 2264 * The register to store the long path.
michael@0 2265 *
michael@0 2266 * $R7 = storage for single character comparison
michael@0 2267 * $R8 = storage for _IN_PATH
michael@0 2268 * $R9 = _IN_PATH and _OUT_PATH
michael@0 2269 */
michael@0 2270 !macro RemoveQuotesFromPath
michael@0 2271
michael@0 2272 !ifndef ${_MOZFUNC_UN}RemoveQuotesFromPath
michael@0 2273 !verbose push
michael@0 2274 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2275 !define ${_MOZFUNC_UN}RemoveQuotesFromPath "!insertmacro ${_MOZFUNC_UN}RemoveQuotesFromPathCall"
michael@0 2276
michael@0 2277 Function ${_MOZFUNC_UN}RemoveQuotesFromPath
michael@0 2278 Exch $R9
michael@0 2279 Push $R8
michael@0 2280 Push $R7
michael@0 2281
michael@0 2282 StrCpy $R7 "$R9" 1
michael@0 2283 StrCmp $R7 "$\"" +1 +2
michael@0 2284 StrCpy $R9 "$R9" "" 1
michael@0 2285
michael@0 2286 StrCpy $R7 "$R9" "" -1
michael@0 2287 StrCmp $R7 "$\"" +1 +2
michael@0 2288 StrCpy $R9 "$R9" -1
michael@0 2289
michael@0 2290 Pop $R7
michael@0 2291 Pop $R8
michael@0 2292 Exch $R9
michael@0 2293 FunctionEnd
michael@0 2294
michael@0 2295 !verbose pop
michael@0 2296 !endif
michael@0 2297 !macroend
michael@0 2298
michael@0 2299 !macro RemoveQuotesFromPathCall _IN_PATH _OUT_PATH
michael@0 2300 !verbose push
michael@0 2301 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2302 Push "${_IN_PATH}"
michael@0 2303 Call RemoveQuotesFromPath
michael@0 2304 Pop ${_OUT_PATH}
michael@0 2305 !verbose pop
michael@0 2306 !macroend
michael@0 2307
michael@0 2308 !macro un.RemoveQuotesFromPathCall _IN_PATH _OUT_PATH
michael@0 2309 !verbose push
michael@0 2310 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2311 Push "${_IN_PATH}"
michael@0 2312 Call un.RemoveQuotesFromPath
michael@0 2313 Pop ${_OUT_PATH}
michael@0 2314 !verbose pop
michael@0 2315 !macroend
michael@0 2316
michael@0 2317 !macro un.RemoveQuotesFromPath
michael@0 2318 !ifndef un.RemoveQuotesFromPath
michael@0 2319 !verbose push
michael@0 2320 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2321 !undef _MOZFUNC_UN
michael@0 2322 !define _MOZFUNC_UN "un."
michael@0 2323
michael@0 2324 !insertmacro RemoveQuotesFromPath
michael@0 2325
michael@0 2326 !undef _MOZFUNC_UN
michael@0 2327 !define _MOZFUNC_UN
michael@0 2328 !verbose pop
michael@0 2329 !endif
michael@0 2330 !macroend
michael@0 2331
michael@0 2332 /**
michael@0 2333 * Returns the long path for an existing file or directory. GetLongPathNameW
michael@0 2334 * may not be available on Win95 if Microsoft Layer for Unicode is not
michael@0 2335 * installed and GetFullPathName only returns a long path for the last file or
michael@0 2336 * directory that doesn't end with a \ in the path that it is passed. If the
michael@0 2337 * path does not exist on the file system this will return an empty string. To
michael@0 2338 * provide a consistent result trailing back-slashes are always removed.
michael@0 2339 *
michael@0 2340 * Note: 1024 used by GetLongPathNameW is the maximum NSIS string length.
michael@0 2341 *
michael@0 2342 * @param _IN_PATH
michael@0 2343 * The string containing the path.
michael@0 2344 * @param _OUT_PATH
michael@0 2345 * The register to store the long path.
michael@0 2346 *
michael@0 2347 * $R4 = counter value when the previous \ was found
michael@0 2348 * $R5 = directory or file name found during loop
michael@0 2349 * $R6 = return value from GetLongPathNameW and loop counter
michael@0 2350 * $R7 = long path from GetLongPathNameW and single char from path for comparison
michael@0 2351 * $R8 = storage for _IN_PATH
michael@0 2352 * $R9 = _IN_PATH _OUT_PATH
michael@0 2353 */
michael@0 2354 !macro GetLongPath
michael@0 2355
michael@0 2356 !ifndef ${_MOZFUNC_UN}GetLongPath
michael@0 2357 !verbose push
michael@0 2358 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2359 !define ${_MOZFUNC_UN}GetLongPath "!insertmacro ${_MOZFUNC_UN}GetLongPathCall"
michael@0 2360
michael@0 2361 Function ${_MOZFUNC_UN}GetLongPath
michael@0 2362 Exch $R9
michael@0 2363 Push $R8
michael@0 2364 Push $R7
michael@0 2365 Push $R6
michael@0 2366 Push $R5
michael@0 2367 Push $R4
michael@0 2368
michael@0 2369 ClearErrors
michael@0 2370
michael@0 2371 GetFullPathName $R8 "$R9"
michael@0 2372 IfErrors end_GetLongPath +1 ; If the path doesn't exist return an empty string.
michael@0 2373
michael@0 2374 System::Call 'kernel32::GetLongPathNameW(w R8, w .R7, i 1024)i .R6'
michael@0 2375 StrCmp "$R7" "" +4 +1 ; Empty string when GetLongPathNameW is not present.
michael@0 2376 StrCmp $R6 0 +3 +1 ; Should never equal 0 since the path exists.
michael@0 2377 StrCpy $R9 "$R7"
michael@0 2378 GoTo end_GetLongPath
michael@0 2379
michael@0 2380 ; Do it the hard way.
michael@0 2381 StrCpy $R4 0 ; Stores the position in the string of the last \ found.
michael@0 2382 StrCpy $R6 -1 ; Set the counter to -1 so it will start at 0.
michael@0 2383
michael@0 2384 loop_GetLongPath:
michael@0 2385 IntOp $R6 $R6 + 1 ; Increment the counter.
michael@0 2386 StrCpy $R7 $R8 1 $R6 ; Starting from the counter copy the next char.
michael@0 2387 StrCmp $R7 "" +2 +1 ; Are there no more chars?
michael@0 2388 StrCmp $R7 "\" +1 -3 ; Is it a \?
michael@0 2389
michael@0 2390 ; Copy chars starting from the previously found \ to the counter.
michael@0 2391 StrCpy $R5 $R8 $R6 $R4
michael@0 2392
michael@0 2393 ; If this is the first \ found we want to swap R9 with R5 so a \ will
michael@0 2394 ; be appended to the drive letter and colon (e.g. C: will become C:\).
michael@0 2395 StrCmp $R4 0 +1 +3
michael@0 2396 StrCpy $R9 $R5
michael@0 2397 StrCpy $R5 ""
michael@0 2398
michael@0 2399 GetFullPathName $R9 "$R9\$R5"
michael@0 2400
michael@0 2401 StrCmp $R7 "" end_GetLongPath +1 ; Are there no more chars?
michael@0 2402
michael@0 2403 ; Store the counter for the current \ and prefix it for StrCpy operations.
michael@0 2404 StrCpy $R4 "+$R6"
michael@0 2405 IntOp $R6 $R6 + 1 ; Increment the counter so we skip over the \.
michael@0 2406 StrCpy $R8 $R8 "" $R6 ; Copy chars starting from the counter to the end.
michael@0 2407 StrCpy $R6 -1 ; Reset the counter to -1 so it will start over at 0.
michael@0 2408 GoTo loop_GetLongPath
michael@0 2409
michael@0 2410 end_GetLongPath:
michael@0 2411 ; If there is a trailing slash remove it
michael@0 2412 StrCmp $R9 "" +4 +1
michael@0 2413 StrCpy $R8 "$R9" "" -1
michael@0 2414 StrCmp $R8 "\" +1 +2
michael@0 2415 StrCpy $R9 "$R9" -1
michael@0 2416
michael@0 2417 ClearErrors
michael@0 2418
michael@0 2419 Pop $R4
michael@0 2420 Pop $R5
michael@0 2421 Pop $R6
michael@0 2422 Pop $R7
michael@0 2423 Pop $R8
michael@0 2424 Exch $R9
michael@0 2425 FunctionEnd
michael@0 2426
michael@0 2427 !verbose pop
michael@0 2428 !endif
michael@0 2429 !macroend
michael@0 2430
michael@0 2431 !macro GetLongPathCall _IN_PATH _OUT_PATH
michael@0 2432 !verbose push
michael@0 2433 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2434 Push "${_IN_PATH}"
michael@0 2435 Call GetLongPath
michael@0 2436 Pop ${_OUT_PATH}
michael@0 2437 !verbose pop
michael@0 2438 !macroend
michael@0 2439
michael@0 2440 !macro un.GetLongPathCall _IN_PATH _OUT_PATH
michael@0 2441 !verbose push
michael@0 2442 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2443 Push "${_IN_PATH}"
michael@0 2444 Call un.GetLongPath
michael@0 2445 Pop ${_OUT_PATH}
michael@0 2446 !verbose pop
michael@0 2447 !macroend
michael@0 2448
michael@0 2449 !macro un.GetLongPath
michael@0 2450 !ifndef un.GetLongPath
michael@0 2451 !verbose push
michael@0 2452 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2453 !undef _MOZFUNC_UN
michael@0 2454 !define _MOZFUNC_UN "un."
michael@0 2455
michael@0 2456 !insertmacro GetLongPath
michael@0 2457
michael@0 2458 !undef _MOZFUNC_UN
michael@0 2459 !define _MOZFUNC_UN
michael@0 2460 !verbose pop
michael@0 2461 !endif
michael@0 2462 !macroend
michael@0 2463
michael@0 2464
michael@0 2465 ################################################################################
michael@0 2466 # Macros for cleaning up the registry and file system
michael@0 2467
michael@0 2468 /**
michael@0 2469 * Removes registry keys that reference this install location and for paths that
michael@0 2470 * no longer exist. This uses SHCTX to determine the registry hive so you must
michael@0 2471 * call SetShellVarContext first.
michael@0 2472 *
michael@0 2473 * @param _KEY
michael@0 2474 * The registry subkey (typically this will be Software\Mozilla).
michael@0 2475 *
michael@0 2476 * XXXrstrong - there is the potential for Key: Software/Mozilla/AppName,
michael@0 2477 * ValueName: CurrentVersion, ValueData: AppVersion to reference a key that is
michael@0 2478 * no longer available due to this cleanup. This should be no worse than prior
michael@0 2479 * to this reg cleanup since the referenced key would be for an app that is no
michael@0 2480 * longer installed on the system.
michael@0 2481 *
michael@0 2482 * $R0 = on x64 systems set to 'false' at the beginning of the macro when
michael@0 2483 * enumerating the x86 registry view and set to 'true' when enumerating
michael@0 2484 * the x64 registry view.
michael@0 2485 * $R1 = stores the long path to $INSTDIR
michael@0 2486 * $R2 = return value from the stack from the GetParent and GetLongPath macros
michael@0 2487 * $R3 = return value from the outer loop's EnumRegKey
michael@0 2488 * $R4 = return value from the inner loop's EnumRegKey
michael@0 2489 * $R5 = return value from ReadRegStr
michael@0 2490 * $R6 = counter for the outer loop's EnumRegKey
michael@0 2491 * $R7 = counter for the inner loop's EnumRegKey
michael@0 2492 * $R8 = return value from the stack from the RemoveQuotesFromPath macro
michael@0 2493 * $R9 = _KEY
michael@0 2494 */
michael@0 2495 !macro RegCleanMain
michael@0 2496
michael@0 2497 !ifndef ${_MOZFUNC_UN}RegCleanMain
michael@0 2498 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 2499 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
michael@0 2500 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 2501 !insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
michael@0 2502 !undef _MOZFUNC_UN
michael@0 2503 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 2504 !undef _MOZFUNC_UN_TMP
michael@0 2505
michael@0 2506 !verbose push
michael@0 2507 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2508 !define ${_MOZFUNC_UN}RegCleanMain "!insertmacro ${_MOZFUNC_UN}RegCleanMainCall"
michael@0 2509
michael@0 2510 Function ${_MOZFUNC_UN}RegCleanMain
michael@0 2511 Exch $R9
michael@0 2512 Push $R8
michael@0 2513 Push $R7
michael@0 2514 Push $R6
michael@0 2515 Push $R5
michael@0 2516 Push $R4
michael@0 2517 Push $R3
michael@0 2518 Push $R2
michael@0 2519 Push $R1
michael@0 2520 Push $R0
michael@0 2521
michael@0 2522 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R1
michael@0 2523 StrCpy $R6 0 ; set the counter for the outer loop to 0
michael@0 2524
michael@0 2525 ${If} ${RunningX64}
michael@0 2526 StrCpy $R0 "false"
michael@0 2527 ; Set the registry to the 32 bit registry for 64 bit installations or to
michael@0 2528 ; the 64 bit registry for 32 bit installations at the beginning so it can
michael@0 2529 ; easily be set back to the correct registry view when finished.
michael@0 2530 !ifdef HAVE_64BIT_OS
michael@0 2531 SetRegView 32
michael@0 2532 !else
michael@0 2533 SetRegView 64
michael@0 2534 !endif
michael@0 2535 ${EndIf}
michael@0 2536
michael@0 2537 outerloop:
michael@0 2538 EnumRegKey $R3 SHCTX $R9 $R6
michael@0 2539 StrCmp $R3 "" end +1 ; if empty there are no more keys to enumerate
michael@0 2540 IntOp $R6 $R6 + 1 ; increment the outer loop's counter
michael@0 2541 ClearErrors
michael@0 2542 ReadRegStr $R5 SHCTX "$R9\$R3\bin" "PathToExe"
michael@0 2543 IfErrors 0 outercontinue
michael@0 2544 StrCpy $R7 0 ; set the counter for the inner loop to 0
michael@0 2545
michael@0 2546 innerloop:
michael@0 2547 EnumRegKey $R4 SHCTX "$R9\$R3" $R7
michael@0 2548 StrCmp $R4 "" outerloop +1 ; if empty there are no more keys to enumerate
michael@0 2549 IntOp $R7 $R7 + 1 ; increment the inner loop's counter
michael@0 2550 ClearErrors
michael@0 2551 ReadRegStr $R5 SHCTX "$R9\$R3\$R4\Main" "PathToExe"
michael@0 2552 IfErrors innerloop
michael@0 2553
michael@0 2554 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R8
michael@0 2555 ${${_MOZFUNC_UN}GetParent} "$R8" $R2
michael@0 2556 ${${_MOZFUNC_UN}GetLongPath} "$R2" $R2
michael@0 2557 IfFileExists "$R2" +1 innerloop
michael@0 2558 StrCmp "$R2" "$R1" +1 innerloop
michael@0 2559
michael@0 2560 ClearErrors
michael@0 2561 DeleteRegKey SHCTX "$R9\$R3\$R4"
michael@0 2562 IfErrors innerloop
michael@0 2563 IntOp $R7 $R7 - 1 ; decrement the inner loop's counter when the key is deleted successfully.
michael@0 2564 ClearErrors
michael@0 2565 DeleteRegKey /ifempty SHCTX "$R9\$R3"
michael@0 2566 IfErrors innerloop outerdecrement
michael@0 2567
michael@0 2568 outercontinue:
michael@0 2569 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R8
michael@0 2570 ${${_MOZFUNC_UN}GetParent} "$R8" $R2
michael@0 2571 ${${_MOZFUNC_UN}GetLongPath} "$R2" $R2
michael@0 2572 IfFileExists "$R2" +1 outerloop
michael@0 2573 StrCmp "$R2" "$R1" +1 outerloop
michael@0 2574
michael@0 2575 ClearErrors
michael@0 2576 DeleteRegKey SHCTX "$R9\$R3"
michael@0 2577 IfErrors outerloop
michael@0 2578
michael@0 2579 outerdecrement:
michael@0 2580 IntOp $R6 $R6 - 1 ; decrement the outer loop's counter when the key is deleted successfully.
michael@0 2581 GoTo outerloop
michael@0 2582
michael@0 2583 end:
michael@0 2584 ${If} ${RunningX64}
michael@0 2585 ${AndIf} "$R0" == "false"
michael@0 2586 ; Set the registry to the correct view.
michael@0 2587 !ifdef HAVE_64BIT_OS
michael@0 2588 SetRegView 64
michael@0 2589 !else
michael@0 2590 SetRegView 32
michael@0 2591 !endif
michael@0 2592
michael@0 2593 StrCpy $R6 0 ; set the counter for the outer loop to 0
michael@0 2594 StrCpy $R0 "true"
michael@0 2595 GoTo outerloop
michael@0 2596 ${EndIf}
michael@0 2597
michael@0 2598 ClearErrors
michael@0 2599
michael@0 2600 Pop $R0
michael@0 2601 Pop $R1
michael@0 2602 Pop $R2
michael@0 2603 Pop $R3
michael@0 2604 Pop $R4
michael@0 2605 Pop $R5
michael@0 2606 Pop $R6
michael@0 2607 Pop $R7
michael@0 2608 Pop $R8
michael@0 2609 Exch $R9
michael@0 2610 FunctionEnd
michael@0 2611
michael@0 2612 !verbose pop
michael@0 2613 !endif
michael@0 2614 !macroend
michael@0 2615
michael@0 2616 !macro RegCleanMainCall _KEY
michael@0 2617 !verbose push
michael@0 2618 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2619 Push "${_KEY}"
michael@0 2620 Call RegCleanMain
michael@0 2621 !verbose pop
michael@0 2622 !macroend
michael@0 2623
michael@0 2624 !macro un.RegCleanMainCall _KEY
michael@0 2625 !verbose push
michael@0 2626 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2627 Push "${_KEY}"
michael@0 2628 Call un.RegCleanMain
michael@0 2629 !verbose pop
michael@0 2630 !macroend
michael@0 2631
michael@0 2632 !macro un.RegCleanMain
michael@0 2633 !ifndef un.RegCleanMain
michael@0 2634 !verbose push
michael@0 2635 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2636 !undef _MOZFUNC_UN
michael@0 2637 !define _MOZFUNC_UN "un."
michael@0 2638
michael@0 2639 !insertmacro RegCleanMain
michael@0 2640
michael@0 2641 !undef _MOZFUNC_UN
michael@0 2642 !define _MOZFUNC_UN
michael@0 2643 !verbose pop
michael@0 2644 !endif
michael@0 2645 !macroend
michael@0 2646
michael@0 2647 /**
michael@0 2648 * Removes all registry keys from \Software\Windows\CurrentVersion\Uninstall
michael@0 2649 * that reference this install location in both the 32 bit and 64 bit registry
michael@0 2650 * view. This macro uses SHCTX to determine the registry hive so you must call
michael@0 2651 * SetShellVarContext first.
michael@0 2652 *
michael@0 2653 * $R3 = on x64 systems set to 'false' at the beginning of the macro when
michael@0 2654 * enumerating the x86 registry view and set to 'true' when enumerating
michael@0 2655 * the x64 registry view.
michael@0 2656 * $R4 = stores the long path to $INSTDIR
michael@0 2657 * $R5 = return value from ReadRegStr
michael@0 2658 * $R6 = string for the base reg key (e.g. Software\Microsoft\Windows\CurrentVersion\Uninstall)
michael@0 2659 * $R7 = return value from EnumRegKey
michael@0 2660 * $R8 = counter for EnumRegKey
michael@0 2661 * $R9 = return value from the stack from the RemoveQuotesFromPath and GetLongPath macros
michael@0 2662 */
michael@0 2663 !macro RegCleanUninstall
michael@0 2664
michael@0 2665 !ifndef ${_MOZFUNC_UN}RegCleanUninstall
michael@0 2666 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 2667 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 2668 !insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
michael@0 2669 !undef _MOZFUNC_UN
michael@0 2670 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 2671 !undef _MOZFUNC_UN_TMP
michael@0 2672
michael@0 2673 !verbose push
michael@0 2674 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2675 !define ${_MOZFUNC_UN}RegCleanUninstall "!insertmacro ${_MOZFUNC_UN}RegCleanUninstallCall"
michael@0 2676
michael@0 2677 Function ${_MOZFUNC_UN}RegCleanUninstall
michael@0 2678 Push $R9
michael@0 2679 Push $R8
michael@0 2680 Push $R7
michael@0 2681 Push $R6
michael@0 2682 Push $R5
michael@0 2683 Push $R4
michael@0 2684 Push $R3
michael@0 2685
michael@0 2686 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R4
michael@0 2687 StrCpy $R6 "Software\Microsoft\Windows\CurrentVersion\Uninstall"
michael@0 2688 StrCpy $R7 ""
michael@0 2689 StrCpy $R8 0
michael@0 2690
michael@0 2691 ${If} ${RunningX64}
michael@0 2692 StrCpy $R3 "false"
michael@0 2693 ; Set the registry to the 32 bit registry for 64 bit installations or to
michael@0 2694 ; the 64 bit registry for 32 bit installations at the beginning so it can
michael@0 2695 ; easily be set back to the correct registry view when finished.
michael@0 2696 !ifdef HAVE_64BIT_OS
michael@0 2697 SetRegView 32
michael@0 2698 !else
michael@0 2699 SetRegView 64
michael@0 2700 !endif
michael@0 2701 ${EndIf}
michael@0 2702
michael@0 2703 loop:
michael@0 2704 EnumRegKey $R7 SHCTX $R6 $R8
michael@0 2705 StrCmp $R7 "" end +1
michael@0 2706 IntOp $R8 $R8 + 1 ; Increment the counter
michael@0 2707 ClearErrors
michael@0 2708 ReadRegStr $R5 SHCTX "$R6\$R7" "InstallLocation"
michael@0 2709 IfErrors loop
michael@0 2710 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R9
michael@0 2711 ${${_MOZFUNC_UN}GetLongPath} "$R9" $R9
michael@0 2712 StrCmp "$R9" "$R4" +1 loop
michael@0 2713 ClearErrors
michael@0 2714 DeleteRegKey SHCTX "$R6\$R7"
michael@0 2715 IfErrors loop +1
michael@0 2716 IntOp $R8 $R8 - 1 ; Decrement the counter on successful deletion
michael@0 2717 GoTo loop
michael@0 2718
michael@0 2719 end:
michael@0 2720 ${If} ${RunningX64}
michael@0 2721 ${AndIf} "$R3" == "false"
michael@0 2722 ; Set the registry to the correct view.
michael@0 2723 !ifdef HAVE_64BIT_OS
michael@0 2724 SetRegView 64
michael@0 2725 !else
michael@0 2726 SetRegView 32
michael@0 2727 !endif
michael@0 2728
michael@0 2729 StrCpy $R7 ""
michael@0 2730 StrCpy $R8 0
michael@0 2731 StrCpy $R3 "true"
michael@0 2732 GoTo loop
michael@0 2733 ${EndIf}
michael@0 2734
michael@0 2735 ClearErrors
michael@0 2736
michael@0 2737 Pop $R3
michael@0 2738 Pop $R4
michael@0 2739 Pop $R5
michael@0 2740 Pop $R6
michael@0 2741 Pop $R7
michael@0 2742 Pop $R8
michael@0 2743 Pop $R9
michael@0 2744 FunctionEnd
michael@0 2745
michael@0 2746 !verbose pop
michael@0 2747 !endif
michael@0 2748 !macroend
michael@0 2749
michael@0 2750 !macro RegCleanUninstallCall
michael@0 2751 !verbose push
michael@0 2752 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2753 Call RegCleanUninstall
michael@0 2754 !verbose pop
michael@0 2755 !macroend
michael@0 2756
michael@0 2757 !macro un.RegCleanUninstallCall
michael@0 2758 !verbose push
michael@0 2759 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2760 Call un.RegCleanUninstall
michael@0 2761 !verbose pop
michael@0 2762 !macroend
michael@0 2763
michael@0 2764 !macro un.RegCleanUninstall
michael@0 2765 !ifndef un.RegCleanUninstall
michael@0 2766 !verbose push
michael@0 2767 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2768 !undef _MOZFUNC_UN
michael@0 2769 !define _MOZFUNC_UN "un."
michael@0 2770
michael@0 2771 !insertmacro RegCleanUninstall
michael@0 2772
michael@0 2773 !undef _MOZFUNC_UN
michael@0 2774 !define _MOZFUNC_UN
michael@0 2775 !verbose pop
michael@0 2776 !endif
michael@0 2777 !macroend
michael@0 2778
michael@0 2779 /**
michael@0 2780 * Removes an application specific handler registry key under Software\Classes
michael@0 2781 * for both HKCU and HKLM when its open command refers to this install
michael@0 2782 * location or the install location doesn't exist.
michael@0 2783 *
michael@0 2784 * @param _HANDLER_NAME
michael@0 2785 * The registry name for the handler.
michael@0 2786 *
michael@0 2787 * $R7 = stores the long path to the $INSTDIR
michael@0 2788 * $R8 = stores the path to the open command's parent directory
michael@0 2789 * $R9 = _HANDLER_NAME
michael@0 2790 */
michael@0 2791 !macro RegCleanAppHandler
michael@0 2792
michael@0 2793 !ifndef ${_MOZFUNC_UN}RegCleanAppHandler
michael@0 2794 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 2795 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 2796 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
michael@0 2797 !insertmacro ${_MOZFUNC_UN_TMP}GetPathFromString
michael@0 2798 !undef _MOZFUNC_UN
michael@0 2799 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 2800 !undef _MOZFUNC_UN_TMP
michael@0 2801
michael@0 2802 !verbose push
michael@0 2803 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2804 !define ${_MOZFUNC_UN}RegCleanAppHandler "!insertmacro ${_MOZFUNC_UN}RegCleanAppHandlerCall"
michael@0 2805
michael@0 2806 Function ${_MOZFUNC_UN}RegCleanAppHandler
michael@0 2807 Exch $R9
michael@0 2808 Push $R8
michael@0 2809 Push $R7
michael@0 2810
michael@0 2811 ClearErrors
michael@0 2812 ReadRegStr $R8 HKCU "Software\Classes\$R9\shell\open\command" ""
michael@0 2813 IfErrors next +1
michael@0 2814 ${${_MOZFUNC_UN}GetPathFromString} "$R8" $R8
michael@0 2815 ${${_MOZFUNC_UN}GetParent} "$R8" $R8
michael@0 2816 IfFileExists "$R8" +3 +1
michael@0 2817 DeleteRegKey HKCU "Software\Classes\$R9"
michael@0 2818 GoTo next
michael@0 2819
michael@0 2820 ${${_MOZFUNC_UN}GetLongPath} "$R8" $R8
michael@0 2821 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R7
michael@0 2822 StrCmp "$R7" "$R8" +1 next
michael@0 2823 DeleteRegKey HKCU "Software\Classes\$R9"
michael@0 2824
michael@0 2825 next:
michael@0 2826 ReadRegStr $R8 HKLM "Software\Classes\$R9\shell\open\command" ""
michael@0 2827 IfErrors end
michael@0 2828 ${${_MOZFUNC_UN}GetPathFromString} "$R8" $R8
michael@0 2829 ${${_MOZFUNC_UN}GetParent} "$R8" $R8
michael@0 2830 IfFileExists "$R8" +3 +1
michael@0 2831 DeleteRegKey HKLM "Software\Classes\$R9"
michael@0 2832 GoTo end
michael@0 2833
michael@0 2834 ${${_MOZFUNC_UN}GetLongPath} "$R8" $R8
michael@0 2835 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R7
michael@0 2836 StrCmp "$R7" "$R8" +1 end
michael@0 2837 DeleteRegKey HKLM "Software\Classes\$R9"
michael@0 2838
michael@0 2839 end:
michael@0 2840
michael@0 2841 Pop $R7
michael@0 2842 Pop $R8
michael@0 2843 Exch $R9
michael@0 2844 FunctionEnd
michael@0 2845
michael@0 2846 !verbose pop
michael@0 2847 !endif
michael@0 2848 !macroend
michael@0 2849
michael@0 2850 !macro RegCleanAppHandlerCall _HANDLER_NAME
michael@0 2851 !verbose push
michael@0 2852 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2853 Push "${_HANDLER_NAME}"
michael@0 2854 Call RegCleanAppHandler
michael@0 2855 !verbose pop
michael@0 2856 !macroend
michael@0 2857
michael@0 2858 !macro un.RegCleanAppHandlerCall _HANDLER_NAME
michael@0 2859 !verbose push
michael@0 2860 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2861 Push "${_HANDLER_NAME}"
michael@0 2862 Call un.RegCleanAppHandler
michael@0 2863 !verbose pop
michael@0 2864 !macroend
michael@0 2865
michael@0 2866 !macro un.RegCleanAppHandler
michael@0 2867 !ifndef un.RegCleanAppHandler
michael@0 2868 !verbose push
michael@0 2869 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2870 !undef _MOZFUNC_UN
michael@0 2871 !define _MOZFUNC_UN "un."
michael@0 2872
michael@0 2873 !insertmacro RegCleanAppHandler
michael@0 2874
michael@0 2875 !undef _MOZFUNC_UN
michael@0 2876 !define _MOZFUNC_UN
michael@0 2877 !verbose pop
michael@0 2878 !endif
michael@0 2879 !macroend
michael@0 2880
michael@0 2881 /**
michael@0 2882 * Cleans up the registry for a protocol handler when its open command
michael@0 2883 * refers to this install location. For HKCU the registry key is deleted
michael@0 2884 * and for HKLM the values set by the application are deleted.
michael@0 2885 *
michael@0 2886 * @param _HANDLER_NAME
michael@0 2887 * The registry name for the handler.
michael@0 2888 *
michael@0 2889 * $R7 = stores the long path to $INSTDIR
michael@0 2890 * $R8 = stores the the long path to the open command's parent directory
michael@0 2891 * $R9 = _HANDLER_NAME
michael@0 2892 */
michael@0 2893 !macro un.RegCleanProtocolHandler
michael@0 2894
michael@0 2895 !ifndef un.RegCleanProtocolHandler
michael@0 2896 !insertmacro un.GetLongPath
michael@0 2897 !insertmacro un.GetParent
michael@0 2898 !insertmacro un.GetPathFromString
michael@0 2899
michael@0 2900 !verbose push
michael@0 2901 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2902 !define un.RegCleanProtocolHandler "!insertmacro un.RegCleanProtocolHandlerCall"
michael@0 2903
michael@0 2904 Function un.RegCleanProtocolHandler
michael@0 2905 Exch $R9
michael@0 2906 Push $R8
michael@0 2907 Push $R7
michael@0 2908
michael@0 2909 ReadRegStr $R8 HKCU "Software\Classes\$R9\shell\open\command" ""
michael@0 2910 ${un.GetLongPath} "$INSTDIR" $R7
michael@0 2911
michael@0 2912 StrCmp "$R8" "" next +1
michael@0 2913 ${un.GetPathFromString} "$R8" $R8
michael@0 2914 ${un.GetParent} "$R8" $R8
michael@0 2915 ${un.GetLongPath} "$R8" $R8
michael@0 2916 StrCmp "$R7" "$R8" +1 next
michael@0 2917 DeleteRegKey HKCU "Software\Classes\$R9"
michael@0 2918
michael@0 2919 next:
michael@0 2920 ReadRegStr $R8 HKLM "Software\Classes\$R9\shell\open\command" ""
michael@0 2921 StrCmp "$R8" "" end +1
michael@0 2922 ${un.GetLongPath} "$INSTDIR" $R7
michael@0 2923 ${un.GetPathFromString} "$R8" $R8
michael@0 2924 ${un.GetParent} "$R8" $R8
michael@0 2925 ${un.GetLongPath} "$R8" $R8
michael@0 2926 StrCmp "$R7" "$R8" +1 end
michael@0 2927 DeleteRegValue HKLM "Software\Classes\$R9\DefaultIcon" ""
michael@0 2928 DeleteRegValue HKLM "Software\Classes\$R9\shell\open" ""
michael@0 2929 DeleteRegValue HKLM "Software\Classes\$R9\shell\open\command" ""
michael@0 2930 DeleteRegValue HKLM "Software\Classes\$R9\shell\ddeexec" ""
michael@0 2931 DeleteRegValue HKLM "Software\Classes\$R9\shell\ddeexec\Application" ""
michael@0 2932 DeleteRegValue HKLM "Software\Classes\$R9\shell\ddeexec\Topic" ""
michael@0 2933
michael@0 2934 end:
michael@0 2935
michael@0 2936 Pop $R7
michael@0 2937 Pop $R8
michael@0 2938 Exch $R9
michael@0 2939 FunctionEnd
michael@0 2940
michael@0 2941 !verbose pop
michael@0 2942 !endif
michael@0 2943 !macroend
michael@0 2944
michael@0 2945 !macro un.RegCleanProtocolHandlerCall _HANDLER_NAME
michael@0 2946 !verbose push
michael@0 2947 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2948 Push "${_HANDLER_NAME}"
michael@0 2949 Call un.RegCleanProtocolHandler
michael@0 2950 !verbose pop
michael@0 2951 !macroend
michael@0 2952
michael@0 2953 /**
michael@0 2954 * Cleans up the registry for a file handler when the passed in value equals
michael@0 2955 * the default value for the file handler. For HKCU the registry key is deleted
michael@0 2956 * and for HKLM the default value is deleted.
michael@0 2957 *
michael@0 2958 * @param _HANDLER_NAME
michael@0 2959 * The registry name for the handler.
michael@0 2960 * @param _DEFAULT_VALUE
michael@0 2961 * The value to check for against the handler's default value.
michael@0 2962 *
michael@0 2963 * $R6 = stores the long path to $INSTDIR
michael@0 2964 * $R7 = _DEFAULT_VALUE
michael@0 2965 * $R9 = _HANDLER_NAME
michael@0 2966 */
michael@0 2967 !macro RegCleanFileHandler
michael@0 2968
michael@0 2969 !ifndef ${_MOZFUNC_UN}RegCleanFileHandler
michael@0 2970 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 2971 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 2972 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
michael@0 2973 !insertmacro ${_MOZFUNC_UN_TMP}GetPathFromString
michael@0 2974 !undef _MOZFUNC_UN
michael@0 2975 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 2976 !undef _MOZFUNC_UN_TMP
michael@0 2977
michael@0 2978 !verbose push
michael@0 2979 !verbose ${_MOZFUNC_VERBOSE}
michael@0 2980 !define ${_MOZFUNC_UN}RegCleanFileHandler "!insertmacro ${_MOZFUNC_UN}RegCleanFileHandlerCall"
michael@0 2981
michael@0 2982 Function ${_MOZFUNC_UN}RegCleanFileHandler
michael@0 2983 Exch $R9
michael@0 2984 Exch 1
michael@0 2985 Exch $R8
michael@0 2986 Push $R7
michael@0 2987
michael@0 2988 ReadRegStr $R7 HKCU "Software\Classes\$R9" ""
michael@0 2989 StrCmp "$R7" "$R8" +1 +2
michael@0 2990 DeleteRegKey HKCU "Software\Classes\$R9"
michael@0 2991
michael@0 2992 ReadRegStr $R7 HKLM "Software\Classes\$R9" ""
michael@0 2993 StrCmp "$R7" "$R8" +1 +2
michael@0 2994 DeleteRegValue HKLM "Software\Classes\$R9" ""
michael@0 2995
michael@0 2996 ClearErrors
michael@0 2997
michael@0 2998 Pop $R7
michael@0 2999 Exch $R8
michael@0 3000 Exch 1
michael@0 3001 Exch $R9
michael@0 3002 FunctionEnd
michael@0 3003
michael@0 3004 !verbose pop
michael@0 3005 !endif
michael@0 3006 !macroend
michael@0 3007
michael@0 3008 !macro RegCleanFileHandlerCall _HANDLER_NAME _DEFAULT_VALUE
michael@0 3009 !verbose push
michael@0 3010 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3011 Push "${_DEFAULT_VALUE}"
michael@0 3012 Push "${_HANDLER_NAME}"
michael@0 3013 Call RegCleanFileHandler
michael@0 3014 !verbose pop
michael@0 3015 !macroend
michael@0 3016
michael@0 3017 !macro un.RegCleanFileHandlerCall _HANDLER_NAME _DEFAULT_VALUE
michael@0 3018 !verbose push
michael@0 3019 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3020 Push "${_DEFAULT_VALUE}"
michael@0 3021 Push "${_HANDLER_NAME}"
michael@0 3022 Call un.RegCleanFileHandler
michael@0 3023 !verbose pop
michael@0 3024 !macroend
michael@0 3025
michael@0 3026 !macro un.RegCleanFileHandler
michael@0 3027 !ifndef un.RegCleanFileHandler
michael@0 3028 !verbose push
michael@0 3029 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3030 !undef _MOZFUNC_UN
michael@0 3031 !define _MOZFUNC_UN "un."
michael@0 3032
michael@0 3033 !insertmacro RegCleanFileHandler
michael@0 3034
michael@0 3035 !undef _MOZFUNC_UN
michael@0 3036 !define _MOZFUNC_UN
michael@0 3037 !verbose pop
michael@0 3038 !endif
michael@0 3039 !macroend
michael@0 3040
michael@0 3041 /**
michael@0 3042 * Checks if a handler's open command points to this installation directory.
michael@0 3043 * Uses SHCTX to determine the registry hive (e.g. HKLM or HKCU) to check.
michael@0 3044 *
michael@0 3045 * @param _HANDLER_NAME
michael@0 3046 * The registry name for the handler.
michael@0 3047 * @param _RESULT
michael@0 3048 * true if it is the handler's open command points to this
michael@0 3049 * installation directory and false if it does not.
michael@0 3050 *
michael@0 3051 * $R7 = stores the value of the open command and the path macros return values
michael@0 3052 * $R8 = stores the handler's registry key name
michael@0 3053 * $R9 = _DEFAULT_VALUE and _RESULT
michael@0 3054 */
michael@0 3055 !macro IsHandlerForInstallDir
michael@0 3056
michael@0 3057 !ifndef ${_MOZFUNC_UN}IsHandlerForInstallDir
michael@0 3058 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 3059 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 3060 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
michael@0 3061 !insertmacro ${_MOZFUNC_UN_TMP}GetPathFromString
michael@0 3062 !undef _MOZFUNC_UN
michael@0 3063 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 3064 !undef _MOZFUNC_UN_TMP
michael@0 3065
michael@0 3066 !verbose push
michael@0 3067 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3068 !define ${_MOZFUNC_UN}IsHandlerForInstallDir "!insertmacro ${_MOZFUNC_UN}IsHandlerForInstallDirCall"
michael@0 3069
michael@0 3070 Function ${_MOZFUNC_UN}IsHandlerForInstallDir
michael@0 3071 Exch $R9
michael@0 3072 Push $R8
michael@0 3073 Push $R7
michael@0 3074
michael@0 3075 StrCpy $R8 "$R9"
michael@0 3076 StrCpy $R9 "false"
michael@0 3077 ReadRegStr $R7 SHCTX "Software\Classes\$R8\shell\open\command" ""
michael@0 3078
michael@0 3079 ${If} $R7 != ""
michael@0 3080 ${GetPathFromString} "$R7" $R7
michael@0 3081 ${GetParent} "$R7" $R7
michael@0 3082 ${GetLongPath} "$R7" $R7
michael@0 3083 ${If} $R7 == $INSTDIR
michael@0 3084 StrCpy $R9 "true"
michael@0 3085 ${EndIf}
michael@0 3086 ${EndIf}
michael@0 3087
michael@0 3088 ClearErrors
michael@0 3089
michael@0 3090 Pop $R7
michael@0 3091 Pop $R8
michael@0 3092 Exch $R9
michael@0 3093 FunctionEnd
michael@0 3094
michael@0 3095 !verbose pop
michael@0 3096 !endif
michael@0 3097 !macroend
michael@0 3098
michael@0 3099 !macro IsHandlerForInstallDirCall _HANDLER_NAME _RESULT
michael@0 3100 !verbose push
michael@0 3101 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3102 Push "${_HANDLER_NAME}"
michael@0 3103 Call IsHandlerForInstallDir
michael@0 3104 Pop "${_RESULT}"
michael@0 3105 !verbose pop
michael@0 3106 !macroend
michael@0 3107
michael@0 3108 !macro un.IsHandlerForInstallDirCall _HANDLER_NAME _RESULT
michael@0 3109 !verbose push
michael@0 3110 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3111 Push "${_HANDLER_NAME}"
michael@0 3112 Call un.IsHandlerForInstallDir
michael@0 3113 Pop "${_RESULT}"
michael@0 3114 !verbose pop
michael@0 3115 !macroend
michael@0 3116
michael@0 3117 !macro un.IsHandlerForInstallDir
michael@0 3118 !ifndef un.IsHandlerForInstallDir
michael@0 3119 !verbose push
michael@0 3120 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3121 !undef _MOZFUNC_UN
michael@0 3122 !define _MOZFUNC_UN "un."
michael@0 3123
michael@0 3124 !insertmacro IsHandlerForInstallDir
michael@0 3125
michael@0 3126 !undef _MOZFUNC_UN
michael@0 3127 !define _MOZFUNC_UN
michael@0 3128 !verbose pop
michael@0 3129 !endif
michael@0 3130 !macroend
michael@0 3131
michael@0 3132 /**
michael@0 3133 * Removes the application's VirtualStore directory if present when the
michael@0 3134 * installation directory is a sub-directory of the program files directory.
michael@0 3135 *
michael@0 3136 * $R4 = $PROGRAMFILES/$PROGRAMFILES64 for CleanVirtualStore_Internal
michael@0 3137 * $R5 = various path values.
michael@0 3138 * $R6 = length of the long path to $PROGRAMFILES32 or $PROGRAMFILES64
michael@0 3139 * $R7 = long path to $PROGRAMFILES32 or $PROGRAMFILES64
michael@0 3140 * $R8 = length of the long path to $INSTDIR
michael@0 3141 * $R9 = long path to $INSTDIR
michael@0 3142 */
michael@0 3143 !macro CleanVirtualStore
michael@0 3144
michael@0 3145 !ifndef ${_MOZFUNC_UN}CleanVirtualStore
michael@0 3146 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 3147 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 3148 !undef _MOZFUNC_UN
michael@0 3149 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 3150 !undef _MOZFUNC_UN_TMP
michael@0 3151
michael@0 3152 !verbose push
michael@0 3153 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3154 !define ${_MOZFUNC_UN}CleanVirtualStore "!insertmacro ${_MOZFUNC_UN}CleanVirtualStoreCall"
michael@0 3155
michael@0 3156 Function ${_MOZFUNC_UN}CleanVirtualStore
michael@0 3157 Push $R9
michael@0 3158 Push $R8
michael@0 3159 Push $R7
michael@0 3160 Push $R6
michael@0 3161 Push $R5
michael@0 3162 Push $R4
michael@0 3163
michael@0 3164 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R9
michael@0 3165 ${If} "$R9" != ""
michael@0 3166 StrLen $R8 "$R9"
michael@0 3167
michael@0 3168 StrCpy $R4 $PROGRAMFILES32
michael@0 3169 Call ${_MOZFUNC_UN}CleanVirtualStore_Internal
michael@0 3170
michael@0 3171 ${If} ${RunningX64}
michael@0 3172 StrCpy $R4 $PROGRAMFILES64
michael@0 3173 Call ${_MOZFUNC_UN}CleanVirtualStore_Internal
michael@0 3174 ${EndIf}
michael@0 3175
michael@0 3176 ${EndIf}
michael@0 3177
michael@0 3178 ClearErrors
michael@0 3179
michael@0 3180 Pop $R4
michael@0 3181 Pop $R5
michael@0 3182 Pop $R6
michael@0 3183 Pop $R7
michael@0 3184 Pop $R8
michael@0 3185 Pop $R9
michael@0 3186 FunctionEnd
michael@0 3187
michael@0 3188 Function ${_MOZFUNC_UN}CleanVirtualStore_Internal
michael@0 3189 ${${_MOZFUNC_UN}GetLongPath} "" $R7
michael@0 3190 ${If} "$R7" != ""
michael@0 3191 StrLen $R6 "$R7"
michael@0 3192 ${If} $R8 < $R6
michael@0 3193 ; Copy from the start of $INSTDIR the length of $PROGRAMFILES64
michael@0 3194 StrCpy $R5 "$R9" $R6
michael@0 3195 ${If} "$R5" == "$R7"
michael@0 3196 ; Remove the drive letter and colon from the $INSTDIR long path
michael@0 3197 StrCpy $R5 "$R9" "" 2
michael@0 3198 StrCpy $R5 "$LOCALAPPDATA\VirtualStore$R5"
michael@0 3199 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
michael@0 3200 ${If} "$R5" != ""
michael@0 3201 ${AndIf} ${FileExists} "$R5"
michael@0 3202 RmDir /r "$R5"
michael@0 3203 ${EndIf}
michael@0 3204 ${EndIf}
michael@0 3205 ${EndIf}
michael@0 3206 ${EndIf}
michael@0 3207 FunctionEnd
michael@0 3208
michael@0 3209 !verbose pop
michael@0 3210 !endif
michael@0 3211 !macroend
michael@0 3212
michael@0 3213 !macro CleanVirtualStoreCall
michael@0 3214 !verbose push
michael@0 3215 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3216 Call CleanVirtualStore
michael@0 3217 !verbose pop
michael@0 3218 !macroend
michael@0 3219
michael@0 3220 !macro un.CleanVirtualStoreCall
michael@0 3221 !verbose push
michael@0 3222 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3223 Call un.CleanVirtualStore
michael@0 3224 !verbose pop
michael@0 3225 !macroend
michael@0 3226
michael@0 3227 !macro un.CleanVirtualStore
michael@0 3228 !ifndef un.CleanVirtualStore
michael@0 3229 !verbose push
michael@0 3230 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3231 !undef _MOZFUNC_UN
michael@0 3232 !define _MOZFUNC_UN "un."
michael@0 3233
michael@0 3234 !insertmacro CleanVirtualStore
michael@0 3235
michael@0 3236 !undef _MOZFUNC_UN
michael@0 3237 !define _MOZFUNC_UN
michael@0 3238 !verbose pop
michael@0 3239 !endif
michael@0 3240 !macroend
michael@0 3241
michael@0 3242 /**
michael@0 3243 * If present removes the updates directory located in the profile's local
michael@0 3244 * directory for this installation.
michael@0 3245 * This macro is obsolete and should no longer be used. Please see
michael@0 3246 * CleanUpdateDirectories.
michael@0 3247 *
michael@0 3248 * @param _REL_PROFILE_PATH
michael@0 3249 * The relative path to the profile directory from $LOCALAPPDATA.
michael@0 3250 *
michael@0 3251 * $R4 = various path values.
michael@0 3252 * $R5 = length of the long path to $PROGRAMFILES
michael@0 3253 * $R6 = length of the long path to $INSTDIR
michael@0 3254 * $R7 = long path to $PROGRAMFILES
michael@0 3255 * $R8 = long path to $INSTDIR
michael@0 3256 * $R9 = _REL_PROFILE_PATH
michael@0 3257 */
michael@0 3258 !macro CleanUpdatesDir
michael@0 3259
michael@0 3260 !ifndef ${_MOZFUNC_UN}CleanUpdatesDir
michael@0 3261 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 3262 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 3263 !undef _MOZFUNC_UN
michael@0 3264 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 3265 !undef _MOZFUNC_UN_TMP
michael@0 3266
michael@0 3267 !verbose push
michael@0 3268 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3269 !define ${_MOZFUNC_UN}CleanUpdatesDir "!insertmacro ${_MOZFUNC_UN}CleanUpdatesDirCall"
michael@0 3270
michael@0 3271 Function ${_MOZFUNC_UN}CleanUpdatesDir
michael@0 3272 Exch $R9
michael@0 3273 Push $R8
michael@0 3274 Push $R7
michael@0 3275 Push $R6
michael@0 3276 Push $R5
michael@0 3277 Push $R4
michael@0 3278
michael@0 3279 StrCmp $R9 "" end +1 ; The relative path to the app's profiles is required
michael@0 3280 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R8
michael@0 3281 StrCmp $R8 "" end +1
michael@0 3282 ${${_MOZFUNC_UN}GetLongPath} "$PROGRAMFILES" $R7
michael@0 3283 StrCmp $R7 "" end +1
michael@0 3284
michael@0 3285 StrLen $R6 "$R8"
michael@0 3286 StrLen $R5 "$R7"
michael@0 3287 ; Only continue If the length of $INSTDIR is greater than the length of
michael@0 3288 ; $PROGRAMFILES
michael@0 3289 IntCmp $R6 $R5 end end +1
michael@0 3290
michael@0 3291 ; Copy from the start of $INSTDIR the length of $PROGRAMFILES
michael@0 3292 StrCpy $R4 "$R8" $R5
michael@0 3293 StrCmp "$R4" "$R7" +1 end ; Check if $INSTDIR is under $PROGRAMFILES
michael@0 3294
michael@0 3295 ; Copy the relative path to $INSTDIR from $PROGRAMFILES
michael@0 3296 StrCpy $R4 "$R8" "" $R5
michael@0 3297
michael@0 3298 ; Concatenate the path to $LOCALAPPDATA the relative profile path and the
michael@0 3299 ; relative path to $INSTDIR from $PROGRAMFILES
michael@0 3300 StrCpy $R4 "$LOCALAPPDATA\$R9$R4"
michael@0 3301 ${${_MOZFUNC_UN}GetLongPath} "$R4" $R4
michael@0 3302 StrCmp $R4 "" end +1
michael@0 3303
michael@0 3304 IfFileExists "$R4\updates" +1 end
michael@0 3305 RmDir /r "$R4"
michael@0 3306
michael@0 3307 end:
michael@0 3308 ClearErrors
michael@0 3309
michael@0 3310 Pop $R4
michael@0 3311 Pop $R5
michael@0 3312 Pop $R6
michael@0 3313 Pop $R7
michael@0 3314 Pop $R8
michael@0 3315 Exch $R9
michael@0 3316 FunctionEnd
michael@0 3317
michael@0 3318 !verbose pop
michael@0 3319 !endif
michael@0 3320 !macroend
michael@0 3321
michael@0 3322 !macro CleanUpdatesDirCall _REL_PROFILE_PATH
michael@0 3323 !verbose push
michael@0 3324 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3325 Push "${_REL_PROFILE_PATH}"
michael@0 3326 Call CleanUpdatesDir
michael@0 3327 !verbose pop
michael@0 3328 !macroend
michael@0 3329
michael@0 3330 !macro un.CleanUpdatesDirCall _REL_PROFILE_PATH
michael@0 3331 !verbose push
michael@0 3332 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3333 Push "${_REL_PROFILE_PATH}"
michael@0 3334 Call un.CleanUpdatesDir
michael@0 3335 !verbose pop
michael@0 3336 !macroend
michael@0 3337
michael@0 3338 !macro un.CleanUpdatesDir
michael@0 3339 !ifndef un.CleanUpdatesDir
michael@0 3340 !verbose push
michael@0 3341 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3342 !undef _MOZFUNC_UN
michael@0 3343 !define _MOZFUNC_UN "un."
michael@0 3344
michael@0 3345 !insertmacro CleanUpdatesDir
michael@0 3346
michael@0 3347 !undef _MOZFUNC_UN
michael@0 3348 !define _MOZFUNC_UN
michael@0 3349 !verbose pop
michael@0 3350 !endif
michael@0 3351 !macroend
michael@0 3352
michael@0 3353 /**
michael@0 3354 * If present removes the updates directory located in the profile's local
michael@0 3355 * directory for this installation.
michael@0 3356 *
michael@0 3357 * @param _OLD_REL_PATH
michael@0 3358 * The relative path to the profile directory from $LOCALAPPDATA.
michael@0 3359 * Calculated for the old update directory not based on a hash.
michael@0 3360 * @param _NEW_REL_PATH
michael@0 3361 * The relative path to the profile directory from $LOCALAPPDATA.
michael@0 3362 * Calculated for the new update directory based on a hash.
michael@0 3363 *
michael@0 3364 * $R8 = _NEW_REL_PATH
michael@0 3365 * $R7 = _OLD_REL_PATH
michael@0 3366 * $R1 = taskBar ID hash located in registry at SOFTWARE\_OLD_REL_PATH\TaskBarIDs
michael@0 3367 * $R2 = various path values.
michael@0 3368 * $R3 = length of the long path to $PROGRAMFILES
michael@0 3369 * $R4 = length of the long path to $INSTDIR
michael@0 3370 * $R5 = long path to $PROGRAMFILES
michael@0 3371 * $R6 = long path to $INSTDIR
michael@0 3372 * $R0 = path to the new update directory built from _NEW_REL_PATH and
michael@0 3373 * the taskbar ID.
michael@0 3374 */
michael@0 3375 !macro CleanUpdateDirectories
michael@0 3376
michael@0 3377 !ifndef ${_MOZFUNC_UN}CleanUpdateDirectories
michael@0 3378 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 3379 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 3380 !undef _MOZFUNC_UN
michael@0 3381 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 3382 !undef _MOZFUNC_UN_TMP
michael@0 3383
michael@0 3384 !verbose push
michael@0 3385 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3386 !define ${_MOZFUNC_UN}CleanUpdateDirectories "!insertmacro ${_MOZFUNC_UN}CleanUpdateDirectoriesCall"
michael@0 3387
michael@0 3388 Function ${_MOZFUNC_UN}CleanUpdateDirectories
michael@0 3389 Exch $R8
michael@0 3390 Exch 1
michael@0 3391 Exch $R7
michael@0 3392 Push $R6
michael@0 3393 Push $R5
michael@0 3394 Push $R4
michael@0 3395 Push $R3
michael@0 3396 Push $R2
michael@0 3397 Push $R1
michael@0 3398 Push $R0
michael@0 3399
michael@0 3400 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R6
michael@0 3401 StrLen $R4 "$R6"
michael@0 3402
michael@0 3403 ${${_MOZFUNC_UN}GetLongPath} "$PROGRAMFILES" $R5
michael@0 3404 StrLen $R3 "$R5"
michael@0 3405
michael@0 3406 ${If} $R7 != "" ; _OLD_REL_PATH was passed
michael@0 3407 ${AndIf} $R6 != "" ; We have the install dir path
michael@0 3408 ${AndIf} $R5 != "" ; We the program files path
michael@0 3409 ${AndIf} $R4 > $R3 ; The length of $INSTDIR > the length of $PROGRAMFILES
michael@0 3410
michael@0 3411 ; Copy from the start of $INSTDIR the length of $PROGRAMFILES
michael@0 3412 StrCpy $R2 "$R6" $R3
michael@0 3413
michael@0 3414 ; Check if $INSTDIR is under $PROGRAMFILES
michael@0 3415 ${If} $R2 == $R5
michael@0 3416
michael@0 3417 ; Copy the relative path to $INSTDIR from $PROGRAMFILES
michael@0 3418 StrCpy $R2 "$R6" "" $R3
michael@0 3419
michael@0 3420 ; Concatenate the path $LOCALAPPDATA to the relative profile path and
michael@0 3421 ; the relative path to $INSTDIR from $PROGRAMFILES
michael@0 3422 StrCpy $R2 "$LOCALAPPDATA\$R7$R2"
michael@0 3423 ${${_MOZFUNC_UN}GetLongPath} "$R2" $R2
michael@0 3424
michael@0 3425 ${If} $R2 != ""
michael@0 3426 ; Backup the old update directory logs and delete the directory
michael@0 3427 ${If} ${FileExists} "$R2\updates\last-update.log"
michael@0 3428 Rename "$R2\updates\last-update.log" "$TEMP\moz-update-old-last-update.log"
michael@0 3429 ${EndIf}
michael@0 3430
michael@0 3431 ${If} ${FileExists} "$R2\updates\backup-update.log"
michael@0 3432 Rename "$R2\updates\backup-update.log" "$TEMP\moz-update-old-backup-update.log"
michael@0 3433 ${EndIf}
michael@0 3434
michael@0 3435 ${If} ${FileExists} "$R2\updates"
michael@0 3436 RmDir /r "$R2"
michael@0 3437 ${EndIf}
michael@0 3438 ${EndIf}
michael@0 3439
michael@0 3440 ; Get the taskbar ID hash for this installation path
michael@0 3441 ReadRegStr $R1 HKLM "SOFTWARE\$R7\TaskBarIDs" $R6
michael@0 3442 ${If} $R1 == ""
michael@0 3443 ReadRegStr $R1 HKCU "SOFTWARE\$R7\TaskBarIDs" $R6
michael@0 3444 ${EndIf}
michael@0 3445
michael@0 3446 ; If the taskbar ID hash exists then delete the new update directory
michael@0 3447 ; Backup its logs before deleting it.
michael@0 3448 ${If} $R1 != ""
michael@0 3449 StrCpy $R0 "$LOCALAPPDATA\$R8\$R1"
michael@0 3450
michael@0 3451 ${If} ${FileExists} "$R0\updates\last-update.log"
michael@0 3452 Rename "$R0\updates\last-update.log" "$TEMP\moz-update-new-last-update.log"
michael@0 3453 ${EndIf}
michael@0 3454
michael@0 3455 ${If} ${FileExists} "$R0\updates\backup-update.log"
michael@0 3456 Rename "$R0\updates\backup-update.log" "$TEMP\moz-update-new-backup-update.log"
michael@0 3457 ${EndIf}
michael@0 3458
michael@0 3459 ; Remove the old updates directory
michael@0 3460 ${If} ${FileExists} "$R0\updates"
michael@0 3461 RmDir /r "$R0"
michael@0 3462 ${EndIf}
michael@0 3463 ${EndIf}
michael@0 3464 ${EndIf}
michael@0 3465 ${EndIf}
michael@0 3466
michael@0 3467 ClearErrors
michael@0 3468
michael@0 3469 Pop $R0
michael@0 3470 Pop $R1
michael@0 3471 Pop $R2
michael@0 3472 Pop $R3
michael@0 3473 Pop $R4
michael@0 3474 Pop $R5
michael@0 3475 Pop $R6
michael@0 3476 Exch $R7
michael@0 3477 Exch 1
michael@0 3478 Exch $R8
michael@0 3479 FunctionEnd
michael@0 3480
michael@0 3481 !verbose pop
michael@0 3482 !endif
michael@0 3483 !macroend
michael@0 3484
michael@0 3485 !macro CleanUpdateDirectoriesCall _OLD_REL_PATH _NEW_REL_PATH
michael@0 3486 !verbose push
michael@0 3487 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3488 Push "${_OLD_REL_PATH}"
michael@0 3489 Push "${_NEW_REL_PATH}"
michael@0 3490 Call CleanUpdateDirectories
michael@0 3491 !verbose pop
michael@0 3492 !macroend
michael@0 3493
michael@0 3494 !macro un.CleanUpdateDirectoriesCall _OLD_REL_PATH _NEW_REL_PATH
michael@0 3495 !verbose push
michael@0 3496 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3497 Push "${_OLD_REL_PATH}"
michael@0 3498 Push "${_NEW_REL_PATH}"
michael@0 3499 Call un.CleanUpdateDirectories
michael@0 3500 !verbose pop
michael@0 3501 !macroend
michael@0 3502
michael@0 3503 !macro un.CleanUpdateDirectories
michael@0 3504 !ifndef un.CleanUpdateDirectories
michael@0 3505 !verbose push
michael@0 3506 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3507 !undef _MOZFUNC_UN
michael@0 3508 !define _MOZFUNC_UN "un."
michael@0 3509
michael@0 3510 !insertmacro CleanUpdateDirectories
michael@0 3511
michael@0 3512 !undef _MOZFUNC_UN
michael@0 3513 !define _MOZFUNC_UN
michael@0 3514 !verbose pop
michael@0 3515 !endif
michael@0 3516 !macroend
michael@0 3517
michael@0 3518 /**
michael@0 3519 * Deletes all relative profiles specified in an application's profiles.ini and
michael@0 3520 * performs various other cleanup.
michael@0 3521 *
michael@0 3522 * @param _REL_PROFILE_PATH
michael@0 3523 * The relative path to the profile directory.
michael@0 3524 *
michael@0 3525 * $R6 = value of IsRelative read from profiles.ini
michael@0 3526 * $R7 = value of Path to profile read from profiles.ini
michael@0 3527 * $R8 = counter for reading profiles (e.g. Profile0, Profile1, etc.)
michael@0 3528 * $R9 = _REL_PROFILE_PATH
michael@0 3529 */
michael@0 3530 !macro DeleteRelativeProfiles
michael@0 3531
michael@0 3532 !ifndef ${_MOZFUNC_UN}DeleteRelativeProfiles
michael@0 3533 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 3534 !insertmacro ${_MOZFUNC_UN_TMP}WordReplace
michael@0 3535 !undef _MOZFUNC_UN
michael@0 3536 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 3537 !undef _MOZFUNC_UN_TMP
michael@0 3538
michael@0 3539 !verbose push
michael@0 3540 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3541 !define ${_MOZFUNC_UN}DeleteRelativeProfiles "!insertmacro ${_MOZFUNC_UN}DeleteRelativeProfilesCall"
michael@0 3542
michael@0 3543 Function ${_MOZFUNC_UN}DeleteRelativeProfiles
michael@0 3544 Exch $R9
michael@0 3545 Push $R8
michael@0 3546 Push $R7
michael@0 3547 Push $R6
michael@0 3548
michael@0 3549 SetShellVarContext current
michael@0 3550 StrCpy $R8 -1
michael@0 3551
michael@0 3552 loop:
michael@0 3553 IntOp $R8 $R8 + 1 ; Increment the counter.
michael@0 3554 ReadINIStr $R7 "$APPDATA\$R9\profiles.ini" "Profile$R8" "Path"
michael@0 3555 IfErrors end +1
michael@0 3556
michael@0 3557 ; Only remove relative profiles
michael@0 3558 ReadINIStr $R6 "$APPDATA\$R9\profiles.ini" "Profile$R8" "IsRelative"
michael@0 3559 StrCmp "$R6" "1" +1 loop
michael@0 3560
michael@0 3561 ; Relative paths in profiles.ini use / as a separator
michael@0 3562 ${${_MOZFUNC_UN}WordReplace} "$R7" "/" "\" "+" $R7
michael@0 3563
michael@0 3564 IfFileExists "$LOCALAPPDATA\$R9\$R7" +1 +2
michael@0 3565 RmDir /r "$LOCALAPPDATA\$R9\$R7"
michael@0 3566 IfFileExists "$APPDATA\$R9\$R7" +1 +2
michael@0 3567 RmDir /r "$APPDATA\$R9\$R7"
michael@0 3568 GoTo loop
michael@0 3569
michael@0 3570 end:
michael@0 3571 ; Remove profiles directory under LOCALAPPDATA (e.g. cache, etc.) since
michael@0 3572 ; they are at times abandoned.
michael@0 3573 RmDir /r "$LOCALAPPDATA\$R9\Profiles"
michael@0 3574 RmDir /r "$APPDATA\$R9\Crash Reports"
michael@0 3575 Delete "$APPDATA\$R9\profiles.ini"
michael@0 3576 Delete "$APPDATA\$R9\console.log"
michael@0 3577 Delete "$APPDATA\$R9\pluginreg.dat"
michael@0 3578 RmDir "$APPDATA\$R9\Profiles"
michael@0 3579 RmDir "$APPDATA\$R9"
michael@0 3580
michael@0 3581 Pop $R6
michael@0 3582 Pop $R7
michael@0 3583 Pop $R8
michael@0 3584 Exch $R9
michael@0 3585 FunctionEnd
michael@0 3586
michael@0 3587 !verbose pop
michael@0 3588 !endif
michael@0 3589 !macroend
michael@0 3590
michael@0 3591 !macro DeleteRelativeProfilesCall _REL_PROFILE_PATH
michael@0 3592 !verbose push
michael@0 3593 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3594 Push "${_REL_PROFILE_PATH}"
michael@0 3595 Call DeleteRelativeProfiles
michael@0 3596 !verbose pop
michael@0 3597 !macroend
michael@0 3598
michael@0 3599 !macro un.DeleteRelativeProfilesCall _REL_PROFILE_PATH
michael@0 3600 !verbose push
michael@0 3601 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3602 Push "${_REL_PROFILE_PATH}"
michael@0 3603 Call un.DeleteRelativeProfiles
michael@0 3604 !verbose pop
michael@0 3605 !macroend
michael@0 3606
michael@0 3607 !macro un.DeleteRelativeProfiles
michael@0 3608 !ifndef un.DeleteRelativeProfiles
michael@0 3609 !verbose push
michael@0 3610 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3611 !undef _MOZFUNC_UN
michael@0 3612 !define _MOZFUNC_UN "un."
michael@0 3613
michael@0 3614 !insertmacro DeleteRelativeProfiles
michael@0 3615
michael@0 3616 !undef _MOZFUNC_UN
michael@0 3617 !define _MOZFUNC_UN
michael@0 3618 !verbose pop
michael@0 3619 !endif
michael@0 3620 !macroend
michael@0 3621
michael@0 3622 /**
michael@0 3623 * Deletes shortcuts and Start Menu directories under Programs as specified by
michael@0 3624 * the shortcuts log ini file and on Windows 7 unpins TaskBar and Start Menu
michael@0 3625 * shortcuts. The shortcuts will not be deleted if the shortcut target isn't for
michael@0 3626 * this install location which is determined by the shortcut having a target of
michael@0 3627 * $INSTDIR\${FileMainEXE}. The context (All Users or Current User) of the
michael@0 3628 * $DESKTOP and $SMPROGRAMS constants depends on the
michael@0 3629 * SetShellVarContext setting and must be set by the caller of this macro. There
michael@0 3630 * is no All Users context for $QUICKLAUNCH but this will not cause a problem
michael@0 3631 * since the macro will just continue past the $QUICKLAUNCH shortcut deletion
michael@0 3632 * section on subsequent calls.
michael@0 3633 *
michael@0 3634 * The ini file sections must have the following format (the order of the
michael@0 3635 * sections in the ini file is not important):
michael@0 3636 * [SMPROGRAMS]
michael@0 3637 * ; RelativePath is the directory relative from the Start Menu
michael@0 3638 * ; Programs directory.
michael@0 3639 * RelativePath=Mozilla App
michael@0 3640 * ; Shortcut1 is the first shortcut, Shortcut2 is the second shortcut, and so
michael@0 3641 * ; on. There must not be a break in the sequence of the numbers.
michael@0 3642 * Shortcut1=Mozilla App.lnk
michael@0 3643 * Shortcut2=Mozilla App (Safe Mode).lnk
michael@0 3644 * [DESKTOP]
michael@0 3645 * ; Shortcut1 is the first shortcut, Shortcut2 is the second shortcut, and so
michael@0 3646 * ; on. There must not be a break in the sequence of the numbers.
michael@0 3647 * Shortcut1=Mozilla App.lnk
michael@0 3648 * Shortcut2=Mozilla App (Safe Mode).lnk
michael@0 3649 * [QUICKLAUNCH]
michael@0 3650 * ; Shortcut1 is the first shortcut, Shortcut2 is the second shortcut, and so
michael@0 3651 * ; on. There must not be a break in the sequence of the numbers for the
michael@0 3652 * ; suffix.
michael@0 3653 * Shortcut1=Mozilla App.lnk
michael@0 3654 * Shortcut2=Mozilla App (Safe Mode).lnk
michael@0 3655 * [STARTMENU]
michael@0 3656 * ; Shortcut1 is the first shortcut, Shortcut2 is the second shortcut, and so
michael@0 3657 * ; on. There must not be a break in the sequence of the numbers for the
michael@0 3658 * ; suffix.
michael@0 3659 * Shortcut1=Mozilla App.lnk
michael@0 3660 * Shortcut2=Mozilla App (Safe Mode).lnk
michael@0 3661 *
michael@0 3662 * $R4 = counter for appending to Shortcut for enumerating the ini file entries
michael@0 3663 * $R5 = return value from ShellLink::GetShortCutTarget and
michael@0 3664 * ApplicationID::UninstallPinnedItem
michael@0 3665 * $R6 = find handle and the long path to the Start Menu Programs directory
michael@0 3666 * (e.g. $SMPROGRAMS)
michael@0 3667 * $R7 = path to the $QUICKLAUNCH\User Pinned directory and the return value
michael@0 3668 * from ReadINIStr for the relative path to the applications directory
michael@0 3669 * under the Start Menu Programs directory and the long path to this
michael@0 3670 * directory
michael@0 3671 * $R8 = return filename from FindFirst / FindNext and the return value from
michael@0 3672 * ReadINIStr for enumerating shortcuts
michael@0 3673 * $R9 = long path to the shortcuts log ini file
michael@0 3674 */
michael@0 3675 !macro DeleteShortcuts
michael@0 3676
michael@0 3677 !ifndef ${_MOZFUNC_UN}DeleteShortcuts
michael@0 3678 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 3679 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 3680 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
michael@0 3681 !undef _MOZFUNC_UN
michael@0 3682 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 3683 !undef _MOZFUNC_UN_TMP
michael@0 3684
michael@0 3685 !verbose push
michael@0 3686 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3687 !define ${_MOZFUNC_UN}DeleteShortcuts "!insertmacro ${_MOZFUNC_UN}DeleteShortcutsCall"
michael@0 3688
michael@0 3689 Function ${_MOZFUNC_UN}DeleteShortcuts
michael@0 3690 Push $R9
michael@0 3691 Push $R8
michael@0 3692 Push $R7
michael@0 3693 Push $R6
michael@0 3694 Push $R5
michael@0 3695 Push $R4
michael@0 3696
michael@0 3697 ${If} ${AtLeastWin7}
michael@0 3698 ; Since shortcuts that are pinned can later be removed without removing
michael@0 3699 ; the pinned shortcut unpin the pinned shortcuts for the application's
michael@0 3700 ; main exe using the pinned shortcuts themselves.
michael@0 3701 StrCpy $R7 "$QUICKLAUNCH\User Pinned"
michael@0 3702
michael@0 3703 ${If} ${FileExists} "$R7\TaskBar"
michael@0 3704 ; Delete TaskBar pinned shortcuts for the application's main exe
michael@0 3705 FindFirst $R6 $R8 "$R7\TaskBar\*.lnk"
michael@0 3706 ${Do}
michael@0 3707 ${If} ${FileExists} "$R7\TaskBar\$R8"
michael@0 3708 ShellLink::GetShortCutTarget "$R7\TaskBar\$R8"
michael@0 3709 Pop $R5
michael@0 3710 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
michael@0 3711 ${If} "$R5" == "$INSTDIR\${FileMainEXE}"
michael@0 3712 ApplicationID::UninstallPinnedItem "$R7\TaskBar\$R8"
michael@0 3713 Pop $R5
michael@0 3714 ${EndIf}
michael@0 3715 ${EndIf}
michael@0 3716 ClearErrors
michael@0 3717 FindNext $R6 $R8
michael@0 3718 ${If} ${Errors}
michael@0 3719 ${ExitDo}
michael@0 3720 ${EndIf}
michael@0 3721 ${Loop}
michael@0 3722 FindClose $R6
michael@0 3723 ${EndIf}
michael@0 3724
michael@0 3725 ${If} ${FileExists} "$R7\StartMenu"
michael@0 3726 ; Delete Start Menu pinned shortcuts for the application's main exe
michael@0 3727 FindFirst $R6 $R8 "$R7\StartMenu\*.lnk"
michael@0 3728 ${Do}
michael@0 3729 ${If} ${FileExists} "$R7\StartMenu\$R8"
michael@0 3730 ShellLink::GetShortCutTarget "$R7\StartMenu\$R8"
michael@0 3731 Pop $R5
michael@0 3732 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
michael@0 3733 ${If} "$R5" == "$INSTDIR\${FileMainEXE}"
michael@0 3734 ApplicationID::UninstallPinnedItem "$R7\StartMenu\$R8"
michael@0 3735 Pop $R5
michael@0 3736 ${EndIf}
michael@0 3737 ${EndIf}
michael@0 3738 ClearErrors
michael@0 3739 FindNext $R6 $R8
michael@0 3740 ${If} ${Errors}
michael@0 3741 ${ExitDo}
michael@0 3742 ${EndIf}
michael@0 3743 ${Loop}
michael@0 3744 FindClose $R6
michael@0 3745 ${EndIf}
michael@0 3746 ${EndIf}
michael@0 3747
michael@0 3748 ; Don't call ApplicationID::UninstallPinnedItem since pinned items for
michael@0 3749 ; this application were removed above and removing them below will remove
michael@0 3750 ; the association of side by side installations.
michael@0 3751 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR\uninstall\${SHORTCUTS_LOG}" $R9
michael@0 3752 ${If} ${FileExists} "$R9"
michael@0 3753 ; Delete Start Menu shortcuts for this application
michael@0 3754 StrCpy $R4 -1
michael@0 3755 ${Do}
michael@0 3756 IntOp $R4 $R4 + 1 ; Increment the counter
michael@0 3757 ClearErrors
michael@0 3758 ReadINIStr $R8 "$R9" "STARTMENU" "Shortcut$R4"
michael@0 3759 ${If} ${Errors}
michael@0 3760 ${ExitDo}
michael@0 3761 ${EndIf}
michael@0 3762
michael@0 3763 ${If} ${FileExists} "$SMPROGRAMS\$R8"
michael@0 3764 ShellLink::GetShortCutTarget "$SMPROGRAMS\$R8"
michael@0 3765 Pop $R5
michael@0 3766 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
michael@0 3767 ${If} "$INSTDIR\${FileMainEXE}" == "$R5"
michael@0 3768 Delete "$SMPROGRAMS\$R8"
michael@0 3769 ${EndIf}
michael@0 3770 ${EndIf}
michael@0 3771 ${Loop}
michael@0 3772
michael@0 3773 ; Delete Quick Launch shortcuts for this application
michael@0 3774 StrCpy $R4 -1
michael@0 3775 ${Do}
michael@0 3776 IntOp $R4 $R4 + 1 ; Increment the counter
michael@0 3777 ClearErrors
michael@0 3778 ReadINIStr $R8 "$R9" "QUICKLAUNCH" "Shortcut$R4"
michael@0 3779 ${If} ${Errors}
michael@0 3780 ${ExitDo}
michael@0 3781 ${EndIf}
michael@0 3782
michael@0 3783 ${If} ${FileExists} "$QUICKLAUNCH\$R8"
michael@0 3784 ShellLink::GetShortCutTarget "$QUICKLAUNCH\$R8"
michael@0 3785 Pop $R5
michael@0 3786 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
michael@0 3787 ${If} "$INSTDIR\${FileMainEXE}" == "$R5"
michael@0 3788 Delete "$QUICKLAUNCH\$R8"
michael@0 3789 ${EndIf}
michael@0 3790 ${EndIf}
michael@0 3791 ${Loop}
michael@0 3792
michael@0 3793 ; Delete Desktop shortcuts for this application
michael@0 3794 StrCpy $R4 -1
michael@0 3795 ${Do}
michael@0 3796 IntOp $R4 $R4 + 1 ; Increment the counter
michael@0 3797 ClearErrors
michael@0 3798 ReadINIStr $R8 "$R9" "DESKTOP" "Shortcut$R4"
michael@0 3799 ${If} ${Errors}
michael@0 3800 ${ExitDo}
michael@0 3801 ${EndIf}
michael@0 3802
michael@0 3803 ${If} ${FileExists} "$DESKTOP\$R8"
michael@0 3804 ShellLink::GetShortCutTarget "$DESKTOP\$R8"
michael@0 3805 Pop $R5
michael@0 3806 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
michael@0 3807 ${If} "$INSTDIR\${FileMainEXE}" == "$R5"
michael@0 3808 Delete "$DESKTOP\$R8"
michael@0 3809 ${EndIf}
michael@0 3810 ${EndIf}
michael@0 3811 ${Loop}
michael@0 3812
michael@0 3813 ${${_MOZFUNC_UN}GetLongPath} "$SMPROGRAMS" $R6
michael@0 3814
michael@0 3815 ; Delete Start Menu Programs shortcuts for this application
michael@0 3816 ClearErrors
michael@0 3817 ReadINIStr $R7 "$R9" "SMPROGRAMS" "RelativePathToDir"
michael@0 3818 ${${_MOZFUNC_UN}GetLongPath} "$R6\$R7" $R7
michael@0 3819 ${Unless} "$R7" == ""
michael@0 3820 StrCpy $R4 -1
michael@0 3821 ${Do}
michael@0 3822 IntOp $R4 $R4 + 1 ; Increment the counter
michael@0 3823 ClearErrors
michael@0 3824 ReadINIStr $R8 "$R9" "SMPROGRAMS" "Shortcut$R4"
michael@0 3825 ${If} ${Errors}
michael@0 3826 ${ExitDo}
michael@0 3827 ${EndIf}
michael@0 3828
michael@0 3829 ${If} ${FileExists} "$R7\$R8"
michael@0 3830 ShellLink::GetShortCutTarget "$R7\$R8"
michael@0 3831 Pop $R5
michael@0 3832 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
michael@0 3833 ${If} "$INSTDIR\${FileMainEXE}" == "$R5"
michael@0 3834 Delete "$R7\$R8"
michael@0 3835 ${EndIf}
michael@0 3836 ${EndIf}
michael@0 3837 ${Loop}
michael@0 3838
michael@0 3839 ; Delete Start Menu Programs directories for this application
michael@0 3840 ${Do}
michael@0 3841 ClearErrors
michael@0 3842 ${If} "$R6" == "$R7"
michael@0 3843 ${ExitDo}
michael@0 3844 ${EndIf}
michael@0 3845 RmDir "$R7"
michael@0 3846 ${If} ${Errors}
michael@0 3847 ${ExitDo}
michael@0 3848 ${EndIf}
michael@0 3849 ${${_MOZFUNC_UN}GetParent} "$R7" $R7
michael@0 3850 ${Loop}
michael@0 3851 ${EndUnless}
michael@0 3852 ${EndIf}
michael@0 3853
michael@0 3854 ClearErrors
michael@0 3855
michael@0 3856 Pop $R4
michael@0 3857 Pop $R5
michael@0 3858 Pop $R6
michael@0 3859 Pop $R7
michael@0 3860 Pop $R8
michael@0 3861 Pop $R9
michael@0 3862 FunctionEnd
michael@0 3863
michael@0 3864 !verbose pop
michael@0 3865 !endif
michael@0 3866 !macroend
michael@0 3867
michael@0 3868 !macro DeleteShortcutsCall
michael@0 3869 !verbose push
michael@0 3870 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3871 Call DeleteShortcuts
michael@0 3872 !verbose pop
michael@0 3873 !macroend
michael@0 3874
michael@0 3875 !macro un.DeleteShortcutsCall
michael@0 3876 !verbose push
michael@0 3877 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3878 Call un.DeleteShortcuts
michael@0 3879 !verbose pop
michael@0 3880 !macroend
michael@0 3881
michael@0 3882 !macro un.DeleteShortcuts
michael@0 3883 !ifndef un.DeleteShortcuts
michael@0 3884 !verbose push
michael@0 3885 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3886 !undef _MOZFUNC_UN
michael@0 3887 !define _MOZFUNC_UN "un."
michael@0 3888
michael@0 3889 !insertmacro DeleteShortcuts
michael@0 3890
michael@0 3891 !undef _MOZFUNC_UN
michael@0 3892 !define _MOZFUNC_UN
michael@0 3893 !verbose pop
michael@0 3894 !endif
michael@0 3895 !macroend
michael@0 3896
michael@0 3897
michael@0 3898 ################################################################################
michael@0 3899 # Macros for parsing and updating the uninstall.log
michael@0 3900
michael@0 3901 /**
michael@0 3902 * Updates the uninstall.log with new files added by software update.
michael@0 3903 *
michael@0 3904 * When modifying this macro be aware that LineFind uses all registers except
michael@0 3905 * $R0-$R3 and TextCompareNoDetails uses all registers except $R0-$R9 so be
michael@0 3906 * cautious. Callers of this macro are not affected.
michael@0 3907 */
michael@0 3908 !macro UpdateUninstallLog
michael@0 3909
michael@0 3910 !ifndef UpdateUninstallLog
michael@0 3911 !insertmacro FileJoin
michael@0 3912 !insertmacro LineFind
michael@0 3913 !insertmacro TextCompareNoDetails
michael@0 3914 !insertmacro TrimNewLines
michael@0 3915
michael@0 3916 !verbose push
michael@0 3917 !verbose ${_MOZFUNC_VERBOSE}
michael@0 3918 !define UpdateUninstallLog "!insertmacro UpdateUninstallLogCall"
michael@0 3919
michael@0 3920 Function UpdateUninstallLog
michael@0 3921 Push $R3
michael@0 3922 Push $R2
michael@0 3923 Push $R1
michael@0 3924 Push $R0
michael@0 3925
michael@0 3926 ClearErrors
michael@0 3927
michael@0 3928 GetFullPathName $R3 "$INSTDIR\uninstall"
michael@0 3929 ${If} ${FileExists} "$R3\uninstall.update"
michael@0 3930 ${LineFind} "$R3\uninstall.update" "" "1:-1" "CleanupUpdateLog"
michael@0 3931
michael@0 3932 GetTempFileName $R2 "$R3"
michael@0 3933 FileOpen $R1 "$R2" w
michael@0 3934 ${TextCompareNoDetails} "$R3\uninstall.update" "$R3\uninstall.log" "SlowDiff" "CreateUpdateDiff"
michael@0 3935 FileClose $R1
michael@0 3936
michael@0 3937 IfErrors +2 0
michael@0 3938 ${FileJoin} "$R3\uninstall.log" "$R2" "$R3\uninstall.log"
michael@0 3939
michael@0 3940 ${DeleteFile} "$R2"
michael@0 3941 ${EndIf}
michael@0 3942
michael@0 3943 ClearErrors
michael@0 3944
michael@0 3945 Pop $R0
michael@0 3946 Pop $R1
michael@0 3947 Pop $R2
michael@0 3948 Pop $R3
michael@0 3949 FunctionEnd
michael@0 3950
michael@0 3951 ; This callback MUST use labels vs. relative line numbers.
michael@0 3952 Function CleanupUpdateLog
michael@0 3953 StrCpy $R2 "$R9" 12
michael@0 3954 StrCmp "$R2" "EXECUTE ADD " +1 skip
michael@0 3955 StrCpy $R9 "$R9" "" 12
michael@0 3956
michael@0 3957 Push $R6
michael@0 3958 Push $R5
michael@0 3959 Push $R4
michael@0 3960 StrCpy $R4 "" ; Initialize to an empty string.
michael@0 3961 StrCpy $R6 -1 ; Set the counter to -1 so it will start at 0.
michael@0 3962
michael@0 3963 loop:
michael@0 3964 IntOp $R6 $R6 + 1 ; Increment the counter.
michael@0 3965 StrCpy $R5 $R9 1 $R6 ; Starting from the counter copy the next char.
michael@0 3966 StrCmp $R5 "" copy ; Are there no more chars?
michael@0 3967 StrCmp $R5 "/" +1 +2 ; Is the char a /?
michael@0 3968 StrCpy $R5 "\" ; Replace the char with a \.
michael@0 3969
michael@0 3970 StrCpy $R4 "$R4$R5"
michael@0 3971 GoTo loop
michael@0 3972
michael@0 3973 copy:
michael@0 3974 StrCpy $R9 "File: \$R4"
michael@0 3975 Pop $R6
michael@0 3976 Pop $R5
michael@0 3977 Pop $R4
michael@0 3978 GoTo end
michael@0 3979
michael@0 3980 skip:
michael@0 3981 StrCpy $0 "SkipWrite"
michael@0 3982
michael@0 3983 end:
michael@0 3984 Push $0
michael@0 3985 FunctionEnd
michael@0 3986
michael@0 3987 Function CreateUpdateDiff
michael@0 3988 ${TrimNewLines} "$9" $9
michael@0 3989 ${If} $9 != ""
michael@0 3990 FileWrite $R1 "$9$\r$\n"
michael@0 3991 ${EndIf}
michael@0 3992
michael@0 3993 Push 0
michael@0 3994 FunctionEnd
michael@0 3995
michael@0 3996 !verbose pop
michael@0 3997 !endif
michael@0 3998 !macroend
michael@0 3999
michael@0 4000 !macro UpdateUninstallLogCall
michael@0 4001 !verbose push
michael@0 4002 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4003 Call UpdateUninstallLog
michael@0 4004 !verbose pop
michael@0 4005 !macroend
michael@0 4006
michael@0 4007 /**
michael@0 4008 * Copies files from a source directory to a destination directory with logging
michael@0 4009 * to the uninstall.log. If any destination files are in use a reboot will be
michael@0 4010 * necessary to complete the installation and the reboot flag (see IfRebootFlag
michael@0 4011 * in the NSIS documentation).
michael@0 4012 *
michael@0 4013 * @param _PATH_TO_SOURCE
michael@0 4014 * Source path to copy the files from. This must not end with a \.
michael@0 4015 *
michael@0 4016 * @param _PATH_TO_DESTINATION
michael@0 4017 * Destination path to copy the files to. This must not end with a \.
michael@0 4018 *
michael@0 4019 * @param _PREFIX_ERROR_CREATEDIR
michael@0 4020 * Prefix for the directory creation error message. The directory path
michael@0 4021 * will be inserted below this string.
michael@0 4022 *
michael@0 4023 * @param _SUFFIX_ERROR_CREATEDIR
michael@0 4024 * Suffix for the directory creation error message. The directory path
michael@0 4025 * will be inserted above this string.
michael@0 4026 *
michael@0 4027 * $0 = destination file's parent directory used in the create_dir label
michael@0 4028 * $R0 = copied value from $R6 (e.g. _PATH_TO_SOURCE)
michael@0 4029 * $R1 = copied value from $R7 (e.g. _PATH_TO_DESTINATION)
michael@0 4030 * $R2 = string length of the path to source
michael@0 4031 * $R3 = relative path from the path to source
michael@0 4032 * $R4 = copied value from $R8 (e.g. _PREFIX_ERROR_CREATEDIR)
michael@0 4033 * $R5 = copied value from $R9 (e.g. _SUFFIX_ERROR_CREATEDIR)
michael@0 4034 * note: the LocateNoDetails macro uses these registers so we copy the values
michael@0 4035 * to other registers.
michael@0 4036 * $R6 = initially _PATH_TO_SOURCE and then set to "size" ($R6="" if directory,
michael@0 4037 * $R6="0" if file with /S=)"path\name" in callback
michael@0 4038 * $R7 = initially _PATH_TO_DESTINATION and then set to "name" in callback
michael@0 4039 * $R8 = initially _PREFIX_ERROR_CREATEDIR and then set to "path" in callback
michael@0 4040 * $R9 = initially _SUFFIX_ERROR_CREATEDIR and then set to "path\name" in
michael@0 4041 * callback
michael@0 4042 */
michael@0 4043 !macro CopyFilesFromDir
michael@0 4044
michael@0 4045 !ifndef CopyFilesFromDir
michael@0 4046 !insertmacro LocateNoDetails
michael@0 4047 !insertmacro OnEndCommon
michael@0 4048 !insertmacro WordReplace
michael@0 4049
michael@0 4050 !verbose push
michael@0 4051 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4052 !define CopyFilesFromDir "!insertmacro CopyFilesFromDirCall"
michael@0 4053
michael@0 4054 Function CopyFilesFromDir
michael@0 4055 Exch $R9
michael@0 4056 Exch 1
michael@0 4057 Exch $R8
michael@0 4058 Exch 2
michael@0 4059 Exch $R7
michael@0 4060 Exch 3
michael@0 4061 Exch $R6
michael@0 4062 Push $R5
michael@0 4063 Push $R4
michael@0 4064 Push $R3
michael@0 4065 Push $R2
michael@0 4066 Push $R1
michael@0 4067 Push $R0
michael@0 4068 Push $0
michael@0 4069
michael@0 4070 StrCpy $R0 "$R6"
michael@0 4071 StrCpy $R1 "$R7"
michael@0 4072 StrCpy $R4 "$R8"
michael@0 4073 StrCpy $R5 "$R9"
michael@0 4074
michael@0 4075 StrLen $R2 "$R0"
michael@0 4076
michael@0 4077 ${LocateNoDetails} "$R0" "/L=FD" "CopyFileCallback"
michael@0 4078
michael@0 4079 Pop $0
michael@0 4080 Pop $R0
michael@0 4081 Pop $R1
michael@0 4082 Pop $R2
michael@0 4083 Pop $R3
michael@0 4084 Pop $R4
michael@0 4085 Pop $R5
michael@0 4086 Exch $R6
michael@0 4087 Exch 3
michael@0 4088 Exch $R7
michael@0 4089 Exch 2
michael@0 4090 Exch $R8
michael@0 4091 Exch 1
michael@0 4092 Exch $R9
michael@0 4093 FunctionEnd
michael@0 4094
michael@0 4095 Function CopyFileCallback
michael@0 4096 StrCpy $R3 $R8 "" $R2 ; $R3 always begins with a \.
michael@0 4097
michael@0 4098 retry:
michael@0 4099 ClearErrors
michael@0 4100 StrCmp $R6 "" +1 copy_file
michael@0 4101 IfFileExists "$R1$R3\$R7" end +1
michael@0 4102 StrCpy $0 "$R1$R3\$R7"
michael@0 4103
michael@0 4104 create_dir:
michael@0 4105 ClearErrors
michael@0 4106 CreateDirectory "$0"
michael@0 4107 IfFileExists "$0" +1 err_create_dir ; protect against looping.
michael@0 4108 ${LogMsg} "Created Directory: $0"
michael@0 4109 StrCmp $R6 "" end copy_file
michael@0 4110
michael@0 4111 err_create_dir:
michael@0 4112 ${LogMsg} "** ERROR Creating Directory: $0 **"
michael@0 4113 MessageBox MB_RETRYCANCEL|MB_ICONQUESTION "$R4$\r$\n$\r$\n$0$\r$\n$\r$\n$R5" IDRETRY retry
michael@0 4114 ${OnEndCommon}
michael@0 4115 Quit
michael@0 4116
michael@0 4117 copy_file:
michael@0 4118 StrCpy $0 "$R1$R3"
michael@0 4119 StrCmp "$0" "$INSTDIR" +2 +1
michael@0 4120 IfFileExists "$0" +1 create_dir
michael@0 4121
michael@0 4122 ClearErrors
michael@0 4123 ${DeleteFile} "$R1$R3\$R7"
michael@0 4124 IfErrors +1 dest_clear
michael@0 4125 ClearErrors
michael@0 4126 Rename "$R1$R3\$R7" "$R1$R3\$R7.moz-delete"
michael@0 4127 IfErrors +1 reboot_delete
michael@0 4128
michael@0 4129 ; file will replace destination file on reboot
michael@0 4130 Rename "$R9" "$R9.moz-upgrade"
michael@0 4131 CopyFiles /SILENT "$R9.moz-upgrade" "$R1$R3"
michael@0 4132 Rename /REBOOTOK "$R1$R3\$R7.moz-upgrade" "$R1$R3\$R7"
michael@0 4133 ${LogMsg} "Copied File: $R1$R3\$R7.moz-upgrade"
michael@0 4134 ${LogMsg} "Delayed Install File (Reboot Required): $R1$R3\$R7"
michael@0 4135 GoTo log_uninstall
michael@0 4136
michael@0 4137 ; file will be deleted on reboot
michael@0 4138 reboot_delete:
michael@0 4139 CopyFiles /SILENT $R9 "$R1$R3"
michael@0 4140 Delete /REBOOTOK "$R1$R3\$R7.moz-delete"
michael@0 4141 ${LogMsg} "Installed File: $R1$R3\$R7"
michael@0 4142 ${LogMsg} "Delayed Delete File (Reboot Required): $R1$R3\$R7.moz-delete"
michael@0 4143 GoTo log_uninstall
michael@0 4144
michael@0 4145 ; destination file doesn't exist - coast is clear
michael@0 4146 dest_clear:
michael@0 4147 CopyFiles /SILENT $R9 "$R1$R3"
michael@0 4148 ${LogMsg} "Installed File: $R1$R3\$R7"
michael@0 4149
michael@0 4150 log_uninstall:
michael@0 4151 ; If the file is installed into the installation directory remove the
michael@0 4152 ; installation directory's path from the file path when writing to the
michael@0 4153 ; uninstall.log so it will be a relative path. This allows the same
michael@0 4154 ; helper.exe to be used with zip builds if we supply an uninstall.log.
michael@0 4155 ${WordReplace} "$R1$R3\$R7" "$INSTDIR" "" "+" $R3
michael@0 4156 ${LogUninstall} "File: $R3"
michael@0 4157
michael@0 4158 end:
michael@0 4159 Push 0
michael@0 4160 FunctionEnd
michael@0 4161
michael@0 4162 !verbose pop
michael@0 4163 !endif
michael@0 4164 !macroend
michael@0 4165
michael@0 4166 !macro CopyFilesFromDirCall _PATH_TO_SOURCE _PATH_TO_DESTINATION \
michael@0 4167 _PREFIX_ERROR_CREATEDIR _SUFFIX_ERROR_CREATEDIR
michael@0 4168 !verbose push
michael@0 4169 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4170 Push "${_PATH_TO_SOURCE}"
michael@0 4171 Push "${_PATH_TO_DESTINATION}"
michael@0 4172 Push "${_PREFIX_ERROR_CREATEDIR}"
michael@0 4173 Push "${_SUFFIX_ERROR_CREATEDIR}"
michael@0 4174 Call CopyFilesFromDir
michael@0 4175 !verbose pop
michael@0 4176 !macroend
michael@0 4177
michael@0 4178 /**
michael@0 4179 * Parses the uninstall.log on install to first remove a previous installation's
michael@0 4180 * files and then their directories if empty prior to installing.
michael@0 4181 *
michael@0 4182 * When modifying this macro be aware that LineFind uses all registers except
michael@0 4183 * $R0-$R3 so be cautious. Callers of this macro are not affected.
michael@0 4184 */
michael@0 4185 !macro OnInstallUninstall
michael@0 4186
michael@0 4187 !ifndef OnInstallUninstall
michael@0 4188 !insertmacro GetParent
michael@0 4189 !insertmacro LineFind
michael@0 4190 !insertmacro TrimNewLines
michael@0 4191
michael@0 4192 !verbose push
michael@0 4193 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4194 !define OnInstallUninstall "!insertmacro OnInstallUninstallCall"
michael@0 4195
michael@0 4196 Function OnInstallUninstall
michael@0 4197 Push $R9
michael@0 4198 Push $R8
michael@0 4199 Push $R7
michael@0 4200 Push $R6
michael@0 4201 Push $R5
michael@0 4202 Push $R4
michael@0 4203 Push $R3
michael@0 4204 Push $R2
michael@0 4205 Push $R1
michael@0 4206 Push $R0
michael@0 4207 Push $TmpVal
michael@0 4208
michael@0 4209 IfFileExists "$INSTDIR\uninstall\uninstall.log" +1 end
michael@0 4210
michael@0 4211 ${LogHeader} "Removing Previous Installation"
michael@0 4212
michael@0 4213 ; Copy the uninstall log file to a temporary file
michael@0 4214 GetTempFileName $TmpVal
michael@0 4215 CopyFiles /SILENT /FILESONLY "$INSTDIR\uninstall\uninstall.log" "$TmpVal"
michael@0 4216
michael@0 4217 ; Delete files
michael@0 4218 ${LineFind} "$TmpVal" "/NUL" "1:-1" "RemoveFilesCallback"
michael@0 4219
michael@0 4220 ; Remove empty directories
michael@0 4221 ${LineFind} "$TmpVal" "/NUL" "1:-1" "RemoveDirsCallback"
michael@0 4222
michael@0 4223 ; Delete the temporary uninstall log file
michael@0 4224 Delete /REBOOTOK "$TmpVal"
michael@0 4225
michael@0 4226 ; Delete the uninstall log file
michael@0 4227 Delete "$INSTDIR\uninstall\uninstall.log"
michael@0 4228
michael@0 4229 end:
michael@0 4230 ClearErrors
michael@0 4231
michael@0 4232 Pop $TmpVal
michael@0 4233 Pop $R0
michael@0 4234 Pop $R1
michael@0 4235 Pop $R2
michael@0 4236 Pop $R3
michael@0 4237 Pop $R4
michael@0 4238 Pop $R5
michael@0 4239 Pop $R6
michael@0 4240 Pop $R7
michael@0 4241 Pop $R8
michael@0 4242 Pop $R9
michael@0 4243 FunctionEnd
michael@0 4244
michael@0 4245 Function RemoveFilesCallback
michael@0 4246 ${TrimNewLines} "$R9" $R9
michael@0 4247 StrCpy $R1 "$R9" 5 ; Copy the first five chars
michael@0 4248
michael@0 4249 StrCmp "$R1" "File:" +1 end
michael@0 4250 StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
michael@0 4251 StrCpy $R0 "$R9" 1 ; Copy the first char
michael@0 4252
michael@0 4253 StrCmp "$R0" "\" +1 end ; If this isn't a relative path goto end
michael@0 4254 StrCmp "$R9" "\install.log" end +1 ; Skip the install.log
michael@0 4255 StrCmp "$R9" "\MapiProxy_InUse.dll" end +1 ; Skip the MapiProxy_InUse.dll
michael@0 4256 StrCmp "$R9" "\mozMapi32_InUse.dll" end +1 ; Skip the mozMapi32_InUse.dll
michael@0 4257
michael@0 4258 StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
michael@0 4259 IfFileExists "$R1" +1 end
michael@0 4260
michael@0 4261 ClearErrors
michael@0 4262 Delete "$R1"
michael@0 4263 ${Unless} ${Errors}
michael@0 4264 ${LogMsg} "Deleted File: $R1"
michael@0 4265 Goto end
michael@0 4266 ${EndUnless}
michael@0 4267
michael@0 4268 ClearErrors
michael@0 4269 Rename "$R1" "$R1.moz-delete"
michael@0 4270 ${Unless} ${Errors}
michael@0 4271 Delete /REBOOTOK "$R1.moz-delete"
michael@0 4272 ${LogMsg} "Delayed Delete File (Reboot Required): $R1.moz-delete"
michael@0 4273 GoTo end
michael@0 4274 ${EndUnless}
michael@0 4275
michael@0 4276 ; Check if the file exists in the source. If it does the new file will
michael@0 4277 ; replace the existing file when the system is rebooted. If it doesn't
michael@0 4278 ; the file will be deleted when the system is rebooted.
michael@0 4279 ${Unless} ${FileExists} "$EXEDIR\core$R9"
michael@0 4280 ${AndUnless} ${FileExists} "$EXEDIR\optional$R9"
michael@0 4281 Delete /REBOOTOK "$R1"
michael@0 4282 ${LogMsg} "Delayed Delete File (Reboot Required): $R1"
michael@0 4283 ${EndUnless}
michael@0 4284
michael@0 4285 end:
michael@0 4286 ClearErrors
michael@0 4287
michael@0 4288 Push 0
michael@0 4289 FunctionEnd
michael@0 4290
michael@0 4291 ; Using locate will leave file handles open to some of the directories
michael@0 4292 ; which will prevent the deletion of these directories. This parses the
michael@0 4293 ; uninstall.log and uses the file entries to find / remove empty
michael@0 4294 ; directories.
michael@0 4295 Function RemoveDirsCallback
michael@0 4296 ${TrimNewLines} "$R9" $R9
michael@0 4297 StrCpy $R0 "$R9" 5 ; Copy the first five chars
michael@0 4298 StrCmp "$R0" "File:" +1 end
michael@0 4299
michael@0 4300 StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
michael@0 4301 StrCpy $R0 "$R9" 1 ; Copy the first char
michael@0 4302
michael@0 4303 StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
michael@0 4304 StrCmp "$R0" "\" loop end ; If this isn't a relative path goto end
michael@0 4305
michael@0 4306 loop:
michael@0 4307 ${GetParent} "$R1" $R1 ; Get the parent directory for the path
michael@0 4308 StrCmp "$R1" "$INSTDIR" end +1 ; If the directory is the install dir goto end
michael@0 4309
michael@0 4310 IfFileExists "$R1" +1 loop ; Only try to remove the dir if it exists
michael@0 4311 ClearErrors
michael@0 4312 RmDir "$R1" ; Remove the dir
michael@0 4313 IfErrors end +1 ; If we fail there is no use trying to remove its parent dir
michael@0 4314 ${LogMsg} "Deleted Directory: $R1"
michael@0 4315 GoTo loop
michael@0 4316
michael@0 4317 end:
michael@0 4318 ClearErrors
michael@0 4319
michael@0 4320 Push 0
michael@0 4321 FunctionEnd
michael@0 4322
michael@0 4323 !verbose pop
michael@0 4324 !endif
michael@0 4325 !macroend
michael@0 4326
michael@0 4327 !macro OnInstallUninstallCall
michael@0 4328 !verbose push
michael@0 4329 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4330 Call OnInstallUninstall
michael@0 4331 !verbose pop
michael@0 4332 !macroend
michael@0 4333
michael@0 4334 /**
michael@0 4335 * Parses the uninstall.log for the stub installer on install to first remove a
michael@0 4336 * previous installation's files prior to installing.
michael@0 4337 *
michael@0 4338 * When modifying this macro be aware that LineFind uses all registers except
michael@0 4339 * $R0-$R3 so be cautious. Callers of this macro are not affected.
michael@0 4340 *
michael@0 4341 * @param _PROGRESSBAR
michael@0 4342 * The progress bar to update using PBM_STEPIT. Can also be "false" if
michael@0 4343 * updating a progressbar isn't needed.
michael@0 4344 * @param _INSTALL_STEP_COUNTER
michael@0 4345 * The install step counter to increment. The variable specified in
michael@0 4346 * this parameter is also updated. Can also be "false" if a counter
michael@0 4347 * isn't needed.
michael@0 4348 *
michael@0 4349 * $R2 = _INSTALL_STEP_COUNTER
michael@0 4350 * $R3 = _PROGRESSBAR
michael@0 4351 */
michael@0 4352 !macro OnStubInstallUninstall
michael@0 4353
michael@0 4354 !ifndef OnStubInstallUninstall
michael@0 4355 !insertmacro GetParent
michael@0 4356 !insertmacro LineFind
michael@0 4357 !insertmacro TrimNewLines
michael@0 4358
michael@0 4359 !verbose push
michael@0 4360 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4361 !define OnStubInstallUninstall "!insertmacro OnStubInstallUninstallCall"
michael@0 4362
michael@0 4363 Function OnStubInstallUninstall
michael@0 4364 Exch $R2
michael@0 4365 Exch 1
michael@0 4366 Exch $R3
michael@0 4367 Push $R9
michael@0 4368 Push $R8
michael@0 4369 Push $R7
michael@0 4370 Push $R6
michael@0 4371 Push $R5
michael@0 4372 Push $R4
michael@0 4373 Push $R1
michael@0 4374 Push $R0
michael@0 4375 Push $TmpVal
michael@0 4376
michael@0 4377 IfFileExists "$INSTDIR\uninstall\uninstall.log" +1 end
michael@0 4378
michael@0 4379 ; Copy the uninstall log file to a temporary file
michael@0 4380 GetTempFileName $TmpVal
michael@0 4381 CopyFiles /SILENT /FILESONLY "$INSTDIR\uninstall\uninstall.log" "$TmpVal"
michael@0 4382
michael@0 4383 CreateDirectory "$INSTDIR\${TO_BE_DELETED}"
michael@0 4384
michael@0 4385 ; Delete files
michael@0 4386 ${LineFind} "$TmpVal" "/NUL" "1:-1" "StubRemoveFilesCallback"
michael@0 4387
michael@0 4388 ; Delete the temporary uninstall log file
michael@0 4389 Delete /REBOOTOK "$TmpVal"
michael@0 4390
michael@0 4391 RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
michael@0 4392
michael@0 4393 end:
michael@0 4394 ClearErrors
michael@0 4395
michael@0 4396 Pop $TmpVal
michael@0 4397 Pop $R0
michael@0 4398 Pop $R1
michael@0 4399 Pop $R4
michael@0 4400 Pop $R5
michael@0 4401 Pop $R6
michael@0 4402 Pop $R7
michael@0 4403 Pop $R8
michael@0 4404 Pop $R9
michael@0 4405 Exch $R3
michael@0 4406 Exch 1
michael@0 4407 Exch $R2
michael@0 4408 FunctionEnd
michael@0 4409
michael@0 4410 Function StubRemoveFilesCallback
michael@0 4411 ${TrimNewLines} "$R9" $R9
michael@0 4412 StrCpy $R1 "$R9" 5 ; Copy the first five chars
michael@0 4413
michael@0 4414 StrCmp "$R1" "File:" +1 end
michael@0 4415 StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
michael@0 4416 StrCpy $R0 "$R9" 1 ; Copy the first char
michael@0 4417
michael@0 4418 StrCmp "$R0" "\" +1 end ; If this isn't a relative path goto end
michael@0 4419 StrCmp "$R9" "\MapiProxy_InUse.dll" end +1 ; Skip the MapiProxy_InUse.dll
michael@0 4420 StrCmp "$R9" "\mozMapi32_InUse.dll" end +1 ; Skip the mozMapi32_InUse.dll
michael@0 4421
michael@0 4422 StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
michael@0 4423 IfFileExists "$R1" +1 end
michael@0 4424
michael@0 4425 ${Unless} "$R2" == "false"
michael@0 4426 IntOp $R2 $R2 + 2
michael@0 4427 ${EndIf}
michael@0 4428 ${Unless} "$R3" == "false"
michael@0 4429 SendMessage $R3 ${PBM_STEPIT} 0 0
michael@0 4430 SendMessage $R3 ${PBM_STEPIT} 0 0
michael@0 4431 ${EndIf}
michael@0 4432
michael@0 4433 ClearErrors
michael@0 4434 Delete "$R1"
michael@0 4435 ${Unless} ${Errors}
michael@0 4436 Goto end
michael@0 4437 ${EndUnless}
michael@0 4438
michael@0 4439 GetTempFileName $R0 "$INSTDIR\${TO_BE_DELETED}"
michael@0 4440 Delete "$R0"
michael@0 4441 ClearErrors
michael@0 4442 Rename "$R1" "$R0"
michael@0 4443 ${If} ${Errors}
michael@0 4444 Delete /REBOOTOK "$R1"
michael@0 4445 ${EndUnless}
michael@0 4446
michael@0 4447 end:
michael@0 4448 ClearErrors
michael@0 4449
michael@0 4450 Push 0
michael@0 4451 FunctionEnd
michael@0 4452
michael@0 4453 !verbose pop
michael@0 4454 !endif
michael@0 4455 !macroend
michael@0 4456
michael@0 4457 !macro OnStubInstallUninstallCall _PROGRESSBAR _INSTALL_STEP_COUNTER
michael@0 4458 !verbose push
michael@0 4459 Push "${_PROGRESSBAR}"
michael@0 4460 Push "${_INSTALL_STEP_COUNTER}"
michael@0 4461 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4462 Call OnStubInstallUninstall
michael@0 4463 Pop ${_INSTALL_STEP_COUNTER}
michael@0 4464 !verbose pop
michael@0 4465 !macroend
michael@0 4466
michael@0 4467 /**
michael@0 4468 * Parses the uninstall.log to unregister dll's, remove files, and remove
michael@0 4469 * empty directories for this installation.
michael@0 4470 *
michael@0 4471 * When modifying this macro be aware that LineFind uses all registers except
michael@0 4472 * $R0-$R3 so be cautious. Callers of this macro are not affected.
michael@0 4473 */
michael@0 4474 !macro un.ParseUninstallLog
michael@0 4475
michael@0 4476 !ifndef un.ParseUninstallLog
michael@0 4477 !insertmacro un.GetParent
michael@0 4478 !insertmacro un.LineFind
michael@0 4479 !insertmacro un.TrimNewLines
michael@0 4480
michael@0 4481 !verbose push
michael@0 4482 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4483 !define un.ParseUninstallLog "!insertmacro un.ParseUninstallLogCall"
michael@0 4484
michael@0 4485 Function un.ParseUninstallLog
michael@0 4486 Push $R9
michael@0 4487 Push $R8
michael@0 4488 Push $R7
michael@0 4489 Push $R6
michael@0 4490 Push $R5
michael@0 4491 Push $R4
michael@0 4492 Push $R3
michael@0 4493 Push $R2
michael@0 4494 Push $R1
michael@0 4495 Push $R0
michael@0 4496 Push $TmpVal
michael@0 4497
michael@0 4498 IfFileExists "$INSTDIR\uninstall\uninstall.log" +1 end
michael@0 4499
michael@0 4500 ; Copy the uninstall log file to a temporary file
michael@0 4501 GetTempFileName $TmpVal
michael@0 4502 CopyFiles /SILENT /FILESONLY "$INSTDIR\uninstall\uninstall.log" "$TmpVal"
michael@0 4503
michael@0 4504 ; Unregister DLL's
michael@0 4505 ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.UnRegDLLsCallback"
michael@0 4506
michael@0 4507 ; Delete files
michael@0 4508 ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.RemoveFilesCallback"
michael@0 4509
michael@0 4510 ; Remove empty directories
michael@0 4511 ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.RemoveDirsCallback"
michael@0 4512
michael@0 4513 ; Delete the temporary uninstall log file
michael@0 4514 Delete /REBOOTOK "$TmpVal"
michael@0 4515
michael@0 4516 end:
michael@0 4517
michael@0 4518 Pop $TmpVal
michael@0 4519 Pop $R0
michael@0 4520 Pop $R1
michael@0 4521 Pop $R2
michael@0 4522 Pop $R3
michael@0 4523 Pop $R4
michael@0 4524 Pop $R5
michael@0 4525 Pop $R6
michael@0 4526 Pop $R7
michael@0 4527 Pop $R8
michael@0 4528 Pop $R9
michael@0 4529 FunctionEnd
michael@0 4530
michael@0 4531 Function un.RemoveFilesCallback
michael@0 4532 ${un.TrimNewLines} "$R9" $R9
michael@0 4533 StrCpy $R1 "$R9" 5
michael@0 4534
michael@0 4535 StrCmp "$R1" "File:" +1 end
michael@0 4536 StrCpy $R9 "$R9" "" 6
michael@0 4537 StrCpy $R0 "$R9" 1
michael@0 4538
michael@0 4539 StrCpy $R1 "$INSTDIR$R9"
michael@0 4540 StrCmp "$R0" "\" +2 +1
michael@0 4541 StrCpy $R1 "$R9"
michael@0 4542
michael@0 4543 IfFileExists "$R1" +1 end
michael@0 4544 Delete "$R1"
michael@0 4545 IfErrors +1 end
michael@0 4546 ClearErrors
michael@0 4547 Rename "$R1" "$R1.moz-delete"
michael@0 4548 IfErrors +1 +3
michael@0 4549 Delete /REBOOTOK "$R1"
michael@0 4550 GoTo end
michael@0 4551
michael@0 4552 Delete /REBOOTOK "$R1.moz-delete"
michael@0 4553
michael@0 4554 end:
michael@0 4555 ClearErrors
michael@0 4556
michael@0 4557 Push 0
michael@0 4558 FunctionEnd
michael@0 4559
michael@0 4560 Function un.UnRegDLLsCallback
michael@0 4561 ${un.TrimNewLines} "$R9" $R9
michael@0 4562 StrCpy $R1 "$R9" 7
michael@0 4563
michael@0 4564 StrCmp $R1 "DLLReg:" +1 end
michael@0 4565 StrCpy $R9 "$R9" "" 8
michael@0 4566 StrCpy $R0 "$R9" 1
michael@0 4567
michael@0 4568 StrCpy $R1 "$INSTDIR$R9"
michael@0 4569 StrCmp $R0 "\" +2 +1
michael@0 4570 StrCpy $R1 "$R9"
michael@0 4571
michael@0 4572 ${UnregisterDLL} $R1
michael@0 4573
michael@0 4574 end:
michael@0 4575 ClearErrors
michael@0 4576
michael@0 4577 Push 0
michael@0 4578 FunctionEnd
michael@0 4579
michael@0 4580 ; Using locate will leave file handles open to some of the directories
michael@0 4581 ; which will prevent the deletion of these directories. This parses the
michael@0 4582 ; uninstall.log and uses the file entries to find / remove empty
michael@0 4583 ; directories.
michael@0 4584 Function un.RemoveDirsCallback
michael@0 4585 ${un.TrimNewLines} "$R9" $R9
michael@0 4586 StrCpy $R0 "$R9" 5 ; Copy the first five chars
michael@0 4587 StrCmp "$R0" "File:" +1 end
michael@0 4588
michael@0 4589 StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
michael@0 4590 StrCpy $R0 "$R9" 1 ; Copy the first char
michael@0 4591
michael@0 4592 StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
michael@0 4593 StrCmp "$R0" "\" loop ; If this is a relative path goto the loop
michael@0 4594 StrCpy $R1 "$R9" ; Already a full path so copy the string
michael@0 4595
michael@0 4596 loop:
michael@0 4597 ${un.GetParent} "$R1" $R1 ; Get the parent directory for the path
michael@0 4598 StrCmp "$R1" "$INSTDIR" end ; If the directory is the install dir goto end
michael@0 4599
michael@0 4600 ; We only try to remove empty directories but the Desktop, StartMenu, and
michael@0 4601 ; QuickLaunch directories can be empty so guard against removing them.
michael@0 4602 SetShellVarContext all ; Set context to all users
michael@0 4603 StrCmp "$R1" "$DESKTOP" end ; All users desktop
michael@0 4604 StrCmp "$R1" "$STARTMENU" end ; All users start menu
michael@0 4605
michael@0 4606 SetShellVarContext current ; Set context to all users
michael@0 4607 StrCmp "$R1" "$DESKTOP" end ; Current user desktop
michael@0 4608 StrCmp "$R1" "$STARTMENU" end ; Current user start menu
michael@0 4609 StrCmp "$R1" "$QUICKLAUNCH" end ; Current user quick launch
michael@0 4610
michael@0 4611 IfFileExists "$R1" +1 +3 ; Only try to remove the dir if it exists
michael@0 4612 ClearErrors
michael@0 4613 RmDir "$R1" ; Remove the dir
michael@0 4614 IfErrors end ; If we fail there is no use trying to remove its parent dir
michael@0 4615
michael@0 4616 StrCmp "$R0" "\" loop end ; Only loop when the path is relative to the install dir
michael@0 4617
michael@0 4618 end:
michael@0 4619 ClearErrors
michael@0 4620
michael@0 4621 Push 0
michael@0 4622 FunctionEnd
michael@0 4623
michael@0 4624 !verbose pop
michael@0 4625 !endif
michael@0 4626 !macroend
michael@0 4627
michael@0 4628 !macro un.ParseUninstallLogCall
michael@0 4629 !verbose push
michael@0 4630 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4631 Call un.ParseUninstallLog
michael@0 4632 !verbose pop
michael@0 4633 !macroend
michael@0 4634
michael@0 4635 /**
michael@0 4636 * Finds a valid Start Menu shortcut in the uninstall log and returns the
michael@0 4637 * relative path from the Start Menu's Programs directory to the shortcut's
michael@0 4638 * directory.
michael@0 4639 *
michael@0 4640 * When modifying this macro be aware that LineFind uses all registers except
michael@0 4641 * $R0-$R3 so be cautious. Callers of this macro are not affected.
michael@0 4642 *
michael@0 4643 * @return _REL_PATH_TO_DIR
michael@0 4644 * The relative path to the application's Start Menu directory from the
michael@0 4645 * Start Menu's Programs directory.
michael@0 4646 */
michael@0 4647 !macro FindSMProgramsDir
michael@0 4648
michael@0 4649 !ifndef FindSMProgramsDir
michael@0 4650 !insertmacro GetParent
michael@0 4651 !insertmacro LineFind
michael@0 4652 !insertmacro TrimNewLines
michael@0 4653
michael@0 4654 !verbose push
michael@0 4655 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4656 !define FindSMProgramsDir "!insertmacro FindSMProgramsDirCall"
michael@0 4657
michael@0 4658 Function FindSMProgramsDir
michael@0 4659 Exch $R3
michael@0 4660 Push $R2
michael@0 4661 Push $R1
michael@0 4662 Push $R0
michael@0 4663
michael@0 4664 StrCpy $R3 ""
michael@0 4665 ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.log"
michael@0 4666 ${LineFind} "$INSTDIR\uninstall\uninstall.log" "/NUL" "1:-1" "FindSMProgramsDirRelPath"
michael@0 4667 ${EndIf}
michael@0 4668 ClearErrors
michael@0 4669
michael@0 4670 Pop $R0
michael@0 4671 Pop $R1
michael@0 4672 Pop $R2
michael@0 4673 Exch $R3
michael@0 4674 FunctionEnd
michael@0 4675
michael@0 4676 ; This callback MUST use labels vs. relative line numbers.
michael@0 4677 Function FindSMProgramsDirRelPath
michael@0 4678 Push 0
michael@0 4679 ${TrimNewLines} "$R9" $R9
michael@0 4680 StrCpy $R4 "$R9" 5
michael@0 4681
michael@0 4682 StrCmp "$R4" "File:" +1 end_FindSMProgramsDirRelPath
michael@0 4683 StrCpy $R9 "$R9" "" 6
michael@0 4684 StrCpy $R4 "$R9" 1
michael@0 4685
michael@0 4686 StrCmp "$R4" "\" end_FindSMProgramsDirRelPath +1
michael@0 4687
michael@0 4688 SetShellVarContext all
michael@0 4689 ${GetLongPath} "$SMPROGRAMS" $R4
michael@0 4690 StrLen $R2 "$R4"
michael@0 4691 StrCpy $R1 "$R9" $R2
michael@0 4692 StrCmp "$R1" "$R4" +1 end_FindSMProgramsDirRelPath
michael@0 4693 IfFileExists "$R9" +1 end_FindSMProgramsDirRelPath
michael@0 4694 ShellLink::GetShortCutTarget "$R9"
michael@0 4695 Pop $R0
michael@0 4696 StrCmp "$INSTDIR\${FileMainEXE}" "$R0" +1 end_FindSMProgramsDirRelPath
michael@0 4697 ${GetParent} "$R9" $R3
michael@0 4698 IntOp $R2 $R2 + 1
michael@0 4699 StrCpy $R3 "$R3" "" $R2
michael@0 4700
michael@0 4701 Pop $R4 ; Remove the previously pushed 0 from the stack and
michael@0 4702 push "StopLineFind" ; push StopLineFind to stop finding more lines.
michael@0 4703
michael@0 4704 end_FindSMProgramsDirRelPath:
michael@0 4705 ClearErrors
michael@0 4706
michael@0 4707 FunctionEnd
michael@0 4708
michael@0 4709 !verbose pop
michael@0 4710 !endif
michael@0 4711 !macroend
michael@0 4712
michael@0 4713 !macro FindSMProgramsDirCall _REL_PATH_TO_DIR
michael@0 4714 !verbose push
michael@0 4715 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4716 Call FindSMProgramsDir
michael@0 4717 Pop ${_REL_PATH_TO_DIR}
michael@0 4718 !verbose pop
michael@0 4719 !macroend
michael@0 4720
michael@0 4721
michael@0 4722 ################################################################################
michael@0 4723 # Macros for custom branding
michael@0 4724
michael@0 4725 /**
michael@0 4726 * Sets BrandFullName and / or BrandShortName to values provided in the specified
michael@0 4727 * ini file and defaults to BrandShortName and BrandFullName as defined in
michael@0 4728 * branding.nsi when the associated ini file entry is not specified.
michael@0 4729 *
michael@0 4730 * ini file format:
michael@0 4731 * [Branding]
michael@0 4732 * BrandFullName=Custom Full Name
michael@0 4733 * BrandShortName=Custom Short Name
michael@0 4734 *
michael@0 4735 * @param _PATH_TO_INI
michael@0 4736 * Path to the ini file.
michael@0 4737 *
michael@0 4738 * $R6 = return value from ReadINIStr
michael@0 4739 * $R7 = stores BrandShortName
michael@0 4740 * $R8 = stores BrandFullName
michael@0 4741 * $R9 = _PATH_TO_INI
michael@0 4742 */
michael@0 4743 !macro SetBrandNameVars
michael@0 4744
michael@0 4745 !ifndef ${_MOZFUNC_UN}SetBrandNameVars
michael@0 4746 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 4747 !insertmacro ${_MOZFUNC_UN_TMP}WordReplace
michael@0 4748 !undef _MOZFUNC_UN
michael@0 4749 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 4750 !undef _MOZFUNC_UN_TMP
michael@0 4751
michael@0 4752 ; Prevent declaring vars twice when the SetBrandNameVars macro is
michael@0 4753 ; inserted into both the installer and uninstaller.
michael@0 4754 !ifndef SetBrandNameVars
michael@0 4755 Var BrandFullName
michael@0 4756 Var BrandFullNameDA
michael@0 4757 Var BrandShortName
michael@0 4758 !endif
michael@0 4759
michael@0 4760 !verbose push
michael@0 4761 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4762 !define ${_MOZFUNC_UN}SetBrandNameVars "!insertmacro ${_MOZFUNC_UN}SetBrandNameVarsCall"
michael@0 4763
michael@0 4764 Function ${_MOZFUNC_UN}SetBrandNameVars
michael@0 4765 Exch $R9
michael@0 4766 Push $R8
michael@0 4767 Push $R7
michael@0 4768 Push $R6
michael@0 4769
michael@0 4770 StrCpy $R8 "${BrandFullName}"
michael@0 4771 StrCpy $R7 "${BrandShortName}"
michael@0 4772
michael@0 4773 IfFileExists "$R9" +1 finish
michael@0 4774
michael@0 4775 ClearErrors
michael@0 4776 ReadINIStr $R6 $R9 "Branding" "BrandFullName"
michael@0 4777 IfErrors +2 +1
michael@0 4778 StrCpy $R8 "$R6"
michael@0 4779
michael@0 4780 ClearErrors
michael@0 4781 ReadINIStr $R6 $R9 "Branding" "BrandShortName"
michael@0 4782 IfErrors +2 +1
michael@0 4783 StrCpy $R7 "$R6"
michael@0 4784
michael@0 4785 finish:
michael@0 4786 StrCpy $BrandFullName "$R8"
michael@0 4787 ${${_MOZFUNC_UN}WordReplace} "$R8" "&" "&&" "+" $R8
michael@0 4788 StrCpy $BrandFullNameDA "$R8"
michael@0 4789 StrCpy $BrandShortName "$R7"
michael@0 4790
michael@0 4791 Pop $R6
michael@0 4792 Pop $R7
michael@0 4793 Pop $R8
michael@0 4794 Exch $R9
michael@0 4795 FunctionEnd
michael@0 4796
michael@0 4797 !verbose pop
michael@0 4798 !endif
michael@0 4799 !macroend
michael@0 4800
michael@0 4801 !macro SetBrandNameVarsCall _PATH_TO_INI
michael@0 4802 !verbose push
michael@0 4803 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4804 Push "${_PATH_TO_INI}"
michael@0 4805 Call SetBrandNameVars
michael@0 4806 !verbose pop
michael@0 4807 !macroend
michael@0 4808
michael@0 4809 !macro un.SetBrandNameVarsCall _PATH_TO_INI
michael@0 4810 !verbose push
michael@0 4811 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4812 Push "${_PATH_TO_INI}"
michael@0 4813 Call un.SetBrandNameVars
michael@0 4814 !verbose pop
michael@0 4815 !macroend
michael@0 4816
michael@0 4817 !macro un.SetBrandNameVars
michael@0 4818 !ifndef un.SetBrandNameVars
michael@0 4819 !verbose push
michael@0 4820 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4821 !undef _MOZFUNC_UN
michael@0 4822 !define _MOZFUNC_UN "un."
michael@0 4823
michael@0 4824 !insertmacro SetBrandNameVars
michael@0 4825
michael@0 4826 !undef _MOZFUNC_UN
michael@0 4827 !define _MOZFUNC_UN
michael@0 4828 !verbose pop
michael@0 4829 !endif
michael@0 4830 !macroend
michael@0 4831
michael@0 4832 /**
michael@0 4833 * Replaces the wizard's header image with the one specified.
michael@0 4834 *
michael@0 4835 * @param _PATH_TO_IMAGE
michael@0 4836 * Fully qualified path to the bitmap to use for the header image.
michael@0 4837 *
michael@0 4838 * $R8 = hwnd for the control returned from GetDlgItem.
michael@0 4839 * $R9 = _PATH_TO_IMAGE
michael@0 4840 */
michael@0 4841 !macro ChangeMUIHeaderImage
michael@0 4842
michael@0 4843 !ifndef ${_MOZFUNC_UN}ChangeMUIHeaderImage
michael@0 4844 Var hHeaderBitmap
michael@0 4845
michael@0 4846 !verbose push
michael@0 4847 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4848 !define ${_MOZFUNC_UN}ChangeMUIHeaderImage "!insertmacro ${_MOZFUNC_UN}ChangeMUIHeaderImageCall"
michael@0 4849
michael@0 4850 Function ${_MOZFUNC_UN}ChangeMUIHeaderImage
michael@0 4851 Exch $R9
michael@0 4852 Push $R8
michael@0 4853
michael@0 4854 GetDlgItem $R8 $HWNDPARENT 1046
michael@0 4855 System::Call 'user32::LoadImageW(i 0, w "$R9", i 0, i 0, i 0, i 0x0010|0x2000) i.s'
michael@0 4856 Pop $hHeaderBitmap
michael@0 4857 SendMessage $R8 ${STM_SETIMAGE} 0 $hHeaderBitmap
michael@0 4858 ; There is no way to specify a show function for a custom page so hide
michael@0 4859 ; and then show the control to force the bitmap to redraw.
michael@0 4860 ShowWindow $R8 ${SW_HIDE}
michael@0 4861 ShowWindow $R8 ${SW_SHOW}
michael@0 4862
michael@0 4863 Pop $R8
michael@0 4864 Exch $R9
michael@0 4865 FunctionEnd
michael@0 4866
michael@0 4867 !verbose pop
michael@0 4868 !endif
michael@0 4869 !macroend
michael@0 4870
michael@0 4871 !macro ChangeMUIHeaderImageCall _PATH_TO_IMAGE
michael@0 4872 !verbose push
michael@0 4873 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4874 Push "${_PATH_TO_IMAGE}"
michael@0 4875 Call ChangeMUIHeaderImage
michael@0 4876 !verbose pop
michael@0 4877 !macroend
michael@0 4878
michael@0 4879 !macro un.ChangeMUIHeaderImageCall _PATH_TO_IMAGE
michael@0 4880 !verbose push
michael@0 4881 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4882 Push "${_PATH_TO_IMAGE}"
michael@0 4883 Call un.ChangeMUIHeaderImage
michael@0 4884 !verbose pop
michael@0 4885 !macroend
michael@0 4886
michael@0 4887 !macro un.ChangeMUIHeaderImage
michael@0 4888 !ifndef un.ChangeMUIHeaderImage
michael@0 4889 !verbose push
michael@0 4890 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4891 !undef _MOZFUNC_UN
michael@0 4892 !define _MOZFUNC_UN "un."
michael@0 4893
michael@0 4894 !insertmacro ChangeMUIHeaderImage
michael@0 4895
michael@0 4896 !undef _MOZFUNC_UN
michael@0 4897 !define _MOZFUNC_UN
michael@0 4898 !verbose pop
michael@0 4899 !endif
michael@0 4900 !macroend
michael@0 4901
michael@0 4902
michael@0 4903 ################################################################################
michael@0 4904 # User interface callback helper defines and macros
michael@0 4905
michael@0 4906 /* Install type defines */
michael@0 4907 !ifndef INSTALLTYPE_BASIC
michael@0 4908 !define INSTALLTYPE_BASIC 1
michael@0 4909 !endif
michael@0 4910
michael@0 4911 !ifndef INSTALLTYPE_CUSTOM
michael@0 4912 !define INSTALLTYPE_CUSTOM 2
michael@0 4913 !endif
michael@0 4914
michael@0 4915 /**
michael@0 4916 * Checks whether to display the current page (e.g. if not performing a custom
michael@0 4917 * install don't display the custom pages).
michael@0 4918 */
michael@0 4919 !macro CheckCustomCommon
michael@0 4920
michael@0 4921 !ifndef CheckCustomCommon
michael@0 4922 !verbose push
michael@0 4923 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4924 !define CheckCustomCommon "!insertmacro CheckCustomCommonCall"
michael@0 4925
michael@0 4926 Function CheckCustomCommon
michael@0 4927
michael@0 4928 ; Abort if not a custom install
michael@0 4929 IntCmp $InstallType ${INSTALLTYPE_CUSTOM} +2 +1 +1
michael@0 4930 Abort
michael@0 4931
michael@0 4932 FunctionEnd
michael@0 4933
michael@0 4934 !verbose pop
michael@0 4935 !endif
michael@0 4936 !macroend
michael@0 4937
michael@0 4938 !macro CheckCustomCommonCall
michael@0 4939 !verbose push
michael@0 4940 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4941 Call CheckCustomCommon
michael@0 4942 !verbose pop
michael@0 4943 !macroend
michael@0 4944
michael@0 4945 /**
michael@0 4946 * Unloads dll's and releases references when the installer and uninstaller
michael@0 4947 * exit.
michael@0 4948 */
michael@0 4949 !macro OnEndCommon
michael@0 4950
michael@0 4951 !ifndef ${_MOZFUNC_UN}OnEndCommon
michael@0 4952 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 4953 !insertmacro ${_MOZFUNC_UN_TMP}UnloadUAC
michael@0 4954 !undef _MOZFUNC_UN
michael@0 4955 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 4956 !undef _MOZFUNC_UN_TMP
michael@0 4957
michael@0 4958 !verbose push
michael@0 4959 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4960 !define ${_MOZFUNC_UN}OnEndCommon "!insertmacro ${_MOZFUNC_UN}OnEndCommonCall"
michael@0 4961
michael@0 4962 Function ${_MOZFUNC_UN}OnEndCommon
michael@0 4963
michael@0 4964 ${${_MOZFUNC_UN}UnloadUAC}
michael@0 4965 StrCmp $hHeaderBitmap "" +3 +1
michael@0 4966 System::Call "gdi32::DeleteObject(i s)" $hHeaderBitmap
michael@0 4967 StrCpy $hHeaderBitmap ""
michael@0 4968
michael@0 4969 System::Free 0
michael@0 4970
michael@0 4971 FunctionEnd
michael@0 4972
michael@0 4973 !verbose pop
michael@0 4974 !endif
michael@0 4975 !macroend
michael@0 4976
michael@0 4977 !macro OnEndCommonCall
michael@0 4978 !verbose push
michael@0 4979 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4980 Call OnEndCommon
michael@0 4981 !verbose pop
michael@0 4982 !macroend
michael@0 4983
michael@0 4984 !macro un.OnEndCommonCall
michael@0 4985 !verbose push
michael@0 4986 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4987 Call un.OnEndCommon
michael@0 4988 !verbose pop
michael@0 4989 !macroend
michael@0 4990
michael@0 4991 !macro un.OnEndCommon
michael@0 4992 !ifndef un.OnEndCommon
michael@0 4993 !verbose push
michael@0 4994 !verbose ${_MOZFUNC_VERBOSE}
michael@0 4995 !undef _MOZFUNC_UN
michael@0 4996 !define _MOZFUNC_UN "un."
michael@0 4997
michael@0 4998 !insertmacro OnEndCommon
michael@0 4999
michael@0 5000 !undef _MOZFUNC_UN
michael@0 5001 !define _MOZFUNC_UN
michael@0 5002 !verbose pop
michael@0 5003 !endif
michael@0 5004 !macroend
michael@0 5005
michael@0 5006 /**
michael@0 5007 * Called from the installer's .onInit function not to be confused with the
michael@0 5008 * uninstaller's .onInit or the uninstaller's un.onInit functions.
michael@0 5009 *
michael@0 5010 * @param _WARN_UNSUPPORTED_MSG
michael@0 5011 * Message displayed when the Windows version is not supported.
michael@0 5012 *
michael@0 5013 * $R5 = return value from the GetSize macro
michael@0 5014 * $R6 = general string values, return value from GetTempFileName, return
michael@0 5015 * value from the GetSize macro
michael@0 5016 * $R7 = full path to the configuration ini file
michael@0 5017 * $R8 = used for OS Version and Service Pack detection and the return value
michael@0 5018 * from the GetParameters macro
michael@0 5019 * $R9 = _WARN_UNSUPPORTED_MSG
michael@0 5020 */
michael@0 5021 !macro InstallOnInitCommon
michael@0 5022
michael@0 5023 !ifndef InstallOnInitCommon
michael@0 5024 !insertmacro ElevateUAC
michael@0 5025 !insertmacro GetOptions
michael@0 5026 !insertmacro GetParameters
michael@0 5027 !insertmacro GetSize
michael@0 5028
michael@0 5029 !verbose push
michael@0 5030 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5031 !define InstallOnInitCommon "!insertmacro InstallOnInitCommonCall"
michael@0 5032
michael@0 5033 Function InstallOnInitCommon
michael@0 5034 Exch $R9
michael@0 5035 Push $R8
michael@0 5036 Push $R7
michael@0 5037 Push $R6
michael@0 5038 Push $R5
michael@0 5039
michael@0 5040 !ifdef HAVE_64BIT_OS
michael@0 5041 ${Unless} ${RunningX64}
michael@0 5042 ${OrUnless} ${AtLeastWinVista}
michael@0 5043 MessageBox MB_OK|MB_ICONSTOP "$R9" IDOK
michael@0 5044 ; Nothing initialized so no need to call OnEndCommon
michael@0 5045 Quit
michael@0 5046 ${EndUnless}
michael@0 5047
michael@0 5048 SetRegView 64
michael@0 5049 !else
michael@0 5050 StrCpy $R8 "0"
michael@0 5051 ${If} ${AtMostWin2000}
michael@0 5052 StrCpy $R8 "1"
michael@0 5053 ${EndIf}
michael@0 5054
michael@0 5055 ${If} ${IsWinXP}
michael@0 5056 ${AndIf} ${AtMostServicePack} 1
michael@0 5057 StrCpy $R8 "1"
michael@0 5058 ${EndIf}
michael@0 5059
michael@0 5060 ${If} $R8 == "1"
michael@0 5061 ; XXX-rstrong - some systems failed the AtLeastWin2000 test that we
michael@0 5062 ; used to use for an unknown reason and likely fail the AtMostWin2000
michael@0 5063 ; and possibly the IsWinXP test as well. To work around this also
michael@0 5064 ; check if the Windows NT registry Key exists and if it does if the
michael@0 5065 ; first char in CurrentVersion is equal to 3 (Windows NT 3.5 and
michael@0 5066 ; 3.5.1), to 4 (Windows NT 4) or 5 (Windows 2000 and Windows XP).
michael@0 5067 StrCpy $R8 ""
michael@0 5068 ClearErrors
michael@0 5069 ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
michael@0 5070 StrCpy $R8 "$R8" 1
michael@0 5071 ${If} ${Errors}
michael@0 5072 ${OrIf} "$R8" == "3"
michael@0 5073 ${OrIf} "$R8" == "4"
michael@0 5074 ${OrIf} "$R8" == "5"
michael@0 5075 MessageBox MB_OK|MB_ICONSTOP "$R9" IDOK
michael@0 5076 ; Nothing initialized so no need to call OnEndCommon
michael@0 5077 Quit
michael@0 5078 ${EndIf}
michael@0 5079 ${EndUnless}
michael@0 5080 !endif
michael@0 5081
michael@0 5082 ${GetParameters} $R8
michael@0 5083
michael@0 5084 ; Require elevation if the user can elevate
michael@0 5085 ${ElevateUAC}
michael@0 5086
michael@0 5087 ${If} $R8 != ""
michael@0 5088 ; Default install type
michael@0 5089 StrCpy $InstallType ${INSTALLTYPE_BASIC}
michael@0 5090
michael@0 5091 ${Unless} ${Silent}
michael@0 5092 ; Manually check for /S in the command line due to Bug 506867
michael@0 5093 ClearErrors
michael@0 5094 ${GetOptions} "$R8" "/S" $R7
michael@0 5095 ${Unless} ${Errors}
michael@0 5096 SetSilent silent
michael@0 5097 ${Else}
michael@0 5098 ; Support for the deprecated -ms command line argument. The new command
michael@0 5099 ; line arguments are not supported when -ms is used.
michael@0 5100 ClearErrors
michael@0 5101 ${GetOptions} "$R8" "-ms" $R7
michael@0 5102 ${Unless} ${Errors}
michael@0 5103 SetSilent silent
michael@0 5104 ${EndUnless}
michael@0 5105 ${EndUnless}
michael@0 5106 ${EndUnless}
michael@0 5107
michael@0 5108 ; Support for specifying an installation configuration file.
michael@0 5109 ClearErrors
michael@0 5110 ${GetOptions} "$R8" "/INI=" $R7
michael@0 5111 ${Unless} ${Errors}
michael@0 5112 ; The configuration file must also exist
michael@0 5113 ${If} ${FileExists} "$R7"
michael@0 5114 SetSilent silent
michael@0 5115 ReadINIStr $R8 $R7 "Install" "InstallDirectoryName"
michael@0 5116 ${If} $R8 != ""
michael@0 5117 !ifdef HAVE_64BIT_OS
michael@0 5118 StrCpy $INSTDIR "$PROGRAMFILES64\$R8"
michael@0 5119 !else
michael@0 5120 StrCpy $INSTDIR "$PROGRAMFILES32\$R8"
michael@0 5121 !endif
michael@0 5122 ${Else}
michael@0 5123 ReadINIStr $R8 $R7 "Install" "InstallDirectoryPath"
michael@0 5124 ${If} $R8 != ""
michael@0 5125 StrCpy $INSTDIR "$R8"
michael@0 5126 ${EndIf}
michael@0 5127 ${EndIf}
michael@0 5128
michael@0 5129 ; Quit if we are unable to create the installation directory or we are
michael@0 5130 ; unable to write to a file in the installation directory.
michael@0 5131 ClearErrors
michael@0 5132 ${If} ${FileExists} "$INSTDIR"
michael@0 5133 GetTempFileName $R6 "$INSTDIR"
michael@0 5134 FileOpen $R5 "$R6" w
michael@0 5135 FileWrite $R5 "Write Access Test"
michael@0 5136 FileClose $R5
michael@0 5137 Delete $R6
michael@0 5138 ${If} ${Errors}
michael@0 5139 ; Nothing initialized so no need to call OnEndCommon
michael@0 5140 Quit
michael@0 5141 ${EndIf}
michael@0 5142 ${Else}
michael@0 5143 CreateDirectory "$INSTDIR"
michael@0 5144 ${If} ${Errors}
michael@0 5145 ; Nothing initialized so no need to call OnEndCommon
michael@0 5146 Quit
michael@0 5147 ${EndIf}
michael@0 5148 ${EndIf}
michael@0 5149
michael@0 5150 ReadINIStr $R8 $R7 "Install" "QuickLaunchShortcut"
michael@0 5151 ${If} $R8 == "false"
michael@0 5152 StrCpy $AddQuickLaunchSC "0"
michael@0 5153 ${Else}
michael@0 5154 StrCpy $AddQuickLaunchSC "1"
michael@0 5155 ${EndIf}
michael@0 5156
michael@0 5157 ReadINIStr $R8 $R7 "Install" "DesktopShortcut"
michael@0 5158 ${If} $R8 == "false"
michael@0 5159 StrCpy $AddDesktopSC "0"
michael@0 5160 ${Else}
michael@0 5161 StrCpy $AddDesktopSC "1"
michael@0 5162 ${EndIf}
michael@0 5163
michael@0 5164 ReadINIStr $R8 $R7 "Install" "StartMenuShortcuts"
michael@0 5165 ${If} $R8 == "false"
michael@0 5166 StrCpy $AddStartMenuSC "0"
michael@0 5167 ${Else}
michael@0 5168 StrCpy $AddStartMenuSC "1"
michael@0 5169 ${EndIf}
michael@0 5170
michael@0 5171 ReadINIStr $R8 $R7 "Install" "MaintenanceService"
michael@0 5172 ${If} $R8 == "false"
michael@0 5173 StrCpy $InstallMaintenanceService "0"
michael@0 5174 ${EndIf}
michael@0 5175
michael@0 5176 !ifndef NO_STARTMENU_DIR
michael@0 5177 ReadINIStr $R8 $R7 "Install" "StartMenuDirectoryName"
michael@0 5178 ${If} $R8 != ""
michael@0 5179 StrCpy $StartMenuDir "$R8"
michael@0 5180 ${EndIf}
michael@0 5181 !endif
michael@0 5182 ${EndIf}
michael@0 5183 ${EndUnless}
michael@0 5184 ${EndIf}
michael@0 5185 ClearErrors
michael@0 5186
michael@0 5187 Pop $R5
michael@0 5188 Pop $R6
michael@0 5189 Pop $R7
michael@0 5190 Pop $R8
michael@0 5191 Exch $R9
michael@0 5192 FunctionEnd
michael@0 5193
michael@0 5194 !verbose pop
michael@0 5195 !endif
michael@0 5196 !macroend
michael@0 5197
michael@0 5198 !macro InstallOnInitCommonCall _WARN_UNSUPPORTED_MSG
michael@0 5199 !verbose push
michael@0 5200 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5201 Push "${_WARN_UNSUPPORTED_MSG}"
michael@0 5202 Call InstallOnInitCommon
michael@0 5203 !verbose pop
michael@0 5204 !macroend
michael@0 5205
michael@0 5206 /**
michael@0 5207 * Called from the uninstaller's .onInit function not to be confused with the
michael@0 5208 * installer's .onInit or the uninstaller's un.onInit functions.
michael@0 5209 */
michael@0 5210 !macro UninstallOnInitCommon
michael@0 5211
michael@0 5212 !ifndef UninstallOnInitCommon
michael@0 5213 !insertmacro ElevateUAC
michael@0 5214 !insertmacro GetLongPath
michael@0 5215 !insertmacro GetOptions
michael@0 5216 !insertmacro GetParameters
michael@0 5217 !insertmacro GetParent
michael@0 5218 !insertmacro UnloadUAC
michael@0 5219 !insertmacro UpdateShortcutAppModelIDs
michael@0 5220 !insertmacro UpdateUninstallLog
michael@0 5221
michael@0 5222 !verbose push
michael@0 5223 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5224 !define UninstallOnInitCommon "!insertmacro UninstallOnInitCommonCall"
michael@0 5225
michael@0 5226 Function UninstallOnInitCommon
michael@0 5227 ; Prevents breaking apps that don't use SetBrandNameVars
michael@0 5228 !ifdef SetBrandNameVars
michael@0 5229 ${SetBrandNameVars} "$EXEDIR\distribution\setup.ini"
michael@0 5230 !endif
michael@0 5231
michael@0 5232 ; Prevent launching the application when a reboot is required and this
michael@0 5233 ; executable is the main application executable
michael@0 5234 IfFileExists "$EXEDIR\${FileMainEXE}.moz-upgrade" +1 +4
michael@0 5235 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2
michael@0 5236 Reboot
michael@0 5237 Quit ; Nothing initialized so no need to call OnEndCommon
michael@0 5238
michael@0 5239 ${GetParent} "$EXEDIR" $INSTDIR
michael@0 5240 ${GetLongPath} "$INSTDIR" $INSTDIR
michael@0 5241 IfFileExists "$INSTDIR\${FileMainEXE}" +2 +1
michael@0 5242 Quit ; Nothing initialized so no need to call OnEndCommon
michael@0 5243
michael@0 5244 !ifmacrodef InitHashAppModelId
michael@0 5245 ; setup the application model id registration value
michael@0 5246 !ifdef AppName
michael@0 5247 ${InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
michael@0 5248 !endif
michael@0 5249 !endif
michael@0 5250
michael@0 5251 ; Prevents breaking apps that don't use SetBrandNameVars
michael@0 5252 !ifdef SetBrandNameVars
michael@0 5253 ${SetBrandNameVars} "$INSTDIR\distribution\setup.ini"
michael@0 5254 !endif
michael@0 5255
michael@0 5256 ; Application update uses a directory named tobedeleted in the $INSTDIR to
michael@0 5257 ; delete files on OS reboot when they are in use. Try to delete this
michael@0 5258 ; directory if it exists.
michael@0 5259 ${If} ${FileExists} "$INSTDIR\${TO_BE_DELETED}"
michael@0 5260 RmDir /r "$INSTDIR\${TO_BE_DELETED}"
michael@0 5261 ${EndIf}
michael@0 5262
michael@0 5263 ; Prevent all operations (e.g. set as default, postupdate, etc.) when a
michael@0 5264 ; reboot is required and the executable launched is helper.exe
michael@0 5265 IfFileExists "$INSTDIR\${FileMainEXE}.moz-upgrade" +1 +4
michael@0 5266 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2
michael@0 5267 Reboot
michael@0 5268 Quit ; Nothing initialized so no need to call OnEndCommon
michael@0 5269
michael@0 5270 !ifdef HAVE_64BIT_OS
michael@0 5271 SetRegView 64
michael@0 5272 !endif
michael@0 5273
michael@0 5274 ${GetParameters} $R0
michael@0 5275
michael@0 5276 StrCmp "$R0" "" continue +1
michael@0 5277
michael@0 5278 ; Update this user's shortcuts with the latest app user model id.
michael@0 5279 ClearErrors
michael@0 5280 ${GetOptions} "$R0" "/UpdateShortcutAppUserModelIds" $R2
michael@0 5281 IfErrors hideshortcuts +1
michael@0 5282 StrCpy $R2 ""
michael@0 5283 !ifmacrodef InitHashAppModelId
michael@0 5284 ${If} "$AppUserModelID" != ""
michael@0 5285 ${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "$AppUserModelID" $R2
michael@0 5286 ${EndIf}
michael@0 5287 !endif
michael@0 5288 StrCmp "$R2" "false" +1 finish ; true indicates that shortcuts have been updated
michael@0 5289 Quit ; Nothing initialized so no need to call OnEndCommon
michael@0 5290
michael@0 5291 ; Require elevation if the user can elevate
michael@0 5292 hideshortcuts:
michael@0 5293 ClearErrors
michael@0 5294 ${GetOptions} "$R0" "/HideShortcuts" $R2
michael@0 5295 IfErrors showshortcuts +1
michael@0 5296 !ifndef NONADMIN_ELEVATE
michael@0 5297 ${ElevateUAC}
michael@0 5298 !endif
michael@0 5299 ${HideShortcuts}
michael@0 5300 GoTo finish
michael@0 5301
michael@0 5302 ; Require elevation if the user can elevate
michael@0 5303 showshortcuts:
michael@0 5304 ClearErrors
michael@0 5305 ${GetOptions} "$R0" "/ShowShortcuts" $R2
michael@0 5306 IfErrors defaultappuser +1
michael@0 5307 !ifndef NONADMIN_ELEVATE
michael@0 5308 ${ElevateUAC}
michael@0 5309 !endif
michael@0 5310 ${ShowShortcuts}
michael@0 5311 GoTo finish
michael@0 5312
michael@0 5313 ; Require elevation if the the StartMenuInternet registry keys require
michael@0 5314 ; updating and the user can elevate
michael@0 5315 defaultappuser:
michael@0 5316 ClearErrors
michael@0 5317 ${GetOptions} "$R0" "/SetAsDefaultAppUser" $R2
michael@0 5318 IfErrors defaultappglobal +1
michael@0 5319 ${SetAsDefaultAppUser}
michael@0 5320 GoTo finish
michael@0 5321
michael@0 5322 ; Require elevation if the user can elevate
michael@0 5323 defaultappglobal:
michael@0 5324 ClearErrors
michael@0 5325 ${GetOptions} "$R0" "/SetAsDefaultAppGlobal" $R2
michael@0 5326 IfErrors postupdate +1
michael@0 5327 ${ElevateUAC}
michael@0 5328 ${SetAsDefaultAppGlobal}
michael@0 5329 GoTo finish
michael@0 5330
michael@0 5331 ; Do not attempt to elevate. The application launching this executable is
michael@0 5332 ; responsible for elevation if it is required.
michael@0 5333 postupdate:
michael@0 5334 ${WordReplace} "$R0" "$\"" "" "+" $R0
michael@0 5335 ClearErrors
michael@0 5336 ${GetOptions} "$R0" "/PostUpdate" $R2
michael@0 5337 IfErrors continue +1
michael@0 5338 ; If the uninstall.log does not exist don't perform post update
michael@0 5339 ; operations. This prevents updating the registry for zip builds.
michael@0 5340 IfFileExists "$EXEDIR\uninstall.log" +2 +1
michael@0 5341 Quit ; Nothing initialized so no need to call OnEndCommon
michael@0 5342 ${PostUpdate}
michael@0 5343 ClearErrors
michael@0 5344 ${GetOptions} "$R0" "/UninstallLog=" $R2
michael@0 5345 IfErrors updateuninstalllog +1
michael@0 5346 StrCmp "$R2" "" finish +1
michael@0 5347 GetFullPathName $R3 "$R2"
michael@0 5348 IfFileExists "$R3" +1 finish
michael@0 5349 Delete "$INSTDIR\uninstall\*wizard*"
michael@0 5350 Delete "$INSTDIR\uninstall\uninstall.log"
michael@0 5351 CopyFiles /SILENT /FILESONLY "$R3" "$INSTDIR\uninstall\"
michael@0 5352 ${GetParent} "$R3" $R4
michael@0 5353 Delete "$R3"
michael@0 5354 RmDir "$R4"
michael@0 5355 GoTo finish
michael@0 5356
michael@0 5357 ; Do not attempt to elevate. The application launching this executable is
michael@0 5358 ; responsible for elevation if it is required.
michael@0 5359 updateuninstalllog:
michael@0 5360 ${UpdateUninstallLog}
michael@0 5361
michael@0 5362 finish:
michael@0 5363 ${UnloadUAC}
michael@0 5364 System::Call "shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i 0, i 0, i 0)"
michael@0 5365 Quit ; Nothing initialized so no need to call OnEndCommon
michael@0 5366
michael@0 5367 continue:
michael@0 5368
michael@0 5369 ; If the uninstall.log does not exist don't perform uninstall
michael@0 5370 ; operations. This prevents running the uninstaller for zip builds.
michael@0 5371 IfFileExists "$INSTDIR\uninstall\uninstall.log" +2 +1
michael@0 5372 Quit ; Nothing initialized so no need to call OnEndCommon
michael@0 5373
michael@0 5374 ; Require elevation if the user can elevate
michael@0 5375 ${ElevateUAC}
michael@0 5376
michael@0 5377 ; If we made it this far then this installer is being used as an uninstaller.
michael@0 5378 WriteUninstaller "$EXEDIR\uninstaller.exe"
michael@0 5379
michael@0 5380 ${Unless} ${Silent}
michael@0 5381 ; Manually check for /S in the command line due to Bug 506867
michael@0 5382 ClearErrors
michael@0 5383 ${GetOptions} "$R0" "/S" $R2
michael@0 5384 ${Unless} ${Errors}
michael@0 5385 SetSilent silent
michael@0 5386 ${Else}
michael@0 5387 ; Support for the deprecated -ms command line argument.
michael@0 5388 ClearErrors
michael@0 5389 ${GetOptions} "$R0" "-ms" $R2
michael@0 5390 ${Unless} ${Errors}
michael@0 5391 SetSilent silent
michael@0 5392 ${EndUnless}
michael@0 5393 ${EndUnless}
michael@0 5394 ${EndUnless}
michael@0 5395
michael@0 5396 ${If} ${Silent}
michael@0 5397 StrCpy $R1 "$\"$EXEDIR\uninstaller.exe$\" /S"
michael@0 5398 ${Else}
michael@0 5399 StrCpy $R1 "$\"$EXEDIR\uninstaller.exe$\""
michael@0 5400 ${EndIf}
michael@0 5401
michael@0 5402 ; When the uninstaller is launched it copies itself to the temp directory
michael@0 5403 ; so it won't be in use so it can delete itself.
michael@0 5404 ExecWait $R1
michael@0 5405 ${DeleteFile} "$EXEDIR\uninstaller.exe"
michael@0 5406 ${UnloadUAC}
michael@0 5407 SetErrorLevel 0
michael@0 5408 Quit ; Nothing initialized so no need to call OnEndCommon
michael@0 5409
michael@0 5410 FunctionEnd
michael@0 5411
michael@0 5412 !verbose pop
michael@0 5413 !endif
michael@0 5414 !macroend
michael@0 5415
michael@0 5416 !macro UninstallOnInitCommonCall
michael@0 5417 !verbose push
michael@0 5418 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5419 Call UninstallOnInitCommon
michael@0 5420 !verbose pop
michael@0 5421 !macroend
michael@0 5422
michael@0 5423 /**
michael@0 5424 * Called from the uninstaller's un.onInit function not to be confused with the
michael@0 5425 * installer's .onInit or the uninstaller's .onInit functions.
michael@0 5426 */
michael@0 5427 !macro un.UninstallUnOnInitCommon
michael@0 5428
michael@0 5429 !ifndef un.UninstallUnOnInitCommon
michael@0 5430 !insertmacro un.GetLongPath
michael@0 5431 !insertmacro un.GetParent
michael@0 5432 !insertmacro un.SetBrandNameVars
michael@0 5433
michael@0 5434 !verbose push
michael@0 5435 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5436 !define un.UninstallUnOnInitCommon "!insertmacro un.UninstallUnOnInitCommonCall"
michael@0 5437
michael@0 5438 Function un.UninstallUnOnInitCommon
michael@0 5439 ${un.GetParent} "$INSTDIR" $INSTDIR
michael@0 5440 ${un.GetLongPath} "$INSTDIR" $INSTDIR
michael@0 5441 ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}"
michael@0 5442 Abort
michael@0 5443 ${EndUnless}
michael@0 5444
michael@0 5445 !ifdef HAVE_64BIT_OS
michael@0 5446 SetRegView 64
michael@0 5447 !endif
michael@0 5448
michael@0 5449 ; Prevents breaking apps that don't use SetBrandNameVars
michael@0 5450 !ifdef un.SetBrandNameVars
michael@0 5451 ${un.SetBrandNameVars} "$INSTDIR\distribution\setup.ini"
michael@0 5452 !endif
michael@0 5453
michael@0 5454 ; Initialize $hHeaderBitmap to prevent redundant changing of the bitmap if
michael@0 5455 ; the user clicks the back button
michael@0 5456 StrCpy $hHeaderBitmap ""
michael@0 5457 FunctionEnd
michael@0 5458
michael@0 5459 !verbose pop
michael@0 5460 !endif
michael@0 5461 !macroend
michael@0 5462
michael@0 5463 !macro un.UninstallUnOnInitCommonCall
michael@0 5464 !verbose push
michael@0 5465 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5466 Call un.UninstallUnOnInitCommon
michael@0 5467 !verbose pop
michael@0 5468 !macroend
michael@0 5469
michael@0 5470 /**
michael@0 5471 * Called from the MUI leaveOptions function to set the value of $INSTDIR.
michael@0 5472 */
michael@0 5473 !macro LeaveOptionsCommon
michael@0 5474
michael@0 5475 !ifndef LeaveOptionsCommon
michael@0 5476 !insertmacro CanWriteToInstallDir
michael@0 5477 !insertmacro GetLongPath
michael@0 5478
michael@0 5479 !ifndef NO_INSTDIR_FROM_REG
michael@0 5480 !insertmacro GetSingleInstallPath
michael@0 5481 !endif
michael@0 5482
michael@0 5483 !verbose push
michael@0 5484 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5485 !define LeaveOptionsCommon "!insertmacro LeaveOptionsCommonCall"
michael@0 5486
michael@0 5487 Function LeaveOptionsCommon
michael@0 5488 Push $R9
michael@0 5489
michael@0 5490 !ifndef NO_INSTDIR_FROM_REG
michael@0 5491 SetShellVarContext all ; Set SHCTX to HKLM
michael@0 5492 ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
michael@0 5493
michael@0 5494 StrCmp "$R9" "false" +1 finish_get_install_dir
michael@0 5495
michael@0 5496 SetShellVarContext current ; Set SHCTX to HKCU
michael@0 5497 ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
michael@0 5498
michael@0 5499 finish_get_install_dir:
michael@0 5500 StrCmp "$R9" "false" +2 +1
michael@0 5501 StrCpy $INSTDIR "$R9"
michael@0 5502 !endif
michael@0 5503
michael@0 5504 ; If the user doesn't have write access to the installation directory set
michael@0 5505 ; the installation directory to a subdirectory of the All Users application
michael@0 5506 ; directory and if the user can't write to that location set the installation
michael@0 5507 ; directory to a subdirectory of the users local application directory
michael@0 5508 ; (e.g. non-roaming).
michael@0 5509 ${CanWriteToInstallDir} $R9
michael@0 5510 StrCmp "$R9" "false" +1 finish_check_install_dir
michael@0 5511
michael@0 5512 SetShellVarContext all ; Set SHCTX to All Users
michael@0 5513 StrCpy $INSTDIR "$APPDATA\${BrandFullName}\"
michael@0 5514 ${CanWriteToInstallDir} $R9
michael@0 5515 StrCmp "$R9" "false" +2 +1
michael@0 5516 StrCpy $INSTDIR "$LOCALAPPDATA\${BrandFullName}\"
michael@0 5517
michael@0 5518 finish_check_install_dir:
michael@0 5519 IfFileExists "$INSTDIR" +3 +1
michael@0 5520 Pop $R9
michael@0 5521 Return
michael@0 5522
michael@0 5523 ; Always display the long path if the path already exists.
michael@0 5524 ${GetLongPath} "$INSTDIR" $INSTDIR
michael@0 5525
michael@0 5526 ; The call to GetLongPath returns a long path without a trailing
michael@0 5527 ; back-slash. Append a \ to the path to prevent the directory
michael@0 5528 ; name from being appended when using the NSIS create new folder.
michael@0 5529 ; http://www.nullsoft.com/free/nsis/makensis.htm#InstallDir
michael@0 5530 StrCpy $INSTDIR "$INSTDIR\"
michael@0 5531
michael@0 5532 Pop $R9
michael@0 5533 FunctionEnd
michael@0 5534
michael@0 5535 !verbose pop
michael@0 5536 !endif
michael@0 5537 !macroend
michael@0 5538
michael@0 5539 !macro LeaveOptionsCommonCall
michael@0 5540 !verbose push
michael@0 5541 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5542 Call LeaveOptionsCommon
michael@0 5543 !verbose pop
michael@0 5544 !macroend
michael@0 5545
michael@0 5546 /**
michael@0 5547 * Called from the MUI preDirectory function to verify there is enough disk
michael@0 5548 * space for the installation and the installation directory is writable.
michael@0 5549 *
michael@0 5550 * $R9 = returned value from CheckDiskSpace and CanWriteToInstallDir macros
michael@0 5551 */
michael@0 5552 !macro PreDirectoryCommon
michael@0 5553
michael@0 5554 !ifndef PreDirectoryCommon
michael@0 5555 !insertmacro CanWriteToInstallDir
michael@0 5556 !insertmacro CheckDiskSpace
michael@0 5557
michael@0 5558 !verbose push
michael@0 5559 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5560 !define PreDirectoryCommon "!insertmacro PreDirectoryCommonCall"
michael@0 5561
michael@0 5562 Function PreDirectoryCommon
michael@0 5563 Push $R9
michael@0 5564
michael@0 5565 IntCmp $InstallType ${INSTALLTYPE_CUSTOM} end +1 +1
michael@0 5566 ${CanWriteToInstallDir} $R9
michael@0 5567 StrCmp "$R9" "false" end +1
michael@0 5568 ${CheckDiskSpace} $R9
michael@0 5569 StrCmp "$R9" "false" end +1
michael@0 5570 Abort
michael@0 5571
michael@0 5572 end:
michael@0 5573
michael@0 5574 Pop $R9
michael@0 5575 FunctionEnd
michael@0 5576
michael@0 5577 !verbose pop
michael@0 5578 !endif
michael@0 5579 !macroend
michael@0 5580
michael@0 5581 !macro PreDirectoryCommonCall
michael@0 5582 !verbose push
michael@0 5583 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5584 Call PreDirectoryCommon
michael@0 5585 !verbose pop
michael@0 5586 !macroend
michael@0 5587
michael@0 5588 /**
michael@0 5589 * Called from the MUI leaveDirectory function
michael@0 5590 *
michael@0 5591 * @param _WARN_DISK_SPACE
michael@0 5592 * Message displayed when there isn't enough disk space to perform the
michael@0 5593 * installation.
michael@0 5594 * @param _WARN_WRITE_ACCESS
michael@0 5595 * Message displayed when the installer does not have write access to
michael@0 5596 * $INSTDIR.
michael@0 5597 *
michael@0 5598 * $R7 = returned value from CheckDiskSpace and CanWriteToInstallDir macros
michael@0 5599 * $R8 = _WARN_DISK_SPACE
michael@0 5600 * $R9 = _WARN_WRITE_ACCESS
michael@0 5601 */
michael@0 5602 !macro LeaveDirectoryCommon
michael@0 5603
michael@0 5604 !ifndef LeaveDirectoryCommon
michael@0 5605 !insertmacro CheckDiskSpace
michael@0 5606 !insertmacro CanWriteToInstallDir
michael@0 5607
michael@0 5608 !verbose push
michael@0 5609 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5610 !define LeaveDirectoryCommon "!insertmacro LeaveDirectoryCommonCall"
michael@0 5611
michael@0 5612 Function LeaveDirectoryCommon
michael@0 5613 Exch $R9
michael@0 5614 Exch 1
michael@0 5615 Exch $R8
michael@0 5616 Push $R7
michael@0 5617
michael@0 5618 ${CanWriteToInstallDir} $R7
michael@0 5619 ${If} $R7 == "false"
michael@0 5620 MessageBox MB_OK|MB_ICONEXCLAMATION "$R9"
michael@0 5621 Abort
michael@0 5622 ${EndIf}
michael@0 5623
michael@0 5624 ${CheckDiskSpace} $R7
michael@0 5625 ${If} $R7 == "false"
michael@0 5626 MessageBox MB_OK|MB_ICONEXCLAMATION "$R8"
michael@0 5627 Abort
michael@0 5628 ${EndIf}
michael@0 5629
michael@0 5630 Pop $R7
michael@0 5631 Exch $R8
michael@0 5632 Exch 1
michael@0 5633 Exch $R9
michael@0 5634 FunctionEnd
michael@0 5635
michael@0 5636 !verbose pop
michael@0 5637 !endif
michael@0 5638 !macroend
michael@0 5639
michael@0 5640 !macro LeaveDirectoryCommonCall _WARN_DISK_SPACE _WARN_WRITE_ACCESS
michael@0 5641 !verbose push
michael@0 5642 Push "${_WARN_DISK_SPACE}"
michael@0 5643 Push "${_WARN_WRITE_ACCESS}"
michael@0 5644 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5645 Call LeaveDirectoryCommon
michael@0 5646 !verbose pop
michael@0 5647 !macroend
michael@0 5648
michael@0 5649
michael@0 5650 ################################################################################
michael@0 5651 # Install Section common macros.
michael@0 5652
michael@0 5653 /**
michael@0 5654 * Performs common cleanup operations prior to the actual installation.
michael@0 5655 * This macro should be called first when installation starts.
michael@0 5656 */
michael@0 5657 !macro InstallStartCleanupCommon
michael@0 5658
michael@0 5659 !ifndef InstallStartCleanupCommon
michael@0 5660 !insertmacro CleanVirtualStore
michael@0 5661 !insertmacro EndUninstallLog
michael@0 5662 !insertmacro OnInstallUninstall
michael@0 5663
michael@0 5664 !verbose push
michael@0 5665 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5666 !define InstallStartCleanupCommon "!insertmacro InstallStartCleanupCommonCall"
michael@0 5667
michael@0 5668 Function InstallStartCleanupCommon
michael@0 5669
michael@0 5670 ; Remove files not removed by parsing the uninstall.log
michael@0 5671 Delete "$INSTDIR\install_wizard.log"
michael@0 5672 Delete "$INSTDIR\install_status.log"
michael@0 5673
michael@0 5674 RmDir /r "$INSTDIR\updates"
michael@0 5675 Delete "$INSTDIR\updates.xml"
michael@0 5676 Delete "$INSTDIR\active-update.xml"
michael@0 5677
michael@0 5678 RmDir /r "$INSTDIR\distribution"
michael@0 5679
michael@0 5680 ; Remove files from the uninstall directory.
michael@0 5681 ${If} ${FileExists} "$INSTDIR\uninstall"
michael@0 5682 Delete "$INSTDIR\uninstall\*wizard*"
michael@0 5683 Delete "$INSTDIR\uninstall\uninstall.ini"
michael@0 5684 Delete "$INSTDIR\uninstall\cleanup.log"
michael@0 5685 Delete "$INSTDIR\uninstall\uninstall.update"
michael@0 5686 ${OnInstallUninstall}
michael@0 5687 ${EndIf}
michael@0 5688
michael@0 5689 ; Since we write to the uninstall.log in this directory during the
michael@0 5690 ; installation create the directory if it doesn't already exist.
michael@0 5691 IfFileExists "$INSTDIR\uninstall" +2 +1
michael@0 5692 CreateDirectory "$INSTDIR\uninstall"
michael@0 5693
michael@0 5694 ; Application update uses a directory named tobedeleted in the $INSTDIR to
michael@0 5695 ; delete files on OS reboot when they are in use. Try to delete this
michael@0 5696 ; directory if it exists.
michael@0 5697 ${If} ${FileExists} "$INSTDIR\${TO_BE_DELETED}"
michael@0 5698 RmDir /r "$INSTDIR\${TO_BE_DELETED}"
michael@0 5699 ${EndIf}
michael@0 5700
michael@0 5701 ; Remove files that may be left behind by the application in the
michael@0 5702 ; VirtualStore directory.
michael@0 5703 ${CleanVirtualStore}
michael@0 5704 FunctionEnd
michael@0 5705
michael@0 5706 !verbose pop
michael@0 5707 !endif
michael@0 5708 !macroend
michael@0 5709
michael@0 5710 !macro InstallStartCleanupCommonCall
michael@0 5711 !verbose push
michael@0 5712 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5713 Call InstallStartCleanupCommon
michael@0 5714 !verbose pop
michael@0 5715 !macroend
michael@0 5716
michael@0 5717 /**
michael@0 5718 * Performs common cleanup operations after the actual installation.
michael@0 5719 * This macro should be called last during the installation.
michael@0 5720 */
michael@0 5721 !macro InstallEndCleanupCommon
michael@0 5722
michael@0 5723 !ifndef InstallEndCleanupCommon
michael@0 5724 !insertmacro EndUninstallLog
michael@0 5725
michael@0 5726 !verbose push
michael@0 5727 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5728 !define InstallEndCleanupCommon "!insertmacro InstallEndCleanupCommonCall"
michael@0 5729
michael@0 5730 Function InstallEndCleanupCommon
michael@0 5731
michael@0 5732 ; Close the file handle to the uninstall.log
michael@0 5733 ${EndUninstallLog}
michael@0 5734
michael@0 5735 FunctionEnd
michael@0 5736
michael@0 5737 !verbose pop
michael@0 5738 !endif
michael@0 5739 !macroend
michael@0 5740
michael@0 5741 !macro InstallEndCleanupCommonCall
michael@0 5742 !verbose push
michael@0 5743 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5744 Call InstallEndCleanupCommon
michael@0 5745 !verbose pop
michael@0 5746 !macroend
michael@0 5747
michael@0 5748
michael@0 5749 ################################################################################
michael@0 5750 # UAC Related Macros
michael@0 5751
michael@0 5752 /**
michael@0 5753 * Provides UAC elevation support for Vista and above (requires the UAC plugin).
michael@0 5754 *
michael@0 5755 * $0 = return values from calls to the UAC plugin (always uses $0)
michael@0 5756 * $R9 = return values from GetParameters and GetOptions macros
michael@0 5757 */
michael@0 5758 !macro ElevateUAC
michael@0 5759
michael@0 5760 !ifndef ${_MOZFUNC_UN}ElevateUAC
michael@0 5761 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 5762 !insertmacro ${_MOZFUNC_UN_TMP}GetOptions
michael@0 5763 !insertmacro ${_MOZFUNC_UN_TMP}GetParameters
michael@0 5764 !undef _MOZFUNC_UN
michael@0 5765 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 5766 !undef _MOZFUNC_UN_TMP
michael@0 5767
michael@0 5768 !verbose push
michael@0 5769 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5770 !define ${_MOZFUNC_UN}ElevateUAC "!insertmacro ${_MOZFUNC_UN}ElevateUACCall"
michael@0 5771
michael@0 5772 Function ${_MOZFUNC_UN}ElevateUAC
michael@0 5773 Push $R9
michael@0 5774 Push $0
michael@0 5775
michael@0 5776 !ifndef NONADMIN_ELEVATE
michael@0 5777 ${If} ${AtLeastWinVista}
michael@0 5778 UAC::IsAdmin
michael@0 5779 ; If the user is not an admin already
michael@0 5780 ${If} "$0" != "1"
michael@0 5781 UAC::SupportsUAC
michael@0 5782 ; If the system supports UAC
michael@0 5783 ${If} "$0" == "1"
michael@0 5784 UAC::GetElevationType
michael@0 5785 ; If the user account has a split token
michael@0 5786 ${If} "$0" == "3"
michael@0 5787 UAC::RunElevated
michael@0 5788 UAC::Unload
michael@0 5789 ; Nothing besides UAC initialized so no need to call OnEndCommon
michael@0 5790 Quit
michael@0 5791 ${EndIf}
michael@0 5792 ${EndIf}
michael@0 5793 ${Else}
michael@0 5794 ${GetParameters} $R9
michael@0 5795 ${If} $R9 != ""
michael@0 5796 ClearErrors
michael@0 5797 ${GetOptions} "$R9" "/UAC:" $0
michael@0 5798 ; If the command line contains /UAC then we need to initialize
michael@0 5799 ; the UAC plugin to use UAC::ExecCodeSegment to execute code in
michael@0 5800 ; the non-elevated context.
michael@0 5801 ${Unless} ${Errors}
michael@0 5802 UAC::RunElevated
michael@0 5803 ${EndUnless}
michael@0 5804 ${EndIf}
michael@0 5805 ${EndIf}
michael@0 5806 ${EndIf}
michael@0 5807 !else
michael@0 5808 ${If} ${AtLeastWinVista}
michael@0 5809 UAC::IsAdmin
michael@0 5810 ; If the user is not an admin already
michael@0 5811 ${If} "$0" != "1"
michael@0 5812 UAC::SupportsUAC
michael@0 5813 ; If the system supports UAC require that the user elevate
michael@0 5814 ${If} "$0" == "1"
michael@0 5815 UAC::GetElevationType
michael@0 5816 ; If the user account has a split token
michael@0 5817 ${If} "$0" == "3"
michael@0 5818 UAC::RunElevated
michael@0 5819 UAC::Unload
michael@0 5820 ; Nothing besides UAC initialized so no need to call OnEndCommon
michael@0 5821 Quit
michael@0 5822 ${EndIf}
michael@0 5823 ${Else}
michael@0 5824 ; Check if UAC is enabled. If the user has turned UAC on or off
michael@0 5825 ; without rebooting this value will be incorrect. This is an
michael@0 5826 ; edgecase that we have to live with when trying to allow
michael@0 5827 ; installing when the user doesn't have privileges such as a public
michael@0 5828 ; computer while trying to also achieve UAC elevation. When this
michael@0 5829 ; happens the user will be presented with the runas dialog if the
michael@0 5830 ; value is 1 and won't be presented with the UAC dialog when the
michael@0 5831 ; value is 0.
michael@0 5832 ReadRegDWord $R9 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "EnableLUA"
michael@0 5833 ${If} "$R9" == "1"
michael@0 5834 ; This will display the UAC version of the runas dialog which
michael@0 5835 ; requires a password for an existing user account.
michael@0 5836 UAC::RunElevated
michael@0 5837 ${If} "$0" == "0" ; Was elevation successful
michael@0 5838 UAC::Unload
michael@0 5839 ; Nothing besides UAC initialized so no need to call OnEndCommon
michael@0 5840 Quit
michael@0 5841 ${EndIf}
michael@0 5842 ; Unload UAC since the elevation request was not successful and
michael@0 5843 ; install anyway.
michael@0 5844 UAC::Unload
michael@0 5845 ${EndIf}
michael@0 5846 ${EndIf}
michael@0 5847 ${Else}
michael@0 5848 ClearErrors
michael@0 5849 ${${_MOZFUNC_UN}GetParameters} $R9
michael@0 5850 ${${_MOZFUNC_UN}GetOptions} "$R9" "/UAC:" $R9
michael@0 5851 ; If the command line contains /UAC then we need to initialize the UAC
michael@0 5852 ; plugin to use UAC::ExecCodeSegment to execute code in the
michael@0 5853 ; non-elevated context.
michael@0 5854 ${Unless} ${Errors}
michael@0 5855 UAC::RunElevated
michael@0 5856 ${EndUnless}
michael@0 5857 ${EndIf}
michael@0 5858 ${EndIf}
michael@0 5859 !endif
michael@0 5860
michael@0 5861 ClearErrors
michael@0 5862
michael@0 5863 Pop $0
michael@0 5864 Pop $R9
michael@0 5865 FunctionEnd
michael@0 5866
michael@0 5867 !verbose pop
michael@0 5868 !endif
michael@0 5869 !macroend
michael@0 5870
michael@0 5871 !macro ElevateUACCall
michael@0 5872 !verbose push
michael@0 5873 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5874 Call ElevateUAC
michael@0 5875 !verbose pop
michael@0 5876 !macroend
michael@0 5877
michael@0 5878 !macro un.ElevateUACCall
michael@0 5879 !verbose push
michael@0 5880 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5881 Call un.ElevateUAC
michael@0 5882 !verbose pop
michael@0 5883 !macroend
michael@0 5884
michael@0 5885 !macro un.ElevateUAC
michael@0 5886 !ifndef un.ElevateUAC
michael@0 5887 !verbose push
michael@0 5888 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5889 !undef _MOZFUNC_UN
michael@0 5890 !define _MOZFUNC_UN "un."
michael@0 5891
michael@0 5892 !insertmacro ElevateUAC
michael@0 5893
michael@0 5894 !undef _MOZFUNC_UN
michael@0 5895 !define _MOZFUNC_UN
michael@0 5896 !verbose pop
michael@0 5897 !endif
michael@0 5898 !macroend
michael@0 5899
michael@0 5900 /**
michael@0 5901 * Unloads the UAC plugin so the NSIS plugins can be removed when the installer
michael@0 5902 * and uninstaller exit.
michael@0 5903 *
michael@0 5904 * $R9 = return values from GetParameters and GetOptions macros
michael@0 5905 */
michael@0 5906 !macro UnloadUAC
michael@0 5907
michael@0 5908 !ifndef ${_MOZFUNC_UN}UnloadUAC
michael@0 5909 !define _MOZFUNC_UN_TMP_UnloadUAC ${_MOZFUNC_UN}
michael@0 5910 !insertmacro ${_MOZFUNC_UN_TMP_UnloadUAC}GetOptions
michael@0 5911 !insertmacro ${_MOZFUNC_UN_TMP_UnloadUAC}GetParameters
michael@0 5912 !undef _MOZFUNC_UN
michael@0 5913 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP_UnloadUAC}
michael@0 5914 !undef _MOZFUNC_UN_TMP_UnloadUAC
michael@0 5915
michael@0 5916 !verbose push
michael@0 5917 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5918 !define ${_MOZFUNC_UN}UnloadUAC "!insertmacro ${_MOZFUNC_UN}UnloadUACCall"
michael@0 5919
michael@0 5920 Function ${_MOZFUNC_UN}UnloadUAC
michael@0 5921 ${Unless} ${AtLeastWinVista}
michael@0 5922 Return
michael@0 5923 ${EndUnless}
michael@0 5924
michael@0 5925 Push $R9
michael@0 5926
michael@0 5927 ClearErrors
michael@0 5928 ${${_MOZFUNC_UN}GetParameters} $R9
michael@0 5929 ${${_MOZFUNC_UN}GetOptions} "$R9" "/UAC:" $R9
michael@0 5930 ; If the command line contains /UAC then we need to unload the UAC plugin
michael@0 5931 IfErrors +2 +1
michael@0 5932 UAC::Unload
michael@0 5933
michael@0 5934 ClearErrors
michael@0 5935
michael@0 5936 Pop $R9
michael@0 5937 FunctionEnd
michael@0 5938
michael@0 5939 !verbose pop
michael@0 5940 !endif
michael@0 5941 !macroend
michael@0 5942
michael@0 5943 !macro UnloadUACCall
michael@0 5944 !verbose push
michael@0 5945 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5946 Call UnloadUAC
michael@0 5947 !verbose pop
michael@0 5948 !macroend
michael@0 5949
michael@0 5950 !macro un.UnloadUACCall
michael@0 5951 !verbose push
michael@0 5952 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5953 Call un.UnloadUAC
michael@0 5954 !verbose pop
michael@0 5955 !macroend
michael@0 5956
michael@0 5957 !macro un.UnloadUAC
michael@0 5958 !ifndef un.UnloadUAC
michael@0 5959 !verbose push
michael@0 5960 !verbose ${_MOZFUNC_VERBOSE}
michael@0 5961 !undef _MOZFUNC_UN
michael@0 5962 !define _MOZFUNC_UN "un."
michael@0 5963
michael@0 5964 !insertmacro UnloadUAC
michael@0 5965
michael@0 5966 !undef _MOZFUNC_UN
michael@0 5967 !define _MOZFUNC_UN
michael@0 5968 !verbose pop
michael@0 5969 !endif
michael@0 5970 !macroend
michael@0 5971
michael@0 5972
michael@0 5973 ################################################################################
michael@0 5974 # Macros for uninstall.log and install.log logging
michael@0 5975 #
michael@0 5976 # Since these are used by other macros they should be inserted first. All of
michael@0 5977 # these macros can be easily inserted using the _LoggingCommon macro.
michael@0 5978
michael@0 5979 /**
michael@0 5980 * Adds all logging macros in the correct order in one fell swoop as well as
michael@0 5981 * the vars for the install.log and uninstall.log file handles.
michael@0 5982 */
michael@0 5983 !macro _LoggingCommon
michael@0 5984 Var /GLOBAL fhInstallLog
michael@0 5985 Var /GLOBAL fhUninstallLog
michael@0 5986 !insertmacro StartInstallLog
michael@0 5987 !insertmacro EndInstallLog
michael@0 5988 !insertmacro StartUninstallLog
michael@0 5989 !insertmacro EndUninstallLog
michael@0 5990 !macroend
michael@0 5991 !define _LoggingCommon "!insertmacro _LoggingCommon"
michael@0 5992
michael@0 5993 /**
michael@0 5994 * Creates a file named install.log in the install directory (e.g. $INSTDIR)
michael@0 5995 * and adds the installation started message to the install.log for this
michael@0 5996 * installation. This also adds the fhInstallLog and fhUninstallLog vars used
michael@0 5997 * for logging.
michael@0 5998 *
michael@0 5999 * $fhInstallLog = filehandle for $INSTDIR\install.log
michael@0 6000 *
michael@0 6001 * @param _APP_NAME
michael@0 6002 * Typically the BrandFullName
michael@0 6003 * @param _AB_CD
michael@0 6004 * The locale identifier
michael@0 6005 * @param _APP_VERSION
michael@0 6006 * The application version
michael@0 6007 * @param _GRE_VERSION
michael@0 6008 * The Gecko Runtime Engine version
michael@0 6009 *
michael@0 6010 * $R6 = _APP_NAME
michael@0 6011 * $R7 = _AB_CD
michael@0 6012 * $R8 = _APP_VERSION
michael@0 6013 * $R9 = _GRE_VERSION
michael@0 6014 */
michael@0 6015 !macro StartInstallLog
michael@0 6016
michael@0 6017 !ifndef StartInstallLog
michael@0 6018 !insertmacro GetTime
michael@0 6019
michael@0 6020 !verbose push
michael@0 6021 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6022 !define StartInstallLog "!insertmacro StartInstallLogCall"
michael@0 6023
michael@0 6024 Function StartInstallLog
michael@0 6025 Exch $R9
michael@0 6026 Exch 1
michael@0 6027 Exch $R8
michael@0 6028 Exch 2
michael@0 6029 Exch $R7
michael@0 6030 Exch 3
michael@0 6031 Exch $R6
michael@0 6032 Push $R5
michael@0 6033 Push $R4
michael@0 6034 Push $R3
michael@0 6035 Push $R2
michael@0 6036 Push $R1
michael@0 6037 Push $R0
michael@0 6038 Push $9
michael@0 6039
michael@0 6040 ${DeleteFile} "$INSTDIR\install.log"
michael@0 6041 FileOpen $fhInstallLog "$INSTDIR\install.log" w
michael@0 6042 FileWriteWord $fhInstallLog "65279"
michael@0 6043
michael@0 6044 ${GetTime} "" "L" $9 $R0 $R1 $R2 $R3 $R4 $R5
michael@0 6045 FileWriteUTF16LE $fhInstallLog "$R6 Installation Started: $R1-$R0-$9 $R3:$R4:$R5"
michael@0 6046 ${WriteLogSeparator}
michael@0 6047
michael@0 6048 ${LogHeader} "Installation Details"
michael@0 6049 ${LogMsg} "Install Dir: $INSTDIR"
michael@0 6050 ${LogMsg} "Locale : $R7"
michael@0 6051 ${LogMsg} "App Version: $R8"
michael@0 6052 ${LogMsg} "GRE Version: $R9"
michael@0 6053
michael@0 6054 ${If} ${IsWinXP}
michael@0 6055 ${LogMsg} "OS Name : Windows XP"
michael@0 6056 ${ElseIf} ${IsWin2003}
michael@0 6057 ${LogMsg} "OS Name : Windows 2003"
michael@0 6058 ${ElseIf} ${IsWinVista}
michael@0 6059 ${LogMsg} "OS Name : Windows Vista"
michael@0 6060 ${ElseIf} ${IsWin7}
michael@0 6061 ${LogMsg} "OS Name : Windows 7"
michael@0 6062 ${ElseIf} ${IsWin8}
michael@0 6063 ${LogMsg} "OS Name : Windows 8"
michael@0 6064 ${ElseIf} ${AtLeastWin8}
michael@0 6065 ${LogMsg} "OS Name : Above Windows 8"
michael@0 6066 ${Else}
michael@0 6067 ${LogMsg} "OS Name : Unable to detect"
michael@0 6068 ${EndIf}
michael@0 6069
michael@0 6070 !ifdef HAVE_64BIT_OS
michael@0 6071 ${LogMsg} "Target CPU : x64"
michael@0 6072 !else
michael@0 6073 ${LogMsg} "Target CPU : x86"
michael@0 6074 !endif
michael@0 6075
michael@0 6076 Pop $9
michael@0 6077 Pop $R0
michael@0 6078 Pop $R1
michael@0 6079 Pop $R2
michael@0 6080 Pop $R3
michael@0 6081 Pop $R4
michael@0 6082 Pop $R5
michael@0 6083 Exch $R6
michael@0 6084 Exch 3
michael@0 6085 Exch $R7
michael@0 6086 Exch 2
michael@0 6087 Exch $R8
michael@0 6088 Exch 1
michael@0 6089 Exch $R9
michael@0 6090 FunctionEnd
michael@0 6091
michael@0 6092 !verbose pop
michael@0 6093 !endif
michael@0 6094 !macroend
michael@0 6095
michael@0 6096 !macro StartInstallLogCall _APP_NAME _AB_CD _APP_VERSION _GRE_VERSION
michael@0 6097 !verbose push
michael@0 6098 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6099 Push "${_APP_NAME}"
michael@0 6100 Push "${_AB_CD}"
michael@0 6101 Push "${_APP_VERSION}"
michael@0 6102 Push "${_GRE_VERSION}"
michael@0 6103 Call StartInstallLog
michael@0 6104 !verbose pop
michael@0 6105 !macroend
michael@0 6106
michael@0 6107 /**
michael@0 6108 * Writes the installation finished message to the install.log and closes the
michael@0 6109 * file handles to the install.log and uninstall.log
michael@0 6110 *
michael@0 6111 * @param _APP_NAME
michael@0 6112 *
michael@0 6113 * $R9 = _APP_NAME
michael@0 6114 */
michael@0 6115 !macro EndInstallLog
michael@0 6116
michael@0 6117 !ifndef EndInstallLog
michael@0 6118 !insertmacro GetTime
michael@0 6119
michael@0 6120 !verbose push
michael@0 6121 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6122 !define EndInstallLog "!insertmacro EndInstallLogCall"
michael@0 6123
michael@0 6124 Function EndInstallLog
michael@0 6125 Exch $R9
michael@0 6126 Push $R8
michael@0 6127 Push $R7
michael@0 6128 Push $R6
michael@0 6129 Push $R5
michael@0 6130 Push $R4
michael@0 6131 Push $R3
michael@0 6132 Push $R2
michael@0 6133
michael@0 6134 ${WriteLogSeparator}
michael@0 6135 ${GetTime} "" "L" $R2 $R3 $R4 $R5 $R6 $R7 $R8
michael@0 6136 FileWriteUTF16LE $fhInstallLog "$R9 Installation Finished: $R4-$R3-$R2 $R6:$R7:$R8$\r$\n"
michael@0 6137 FileClose $fhInstallLog
michael@0 6138
michael@0 6139 Pop $R2
michael@0 6140 Pop $R3
michael@0 6141 Pop $R4
michael@0 6142 Pop $R5
michael@0 6143 Pop $R6
michael@0 6144 Pop $R7
michael@0 6145 Pop $R8
michael@0 6146 Exch $R9
michael@0 6147 FunctionEnd
michael@0 6148
michael@0 6149 !verbose pop
michael@0 6150 !endif
michael@0 6151 !macroend
michael@0 6152
michael@0 6153 !macro EndInstallLogCall _APP_NAME
michael@0 6154 !verbose push
michael@0 6155 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6156 Push "${_APP_NAME}"
michael@0 6157 Call EndInstallLog
michael@0 6158 !verbose pop
michael@0 6159 !macroend
michael@0 6160
michael@0 6161 /**
michael@0 6162 * Opens the file handle to the uninstall.log.
michael@0 6163 *
michael@0 6164 * $fhUninstallLog = filehandle for $INSTDIR\uninstall\uninstall.log
michael@0 6165 */
michael@0 6166 !macro StartUninstallLog
michael@0 6167
michael@0 6168 !ifndef StartUninstallLog
michael@0 6169 !verbose push
michael@0 6170 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6171 !define StartUninstallLog "!insertmacro StartUninstallLogCall"
michael@0 6172
michael@0 6173 Function StartUninstallLog
michael@0 6174 FileOpen $fhUninstallLog "$INSTDIR\uninstall\uninstall.log" w
michael@0 6175 FunctionEnd
michael@0 6176
michael@0 6177 !verbose pop
michael@0 6178 !endif
michael@0 6179 !macroend
michael@0 6180
michael@0 6181 !macro StartUninstallLogCall
michael@0 6182 !verbose push
michael@0 6183 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6184 Call StartUninstallLog
michael@0 6185 !verbose pop
michael@0 6186 !macroend
michael@0 6187
michael@0 6188 /**
michael@0 6189 * Closes the file handle to the uninstall.log.
michael@0 6190 */
michael@0 6191 !macro EndUninstallLog
michael@0 6192
michael@0 6193 !ifndef EndUninstallLog
michael@0 6194
michael@0 6195 !verbose push
michael@0 6196 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6197 !define EndUninstallLog "!insertmacro EndUninstallLogCall"
michael@0 6198
michael@0 6199 Function EndUninstallLog
michael@0 6200 FileClose $fhUninstallLog
michael@0 6201 FunctionEnd
michael@0 6202
michael@0 6203 !verbose pop
michael@0 6204 !endif
michael@0 6205 !macroend
michael@0 6206
michael@0 6207 !macro EndUninstallLogCall
michael@0 6208 !verbose push
michael@0 6209 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6210 Call EndUninstallLog
michael@0 6211 !verbose pop
michael@0 6212 !macroend
michael@0 6213
michael@0 6214 /**
michael@0 6215 * Adds a section header to the human readable log.
michael@0 6216 *
michael@0 6217 * @param _HEADER
michael@0 6218 * The header text to write to the log.
michael@0 6219 */
michael@0 6220 !macro LogHeader _HEADER
michael@0 6221 ${WriteLogSeparator}
michael@0 6222 FileWriteUTF16LE $fhInstallLog "${_HEADER}"
michael@0 6223 ${WriteLogSeparator}
michael@0 6224 !macroend
michael@0 6225 !define LogHeader "!insertmacro LogHeader"
michael@0 6226
michael@0 6227 /**
michael@0 6228 * Adds a section message to the human readable log.
michael@0 6229 *
michael@0 6230 * @param _MSG
michael@0 6231 * The message text to write to the log.
michael@0 6232 */
michael@0 6233 !macro LogMsg _MSG
michael@0 6234 FileWriteUTF16LE $fhInstallLog " ${_MSG}$\r$\n"
michael@0 6235 !macroend
michael@0 6236 !define LogMsg "!insertmacro LogMsg"
michael@0 6237
michael@0 6238 /**
michael@0 6239 * Adds an uninstall entry to the uninstall log.
michael@0 6240 *
michael@0 6241 * @param _MSG
michael@0 6242 * The message text to write to the log.
michael@0 6243 */
michael@0 6244 !macro LogUninstall _MSG
michael@0 6245 FileWrite $fhUninstallLog "${_MSG}$\r$\n"
michael@0 6246 !macroend
michael@0 6247 !define LogUninstall "!insertmacro LogUninstall"
michael@0 6248
michael@0 6249 /**
michael@0 6250 * Adds a section divider to the human readable log.
michael@0 6251 */
michael@0 6252 !macro WriteLogSeparator
michael@0 6253 FileWriteUTF16LE $fhInstallLog "$\r$\n----------------------------------------\
michael@0 6254 ---------------------------------------$\r$\n"
michael@0 6255 !macroend
michael@0 6256 !define WriteLogSeparator "!insertmacro WriteLogSeparator"
michael@0 6257
michael@0 6258
michael@0 6259 ################################################################################
michael@0 6260 # Macros for managing the shortcuts log ini file
michael@0 6261
michael@0 6262 /**
michael@0 6263 * Adds the most commonly used shortcut logging macros for the installer in one
michael@0 6264 * fell swoop.
michael@0 6265 */
michael@0 6266 !macro _LoggingShortcutsCommon
michael@0 6267 !insertmacro LogDesktopShortcut
michael@0 6268 !insertmacro LogQuickLaunchShortcut
michael@0 6269 !insertmacro LogSMProgramsShortcut
michael@0 6270 !macroend
michael@0 6271 !define _LoggingShortcutsCommon "!insertmacro _LoggingShortcutsCommon"
michael@0 6272
michael@0 6273 /**
michael@0 6274 * Creates the shortcuts log ini file with a UTF-16LE BOM if it doesn't exist.
michael@0 6275 */
michael@0 6276 !macro initShortcutsLog
michael@0 6277 Push $R9
michael@0 6278
michael@0 6279 IfFileExists "$INSTDIR\uninstall\${SHORTCUTS_LOG}" +4 +1
michael@0 6280 FileOpen $R9 "$INSTDIR\uninstall\${SHORTCUTS_LOG}" w
michael@0 6281 FileWriteWord $R9 "65279"
michael@0 6282 FileClose $R9
michael@0 6283
michael@0 6284 Pop $R9
michael@0 6285 !macroend
michael@0 6286 !define initShortcutsLog "!insertmacro initShortcutsLog"
michael@0 6287
michael@0 6288 /**
michael@0 6289 * Adds shortcut entries to the shortcuts log ini file. This macro is primarily
michael@0 6290 * a helper used by the LogDesktopShortcut, LogQuickLaunchShortcut, and
michael@0 6291 * LogSMProgramsShortcut macros but it can be used by other code if desired. If
michael@0 6292 * the value already exists the the value is not written to the file.
michael@0 6293 *
michael@0 6294 * @param _SECTION_NAME
michael@0 6295 * The section name to write to in the shortcut log ini file
michael@0 6296 * @param _FILE_NAME
michael@0 6297 * The shortcut's file name
michael@0 6298 *
michael@0 6299 * $R6 = return value from ReadIniStr for the shortcut file name
michael@0 6300 * $R7 = counter for supporting multiple shortcuts in the same location
michael@0 6301 * $R8 = _SECTION_NAME
michael@0 6302 * $R9 = _FILE_NAME
michael@0 6303 */
michael@0 6304 !macro LogShortcut
michael@0 6305
michael@0 6306 !ifndef LogShortcut
michael@0 6307 !verbose push
michael@0 6308 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6309 !define LogShortcut "!insertmacro LogShortcutCall"
michael@0 6310
michael@0 6311 Function LogShortcut
michael@0 6312 Exch $R9
michael@0 6313 Exch 1
michael@0 6314 Exch $R8
michael@0 6315 Push $R7
michael@0 6316 Push $R6
michael@0 6317
michael@0 6318 ClearErrors
michael@0 6319
michael@0 6320 !insertmacro initShortcutsLog
michael@0 6321
michael@0 6322 StrCpy $R6 ""
michael@0 6323 StrCpy $R7 -1
michael@0 6324
michael@0 6325 StrCmp "$R6" "$R9" +5 +1 ; if the shortcut already exists don't add it
michael@0 6326 IntOp $R7 $R7 + 1 ; increment the counter
michael@0 6327 ReadIniStr $R6 "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "$R8" "Shortcut$R7"
michael@0 6328 IfErrors +1 -3
michael@0 6329 WriteINIStr "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "$R8" "Shortcut$R7" "$R9"
michael@0 6330
michael@0 6331 ClearErrors
michael@0 6332
michael@0 6333 Pop $R6
michael@0 6334 Pop $R7
michael@0 6335 Exch $R8
michael@0 6336 Exch 1
michael@0 6337 Exch $R9
michael@0 6338 FunctionEnd
michael@0 6339
michael@0 6340 !verbose pop
michael@0 6341 !endif
michael@0 6342 !macroend
michael@0 6343
michael@0 6344 !macro LogShortcutCall _SECTION_NAME _FILE_NAME
michael@0 6345 !verbose push
michael@0 6346 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6347 Push "${_SECTION_NAME}"
michael@0 6348 Push "${_FILE_NAME}"
michael@0 6349 Call LogShortcut
michael@0 6350 !verbose pop
michael@0 6351 !macroend
michael@0 6352
michael@0 6353 /**
michael@0 6354 * Adds a Desktop shortcut entry to the shortcuts log ini file.
michael@0 6355 *
michael@0 6356 * @param _FILE_NAME
michael@0 6357 * The shortcut file name (e.g. shortcut.lnk)
michael@0 6358 */
michael@0 6359 !macro LogDesktopShortcut
michael@0 6360
michael@0 6361 !ifndef LogDesktopShortcut
michael@0 6362 !insertmacro LogShortcut
michael@0 6363
michael@0 6364 !verbose push
michael@0 6365 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6366 !define LogDesktopShortcut "!insertmacro LogDesktopShortcutCall"
michael@0 6367
michael@0 6368 Function LogDesktopShortcut
michael@0 6369 Call LogShortcut
michael@0 6370 FunctionEnd
michael@0 6371
michael@0 6372 !verbose pop
michael@0 6373 !endif
michael@0 6374 !macroend
michael@0 6375
michael@0 6376 !macro LogDesktopShortcutCall _FILE_NAME
michael@0 6377 !verbose push
michael@0 6378 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6379 Push "DESKTOP"
michael@0 6380 Push "${_FILE_NAME}"
michael@0 6381 Call LogDesktopShortcut
michael@0 6382 !verbose pop
michael@0 6383 !macroend
michael@0 6384
michael@0 6385 /**
michael@0 6386 * Adds a QuickLaunch shortcut entry to the shortcuts log ini file.
michael@0 6387 *
michael@0 6388 * @param _FILE_NAME
michael@0 6389 * The shortcut file name (e.g. shortcut.lnk)
michael@0 6390 */
michael@0 6391 !macro LogQuickLaunchShortcut
michael@0 6392
michael@0 6393 !ifndef LogQuickLaunchShortcut
michael@0 6394 !insertmacro LogShortcut
michael@0 6395
michael@0 6396 !verbose push
michael@0 6397 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6398 !define LogQuickLaunchShortcut "!insertmacro LogQuickLaunchShortcutCall"
michael@0 6399
michael@0 6400 Function LogQuickLaunchShortcut
michael@0 6401 Call LogShortcut
michael@0 6402 FunctionEnd
michael@0 6403
michael@0 6404 !verbose pop
michael@0 6405 !endif
michael@0 6406 !macroend
michael@0 6407
michael@0 6408 !macro LogQuickLaunchShortcutCall _FILE_NAME
michael@0 6409 !verbose push
michael@0 6410 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6411 Push "QUICKLAUNCH"
michael@0 6412 Push "${_FILE_NAME}"
michael@0 6413 Call LogQuickLaunchShortcut
michael@0 6414 !verbose pop
michael@0 6415 !macroend
michael@0 6416
michael@0 6417 /**
michael@0 6418 * Adds a Start Menu shortcut entry to the shortcuts log ini file.
michael@0 6419 *
michael@0 6420 * @param _FILE_NAME
michael@0 6421 * The shortcut file name (e.g. shortcut.lnk)
michael@0 6422 */
michael@0 6423 !macro LogStartMenuShortcut
michael@0 6424
michael@0 6425 !ifndef LogStartMenuShortcut
michael@0 6426 !insertmacro LogShortcut
michael@0 6427
michael@0 6428 !verbose push
michael@0 6429 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6430 !define LogStartMenuShortcut "!insertmacro LogStartMenuShortcutCall"
michael@0 6431
michael@0 6432 Function LogStartMenuShortcut
michael@0 6433 Call LogShortcut
michael@0 6434 FunctionEnd
michael@0 6435
michael@0 6436 !verbose pop
michael@0 6437 !endif
michael@0 6438 !macroend
michael@0 6439
michael@0 6440 !macro LogStartMenuShortcutCall _FILE_NAME
michael@0 6441 !verbose push
michael@0 6442 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6443 Push "STARTMENU"
michael@0 6444 Push "${_FILE_NAME}"
michael@0 6445 Call LogStartMenuShortcut
michael@0 6446 !verbose pop
michael@0 6447 !macroend
michael@0 6448
michael@0 6449 /**
michael@0 6450 * Adds a Start Menu Programs shortcut entry to the shortcuts log ini file.
michael@0 6451 *
michael@0 6452 * @param _FILE_NAME
michael@0 6453 * The shortcut file name (e.g. shortcut.lnk)
michael@0 6454 */
michael@0 6455 !macro LogSMProgramsShortcut
michael@0 6456
michael@0 6457 !ifndef LogSMProgramsShortcut
michael@0 6458 !insertmacro LogShortcut
michael@0 6459
michael@0 6460 !verbose push
michael@0 6461 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6462 !define LogSMProgramsShortcut "!insertmacro LogSMProgramsShortcutCall"
michael@0 6463
michael@0 6464 Function LogSMProgramsShortcut
michael@0 6465 Call LogShortcut
michael@0 6466 FunctionEnd
michael@0 6467
michael@0 6468 !verbose pop
michael@0 6469 !endif
michael@0 6470 !macroend
michael@0 6471
michael@0 6472 !macro LogSMProgramsShortcutCall _FILE_NAME
michael@0 6473 !verbose push
michael@0 6474 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6475 Push "SMPROGRAMS"
michael@0 6476 Push "${_FILE_NAME}"
michael@0 6477 Call LogSMProgramsShortcut
michael@0 6478 !verbose pop
michael@0 6479 !macroend
michael@0 6480
michael@0 6481 /**
michael@0 6482 * Adds the relative path from the Start Menu Programs directory for the
michael@0 6483 * application's Start Menu directory if it is different from the existing value
michael@0 6484 * to the shortcuts log ini file.
michael@0 6485 *
michael@0 6486 * @param _REL_PATH_TO_DIR
michael@0 6487 * The relative path from the Start Menu Programs directory to the
michael@0 6488 * program's directory.
michael@0 6489 *
michael@0 6490 * $R9 = _REL_PATH_TO_DIR
michael@0 6491 */
michael@0 6492 !macro LogSMProgramsDirRelPath _REL_PATH_TO_DIR
michael@0 6493 Push $R9
michael@0 6494
michael@0 6495 !insertmacro initShortcutsLog
michael@0 6496
michael@0 6497 ReadINIStr $R9 "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "SMPROGRAMS" "RelativePathToDir"
michael@0 6498 StrCmp "$R9" "${_REL_PATH_TO_DIR}" +2 +1
michael@0 6499 WriteINIStr "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "SMPROGRAMS" "RelativePathToDir" "${_REL_PATH_TO_DIR}"
michael@0 6500
michael@0 6501 Pop $R9
michael@0 6502 !macroend
michael@0 6503 !define LogSMProgramsDirRelPath "!insertmacro LogSMProgramsDirRelPath"
michael@0 6504
michael@0 6505 /**
michael@0 6506 * Copies the value for the relative path from the Start Menu programs directory
michael@0 6507 * (e.g. $SMPROGRAMS) to the Start Menu directory as it is stored in the
michael@0 6508 * shortcuts log ini file to the variable specified in the first parameter.
michael@0 6509 */
michael@0 6510 !macro GetSMProgramsDirRelPath _VAR
michael@0 6511 ReadINIStr ${_VAR} "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "SMPROGRAMS" \
michael@0 6512 "RelativePathToDir"
michael@0 6513 !macroend
michael@0 6514 !define GetSMProgramsDirRelPath "!insertmacro GetSMProgramsDirRelPath"
michael@0 6515
michael@0 6516 /**
michael@0 6517 * Copies the shortcuts log ini file path to the variable specified in the
michael@0 6518 * first parameter.
michael@0 6519 */
michael@0 6520 !macro GetShortcutsLogPath _VAR
michael@0 6521 StrCpy ${_VAR} "$INSTDIR\uninstall\${SHORTCUTS_LOG}"
michael@0 6522 !macroend
michael@0 6523 !define GetShortcutsLogPath "!insertmacro GetShortcutsLogPath"
michael@0 6524
michael@0 6525 /**
michael@0 6526 * Deletes the shortcuts log ini file.
michael@0 6527 */
michael@0 6528 !macro DeleteShortcutsLogFile
michael@0 6529 ${DeleteFile} "$INSTDIR\uninstall\${SHORTCUTS_LOG}"
michael@0 6530 !macroend
michael@0 6531 !define DeleteShortcutsLogFile "!insertmacro DeleteShortcutsLogFile"
michael@0 6532
michael@0 6533
michael@0 6534 ################################################################################
michael@0 6535 # Macros for managing specific Windows version features
michael@0 6536
michael@0 6537 /**
michael@0 6538 * Sets the permitted layered service provider (LSP) categories on Windows
michael@0 6539 * Vista and above for the application. Consumers should call this after an
michael@0 6540 * installation log section has completed since this macro will log the results
michael@0 6541 * to the installation log along with a header.
michael@0 6542 *
michael@0 6543 * !IMPORTANT - When calling this macro from an uninstaller do not specify a
michael@0 6544 * parameter. The paramter is hardcoded with 0x00000000 to remove
michael@0 6545 * the LSP category for the application when performing an
michael@0 6546 * uninstall.
michael@0 6547 *
michael@0 6548 * @param _LSP_CATEGORIES
michael@0 6549 * The permitted LSP categories for the application. When called by an
michael@0 6550 * uninstaller this will always be 0x00000000.
michael@0 6551 *
michael@0 6552 * $R5 = error code popped from the stack for the WSCSetApplicationCategory call
michael@0 6553 * $R6 = return value from the WSCSetApplicationCategory call
michael@0 6554 * $R7 = string length for the long path to the main application executable
michael@0 6555 * $R8 = long path to the main application executable
michael@0 6556 * $R9 = _LSP_CATEGORIES
michael@0 6557 */
michael@0 6558 !macro SetAppLSPCategories
michael@0 6559
michael@0 6560 !ifndef ${_MOZFUNC_UN}SetAppLSPCategories
michael@0 6561 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 6562 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 6563 !undef _MOZFUNC_UN
michael@0 6564 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 6565 !undef _MOZFUNC_UN_TMP
michael@0 6566
michael@0 6567 !verbose push
michael@0 6568 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6569 !define ${_MOZFUNC_UN}SetAppLSPCategories "!insertmacro ${_MOZFUNC_UN}SetAppLSPCategoriesCall"
michael@0 6570
michael@0 6571 Function ${_MOZFUNC_UN}SetAppLSPCategories
michael@0 6572 ${Unless} ${AtLeastWinVista}
michael@0 6573 Return
michael@0 6574 ${EndUnless}
michael@0 6575
michael@0 6576 Exch $R9
michael@0 6577 Push $R8
michael@0 6578 Push $R7
michael@0 6579 Push $R6
michael@0 6580 Push $R5
michael@0 6581
michael@0 6582 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR\${FileMainEXE}" $R8
michael@0 6583 StrLen $R7 "$R8"
michael@0 6584
michael@0 6585 ; Remove existing categories by setting the permitted categories to
michael@0 6586 ; 0x00000000 since new categories are ANDed with existing categories. If
michael@0 6587 ; the param value stored in $R9 is 0x00000000 then skip the removal since
michael@0 6588 ; the categories will be removed by the second call to
michael@0 6589 ; WSCSetApplicationCategory.
michael@0 6590 StrCmp "$R9" "0x00000000" +2 +1
michael@0 6591 System::Call "Ws2_32::WSCSetApplicationCategory(w R8, i R7, w n, i 0,\
michael@0 6592 i 0x00000000, i n, *i) i"
michael@0 6593
michael@0 6594 ; Set the permitted LSP categories
michael@0 6595 System::Call "Ws2_32::WSCSetApplicationCategory(w R8, i R7, w n, i 0,\
michael@0 6596 i R9, i n, *i .s) i.R6"
michael@0 6597 Pop $R5
michael@0 6598
michael@0 6599 !ifndef NO_LOG
michael@0 6600 ${LogHeader} "Setting Permitted LSP Categories"
michael@0 6601 StrCmp "$R6" 0 +3 +1
michael@0 6602 ${LogMsg} "** ERROR Setting LSP Categories: $R5 **"
michael@0 6603 GoTo +2
michael@0 6604 ${LogMsg} "Permitted LSP Categories: $R9"
michael@0 6605 !endif
michael@0 6606
michael@0 6607 ClearErrors
michael@0 6608
michael@0 6609 Pop $R5
michael@0 6610 Pop $R6
michael@0 6611 Pop $R7
michael@0 6612 Pop $R8
michael@0 6613 Exch $R9
michael@0 6614 FunctionEnd
michael@0 6615
michael@0 6616 !verbose pop
michael@0 6617 !endif
michael@0 6618 !macroend
michael@0 6619
michael@0 6620 !macro SetAppLSPCategoriesCall _LSP_CATEGORIES
michael@0 6621 !verbose push
michael@0 6622 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6623 Push "${_LSP_CATEGORIES}"
michael@0 6624 Call SetAppLSPCategories
michael@0 6625 !verbose pop
michael@0 6626 !macroend
michael@0 6627
michael@0 6628 !macro un.SetAppLSPCategoriesCall
michael@0 6629 !verbose push
michael@0 6630 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6631 Push "0x00000000"
michael@0 6632 Call un.SetAppLSPCategories
michael@0 6633 !verbose pop
michael@0 6634 !macroend
michael@0 6635
michael@0 6636 !macro un.SetAppLSPCategories
michael@0 6637 !ifndef un.SetAppLSPCategories
michael@0 6638 !verbose push
michael@0 6639 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6640 !undef _MOZFUNC_UN
michael@0 6641 !define _MOZFUNC_UN "un."
michael@0 6642
michael@0 6643 !insertmacro SetAppLSPCategories
michael@0 6644
michael@0 6645 !undef _MOZFUNC_UN
michael@0 6646 !define _MOZFUNC_UN
michael@0 6647 !verbose pop
michael@0 6648 !endif
michael@0 6649 !macroend
michael@0 6650
michael@0 6651 /**
michael@0 6652 * Checks if any pinned TaskBar lnk files point to the executable's path passed
michael@0 6653 * to the macro.
michael@0 6654 *
michael@0 6655 * @param _EXE_PATH
michael@0 6656 * The executable path
michael@0 6657 * @return _RESULT
michael@0 6658 * false if no pinned shotcuts were found for this install location.
michael@0 6659 * true if pinned shotcuts were found for this install location.
michael@0 6660 *
michael@0 6661 * $R5 = stores whether a TaskBar lnk file has been found for the executable
michael@0 6662 * $R6 = long path returned from GetShortCutTarget and GetLongPath
michael@0 6663 * $R7 = file name returned from FindFirst and FindNext
michael@0 6664 * $R8 = find handle for FindFirst and FindNext
michael@0 6665 * $R9 = _EXE_PATH and _RESULT
michael@0 6666 */
michael@0 6667 !macro IsPinnedToTaskBar
michael@0 6668
michael@0 6669 !ifndef IsPinnedToTaskBar
michael@0 6670 !insertmacro GetLongPath
michael@0 6671
michael@0 6672 !verbose push
michael@0 6673 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6674 !define IsPinnedToTaskBar "!insertmacro IsPinnedToTaskBarCall"
michael@0 6675
michael@0 6676 Function IsPinnedToTaskBar
michael@0 6677 Exch $R9
michael@0 6678 Push $R8
michael@0 6679 Push $R7
michael@0 6680 Push $R6
michael@0 6681 Push $R5
michael@0 6682
michael@0 6683 StrCpy $R5 "false"
michael@0 6684
michael@0 6685 ${If} ${AtLeastWin7}
michael@0 6686 ${AndIf} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar"
michael@0 6687 FindFirst $R8 $R7 "$QUICKLAUNCH\User Pinned\TaskBar\*.lnk"
michael@0 6688 ${Do}
michael@0 6689 ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar\$R7"
michael@0 6690 ShellLink::GetShortCutTarget "$QUICKLAUNCH\User Pinned\TaskBar\$R7"
michael@0 6691 Pop $R6
michael@0 6692 ${GetLongPath} "$R6" $R6
michael@0 6693 ${If} "$R6" == "$R9"
michael@0 6694 StrCpy $R5 "true"
michael@0 6695 ${ExitDo}
michael@0 6696 ${EndIf}
michael@0 6697 ${EndIf}
michael@0 6698 ClearErrors
michael@0 6699 FindNext $R8 $R7
michael@0 6700 ${If} ${Errors}
michael@0 6701 ${ExitDo}
michael@0 6702 ${EndIf}
michael@0 6703 ${Loop}
michael@0 6704 FindClose $R8
michael@0 6705 ${EndIf}
michael@0 6706
michael@0 6707 ClearErrors
michael@0 6708
michael@0 6709 StrCpy $R9 $R5
michael@0 6710
michael@0 6711 Pop $R5
michael@0 6712 Pop $R6
michael@0 6713 Pop $R7
michael@0 6714 Pop $R8
michael@0 6715 Exch $R9
michael@0 6716 FunctionEnd
michael@0 6717
michael@0 6718 !verbose pop
michael@0 6719 !endif
michael@0 6720 !macroend
michael@0 6721
michael@0 6722 !macro IsPinnedToTaskBarCall _EXE_PATH _RESULT
michael@0 6723 !verbose push
michael@0 6724 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6725 Push "${_EXE_PATH}"
michael@0 6726 Call IsPinnedToTaskBar
michael@0 6727 Pop ${_RESULT}
michael@0 6728 !verbose pop
michael@0 6729 !macroend
michael@0 6730
michael@0 6731 /**
michael@0 6732 * Checks if any pinned Start Menu lnk files point to the executable's path
michael@0 6733 * passed to the macro.
michael@0 6734 *
michael@0 6735 * @param _EXE_PATH
michael@0 6736 * The executable path
michael@0 6737 * @return _RESULT
michael@0 6738 * false if no pinned shotcuts were found for this install location.
michael@0 6739 * true if pinned shotcuts were found for this install location.
michael@0 6740 *
michael@0 6741 * $R5 = stores whether a Start Menu lnk file has been found for the executable
michael@0 6742 * $R6 = long path returned from GetShortCutTarget and GetLongPath
michael@0 6743 * $R7 = file name returned from FindFirst and FindNext
michael@0 6744 * $R8 = find handle for FindFirst and FindNext
michael@0 6745 * $R9 = _EXE_PATH and _RESULT
michael@0 6746 */
michael@0 6747 !macro IsPinnedToStartMenu
michael@0 6748
michael@0 6749 !ifndef IsPinnedToStartMenu
michael@0 6750 !insertmacro GetLongPath
michael@0 6751
michael@0 6752 !verbose push
michael@0 6753 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6754 !define IsPinnedToStartMenu "!insertmacro IsPinnedToStartMenuCall"
michael@0 6755
michael@0 6756 Function IsPinnedToStartMenu
michael@0 6757 Exch $R9
michael@0 6758 Push $R8
michael@0 6759 Push $R7
michael@0 6760 Push $R6
michael@0 6761 Push $R5
michael@0 6762
michael@0 6763 StrCpy $R5 "false"
michael@0 6764
michael@0 6765 ${If} ${AtLeastWin7}
michael@0 6766 ${AndIf} ${FileExists} "$QUICKLAUNCH\User Pinned\StartMenu"
michael@0 6767 FindFirst $R8 $R7 "$QUICKLAUNCH\User Pinned\StartMenu\*.lnk"
michael@0 6768 ${Do}
michael@0 6769 ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\StartMenu\$R7"
michael@0 6770 ShellLink::GetShortCutTarget "$QUICKLAUNCH\User Pinned\StartMenu\$R7"
michael@0 6771 Pop $R6
michael@0 6772 ${GetLongPath} "$R6" $R6
michael@0 6773 ${If} "$R6" == "$R9"
michael@0 6774 StrCpy $R5 "true"
michael@0 6775 ${ExitDo}
michael@0 6776 ${EndIf}
michael@0 6777 ${EndIf}
michael@0 6778 ClearErrors
michael@0 6779 FindNext $R8 $R7
michael@0 6780 ${If} ${Errors}
michael@0 6781 ${ExitDo}
michael@0 6782 ${EndIf}
michael@0 6783 ${Loop}
michael@0 6784 FindClose $R8
michael@0 6785 ${EndIf}
michael@0 6786
michael@0 6787 ClearErrors
michael@0 6788
michael@0 6789 StrCpy $R9 $R5
michael@0 6790
michael@0 6791 Pop $R5
michael@0 6792 Pop $R6
michael@0 6793 Pop $R7
michael@0 6794 Pop $R8
michael@0 6795 Exch $R9
michael@0 6796 FunctionEnd
michael@0 6797
michael@0 6798 !verbose pop
michael@0 6799 !endif
michael@0 6800 !macroend
michael@0 6801
michael@0 6802 !macro IsPinnedToStartMenuCall _EXE_PATH _RESULT
michael@0 6803 !verbose push
michael@0 6804 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6805 Push "${_EXE_PATH}"
michael@0 6806 Call IsPinnedToStartMenu
michael@0 6807 Pop ${_RESULT}
michael@0 6808 !verbose pop
michael@0 6809 !macroend
michael@0 6810
michael@0 6811 /**
michael@0 6812 * Gets the number of pinned shortcut lnk files pinned to the Task Bar.
michael@0 6813 *
michael@0 6814 * @return _RESULT
michael@0 6815 * number of pinned shortcut lnk files.
michael@0 6816 *
michael@0 6817 * $R7 = file name returned from FindFirst and FindNext
michael@0 6818 * $R8 = find handle for FindFirst and FindNext
michael@0 6819 * $R9 = _RESULT
michael@0 6820 */
michael@0 6821 !macro PinnedToTaskBarLnkCount
michael@0 6822
michael@0 6823 !ifndef PinnedToTaskBarLnkCount
michael@0 6824 !insertmacro GetLongPath
michael@0 6825
michael@0 6826 !verbose push
michael@0 6827 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6828 !define PinnedToTaskBarLnkCount "!insertmacro PinnedToTaskBarLnkCountCall"
michael@0 6829
michael@0 6830 Function PinnedToTaskBarLnkCount
michael@0 6831 Push $R9
michael@0 6832 Push $R8
michael@0 6833 Push $R7
michael@0 6834
michael@0 6835 StrCpy $R9 0
michael@0 6836
michael@0 6837 ${If} ${AtLeastWin7}
michael@0 6838 ${AndIf} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar"
michael@0 6839 FindFirst $R8 $R7 "$QUICKLAUNCH\User Pinned\TaskBar\*.lnk"
michael@0 6840 ${Do}
michael@0 6841 ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar\$R7"
michael@0 6842 IntOp $R9 $R9 + 1
michael@0 6843 ${EndIf}
michael@0 6844 ClearErrors
michael@0 6845 FindNext $R8 $R7
michael@0 6846 ${If} ${Errors}
michael@0 6847 ${ExitDo}
michael@0 6848 ${EndIf}
michael@0 6849 ${Loop}
michael@0 6850 FindClose $R8
michael@0 6851 ${EndIf}
michael@0 6852
michael@0 6853 ClearErrors
michael@0 6854
michael@0 6855 Pop $R7
michael@0 6856 Pop $R8
michael@0 6857 Exch $R9
michael@0 6858 FunctionEnd
michael@0 6859
michael@0 6860 !verbose pop
michael@0 6861 !endif
michael@0 6862 !macroend
michael@0 6863
michael@0 6864 !macro PinnedToTaskBarLnkCountCall _RESULT
michael@0 6865 !verbose push
michael@0 6866 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6867 Call PinnedToTaskBarLnkCount
michael@0 6868 Pop ${_RESULT}
michael@0 6869 !verbose pop
michael@0 6870 !macroend
michael@0 6871
michael@0 6872 /**
michael@0 6873 * Gets the number of pinned shortcut lnk files pinned to the Start Menu.
michael@0 6874 *
michael@0 6875 * @return _RESULT
michael@0 6876 * number of pinned shortcut lnk files.
michael@0 6877 *
michael@0 6878 * $R7 = file name returned from FindFirst and FindNext
michael@0 6879 * $R8 = find handle for FindFirst and FindNext
michael@0 6880 * $R9 = _RESULT
michael@0 6881 */
michael@0 6882 !macro PinnedToStartMenuLnkCount
michael@0 6883
michael@0 6884 !ifndef PinnedToStartMenuLnkCount
michael@0 6885 !insertmacro GetLongPath
michael@0 6886
michael@0 6887 !verbose push
michael@0 6888 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6889 !define PinnedToStartMenuLnkCount "!insertmacro PinnedToStartMenuLnkCountCall"
michael@0 6890
michael@0 6891 Function PinnedToStartMenuLnkCount
michael@0 6892 Push $R9
michael@0 6893 Push $R8
michael@0 6894 Push $R7
michael@0 6895
michael@0 6896 StrCpy $R9 0
michael@0 6897
michael@0 6898 ${If} ${AtLeastWin7}
michael@0 6899 ${AndIf} ${FileExists} "$QUICKLAUNCH\User Pinned\StartMenu"
michael@0 6900 FindFirst $R8 $R7 "$QUICKLAUNCH\User Pinned\StartMenu\*.lnk"
michael@0 6901 ${Do}
michael@0 6902 ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\StartMenu\$R7"
michael@0 6903 IntOp $R9 $R9 + 1
michael@0 6904 ${EndIf}
michael@0 6905 ClearErrors
michael@0 6906 FindNext $R8 $R7
michael@0 6907 ${If} ${Errors}
michael@0 6908 ${ExitDo}
michael@0 6909 ${EndIf}
michael@0 6910 ${Loop}
michael@0 6911 FindClose $R8
michael@0 6912 ${EndIf}
michael@0 6913
michael@0 6914 ClearErrors
michael@0 6915
michael@0 6916 Pop $R7
michael@0 6917 Pop $R8
michael@0 6918 Exch $R9
michael@0 6919 FunctionEnd
michael@0 6920
michael@0 6921 !verbose pop
michael@0 6922 !endif
michael@0 6923 !macroend
michael@0 6924
michael@0 6925 !macro PinnedToStartMenuLnkCountCall _RESULT
michael@0 6926 !verbose push
michael@0 6927 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6928 Call PinnedToStartMenuLnkCount
michael@0 6929 Pop ${_RESULT}
michael@0 6930 !verbose pop
michael@0 6931 !macroend
michael@0 6932
michael@0 6933 /**
michael@0 6934 * Update Start Menu / TaskBar lnk files that point to the executable's path
michael@0 6935 * passed to the macro and all other shortcuts installed by the application with
michael@0 6936 * the current application user model ID. Requires ApplicationID.
michael@0 6937 *
michael@0 6938 * NOTE: this does not update Desktop shortcut application user model ID due to
michael@0 6939 * bug 633728.
michael@0 6940 *
michael@0 6941 * @param _EXE_PATH
michael@0 6942 * The main application executable path
michael@0 6943 * @param _APP_ID
michael@0 6944 * The application user model ID for the current install
michael@0 6945 * @return _RESULT
michael@0 6946 * false if no pinned shotcuts were found for this install location.
michael@0 6947 * true if pinned shotcuts were found for this install location.
michael@0 6948 */
michael@0 6949 !macro UpdateShortcutAppModelIDs
michael@0 6950
michael@0 6951 !ifndef UpdateShortcutAppModelIDs
michael@0 6952 !insertmacro GetLongPath
michael@0 6953
michael@0 6954 !verbose push
michael@0 6955 !verbose ${_MOZFUNC_VERBOSE}
michael@0 6956 !define UpdateShortcutAppModelIDs "!insertmacro UpdateShortcutAppModelIDsCall"
michael@0 6957
michael@0 6958 Function UpdateShortcutAppModelIDs
michael@0 6959 ; stack: path, appid
michael@0 6960 Exch $R9 ; stack: $R9, appid | $R9 = path
michael@0 6961 Exch 1 ; stack: appid, $R9
michael@0 6962 Exch $R8 ; stack: $R8, $R9 | $R8 = appid
michael@0 6963 Push $R7 ; stack: $R7, $R8, $R9
michael@0 6964 Push $R6
michael@0 6965 Push $R5
michael@0 6966 Push $R4
michael@0 6967 Push $R3 ; stack: $R3, $R5, $R6, $R7, $R8, $R9
michael@0 6968 Push $R2
michael@0 6969
michael@0 6970 ; $R9 = main application executable path
michael@0 6971 ; $R8 = appid
michael@0 6972 ; $R7 = path to the application's start menu programs directory
michael@0 6973 ; $R6 = path to the shortcut log ini file
michael@0 6974 ; $R5 = shortcut filename
michael@0 6975 ; $R4 = GetShortCutTarget result
michael@0 6976
michael@0 6977 StrCpy $R3 "false"
michael@0 6978
michael@0 6979 ${If} ${AtLeastWin7}
michael@0 6980 ; installed shortcuts
michael@0 6981 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR\uninstall\${SHORTCUTS_LOG}" $R6
michael@0 6982 ${If} ${FileExists} "$R6"
michael@0 6983 ; Update the Start Menu shortcuts' App ID for this application
michael@0 6984 StrCpy $R2 -1
michael@0 6985 ${Do}
michael@0 6986 IntOp $R2 $R2 + 1 ; Increment the counter
michael@0 6987 ClearErrors
michael@0 6988 ReadINIStr $R5 "$R6" "STARTMENU" "Shortcut$R2"
michael@0 6989 ${If} ${Errors}
michael@0 6990 ${ExitDo}
michael@0 6991 ${EndIf}
michael@0 6992
michael@0 6993 ${If} ${FileExists} "$SMPROGRAMS\$R5"
michael@0 6994 ShellLink::GetShortCutTarget "$SMPROGRAMS\$$R5"
michael@0 6995 Pop $R4
michael@0 6996 ${GetLongPath} "$R4" $R4
michael@0 6997 ${If} "$R4" == "$R9" ; link path == install path
michael@0 6998 ApplicationID::Set "$SMPROGRAMS\$R5" "$R8"
michael@0 6999 Pop $R4
michael@0 7000 ${EndIf}
michael@0 7001 ${EndIf}
michael@0 7002 ${Loop}
michael@0 7003
michael@0 7004 ; Update the Quick Launch shortcuts' App ID for this application
michael@0 7005 StrCpy $R2 -1
michael@0 7006 ${Do}
michael@0 7007 IntOp $R2 $R2 + 1 ; Increment the counter
michael@0 7008 ClearErrors
michael@0 7009 ReadINIStr $R5 "$R6" "QUICKLAUNCH" "Shortcut$R2"
michael@0 7010 ${If} ${Errors}
michael@0 7011 ${ExitDo}
michael@0 7012 ${EndIf}
michael@0 7013
michael@0 7014 ${If} ${FileExists} "$QUICKLAUNCH\$R5"
michael@0 7015 ShellLink::GetShortCutTarget "$QUICKLAUNCH\$R5"
michael@0 7016 Pop $R4
michael@0 7017 ${GetLongPath} "$R4" $R4
michael@0 7018 ${If} "$R4" == "$R9" ; link path == install path
michael@0 7019 ApplicationID::Set "$QUICKLAUNCH\$R5" "$R8"
michael@0 7020 Pop $R4
michael@0 7021 ${EndIf}
michael@0 7022 ${EndIf}
michael@0 7023 ${Loop}
michael@0 7024
michael@0 7025 ; Update the Start Menu Programs shortcuts' App ID for this application
michael@0 7026 ClearErrors
michael@0 7027 ReadINIStr $R7 "$R6" "SMPROGRAMS" "RelativePathToDir"
michael@0 7028 ${Unless} ${Errors}
michael@0 7029 ${${_MOZFUNC_UN}GetLongPath} "$SMPROGRAMS\$R7" $R7
michael@0 7030 ${Unless} "$R7" == ""
michael@0 7031 StrCpy $R2 -1
michael@0 7032 ${Do}
michael@0 7033 IntOp $R2 $R2 + 1 ; Increment the counter
michael@0 7034 ClearErrors
michael@0 7035 ReadINIStr $R5 "$R6" "SMPROGRAMS" "Shortcut$R2"
michael@0 7036 ${If} ${Errors}
michael@0 7037 ${ExitDo}
michael@0 7038 ${EndIf}
michael@0 7039
michael@0 7040 ${If} ${FileExists} "$R7\$R5"
michael@0 7041 ShellLink::GetShortCutTarget "$R7\$R5"
michael@0 7042 Pop $R4
michael@0 7043 ${GetLongPath} "$R4" $R4
michael@0 7044 ${If} "$R4" == "$R9" ; link path == install path
michael@0 7045 ApplicationID::Set "$R7\$R5" "$R8"
michael@0 7046 Pop $R4
michael@0 7047 ${EndIf}
michael@0 7048 ${EndIf}
michael@0 7049 ${Loop}
michael@0 7050 ${EndUnless}
michael@0 7051 ${EndUnless}
michael@0 7052 ${EndIf}
michael@0 7053
michael@0 7054 StrCpy $R7 "$QUICKLAUNCH\User Pinned"
michael@0 7055 StrCpy $R3 "false"
michael@0 7056
michael@0 7057 ; $R9 = main application executable path
michael@0 7058 ; $R8 = appid
michael@0 7059 ; $R7 = user pinned path
michael@0 7060 ; $R6 = find handle
michael@0 7061 ; $R5 = found filename
michael@0 7062 ; $R4 = GetShortCutTarget result
michael@0 7063
michael@0 7064 ; TaskBar links
michael@0 7065 FindFirst $R6 $R5 "$R7\TaskBar\*.lnk"
michael@0 7066 ${Do}
michael@0 7067 ${If} ${FileExists} "$R7\TaskBar\$R5"
michael@0 7068 ShellLink::GetShortCutTarget "$R7\TaskBar\$R5"
michael@0 7069 Pop $R4
michael@0 7070 ${If} "$R4" == "$R9" ; link path == install path
michael@0 7071 ApplicationID::Set "$R7\TaskBar\$R5" "$R8"
michael@0 7072 Pop $R4 ; pop Set result off the stack
michael@0 7073 StrCpy $R3 "true"
michael@0 7074 ${EndIf}
michael@0 7075 ${EndIf}
michael@0 7076 ClearErrors
michael@0 7077 FindNext $R6 $R5
michael@0 7078 ${If} ${Errors}
michael@0 7079 ${ExitDo}
michael@0 7080 ${EndIf}
michael@0 7081 ${Loop}
michael@0 7082 FindClose $R6
michael@0 7083
michael@0 7084 ; Start menu links
michael@0 7085 FindFirst $R6 $R5 "$R7\StartMenu\*.lnk"
michael@0 7086 ${Do}
michael@0 7087 ${If} ${FileExists} "$R7\StartMenu\$R5"
michael@0 7088 ShellLink::GetShortCutTarget "$R7\StartMenu\$R5"
michael@0 7089 Pop $R4
michael@0 7090 ${If} "$R4" == "$R9" ; link path == install path
michael@0 7091 ApplicationID::Set "$R7\StartMenu\$R5" "$R8"
michael@0 7092 Pop $R4 ; pop Set result off the stack
michael@0 7093 StrCpy $R3 "true"
michael@0 7094 ${EndIf}
michael@0 7095 ${EndIf}
michael@0 7096 ClearErrors
michael@0 7097 FindNext $R6 $R5
michael@0 7098 ${If} ${Errors}
michael@0 7099 ${ExitDo}
michael@0 7100 ${EndIf}
michael@0 7101 ${Loop}
michael@0 7102 FindClose $R6
michael@0 7103 ${EndIf}
michael@0 7104
michael@0 7105 ClearErrors
michael@0 7106
michael@0 7107 StrCpy $R9 $R3
michael@0 7108
michael@0 7109 Pop $R2
michael@0 7110 Pop $R3 ; stack: $R4, $R5, $R6, $R7, $R8, $R9
michael@0 7111 Pop $R4 ; stack: $R5, $R6, $R7, $R8, $R9
michael@0 7112 Pop $R5 ; stack: $R6, $R7, $R8, $R9
michael@0 7113 Pop $R6 ; stack: $R7, $R8, $R9
michael@0 7114 Pop $R7 ; stack: $R8, $R9
michael@0 7115 Exch $R8 ; stack: appid, $R9 | $R8 = old $R8
michael@0 7116 Exch 1 ; stack: $R9, appid
michael@0 7117 Exch $R9 ; stack: path, appid | $R9 = old $R9
michael@0 7118 FunctionEnd
michael@0 7119
michael@0 7120 !verbose pop
michael@0 7121 !endif
michael@0 7122 !macroend
michael@0 7123
michael@0 7124 !macro UpdateShortcutAppModelIDsCall _EXE_PATH _APP_ID _RESULT
michael@0 7125 !verbose push
michael@0 7126 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7127 Push "${_APP_ID}"
michael@0 7128 Push "${_EXE_PATH}"
michael@0 7129 Call UpdateShortcutAppModelIDs
michael@0 7130 Pop ${_RESULT}
michael@0 7131 !verbose pop
michael@0 7132 !macroend
michael@0 7133
michael@0 7134 !macro IsUserAdmin
michael@0 7135 ; Copied from: http://nsis.sourceforge.net/IsUserAdmin
michael@0 7136 Function IsUserAdmin
michael@0 7137 Push $R0
michael@0 7138 Push $R1
michael@0 7139 Push $R2
michael@0 7140
michael@0 7141 ClearErrors
michael@0 7142 UserInfo::GetName
michael@0 7143 IfErrors Win9x
michael@0 7144 Pop $R1
michael@0 7145 UserInfo::GetAccountType
michael@0 7146 Pop $R2
michael@0 7147
michael@0 7148 StrCmp $R2 "Admin" 0 Continue
michael@0 7149 StrCpy $R0 "true"
michael@0 7150 Goto Done
michael@0 7151
michael@0 7152 Continue:
michael@0 7153
michael@0 7154 StrCmp $R2 "" Win9x
michael@0 7155 StrCpy $R0 "false"
michael@0 7156 Goto Done
michael@0 7157
michael@0 7158 Win9x:
michael@0 7159 StrCpy $R0 "true"
michael@0 7160
michael@0 7161 Done:
michael@0 7162 Pop $R2
michael@0 7163 Pop $R1
michael@0 7164 Exch $R0
michael@0 7165 FunctionEnd
michael@0 7166 !macroend
michael@0 7167
michael@0 7168 /**
michael@0 7169 * Retrieve if present or generate and store a 64 bit hash of an install path
michael@0 7170 * using the City Hash algorithm. On return the resulting id is saved in the
michael@0 7171 * $AppUserModelID variable declared by inserting this macro. InitHashAppModelId
michael@0 7172 * will attempt to load from HKLM/_REG_PATH first, then HKCU/_REG_PATH. If found
michael@0 7173 * in either it will return the hash it finds. If not found it will generate a
michael@0 7174 * new hash and attempt to store the hash in HKLM/_REG_PATH, then HKCU/_REG_PATH.
michael@0 7175 * Subsequent calls will then retreive the stored hash value. On any failure,
michael@0 7176 * $AppUserModelID will be set to an empty string.
michael@0 7177 *
michael@0 7178 * Registry format: root/_REG_PATH/"_EXE_PATH" = "hash"
michael@0 7179 *
michael@0 7180 * @param _EXE_PATH
michael@0 7181 * The main application executable path
michael@0 7182 * @param _REG_PATH
michael@0 7183 * The HKLM/HKCU agnostic registry path where the key hash should
michael@0 7184 * be stored. ex: "Software\Mozilla\Firefox\TaskBarIDs"
michael@0 7185 * @result (Var) $AppUserModelID contains the app model id.
michael@0 7186 */
michael@0 7187 !macro InitHashAppModelId
michael@0 7188 !ifndef ${_MOZFUNC_UN}InitHashAppModelId
michael@0 7189 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 7190 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
michael@0 7191 !undef _MOZFUNC_UN
michael@0 7192 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 7193 !undef _MOZFUNC_UN_TMP
michael@0 7194
michael@0 7195 !ifndef InitHashAppModelId
michael@0 7196 Var AppUserModelID
michael@0 7197 !endif
michael@0 7198
michael@0 7199 !verbose push
michael@0 7200 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7201 !define ${_MOZFUNC_UN}InitHashAppModelId "!insertmacro ${_MOZFUNC_UN}InitHashAppModelIdCall"
michael@0 7202
michael@0 7203 Function ${_MOZFUNC_UN}InitHashAppModelId
michael@0 7204 ; stack: apppath, regpath
michael@0 7205 Exch $R9 ; stack: $R9, regpath | $R9 = apppath
michael@0 7206 Exch 1 ; stack: regpath, $R9
michael@0 7207 Exch $R8 ; stack: $R8, $R9 | $R8 = regpath
michael@0 7208 Push $R7
michael@0 7209
michael@0 7210 ${If} ${AtLeastWin7}
michael@0 7211 ${${_MOZFUNC_UN}GetLongPath} "$R9" $R9
michael@0 7212 ; Always create a new AppUserModelID and overwrite the existing one
michael@0 7213 ; for the current installation path.
michael@0 7214 CityHash::GetCityHash64 "$R9"
michael@0 7215 Pop $AppUserModelID
michael@0 7216 ${If} $AppUserModelID == "error"
michael@0 7217 GoTo end
michael@0 7218 ${EndIf}
michael@0 7219 ClearErrors
michael@0 7220 WriteRegStr HKLM "$R8" "$R9" "$AppUserModelID"
michael@0 7221 ${If} ${Errors}
michael@0 7222 ClearErrors
michael@0 7223 WriteRegStr HKCU "$R8" "$R9" "$AppUserModelID"
michael@0 7224 ${If} ${Errors}
michael@0 7225 StrCpy $AppUserModelID "error"
michael@0 7226 ${EndIf}
michael@0 7227 ${EndIf}
michael@0 7228 ${EndIf}
michael@0 7229
michael@0 7230 end:
michael@0 7231 ${If} "$AppUserModelID" == "error"
michael@0 7232 StrCpy $AppUserModelID ""
michael@0 7233 ${EndIf}
michael@0 7234
michael@0 7235 ClearErrors
michael@0 7236 Pop $R7
michael@0 7237 Exch $R8
michael@0 7238 Exch 1
michael@0 7239 Exch $R9
michael@0 7240 FunctionEnd
michael@0 7241
michael@0 7242 !verbose pop
michael@0 7243 !endif
michael@0 7244 !macroend
michael@0 7245
michael@0 7246 !macro InitHashAppModelIdCall _EXE_PATH _REG_PATH
michael@0 7247 !verbose push
michael@0 7248 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7249 Push "${_REG_PATH}"
michael@0 7250 Push "${_EXE_PATH}"
michael@0 7251 Call InitHashAppModelId
michael@0 7252 !verbose pop
michael@0 7253 !macroend
michael@0 7254
michael@0 7255 !macro un.InitHashAppModelIdCall _EXE_PATH _REG_PATH
michael@0 7256 !verbose push
michael@0 7257 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7258 Push "${_REG_PATH}"
michael@0 7259 Push "${_EXE_PATH}"
michael@0 7260 Call un.InitHashAppModelId
michael@0 7261 !verbose pop
michael@0 7262 !macroend
michael@0 7263
michael@0 7264 !macro un.InitHashAppModelId
michael@0 7265 !ifndef un.InitHashAppModelId
michael@0 7266 !verbose push
michael@0 7267 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7268 !undef _MOZFUNC_UN
michael@0 7269 !define _MOZFUNC_UN "un."
michael@0 7270
michael@0 7271 !insertmacro InitHashAppModelId
michael@0 7272
michael@0 7273 !undef _MOZFUNC_UN
michael@0 7274 !define _MOZFUNC_UN
michael@0 7275 !verbose pop
michael@0 7276 !endif
michael@0 7277 !macroend
michael@0 7278
michael@0 7279
michael@0 7280 ################################################################################
michael@0 7281 # Helpers for the new user interface
michael@0 7282
michael@0 7283 !ifndef MAXDWORD
michael@0 7284 !define MAXDWORD 0xffffffff
michael@0 7285 !endif
michael@0 7286
michael@0 7287 !ifndef DT_WORDBREAK
michael@0 7288 !define DT_WORDBREAK 0x0010
michael@0 7289 !endif
michael@0 7290 !ifndef DT_SINGLELINE
michael@0 7291 !define DT_SINGLELINE 0x0020
michael@0 7292 !endif
michael@0 7293 !ifndef DT_NOCLIP
michael@0 7294 !define DT_NOCLIP 0x0100
michael@0 7295 !endif
michael@0 7296 !ifndef DT_CALCRECT
michael@0 7297 !define DT_CALCRECT 0x0400
michael@0 7298 !endif
michael@0 7299 !ifndef DT_EDITCONTROL
michael@0 7300 !define DT_EDITCONTROL 0x2000
michael@0 7301 !endif
michael@0 7302 !ifndef DT_RTLREADING
michael@0 7303 !define DT_RTLREADING 0x00020000
michael@0 7304 !endif
michael@0 7305 !ifndef DT_NOFULLWIDTHCHARBREAK
michael@0 7306 !define DT_NOFULLWIDTHCHARBREAK 0x00080000
michael@0 7307 !endif
michael@0 7308
michael@0 7309 !ifndef WS_EX_NOINHERITLAYOUT
michael@0 7310 !define WS_EX_NOINHERITLAYOUT 0x00100000
michael@0 7311 !endif
michael@0 7312 !ifndef WS_EX_LAYOUTRTL
michael@0 7313 !define WS_EX_LAYOUTRTL 0x00400000
michael@0 7314 !endif
michael@0 7315
michael@0 7316 !ifndef PBS_MARQUEE
michael@0 7317 !define PBS_MARQUEE 0x08
michael@0 7318 !endif
michael@0 7319
michael@0 7320 !ifndef PBM_SETRANGE32
michael@0 7321 !define PBM_SETRANGE32 0x406
michael@0 7322 !endif
michael@0 7323 !ifndef PBM_GETRANGE
michael@0 7324 !define PBM_GETRANGE 0x407
michael@0 7325 !endif
michael@0 7326
michael@0 7327 !ifndef SHACF_FILESYSTEM
michael@0 7328 !define SHACF_FILESYSTEM 1
michael@0 7329 !endif
michael@0 7330
michael@0 7331 !define MOZ_LOADTRANSPARENT ${LR_LOADFROMFILE}|${LR_LOADTRANSPARENT}|${LR_LOADMAP3DCOLORS}
michael@0 7332
michael@0 7333 ; Extend nsDialogs.nsh to support creating centered labels if it is already
michael@0 7334 ; included
michael@0 7335 !ifmacrodef __NSD_DefineControl
michael@0 7336 !insertmacro __NSD_DefineControl LabelCenter
michael@0 7337 !define __NSD_LabelCenter_CLASS STATIC
michael@0 7338 !define __NSD_LabelCenter_STYLE ${DEFAULT_STYLES}|${SS_NOTIFY}|${SS_CENTER}
michael@0 7339 !define __NSD_LabelCenter_EXSTYLE ${WS_EX_TRANSPARENT}
michael@0 7340 !endif
michael@0 7341
michael@0 7342 /**
michael@0 7343 * Modified version of the __NSD_SetStretchedImage macro from nsDialogs.nsh that
michael@0 7344 * supports transparency. See nsDialogs documentation for additional info.
michael@0 7345 */
michael@0 7346 !macro __SetStretchedTransparentImage CONTROL IMAGE HANDLE
michael@0 7347 Push $0
michael@0 7348 Push $1
michael@0 7349 Push $2
michael@0 7350 Push $R0
michael@0 7351
michael@0 7352 StrCpy $R0 ${CONTROL} ; in case ${CONTROL} is $0
michael@0 7353 StrCpy $1 ""
michael@0 7354 StrCpy $2 ""
michael@0 7355
michael@0 7356 System::Call '*(i, i, i, i) i.s'
michael@0 7357 Pop $0
michael@0 7358
michael@0 7359 ${If} $0 <> 0
michael@0 7360 System::Call 'user32::GetClientRect(i R0, i r0)'
michael@0 7361 System::Call '*$0(i, i, i .s, i .s)'
michael@0 7362 System::Free $0
michael@0 7363 Pop $1
michael@0 7364 Pop $2
michael@0 7365 ${EndIf}
michael@0 7366
michael@0 7367 System::Call 'user32::LoadImageW(i 0, t s, i ${IMAGE_BITMAP}, i r1, i r2, \
michael@0 7368 i ${MOZ_LOADTRANSPARENT}) i .s' "${IMAGE}"
michael@0 7369 Pop $0
michael@0 7370 SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0
michael@0 7371
michael@0 7372 SetCtlColors $R0 "" transparent
michael@0 7373 ${NSD_AddExStyle} $R0 ${WS_EX_TRANSPARENT}|${WS_EX_TOPMOST}
michael@0 7374
michael@0 7375 Pop $R0
michael@0 7376 Pop $2
michael@0 7377 Pop $1
michael@0 7378 Exch $0
michael@0 7379 Pop ${HANDLE}
michael@0 7380 !macroend
michael@0 7381 !define SetStretchedTransparentImage `!insertmacro __SetStretchedTransparentImage`
michael@0 7382
michael@0 7383 /**
michael@0 7384 * Removes a single style from a control.
michael@0 7385 *
michael@0 7386 * _HANDLE the handle of the control
michael@0 7387 * _STYLE the style to remove
michael@0 7388 */
michael@0 7389 !macro _RemoveStyle _HANDLE _STYLE
michael@0 7390 Push $0
michael@0 7391
michael@0 7392 System::Call 'user32::GetWindowLongW(i ${_HANDLE}, i ${GWL_STYLE}) i .r0'
michael@0 7393 IntOp $0 $0 | ${_STYLE}
michael@0 7394 IntOp $0 $0 - ${_STYLE}
michael@0 7395 System::Call 'user32::SetWindowLongW(i ${_HANDLE}, i ${GWL_STYLE}, i r0)'
michael@0 7396
michael@0 7397 Pop $0
michael@0 7398 !macroend
michael@0 7399 !define RemoveStyle "!insertmacro _RemoveStyle"
michael@0 7400
michael@0 7401 /**
michael@0 7402 * Removes a single extended style from a control.
michael@0 7403 *
michael@0 7404 * _HANDLE the handle of the control
michael@0 7405 * _EXSTYLE the extended style to remove
michael@0 7406 */
michael@0 7407 !macro _RemoveExStyle _HANDLE _EXSTYLE
michael@0 7408 Push $0
michael@0 7409
michael@0 7410 System::Call 'user32::GetWindowLongW(i ${_HANDLE}, i ${GWL_EXSTYLE}) i .r0'
michael@0 7411 IntOp $0 $0 | ${_EXSTYLE}
michael@0 7412 IntOp $0 $0 - ${_EXSTYLE}
michael@0 7413 System::Call 'user32::SetWindowLongW(i ${_HANDLE}, i ${GWL_EXSTYLE}, i r0)'
michael@0 7414
michael@0 7415 Pop $0
michael@0 7416 !macroend
michael@0 7417 !define RemoveExStyle "!insertmacro _RemoveExStyle"
michael@0 7418
michael@0 7419 /**
michael@0 7420 * Gets the extent of the specified text in pixels for sizing a control.
michael@0 7421 *
michael@0 7422 * _TEXT the text to get the text extent for
michael@0 7423 * _FONT the font to use when getting the text extent
michael@0 7424 * _RES_WIDTH return value - control width for the text
michael@0 7425 * _RES_HEIGHT return value - control height for the text
michael@0 7426 */
michael@0 7427 !macro GetTextExtentCall _TEXT _FONT _RES_WIDTH _RES_HEIGHT
michael@0 7428 Push "${_TEXT}"
michael@0 7429 Push "${_FONT}"
michael@0 7430 ${CallArtificialFunction} GetTextExtent_
michael@0 7431 Pop ${_RES_WIDTH}
michael@0 7432 Pop ${_RES_HEIGHT}
michael@0 7433 !macroend
michael@0 7434
michael@0 7435 !define GetTextExtent "!insertmacro GetTextExtentCall"
michael@0 7436 !define un.GetTextExtent "!insertmacro GetTextExtentCall"
michael@0 7437
michael@0 7438 !macro GetTextExtent_
michael@0 7439 Exch $0 ; font
michael@0 7440 Exch 1
michael@0 7441 Exch $1 ; text
michael@0 7442 Push $2
michael@0 7443 Push $3
michael@0 7444 Push $4
michael@0 7445 Push $5
michael@0 7446 Push $6
michael@0 7447 Push $7
michael@0 7448
michael@0 7449 ; Reuse the existing NSIS control which is used for BrandingText instead of
michael@0 7450 ; creating a new control.
michael@0 7451 GetDlgItem $2 $HWNDPARENT 1028
michael@0 7452
michael@0 7453 System::Call 'user32::GetDC(i r2) i .r3'
michael@0 7454 System::Call 'gdi32::SelectObject(i r3, i r0)'
michael@0 7455
michael@0 7456 StrLen $4 "$1"
michael@0 7457
michael@0 7458 System::Call '*(i, i) i .r5'
michael@0 7459 System::Call 'gdi32::GetTextExtentPoint32W(i r3, t$\"$1$\", i r4, i r5)'
michael@0 7460 System::Call '*$5(i .r6, i .r7)'
michael@0 7461 System::Free $5
michael@0 7462
michael@0 7463 System::Call 'user32::ReleaseDC(i r2, i r3)'
michael@0 7464
michael@0 7465 StrCpy $1 $7
michael@0 7466 StrCpy $0 $6
michael@0 7467
michael@0 7468 Pop $7
michael@0 7469 Pop $6
michael@0 7470 Pop $5
michael@0 7471 Pop $4
michael@0 7472 Pop $3
michael@0 7473 Pop $2
michael@0 7474 Exch $1 ; return height
michael@0 7475 Exch 1
michael@0 7476 Exch $0 ; return width
michael@0 7477 !macroend
michael@0 7478
michael@0 7479 /**
michael@0 7480 * Gets the width and the height of a control in pixels.
michael@0 7481 *
michael@0 7482 * _HANDLE the handle of the control
michael@0 7483 * _RES_WIDTH return value - control width for the text
michael@0 7484 * _RES_HEIGHT return value - control height for the text
michael@0 7485 */
michael@0 7486 !macro GetDlgItemWidthHeightCall _HANDLE _RES_WIDTH _RES_HEIGHT
michael@0 7487 Push "${_HANDLE}"
michael@0 7488 ${CallArtificialFunction} GetDlgItemWidthHeight_
michael@0 7489 Pop ${_RES_WIDTH}
michael@0 7490 Pop ${_RES_HEIGHT}
michael@0 7491 !macroend
michael@0 7492
michael@0 7493 !define GetDlgItemWidthHeight "!insertmacro GetDlgItemWidthHeightCall"
michael@0 7494 !define un.GetDlgItemWidthHeight "!insertmacro GetDlgItemWidthHeightCall"
michael@0 7495
michael@0 7496 !macro GetDlgItemWidthHeight_
michael@0 7497 Exch $0 ; handle for the control
michael@0 7498 Push $1
michael@0 7499 Push $2
michael@0 7500
michael@0 7501 System::Call '*(i, i, i, i) i .r2'
michael@0 7502 ; The left and top values will always be 0 so the right and bottom values
michael@0 7503 ; will be the width and height.
michael@0 7504 System::Call 'user32::GetClientRect(i r0, i r2)'
michael@0 7505 System::Call '*$2(i, i, i .r0, i .r1)'
michael@0 7506 System::Free $2
michael@0 7507
michael@0 7508 Pop $2
michael@0 7509 Exch $1 ; return height
michael@0 7510 Exch 1
michael@0 7511 Exch $0 ; return width
michael@0 7512 !macroend
michael@0 7513
michael@0 7514 /**
michael@0 7515 * Gets the number of pixels from the beginning of the dialog to the end of a
michael@0 7516 * control in a RTL friendly manner.
michael@0 7517 *
michael@0 7518 * _HANDLE the handle of the control
michael@0 7519 * _RES_PX return value - pixels from the beginning of the dialog to the end of
michael@0 7520 * the control
michael@0 7521 */
michael@0 7522 !macro GetDlgItemEndPXCall _HANDLE _RES_PX
michael@0 7523 Push "${_HANDLE}"
michael@0 7524 ${CallArtificialFunction} GetDlgItemEndPX_
michael@0 7525 Pop ${_RES_PX}
michael@0 7526 !macroend
michael@0 7527
michael@0 7528 !define GetDlgItemEndPX "!insertmacro GetDlgItemEndPXCall"
michael@0 7529 !define un.GetDlgItemEndPX "!insertmacro GetDlgItemEndPXCall"
michael@0 7530
michael@0 7531 !macro GetDlgItemEndPX_
michael@0 7532 Exch $0 ; handle of the control
michael@0 7533 Push $1
michael@0 7534 Push $2
michael@0 7535
michael@0 7536 ; #32770 is the dialog class
michael@0 7537 FindWindow $1 "#32770" "" $HWNDPARENT
michael@0 7538 System::Call '*(i, i, i, i) i .r2'
michael@0 7539 System::Call 'user32::GetWindowRect(i r0, i r2)'
michael@0 7540 System::Call 'user32::MapWindowPoints(i 0, i r1,i r2, i 2)'
michael@0 7541 System::Call '*$2(i, i, i .r0, i)'
michael@0 7542 System::Free $2
michael@0 7543
michael@0 7544 Pop $2
michael@0 7545 Pop $1
michael@0 7546 Exch $0 ; pixels from the beginning of the dialog to the end of the control
michael@0 7547 !macroend
michael@0 7548
michael@0 7549 /**
michael@0 7550 * Gets the width and height for sizing a control that has the specified text.
michael@0 7551 * If the text has embedded newlines then the width and height will be
michael@0 7552 * determined without trying to optimize the control's width and height. If the
michael@0 7553 * text doesn't contain newlines the control's height and width will be
michael@0 7554 * dynamically determined using a minimum of 3 lines (incrementing the
michael@0 7555 * number of lines if necessary) for the height and the maximum width specified.
michael@0 7556 *
michael@0 7557 * _TEXT the text
michael@0 7558 * _FONT the font to use when getting the width and height
michael@0 7559 * _MAX_WIDTH the maximum width for the control
michael@0 7560 * _RES_WIDTH return value - control width for the text
michael@0 7561 * _RES_HEIGHT return value - control height for the text
michael@0 7562 */
michael@0 7563 !macro GetTextWidthHeight
michael@0 7564
michael@0 7565 !ifndef ${_MOZFUNC_UN}GetTextWidthHeight
michael@0 7566 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
michael@0 7567 !insertmacro ${_MOZFUNC_UN_TMP}WordFind
michael@0 7568 !undef _MOZFUNC_UN
michael@0 7569 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
michael@0 7570 !undef _MOZFUNC_UN_TMP
michael@0 7571
michael@0 7572 !verbose push
michael@0 7573 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7574 !define ${_MOZFUNC_UN}GetTextWidthHeight "!insertmacro ${_MOZFUNC_UN}GetTextWidthHeightCall"
michael@0 7575
michael@0 7576 Function ${_MOZFUNC_UN}GetTextWidthHeight
michael@0 7577 Exch $0 ; maximum width use to calculate the control's width and height
michael@0 7578 Exch 1
michael@0 7579 Exch $1 ; font
michael@0 7580 Exch 2
michael@0 7581 Exch $2 ; text
michael@0 7582 Push $3
michael@0 7583 Push $4
michael@0 7584 Push $5
michael@0 7585 Push $6
michael@0 7586 Push $7
michael@0 7587 Push $8
michael@0 7588 Push $9
michael@0 7589 Push $R0
michael@0 7590 Push $R1
michael@0 7591 Push $R2
michael@0 7592
michael@0 7593 StrCpy $R2 "${DT_NOCLIP}|${DT_CALCRECT}"
michael@0 7594 !ifdef ${AB_CD}_rtl
michael@0 7595 StrCpy $R2 "$R2|${DT_RTLREADING}"
michael@0 7596 !endif
michael@0 7597
michael@0 7598 ; Reuse the existing NSIS control which is used for BrandingText instead
michael@0 7599 ; of creating a new control.
michael@0 7600 GetDlgItem $3 $HWNDPARENT 1028
michael@0 7601
michael@0 7602 System::Call 'user32::GetDC(i r3) i .r4'
michael@0 7603 System::Call 'gdi32::SelectObject(i r4, i r1)'
michael@0 7604
michael@0 7605 StrLen $5 "$2" ; text length
michael@0 7606 System::Call '*(i, i, i, i) i .r6'
michael@0 7607
michael@0 7608 ClearErrors
michael@0 7609 ${${_MOZFUNC_UN}WordFind} "$2" "$\n" "E#" $R0
michael@0 7610 ${If} ${Errors}
michael@0 7611 ; When there aren't newlines in the text calculate the size of the
michael@0 7612 ; rectangle needed for the text with a minimum of three lines of text.
michael@0 7613 ClearErrors
michael@0 7614 System::Call 'user32::DrawTextW(i r4, t $\"$2$\", i r5, i r6, \
michael@0 7615 i $R2|${DT_SINGLELINE})'
michael@0 7616 System::Call '*$6(i, i, i .r8, i .r7)'
michael@0 7617 System::Free $6
michael@0 7618
michael@0 7619 ; Get the approximate number height needed to display the text starting
michael@0 7620 ; with a minimum of 3 lines of text.
michael@0 7621 StrCpy $9 $8
michael@0 7622 StrCpy $R1 2 ; set the number of lines initially to 2
michael@0 7623 ${Do}
michael@0 7624 IntOp $R1 $R1 + 1 ; increment the number of lines
michael@0 7625 IntOp $9 $8 / $R1
michael@0 7626 ${LoopUntil} $9 < $0
michael@0 7627 IntOp $7 $7 * $R1
michael@0 7628
michael@0 7629 StrCpy $R0 $9
michael@0 7630 ${Do}
michael@0 7631 IntOp $R0 $R0 + 20
michael@0 7632 System::Call '*(i, i, i R0, i r7) i .r6'
michael@0 7633 System::Call 'user32::DrawTextW(i r4, t $\"$2$\", i r5, i r6, \
michael@0 7634 i $R2|${DT_WORDBREAK}) i .R1'
michael@0 7635 System::Call '*$6(i, i, i .r8, i .r9)'
michael@0 7636 System::Free $6
michael@0 7637 ${LoopUntil} $7 >= $R1
michael@0 7638 ${Else}
michael@0 7639 ; When there are newlines in the text just return the size of the
michael@0 7640 ; rectangle for the text.
michael@0 7641 System::Call 'user32::DrawTextW(i r4, t $\"$2$\", i r5, i r6, i $R2)'
michael@0 7642 System::Call '*$6(i, i, i .r8, i .r9)'
michael@0 7643 System::Free $6
michael@0 7644 ${EndIf}
michael@0 7645
michael@0 7646 ; Reselect the original DC
michael@0 7647 System::Call 'gdi32::SelectObject(i r4, i r1)'
michael@0 7648 System::Call 'user32::ReleaseDC(i r3, i r4)'
michael@0 7649
michael@0 7650 StrCpy $1 $9
michael@0 7651 StrCpy $0 $8
michael@0 7652
michael@0 7653 Pop $R2
michael@0 7654 Pop $R1
michael@0 7655 Pop $R0
michael@0 7656 Pop $9
michael@0 7657 Pop $8
michael@0 7658 Pop $7
michael@0 7659 Pop $6
michael@0 7660 Pop $5
michael@0 7661 Pop $4
michael@0 7662 Pop $3
michael@0 7663 Exch $2
michael@0 7664 Exch 2
michael@0 7665 Exch $1 ; return height
michael@0 7666 Exch 1
michael@0 7667 Exch $0 ; return width
michael@0 7668 FunctionEnd
michael@0 7669
michael@0 7670 !verbose pop
michael@0 7671 !endif
michael@0 7672 !macroend
michael@0 7673
michael@0 7674 !macro GetTextWidthHeightCall _TEXT _FONT _MAX_WIDTH _RES_WIDTH _RES_HEIGHT
michael@0 7675 !verbose push
michael@0 7676 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7677 Push "${_TEXT}"
michael@0 7678 Push "${_FONT}"
michael@0 7679 Push "${_MAX_WIDTH}"
michael@0 7680 Call GetTextWidthHeight
michael@0 7681 Pop ${_RES_WIDTH}
michael@0 7682 Pop ${_RES_HEIGHT}
michael@0 7683 !verbose pop
michael@0 7684 !macroend
michael@0 7685
michael@0 7686 !macro un.GetTextWidthHeightCall _TEXT _FONT _MAX_WIDTH _RES_WIDTH _RES_HEIGHT
michael@0 7687 !verbose push
michael@0 7688 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7689 Push "${_TEXT}"
michael@0 7690 Push "${_FONT}"
michael@0 7691 Push "${_MAX_WIDTH}"
michael@0 7692 Call un.GetTextWidthHeight
michael@0 7693 Pop ${_RES_WIDTH}
michael@0 7694 Pop ${_RES_HEIGHT}
michael@0 7695 !verbose pop
michael@0 7696 !macroend
michael@0 7697
michael@0 7698 !macro un.GetTextWidthHeight
michael@0 7699 !ifndef un.GetTextWidthHeight
michael@0 7700 !verbose push
michael@0 7701 !verbose ${_MOZFUNC_VERBOSE}
michael@0 7702 !undef _MOZFUNC_UN
michael@0 7703 !define _MOZFUNC_UN "un."
michael@0 7704
michael@0 7705 !insertmacro GetTextWidthHeight
michael@0 7706
michael@0 7707 !undef _MOZFUNC_UN
michael@0 7708 !define _MOZFUNC_UN
michael@0 7709 !verbose pop
michael@0 7710 !endif
michael@0 7711 !macroend
michael@0 7712
michael@0 7713 /**
michael@0 7714 * Gets the elapsed time in seconds between two values in milliseconds stored as
michael@0 7715 * an int64. The caller will typically get the millisecond values using
michael@0 7716 * GetTickCount with a long return value as follows.
michael@0 7717 * System::Call "kernel32::GetTickCount()l .s"
michael@0 7718 * Pop $varname
michael@0 7719 *
michael@0 7720 * _START_TICK_COUNT
michael@0 7721 * _FINISH_TICK_COUNT
michael@0 7722 * _RES_ELAPSED_SECONDS return value - elapsed time between _START_TICK_COUNT
michael@0 7723 * and _FINISH_TICK_COUNT in seconds.
michael@0 7724 */
michael@0 7725 !macro GetSecondsElapsedCall _START_TICK_COUNT _FINISH_TICK_COUNT _RES_ELAPSED_SECONDS
michael@0 7726 Push "${_START_TICK_COUNT}"
michael@0 7727 Push "${_FINISH_TICK_COUNT}"
michael@0 7728 ${CallArtificialFunction} GetSecondsElapsed_
michael@0 7729 Pop ${_RES_ELAPSED_SECONDS}
michael@0 7730 !macroend
michael@0 7731
michael@0 7732 !define GetSecondsElapsed "!insertmacro GetSecondsElapsedCall"
michael@0 7733 !define un.GetSecondsElapsed "!insertmacro GetSecondsElapsedCall"
michael@0 7734
michael@0 7735 !macro GetSecondsElapsed_
michael@0 7736 Exch $0 ; finish tick count
michael@0 7737 Exch 1
michael@0 7738 Exch $1 ; start tick count
michael@0 7739
michael@0 7740 System::Int64Op $0 - $1
michael@0 7741 Pop $0
michael@0 7742 ; Discard the top bits of the int64 by bitmasking with MAXDWORD
michael@0 7743 System::Int64Op $0 & ${MAXDWORD}
michael@0 7744 Pop $0
michael@0 7745
michael@0 7746 ; Convert from milliseconds to seconds
michael@0 7747 System::Int64Op $0 / 1000
michael@0 7748 Pop $0
michael@0 7749
michael@0 7750 Pop $1
michael@0 7751 Exch $0 ; return elapsed seconds
michael@0 7752 !macroend
michael@0 7753
michael@0 7754 !ifdef MOZ_METRO
michael@0 7755 ; Removes the CEH registration if it's set to our installation directory.
michael@0 7756 ; If it's set to some other installation directory, then it should be removed
michael@0 7757 ; by that installation.
michael@0 7758 !macro RemoveDEHRegistrationIfMatchingCall un
michael@0 7759
michael@0 7760 Function ${un}RemoveDEHRegistrationIfMatchingCall
michael@0 7761 ; Retrieve DEH ID from the stack into $R9
michael@0 7762 Exch $R9
michael@0 7763 Exch 1
michael@0 7764
michael@0 7765 ; Retrieve Protocol Activation ID from stack into $R8
michael@0 7766 Exch $R8
michael@0 7767 Exch 2
michael@0 7768
michael@0 7769 ; Retrieve File Activation ID from stack into $R7
michael@0 7770 Exch $R7
michael@0 7771
michael@0 7772 ; Backup the old values of R6 and R5 on the stack
michael@0 7773 Push $R6
michael@0 7774 Push $R5
michael@0 7775
michael@0 7776 ; Conditionally remove the DEH as long as we are the default (HKCU)
michael@0 7777 ReadRegStr $R6 HKCU "Software\Classes\CLSID\$R9\LocalServer32" ""
michael@0 7778 ${${un}GetLongPath} "$INSTDIR" $R5
michael@0 7779 StrCmp "$R6" "" next +1
michael@0 7780 IfFileExists "$R6" +1 clearHKCU
michael@0 7781 ${${un}GetParent} "$R6" $R6
michael@0 7782 ${${un}GetLongPath} "$R6" $R6
michael@0 7783 StrCmp "$R5" "$R6" clearHKCU next
michael@0 7784 clearHKCU:
michael@0 7785 DeleteRegKey HKCU "Software\Classes\CLSID\$R9"
michael@0 7786 DeleteRegValue HKCU "Software\Classes\$R8\shell\open\command" "DelegateExecute"
michael@0 7787 DeleteRegValue HKCU "Software\Classes\$R7\shell\open\command" "DelegateExecute"
michael@0 7788 next:
michael@0 7789
michael@0 7790 ; Conditionally remove the DEH as long as we are the default (HKLM)
michael@0 7791 ReadRegStr $R6 HKLM "Software\Classes\CLSID\$R9\LocalServer32" ""
michael@0 7792 ${${un}GetLongPath} "$INSTDIR" $R5
michael@0 7793 StrCmp "$R6" "" done +1
michael@0 7794 IfFileExists "$R6" +1 clearHKLM
michael@0 7795 ${${un}GetParent} "$R6" $R6
michael@0 7796 ${${un}GetLongPath} "$R6" $R6
michael@0 7797 StrCmp "$R5" "$R6" clearHKLM done
michael@0 7798 clearHKLM:
michael@0 7799 DeleteRegKey HKLM "Software\Classes\CLSID\$R9"
michael@0 7800 DeleteRegValue HKLM "Software\Classes\$R8\shell\open\command" "DelegateExecute"
michael@0 7801 DeleteRegValue HKLM "Software\Classes\$R7\shell\open\command" "DelegateExecute"
michael@0 7802 done:
michael@0 7803
michael@0 7804 ; Always remove the AppUserModelID keys for this installation
michael@0 7805 DeleteRegKey HKCU "Software\Classes\$AppUserModelID"
michael@0 7806 DeleteRegKey HKLM "Software\Classes\$AppUserModelID"
michael@0 7807
michael@0 7808 ; Restore the registers back to their original state
michael@0 7809 Pop $R5
michael@0 7810 Pop $R6
michael@0 7811 Exch $R7
michael@0 7812 Exch 2
michael@0 7813 Exch $R8
michael@0 7814 Exch 1
michael@0 7815 Exch $R9
michael@0 7816 FunctionEnd
michael@0 7817 !macroend
michael@0 7818
michael@0 7819 !macro RemoveDEHRegistrationIfMatching
michael@0 7820 !insertmacro RemoveDEHRegistrationIfMatchingCall ""
michael@0 7821 !macroend
michael@0 7822
michael@0 7823 !macro un.RemoveDEHRegistrationIfMatching
michael@0 7824 !insertmacro RemoveDEHRegistrationIfMatchingCall "un."
michael@0 7825 !macroend
michael@0 7826
michael@0 7827 !macro CleanupMetroBrowserHandlerValues un DELEGATE_EXECUTE_HANDLER_ID \
michael@0 7828 PROTOCOL_ACTIVATION_ID \
michael@0 7829 FILE_ACTIVATION_ID
michael@0 7830 Push ${FILE_ACTIVATION_ID}
michael@0 7831 Push ${PROTOCOL_ACTIVATION_ID}
michael@0 7832 Push ${DELEGATE_EXECUTE_HANDLER_ID}
michael@0 7833 Call ${un}RemoveDEHRegistrationIfMatchingCall
michael@0 7834 !macroend
michael@0 7835 !define CleanupMetroBrowserHandlerValues '!insertmacro CleanupMetroBrowserHandlerValues ""'
michael@0 7836 !define un.CleanupMetroBrowserHandlerValues '!insertmacro CleanupMetroBrowserHandlerValues "un."'
michael@0 7837
michael@0 7838 !macro AddMetroBrowserHandlerValues DELEGATE_EXECUTE_HANDLER_ID \
michael@0 7839 DELEGATE_EXECUTE_HANDLER_PATH \
michael@0 7840 APP_USER_MODEL_ID \
michael@0 7841 PROTOCOL_ACTIVATION_ID \
michael@0 7842 FILE_ACTIVATION_ID
michael@0 7843 ; Win8 doesn't use conventional progid command data to launch anymore.
michael@0 7844 ; Instead it uses a delegate execute handler which is a light weight COM
michael@0 7845 ; server for choosing the metro or desktop browser to launch depending
michael@0 7846 ; on the current environment (metro/desktop) it was activated in.
michael@0 7847 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}" "" ""
michael@0 7848 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe" "" ""
michael@0 7849 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell" "" "open"
michael@0 7850 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open" "CommandId" "open"
michael@0 7851 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "" "$2"
michael@0 7852 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
michael@0 7853
michael@0 7854 ; Augment the url handler registrations with additional data needed for Metro
michael@0 7855 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}" "AppUserModelID" "${APP_USER_MODEL_ID}"
michael@0 7856 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "AppUserModelID" "${APP_USER_MODEL_ID}"
michael@0 7857 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationName" "$BrandShortName"
michael@0 7858 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationIcon" "$INSTDIR\${FileMainEXE},0"
michael@0 7859 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationCompany" "${CompanyName}"
michael@0 7860 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationDescription" "$(REG_APP_DESC)"
michael@0 7861 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell" "" "open"
michael@0 7862 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open" "CommandId" "open"
michael@0 7863 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
michael@0 7864
michael@0 7865 ; Augment the file handler registrations with additional data needed for Metro
michael@0 7866 WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}" "AppUserModelID" "${APP_USER_MODEL_ID}"
michael@0 7867 WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell" "" "open"
michael@0 7868 WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell\open" "CommandId" "open"
michael@0 7869 WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
michael@0 7870
michael@0 7871 ; Win8 Metro delegate execute handler registration
michael@0 7872 WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}" "" "$BrandShortName CommandExecuteHandler"
michael@0 7873 WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}" "AppId" "${DELEGATE_EXECUTE_HANDLER_ID}"
michael@0 7874 WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}\LocalServer32" "" "${DELEGATE_EXECUTE_HANDLER_PATH}"
michael@0 7875 !macroend
michael@0 7876 !define AddMetroBrowserHandlerValues "!insertmacro AddMetroBrowserHandlerValues"
michael@0 7877 !endif ;end MOZ_METRO
michael@0 7878

mercurial