~ubuntu-branches/ubuntu/wily/udj-desktop-client/wily

« back to all changes in this revision

Viewing changes to cmake/modules/NSIS.template.in

  • Committer: Package Import Robot
  • Author(s): Nathan Handler
  • Date: 2012-11-14 15:29:07 UTC
  • mfrom: (1.2.1) (4.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20121114152907-8uj9bwcima77vu28
Tags: 0.6.3-1
* New upstream release
* debian/copyright: Add stanzas for new upstream files
* debian/rules:
  - Do not install ./usr/share/doc/udj/UDJ.1
  - Remove /usr/share/doc/udj directory if it is empty
* debian/control:
  - Bump Standards-Version to 3.9.4 (no changes)
  - Use my @debian.org address for the Maintainer field

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;UDJ installer script.
 
2
;Courtusy of the Tomahawk project (i.e. I shamelessly copied and pasted)
 
3
;www.tomahawk-player.com
 
4
 
 
5
;-----------------------------------------------------------------------------
 
6
; Some installer script options (comment-out options not required)
 
7
;-----------------------------------------------------------------------------
 
8
;!define OPTION_LICENSE_AGREEMENT
 
9
!define OPTION_UAC_PLUGIN_ENHANCED
 
10
!define OPTION_SECTION_SC_START_MENU
 
11
!define OPTION_SECTION_SC_DESKTOP
 
12
!define OPTION_SECTION_SC_QUICK_LAUNCH
 
13
!define OPTION_FINISHPAGE
 
14
!define OPTION_FINISHPAGE_LAUNCHER
 
15
!define OPTION_FINISHPAGE_RELEASE_NOTES
 
16
 
 
17
;-----------------------------------------------------------------------------
 
18
; Some paths.
 
19
;-----------------------------------------------------------------------------
 
20
!ifndef MING_PATH
 
21
    !define MING_PATH "/usr/i686-w64-mingw32/sys-root/mingw"
 
22
!endif
 
23
!define MING_BIN "${MING_PATH}/bin"
 
24
!define MING_LIB "${MING_PATH}/lib"
 
25
!define BUILD_PATH "@CMAKE_BINARY_DIR@"
 
26
!define SOURCE_PATH "@CMAKE_SOURCE_DIR@"
 
27
!define QT_DLL_PATH "${MING_BIN}"
 
28
!define SQLITE_DLL_PATH "${MING_LIB}/qt4/plugins/sqldrivers"
 
29
!define IMAGEFORMATS_DLL_PATH "${MING_LIB}/qt4/plugins/imageformats"
 
30
 
 
31
; We use official release plugins
 
32
; mingw32-vlc from obs misses a lot and has even broken ones probably
 
33
!define VLC_PATH "${SOURCE_PATH}\admin\win\vlc\" ; SIC! ^
 
34
!define VLC_BIN "${VLC_PATH}"
 
35
!define VLC_PLUGIN_PATH "${VLC_BIN}\plugins"
 
36
 
 
37
!define NSI_PATH "${SOURCE_PATH}/admin/win/nsi"
 
38
 
 
39
 
 
40
;-----------------------------------------------------------------------------
 
41
; Installer version
 
42
;-----------------------------------------------------------------------------
 
43
 
 
44
!define VER_MAJOR "@CPACK_PACKAGE_VERSION_MAJOR@"
 
45
!define VER_MINOR "@CPACK_PACKAGE_VERSION_MINOR@"
 
46
!define VER_BUILD "@CPACK_PACKAGE_VERSION_PATCH@"
 
47
!define VERSION "@CPACK_PACKAGE_VERSION@"
 
48
 
 
49
;-----------------------------------------------------------------------------
 
50
; Installer build timestamp.
 
51
;-----------------------------------------------------------------------------
 
52
!define /date BUILD_TIME "built on %Y/%m/%d at %I:%M %p"
 
53
 
 
54
;-----------------------------------------------------------------------------
 
55
; Initial installer setup and definitions.
 
56
;-----------------------------------------------------------------------------
 
57
Name "@CPACK_NSIS_PACKAGE_NAME@"
 
58
Caption "UDJ Installer"
 
59
BrandingText "UDJ ${VERSION} -- ${BUILD_TIME}"
 
60
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
 
61
InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
 
62
InstallDirRegKey HKCU "Software\UDJ" ""
 
63
InstType Standard
 
64
InstType Full
 
65
InstType Minimal
 
66
CRCCheck On
 
67
SetCompressor @CPACK_NSIS_COMPRESSOR@
 
68
RequestExecutionLevel user ;Now using the UAC plugin.
 
69
ReserveFile NSIS.InstallOptions.ini
 
70
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
 
71
 
 
72
@CPACK_NSIS_SECTION_SELECTED_VARS@
 
73
 
 
74
;-----------------------------------------------------------------------------
 
75
; Include some required header files.
 
76
;-----------------------------------------------------------------------------
 
77
!include LogicLib.nsh ;Used by APPDATA uninstaller.
 
78
!include nsDialogs.nsh ;Used by APPDATA uninstaller.
 
79
!include MUI2.nsh ;Used by APPDATA uninstaller.
 
80
!include InstallOptions.nsh ;Required by MUI2 to support old MUI_INSTALLOPTIONS.
 
81
!include Memento.nsh ;Remember user selections.
 
82
!include WinVer.nsh ;Windows version detection.
 
83
!include WordFunc.nsh ;Used by VersionCompare macro function.
 
84
!include UAC.nsh ;Used by the UAC elevation to install as user or admin.
 
85
 
 
86
;-----------------------------------------------------------------------------
 
87
; Memento selections stored in registry.
 
88
;-----------------------------------------------------------------------------
 
89
!define MEMENTO_REGISTRY_ROOT HKLM
 
90
!define MEMENTO_REGISTRY_KEY Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ
 
91
 
 
92
;-----------------------------------------------------------------------------
 
93
; Modern User Interface (MUI) defintions and setup.
 
94
;-----------------------------------------------------------------------------
 
95
!define MUI_ABORTWARNING
 
96
!define MUI_ICON ${NSI_PATH}\installer.ico
 
97
!define MUI_UNICON ${NSI_PATH}\installer.ico
 
98
!define MUI_WELCOMEFINISHPAGE_BITMAP ${NSI_PATH}\welcome.png
 
99
!define MUI_WELCOMEPAGE_TITLE "@CPACK_PACKAGE_NAME@ ${VERSION} Setup$\r$\nInstaller"
 
100
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation.$\r$\n$\r$\n$_CLICK"
 
101
!define MUI_HEADERIMAGE
 
102
!define MUI_HEADERIMAGE_BITMAP ${NSI_PATH}\page_header.jpg
 
103
!define MUI_COMPONENTSPAGE_SMALLDESC
 
104
!define MUI_FINISHPAGE_TITLE "@CPACK_PACKAGE_NAME@ Install Completed"
 
105
!define MUI_FINISHPAGE_LINK "Click here to visit the @CPACK_PACKAGE_NAME@ website."
 
106
!define MUI_FINISHPAGE_LINK_LOCATION "http://@UDJ_ORGANIZATION_DOMAIN@"
 
107
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
 
108
!ifdef OPTION_FINISHPAGE_RELEASE_NOTES
 
109
   !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
 
110
   !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\NOTES.txt"
 
111
   !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show release notes"
 
112
!endif
 
113
!ifdef OPTION_FINISHPAGE_LAUNCHER
 
114
   !define MUI_FINISHPAGE_NOAUTOCLOSE
 
115
   !define MUI_FINISHPAGE_RUN
 
116
   !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchUDJ"
 
117
!endif
 
118
 
 
119
;-----------------------------------------------------------------------------
 
120
; Page macros.
 
121
;-----------------------------------------------------------------------------
 
122
!insertmacro MUI_PAGE_WELCOME
 
123
!ifdef OPTION_LICENSE_AGREEMENT
 
124
   !insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
 
125
!endif
 
126
Page custom PageReinstall PageLeaveReinstall
 
127
!insertmacro MUI_PAGE_COMPONENTS
 
128
!insertmacro MUI_PAGE_DIRECTORY
 
129
!insertmacro MUI_PAGE_INSTFILES
 
130
!ifdef OPTION_FINISHPAGE
 
131
   !insertmacro MUI_PAGE_FINISH
 
132
!endif
 
133
!insertmacro MUI_UNPAGE_CONFIRM
 
134
UninstPage custom un.UnPageUserAppData un.UnPageUserAppDataLeave
 
135
!insertmacro MUI_UNPAGE_INSTFILES
 
136
 
 
137
;-----------------------------------------------------------------------------
 
138
; Other MUI macros.
 
139
;-----------------------------------------------------------------------------
 
140
!insertmacro MUI_LANGUAGE "English"
 
141
 
 
142
##############################################################################
 
143
# #
 
144
# FINISH PAGE LAUNCHER FUNCTIONS #
 
145
# #
 
146
##############################################################################
 
147
 
 
148
Function LaunchUDJ
 
149
   ${UAC.CallFunctionAsUser} LaunchUDJAsUser
 
150
FunctionEnd
 
151
 
 
152
Function LaunchUDJAsUser
 
153
   Exec "$INSTDIR\UDJ.exe"
 
154
FunctionEnd
 
155
 
 
156
##############################################################################
 
157
# #
 
158
# PROCESS HANDLING FUNCTIONS AND MACROS #
 
159
# #
 
160
##############################################################################
 
161
 
 
162
!macro CheckForProcess processName gotoWhenFound gotoWhenNotFound
 
163
   Processes::FindProcess ${processName}
 
164
   StrCmp $R0 "0" ${gotoWhenNotFound} ${gotoWhenFound}
 
165
!macroend
 
166
 
 
167
!macro ConfirmEndProcess processName
 
168
   MessageBox MB_YESNO|MB_ICONEXCLAMATION \
 
169
     "Found ${processName} process(s) which need to be stopped.$\nDo you want the installer to stop these for you?" \
 
170
     IDYES process_${processName}_kill IDNO process_${processName}_ended
 
171
   process_${processName}_kill:
 
172
      DetailPrint "Killing ${processName} processes."
 
173
      Processes::KillProcess ${processName}
 
174
      Sleep 1500
 
175
      StrCmp $R0 "1" process_${processName}_ended
 
176
      DetailPrint "Process to kill not found!"
 
177
   process_${processName}_ended:
 
178
!macroend
 
179
 
 
180
!macro CheckAndConfirmEndProcess processName
 
181
   !insertmacro CheckForProcess ${processName} 0 no_process_${processName}_to_end
 
182
   !insertmacro ConfirmEndProcess ${processName}
 
183
   no_process_${processName}_to_end:
 
184
!macroend
 
185
 
 
186
Function EnsureUDJShutdown
 
187
   !insertmacro CheckAndConfirmEndProcess "UDJ.exe"
 
188
FunctionEnd
 
189
 
 
190
##############################################################################
 
191
# #
 
192
# RE-INSTALLER FUNCTIONS #
 
193
# #
 
194
##############################################################################
 
195
 
 
196
Function PageReinstall
 
197
   ReadRegStr $R0 HKLM "Software\UDJ" ""
 
198
   StrCmp $R0 "" 0 +2
 
199
   Abort
 
200
 
 
201
   ;Detect version
 
202
   ReadRegDWORD $R0 HKLM "Software\UDJ" "VersionMajor"
 
203
   IntCmp $R0 ${VER_MAJOR} minor_check new_version older_version
 
204
   minor_check:
 
205
      ReadRegDWORD $R0 HKLM "Software\UDJ" "VersionMinor"
 
206
      IntCmp $R0 ${VER_MINOR} build_check new_version older_version
 
207
   build_check:
 
208
      ReadRegDWORD $R0 HKLM "Software\UDJ" "VersionBuild"
 
209
      IntCmp $R0 ${VER_BUILD} same_version new_version older_version
 
210
 
 
211
   new_version:
 
212
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "An older version of UDJ is installed on your system. It is recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
 
213
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Uninstall before installing"
 
214
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Do not uninstall"
 
215
      !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install UDJ."
 
216
      StrCpy $R0 "1"
 
217
      Goto reinst_start
 
218
 
 
219
   older_version:
 
220
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "A newer version of UDJ is already installed! It is not recommended that you install an older version. If you really want to install this older version, it is better to uninstall the current version first. Select the operation you want to perform and click Next to continue."
 
221
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Uninstall before installing"
 
222
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Do not uninstall"
 
223
      !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install UDJ."
 
224
      StrCpy $R0 "1"
 
225
      Goto reinst_start
 
226
 
 
227
   same_version:
 
228
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "UDJ ${VERSION} is already installed.\r\nSelect the operation you want to perform and click Next to continue."
 
229
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Add/Reinstall components"
 
230
      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Uninstall UDJ"
 
231
      !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
 
232
      StrCpy $R0 "2"
 
233
 
 
234
   reinst_start:
 
235
      !insertmacro INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
 
236
FunctionEnd
 
237
 
 
238
Function PageLeaveReinstall
 
239
   !insertmacro INSTALLOPTIONS_READ $R1 "NSIS.InstallOptions.ini" "Field 2" "State"
 
240
   StrCmp $R0 "1" 0 +2
 
241
   StrCmp $R1 "1" reinst_uninstall reinst_done
 
242
   StrCmp $R0 "2" 0 +3
 
243
   StrCmp $R1 "1" reinst_done reinst_uninstall
 
244
   reinst_uninstall:
 
245
      ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "UninstallString"
 
246
      HideWindow
 
247
      ClearErrors
 
248
      ExecWait '$R1 _?=$INSTDIR'
 
249
      IfErrors no_remove_uninstaller
 
250
      IfFileExists "$INSTDIR\UDJ.exe" no_remove_uninstaller
 
251
      Delete $R1
 
252
      RMDir $INSTDIR
 
253
   no_remove_uninstaller:
 
254
      StrCmp $R0 "2" 0 +3
 
255
      UAC::Unload
 
256
      Quit
 
257
      BringToFront
 
258
   reinst_done:
 
259
FunctionEnd
 
260
 
 
261
##############################################################################
 
262
# #
 
263
# INSTALLER SECTIONS #
 
264
# #
 
265
##############################################################################
 
266
Section "UDJ Player" SEC_UDJ_PLAYER
 
267
   SectionIn 1 2 3 RO
 
268
   SetDetailsPrint listonly
 
269
 
 
270
   SetDetailsPrint textonly
 
271
   DetailPrint "Installing UDJ Player essentials."
 
272
   SetDetailsPrint listonly
 
273
   SetOutPath "$INSTDIR"
 
274
 
 
275
   !ifdef INSTALL_PATH
 
276
        ;Main executable.
 
277
        File "${INSTALL_PATH}\bin\UDJ.exe"
 
278
 
 
279
   !endif
 
280
   !ifndef INSTALL_PATH
 
281
        ;Main executable.
 
282
        File "${BUILD_PATH}\src\UDJ.exe"
 
283
 
 
284
   !endif
 
285
 
 
286
   ;License & release notes.
 
287
   File "@CPACK_RESOURCE_FILE_LICENSE@"
 
288
   File /oname=NOTES.txt ${NSI_PATH}\RELEASE_NOTES.txt
 
289
 
 
290
   ;QT stuff:
 
291
   File "${QT_DLL_PATH}\QtCore4.dll"
 
292
   File "${QT_DLL_PATH}\QtGui4.dll"
 
293
   File "${QT_DLL_PATH}\QtNetwork4.dll"
 
294
   File "${QT_DLL_PATH}\QtSql4.dll"
 
295
   File "${QT_DLL_PATH}\QtXml4.dll"
 
296
 
 
297
   ;SQLite driver
 
298
   SetOutPath "$INSTDIR\sqldrivers"
 
299
   File "${SQLITE_DLL_PATH}\qsqlite4.dll"
 
300
   SetOutPath "$INSTDIR"
 
301
 
 
302
   ;Image plugins
 
303
   SetOutPath "$INSTDIR\imageformats"
 
304
   File "${IMAGEFORMATS_DLL_PATH}\qgif4.dll"
 
305
   File "${IMAGEFORMATS_DLL_PATH}\qjpeg4.dll"
 
306
   SetOutPath "$INSTDIR"
 
307
 
 
308
   ;Cygwin/c++ stuff
 
309
   ;File "${MING_BIN}\cygmad-0.dll"
 
310
   ;File "${MING_BIN}\libgcc_s_dw2-1.dll"
 
311
   ;File "${MING_BIN}\mingwm10.dll"
 
312
   File "${MING_BIN}\libgcc_s_sjlj-1.dll"
 
313
   File "${MING_BIN}\libstdc++-6.dll"
 
314
 
 
315
   ;Phonon stuff
 
316
   File "${MING_BIN}\libphonon.dll"
 
317
   SetOutPath "$INSTDIR\phonon_backend"
 
318
   File "${VLC_BIN}\phonon_backend\phonon_vlc.dll"
 
319
   SetOutPath "$INSTDIR"
 
320
 
 
321
   ;VLC
 
322
   File "${VLC_BIN}\libvlc.dll"
 
323
   File "${VLC_BIN}\libvlccore.dll"
 
324
   SetOutPath "$INSTDIR\plugins"
 
325
   File /r "${VLC_PLUGIN_PATH}\*.dll"
 
326
   SetOutPath "$INSTDIR"
 
327
 
 
328
   ; Other
 
329
   File "${MING_BIN}\libtag.dll"
 
330
   File "${MING_BIN}\libpng15-15.dll"
 
331
   File "${MING_BIN}\libjpeg-8.dll"
 
332
   File "${MING_BIN}\zlib1.dll"
 
333
   File "${MING_BIN}\libqtsparkle.dll"
 
334
 
 
335
 
 
336
 
 
337
   ; Jabber
 
338
   File "${MING_BIN}\libssl-8.dll"
 
339
   File "${MING_BIN}\libcrypto-8.dll"
 
340
 
 
341
SectionEnd
 
342
 
 
343
SectionGroup "Shortcuts"
 
344
 
 
345
!ifdef OPTION_SECTION_SC_START_MENU
 
346
   ${MementoSection} "Start Menu Program Group" SEC_START_MENU
 
347
      SectionIn 1 2
 
348
      SetDetailsPrint textonly
 
349
      DetailPrint "Adding shortcuts for the UDJ program group to the Start Menu."
 
350
      SetDetailsPrint listonly
 
351
      SetShellVarContext all
 
352
      RMDir /r "$SMPROGRAMS\UDJ"
 
353
      CreateDirectory "$SMPROGRAMS\UDJ"
 
354
      CreateShortCut "$SMPROGRAMS\UDJ\LICENSE.lnk" "$INSTDIR\LICENSE.txt"
 
355
      CreateShortCut "$SMPROGRAMS\UDJ\UDJ.lnk" "$INSTDIR\UDJ.exe"
 
356
      CreateShortCut "$SMPROGRAMS\UDJ\Release notes.lnk" "$INSTDIR\NOTES.txt"
 
357
      CreateShortCut "$SMPROGRAMS\UDJ\Uninstall.lnk" "$INSTDIR\uninstall.exe"
 
358
      SetShellVarContext current
 
359
   ${MementoSectionEnd}
 
360
!endif
 
361
 
 
362
!ifdef OPTION_SECTION_SC_DESKTOP
 
363
   ${MementoSection} "Desktop Shortcut" SEC_DESKTOP
 
364
      SectionIn 1 2
 
365
      SetDetailsPrint textonly
 
366
      DetailPrint "Creating Desktop Shortcuts"
 
367
      SetDetailsPrint listonly
 
368
      CreateShortCut "$DESKTOP\UDJ.lnk" "$INSTDIR\UDJ.exe"
 
369
   ${MementoSectionEnd}
 
370
!endif
 
371
 
 
372
!ifdef OPTION_SECTION_SC_QUICK_LAUNCH
 
373
   ${MementoSection} "Quick Launch Shortcut" SEC_QUICK_LAUNCH
 
374
      SectionIn 1 2
 
375
      SetDetailsPrint textonly
 
376
      DetailPrint "Creating Quick Launch Shortcut"
 
377
      SetDetailsPrint listonly
 
378
      CreateShortCut "$QUICKLAUNCH\UDJ.lnk" "$INSTDIR\UDJ.exe"
 
379
   ${MementoSectionEnd}
 
380
!endif
 
381
 
 
382
SectionGroupEnd
 
383
 
 
384
${MementoSectionDone}
 
385
 
 
386
; Installer section descriptions
 
387
;--------------------------------
 
388
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
 
389
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_UDJ_PLAYER} "UDJ player essentials."
 
