~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to mozilla/toolkit/mozapps/installer/windows/nsis/common.nsh

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

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