390
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_START_MENU} "UDJ program group."
 
391
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} "Desktop shortcut for UDJ."
 
392
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QUICK_LAUNCH} "Quick Launch shortcut for UDJ."
 
393
!insertmacro MUI_FUNCTION_DESCRIPTION_END
 
394
 
 
395
Section -post
 
396
 
 
397
   ;Uninstaller file.
 
398
   SetDetailsPrint textonly
 
399
   DetailPrint "Writing Uninstaller"
 
400
   SetDetailsPrint listonly
 
401
   WriteUninstaller $INSTDIR\uninstall.exe
 
402
 
 
403
   ;Registry keys required for installer version handling and uninstaller.
 
404
   SetDetailsPrint textonly
 
405
   DetailPrint "Writing Installer Registry Keys"
 
406
   SetDetailsPrint listonly
 
407
 
 
408
   ;Version numbers used to detect existing installation version for comparisson.
 
409
   WriteRegStr HKLM "Software\UDJ" "" $INSTDIR
 
410
   WriteRegDWORD HKLM "Software\UDJ" "VersionMajor" "${VER_MAJOR}"
 
411
   WriteRegDWORD HKLM "Software\UDJ" "VersionMinor" "${VER_MINOR}"
 
412
   WriteRegDWORD HKLM "Software\UDJ" "VersionRevision" "${REVISION}"
 
413
   WriteRegDWORD HKLM "Software\UDJ" "VersionBuild" "${VER_BUILD}"
 
414
 
 
415
   ;Add or Remove Programs entry.
 
416
   WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "UninstallString" '"$INSTDIR\Uninstall.exe"'
 
417
   WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "InstallLocation" "$INSTDIR"
 
418
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "DisplayName" "UDJ"
 
419
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "Publisher" "UDJ-player.org"
 
420
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"
 
421
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "DisplayVersion" "${VERSION}"
 
422
   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "VersionMajor" "${VER_MAJOR}"
 
423
   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "VersionMinor" "${VER_MINOR}.${REVISION}"
 
424
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "URLInfoAbout" "http://UDJ-player.org/"
 
425
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "HelpLink" "http://UDJ-player.org/"
 
426
   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "NoModify" "1"
 
427
   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "NoRepair" "1"
 
428
 
 
429
   ; Register UDJ:// protocol handler
 
430
   WriteRegStr HKCR "UDJ" "" "URL:UDJ Protocol"
 
431
   WriteRegStr HKCR "UDJ" "URL Protocol" ""
 
432
   WriteRegStr HKCR "UDJ\DefaultIcon" "" $INSTDIR\UDJ.exe,1
 
433
   WriteRegStr HKCR "UDJ\shell" "" "open"
 
434
   WriteRegStr HKCR "UDJ\shell\open\command" "" '"$INSTDIR\UDJ.exe" "%1"'
 
435
 
 
436
   SetDetailsPrint textonly
 
437
   DetailPrint "Finsihed."
 
438
SectionEnd
 
439
 
 
440
##############################################################################
 
441
# #
 
442
# UNINSTALLER SECTION #
 
443
# #
 
444
##############################################################################
 
445
 
 
446
Var UnPageUserAppDataDialog
 
447
Var UnPageUserAppDataCheckbox
 
448
Var UnPageUserAppDataCheckbox_State
 
449
Var UnPageUserAppDataEditBox
 
450
 
 
451
Function un.UnPageUserAppData
 
452
   !insertmacro MUI_HEADER_TEXT "Uninstall UDJ" "Remove UDJ's data folder from your computer."
 
453
   nsDialogs::Create /NOUNLOAD 1018
 
454
   Pop $UnPageUserAppDataDialog
 
455
 
 
456
   ${If} $UnPageUserAppDataDialog == error
 
457
      Abort
 
458
   ${EndIf}
 
459
 
 
460
   ${NSD_CreateLabel} 0 0 100% 12u "Do you want to delete UDJ's data folder?"
 
461
   Pop $0
 
462
 
 
463
   ${NSD_CreateText} 0 13u 100% 12u "$LOCALAPPDATA\UDJ"
 
464
   Pop $UnPageUserAppDataEditBox
 
465
   SendMessage $UnPageUserAppDataEditBox ${EM_SETREADONLY} 1 0
 
466
 
 
467
   ${NSD_CreateLabel} 0 46u 100% 24u "Leave unchecked to keep the data folder for later use or check to delete the data folder."
 
468
   Pop $0
 
469
 
 
470
   ${NSD_CreateCheckbox} 0 71u 100% 8u "Yes, delete this data folder."
 
471
   Pop $UnPageUserAppDataCheckbox
 
472
 
 
473
   nsDialogs::Show
 
474
FunctionEnd
 
475
 
 
476
Function un.UnPageUserAppDataLeave
 
477
   ${NSD_GetState} $UnPageUserAppDataCheckbox $UnPageUserAppDataCheckbox_State
 
478
FunctionEnd
 
479
 
 
480
Section Uninstall
 
481
   IfFileExists "$INSTDIR\UDJ.exe" UDJ_installed
 
482
      MessageBox MB_YESNO "It does not appear that UDJ is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES UDJ_installed
 
483
      Abort "Uninstall aborted by user"
 
484
   UDJ_installed:
 
485
 
 
486
   ;Delete registry keys.
 
487
   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ"
 
488
   DeleteRegValue HKLM "Software\UDJ" "VersionBuild"
 
489
   DeleteRegValue HKLM "Software\UDJ" "VersionMajor"
 
490
   DeleteRegValue HKLM "Software\UDJ" "VersionMinor"
 
491
   DeleteRegValue HKLM "Software\UDJ" "VersionRevision"
 
492
   DeleteRegValue HKLM "Software\UDJ" ""
 
493
   DeleteRegKey HKLM "Software\UDJ"
 
494
 
 
495
   DeleteRegKey HKCR "UDJ"
 
496
 
 
497
   ;Start menu shortcuts.
 
498
   !ifdef OPTION_SECTION_SC_START_MENU
 
499
      SetShellVarContext all
 
500
      RMDir /r "$SMPROGRAMS\UDJ"
 
501
      SetShellVarContext current
 
502
   !endif
 
503
 
 
504
   ;Desktop shortcut.
 
505
   !ifdef OPTION_SECTION_SC_DESKTOP
 
506
      IfFileExists "$DESKTOP\UDJ.lnk" 0 +2
 
507
         Delete "$DESKTOP\UDJ.lnk"
 
508
   !endif
 
509
 
 
510
   ;Quick Launch shortcut.
 
511
   !ifdef OPTION_SECTION_SC_QUICK_LAUNCH
 
512
      IfFileExists "$QUICKLAUNCH\UDJ.lnk" 0 +2
 
513
         Delete "$QUICKLAUNCH\UDJ.lnk"
 
514
   !endif
 
515
 
 
516
   ;Remove all the Program Files.
 
517
   RMDir /r $INSTDIR
 
518
 
 
519
   ;Uninstall User Data if option is checked, otherwise skip.
 
520
   ${If} $UnPageUserAppDataCheckbox_State == ${BST_CHECKED}
 
521
      RMDir /r "$LOCALAPPDATA\UDJ"
 
522
   ${EndIf}
 
523
 
 
524
   SetDetailsPrint textonly
 
525
   DetailPrint "Finsihed."
 
526
SectionEnd
 
527
 
 
528
##############################################################################
 
529
# #
 
530
# NSIS Installer Event Handler Functions #
 
531
# #
 
532
##############################################################################
 
533
 
 
534
Function .onInit
 
535
   !insertmacro INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
 
536
 
 
537
   ;Remove Quick Launch option from Windows 7, as no longer applicable - usually.
 
538
   ${IfNot} ${AtMostWinVista}
 
539
      SectionSetText ${SEC_QUICK_LAUNCH} "Quick Launch Shortcut (N/A)"
 
540
      SectionSetFlags ${SEC_QUICK_LAUNCH} ${SF_RO}
 
541
      SectionSetInstTypes ${SEC_QUICK_LAUNCH} 0
 
542
   ${EndIf}
 
543
 
 
544
   ${MementoSectionRestore}
 
545
 
 
546
   UAC_Elevate:
 
547
      UAC::RunElevated
 
548
      StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
 
549
      StrCmp 0 $0 0 UAC_Err ; Error?
 
550
      StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
 
551
      Quit
 
552
 
 
553
   UAC_Err:
 
554
      MessageBox MB_ICONSTOP "Unable to elevate, error $0"
 
555
      Abort
 
556
 
 
557
   UAC_ElevationAborted:
 
558
      Abort
 
559
 
 
560
   UAC_Success:
 
561
      StrCmp 1 $3 +4 ;Admin?
 
562
      StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
 
563
      MessageBox MB_ICONSTOP "This installer requires admin access, try again"
 
564
      goto UAC_Elevate
 
565
 
 
566
   ;Prevent multiple instances.
 
567
   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "UDJInstaller") i .r1 ?e'
 
568
   Pop $R0
 
569
   StrCmp $R0 0 +3
 
570
      MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
 
571
      Abort
 
572
 
 
573
   ;Use available InstallLocation when possible. This is useful in the uninstaller
 
574
   ;via re-install, which would otherwise use a default location - a bug.
 
575
   ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UDJ" "InstallLocation"
 
576
   StrCmp $R0 "" SkipSetInstDir
 
577
   StrCpy $INSTDIR $R0
 
578
   SkipSetInstDir:
 
579
 
 
580
   ;Shutdown UDJ in case Add/Remove re-installer option used.
 
581
   Call EnsureUDJShutdown
 
582
FunctionEnd
 
583
 
 
584
Function .onInstSuccess
 
585
   ${MementoSectionSave}
 
586
   UAC::Unload ;Must call unload!
 
587
FunctionEnd
 
588
 
 
589
Function .onInstFailed
 
590
   UAC::Unload ;Must call unload!
 
591
FunctionEnd
 
592
 
 
593
##############################################################################
 
594
# #
 
595
# NSIS Uninstaller Event Handler Functions #
 
596
# #
 
597
##############################################################################
 
598
 
 
599
Function un.onInit
 
600
   UAC_Elevate:
 
601
      UAC::RunElevated
 
602
      StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
 
603
      StrCmp 0 $0 0 UAC_Err ; Error?
 
604
      StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
 
605
      Quit
 
606
 
 
607
   UAC_Err:
 
608
      MessageBox MB_ICONSTOP "Unable to elevate, error $0"
 
609
      Abort
 
610
 
 
611
   UAC_ElevationAborted:
 
612
      Abort
 
613
 
 
614
   UAC_Success:
 
615
      StrCmp 1 $3 +4 ;Admin?
 
616
      StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
 
617
      MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again"
 
618
      goto UAC_Elevate
 
619
 
 
620
   ;Prevent multiple instances.
 
621
   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "UDJUninstaller") i .r1 ?e'
 
622
   Pop $R0
 
623
   StrCmp $R0 0 +3
 
624
      MessageBox MB_OK|MB_ICONEXCLAMATION "This uninstaller is already running."
 
625
      Abort
 
626
FunctionEnd
 
627
 
 
628
Function un.onUnInstSuccess
 
629
   UAC::Unload ;Must call unload!
 
630
FunctionEnd
 
631
 
 
632
Function un.onUnInstFailed
 
633
   UAC::Unload ;Must call unload!
 
634
FunctionEnd