PageRenderTime 200ms CodeModel.GetById 114ms app.highlight 7ms RepoModel.GetById 73ms app.codeStats 1ms

/CMakeModules/NSIS.template.in

http://github.com/tomahawk-player/tomahawk
Autoconf | 813 lines | 651 code | 127 blank | 35 comment | 13 complexity | e63dc861d781de7f6c9d6995d49f1294 MD5 | raw file
  1;Tomahawk installer script.
  2
  3;-----------------------------------------------------------------------------
  4; Some installer script options (comment-out options not required)
  5;-----------------------------------------------------------------------------
  6;!define OPTION_LICENSE_AGREEMENT
  7!define OPTION_UAC_PLUGIN_ENHANCED
  8!define OPTION_SECTION_SC_START_MENU
  9!define OPTION_SECTION_SC_DESKTOP
 10!define OPTION_SECTION_SC_QUICK_LAUNCH
 11!define OPTION_FINISHPAGE
 12!define OPTION_FINISHPAGE_LAUNCHER
 13!define OPTION_FINISHPAGE_RELEASE_NOTES
 14
 15;-----------------------------------------------------------------------------
 16; Some paths.
 17;-----------------------------------------------------------------------------
 18!ifndef MINGW_ROOT
 19    !define MINGW_ROOT "/usr/i686-w64-mingw32/sys-root/mingw"
 20!endif
 21!define APPLICATION_NAME "@CPACK_PACKAGE_NAME@"
 22!define TARGET_NAME "@CPACK_PACKAGE_TARGET_NAME@"
 23;define app id needed for Windows 8 notifications
 24!define AppUserModelId "@TOMAHAWK_APPLICATION_PACKAGE_NAME@"
 25
 26!define MINGW_BIN "${MINGW_ROOT}/bin"
 27!define MINGW_LIB "${MINGW_ROOT}/lib"
 28!define MINGW_SHARE "${MINGW_ROOT}/share"
 29
 30!define BUILD_PATH "@CMAKE_BINARY_DIR@"
 31!define SOURCE_PATH "@CMAKE_SOURCE_DIR@"
 32!define QT_DLL_PATH "${MINGW_BIN}"
 33!define QT_QML_PATH "${MINGW_SHARE}/qt5/qml"
 34!define SQLITE_DLL_PATH "${MINGW_LIB}/qt5/plugins/sqldrivers"
 35!define IMAGEFORMATS_DLL_PATH "${MINGW_LIB}/qt5/plugins/imageformats"
 36
 37; We use official release plugins
 38; mingw32-vlc from obs misses a lot and has even broken ones probably
 39!define VLC_PATH "${SOURCE_PATH}\admin\win\vlc\" ; SIC! ^
 40!define VLC_BIN "${VLC_PATH}"
 41!define VLC_PLUGIN_PATH "${VLC_BIN}\plugins"
 42
 43!define NSI_PATH "${SOURCE_PATH}/admin/win/nsi"
 44
 45;-----------------------------------------------------------------------------
 46; Installer version
 47;-----------------------------------------------------------------------------
 48
 49!define VER_MAJOR "@CPACK_PACKAGE_VERSION_MAJOR@"
 50!define VER_MINOR "@CPACK_PACKAGE_VERSION_MINOR@"
 51!define VER_BUILD "@CPACK_PACKAGE_VERSION_PATCH@"
 52!define VERSION "@CPACK_PACKAGE_VERSION@"
 53
 54;-----------------------------------------------------------------------------
 55; Installer build timestamp.
 56;-----------------------------------------------------------------------------
 57!define /date BUILD_TIME "built on %Y/%m/%d at %I:%M %p"
 58
 59;-----------------------------------------------------------------------------
 60; Initial installer setup and definitions.
 61;-----------------------------------------------------------------------------
 62Name "@CPACK_NSIS_PACKAGE_NAME@"
 63Caption "${APPLICATION_NAME} Installer"
 64BrandingText "${APPLICATION_NAME} ${VERSION}  -- ${BUILD_TIME}"
 65OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
 66InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
 67InstallDirRegKey HKCU "Software\{APPLICATION_NAME}" ""
 68InstType Standard
 69InstType Full
 70InstType Minimal
 71CRCCheck On
 72SetCompressor @CPACK_NSIS_COMPRESSOR@
 73RequestExecutionLevel user ;Now using the UAC plugin.
 74ReserveFile NSIS.InstallOptions.ini
 75ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
 76
 77@CPACK_NSIS_SECTION_SELECTED_VARS@
 78
 79;-----------------------------------------------------------------------------
 80; Include some required header files.
 81;-----------------------------------------------------------------------------
 82!include LogicLib.nsh ;Used by APPDATA uninstaller.
 83!include nsDialogs.nsh ;Used by APPDATA uninstaller.
 84!include MUI2.nsh ;Used by APPDATA uninstaller.
 85!include InstallOptions.nsh ;Required by MUI2 to support old MUI_INSTALLOPTIONS.
 86!include Memento.nsh ;Remember user selections.
 87!include WinVer.nsh ;Windows version detection.
 88!include WordFunc.nsh  ;Used by VersionCompare macro function.
 89!include UAC.nsh ;Used by the UAC elevation to install as user or admin.
 90!include ${NSI_PATH}\SnoreNotify.nsh ; Macro for creation of a shortcut with a AppUserModelId.
 91
 92;-----------------------------------------------------------------------------
 93; Memento selections stored in registry.
 94;-----------------------------------------------------------------------------
 95!define MEMENTO_REGISTRY_ROOT HKLM
 96!define MEMENTO_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}"
 97
 98;-----------------------------------------------------------------------------
 99; Setup macros for the creation of a shortcut supporting Windows 8 notifications.
100;-----------------------------------------------------------------------------
101!define SnoreToastExe "$INSTDIR\SnoreToast.exe"
102
103;-----------------------------------------------------------------------------
104; Modern User Interface (MUI) defintions and setup.
105;-----------------------------------------------------------------------------
106!define MUI_ABORTWARNING
107!define MUI_ICON ${NSI_PATH}\installer.ico
108!define MUI_UNICON ${NSI_PATH}\installer.ico
109!define MUI_WELCOMEFINISHPAGE_BITMAP ${NSI_PATH}\welcome.bmp
110!define MUI_WELCOMEPAGE_TITLE "@CPACK_PACKAGE_NAME@ ${VERSION} Setup$\r$\nInstaller"
111!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation.$\r$\n$\r$\n$_CLICK"
112!define MUI_HEADERIMAGE
113!define MUI_HEADERIMAGE_BITMAP ${NSI_PATH}\page_header.bmp
114!define MUI_COMPONENTSPAGE_SMALLDESC
115!define MUI_FINISHPAGE_TITLE "@CPACK_PACKAGE_NAME@ Install Completed"
116!define MUI_FINISHPAGE_LINK "Click here to visit the @CPACK_PACKAGE_NAME@ website."
117!define MUI_FINISHPAGE_LINK_LOCATION "http://@TOMAHAWK_ORGANIZATION_DOMAIN@"
118!define MUI_FINISHPAGE_NOREBOOTSUPPORT
119!ifdef OPTION_FINISHPAGE_RELEASE_NOTES
120   !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
121   !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\NOTES.txt"
122   !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show release notes"
123!endif
124!ifdef OPTION_FINISHPAGE_LAUNCHER
125   !define MUI_FINISHPAGE_NOAUTOCLOSE
126   !define MUI_FINISHPAGE_RUN
127   !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchTomahawk"
128!endif
129
130;-----------------------------------------------------------------------------
131; Page macros.
132;-----------------------------------------------------------------------------
133!insertmacro MUI_PAGE_WELCOME
134!ifdef OPTION_LICENSE_AGREEMENT
135   !insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
136!endif
137Page custom PageReinstall PageLeaveReinstall
138!insertmacro MUI_PAGE_COMPONENTS
139!insertmacro MUI_PAGE_DIRECTORY
140!insertmacro MUI_PAGE_INSTFILES
141!ifdef OPTION_FINISHPAGE
142   !insertmacro MUI_PAGE_FINISH
143!endif
144!insertmacro MUI_UNPAGE_CONFIRM
145UninstPage custom un.UnPageUserAppData un.UnPageUserAppDataLeave
146!insertmacro MUI_UNPAGE_INSTFILES
147
148;-----------------------------------------------------------------------------
149; Other MUI macros.
150;-----------------------------------------------------------------------------
151!insertmacro MUI_LANGUAGE "English"
152
153##############################################################################
154#                                                                            #
155#   FINISH PAGE LAUNCHER FUNCTIONS                                           #
156#                                                                            #
157##############################################################################
158
159Function LaunchTomahawk
160   ${UAC.CallFunctionAsUser} LaunchTomahawkAsUser
161FunctionEnd
162
163Function LaunchTomahawkAsUser
164   Exec "$INSTDIR\${APPLICATION_NAME}.exe"
165FunctionEnd
166
167##############################################################################
168#                                                                            #
169#   PROCESS HANDLING FUNCTIONS AND MACROS                                    #
170#                                                                            #
171##############################################################################
172
173!macro CheckForProcess processName gotoWhenFound gotoWhenNotFound
174   Processes::FindProcess "${processName}"
175   StrCmp $R0 "0" "${gotoWhenNotFound}" "${gotoWhenFound}"
176!macroend
177
178!macro ConfirmEndProcess processTitle processName
179   MessageBox MB_YESNO|MB_ICONEXCLAMATION \
180     "Found ${processName} process(s) which need to be stopped.$\nDo you want the installer to stop these for you?" \
181     IDYES "process_${processTitle}_kill" IDNO "process_${processTitle}_ended"
182   process_${processTitle}_kill:
183      DetailPrint "Killing ${processName} processes."
184      Processes::KillProcess "${processName}"
185      Sleep 1500
186      StrCmp $R0 "1" "process_${processTitle}_ended"
187      DetailPrint "Process to kill not found!"
188   process_${processTitle}_ended:
189!macroend
190
191!macro CheckAndConfirmEndProcess processTitle processName
192   !insertmacro CheckForProcess "${processName}" 0 "no_process_${processTitle}_to_end"
193   !insertmacro ConfirmEndProcess "${processTitle}" "${processName}"
194   no_process_${processTitle}_to_end:
195!macroend
196
197Function EnsureTomahawkShutdown
198   !insertmacro CheckAndConfirmEndProcess "${TARGET_NAME}" "${APPLICATION_NAME}.exe"
199FunctionEnd
200
201##############################################################################
202#                                                                            #
203#   RE-INSTALLER FUNCTIONS                                                   #
204#                                                                            #
205##############################################################################
206
207Function PageReinstall
208   ReadRegStr $R0 HKLM "Software\${APPLICATION_NAME}" ""
209   StrCmp $R0 "" 0 +2
210   Abort
211
212   ;Detect version
213   ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionMajor"
214   IntCmp $R0 ${VER_MAJOR} minor_check new_version older_version
215   minor_check:
216      ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionMinor"
217      IntCmp $R0 ${VER_MINOR} build_check new_version older_version
218   build_check:
219      ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionBuild"
220      IntCmp $R0 ${VER_BUILD} same_version new_version older_version
221
222   new_version:
223      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "An older version of ${APPLICATION_NAME} 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."
224      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Uninstall before installing"
225      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Do not uninstall"
226      !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install ${APPLICATION_NAME}."
227      StrCpy $R0 "1"
228      Goto reinst_start
229
230   older_version:
231      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "A newer version of ${APPLICATION_NAME} 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."
232      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Uninstall before installing"
233      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Do not uninstall"
234      !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install ${APPLICATION_NAME}."
235      StrCpy $R0 "1"
236      Goto reinst_start
237
238   same_version:
239      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "${APPLICATION_NAME} ${VERSION} is already installed.\r\nSelect the operation you want to perform and click Next to continue."
240      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Add/Reinstall components"
241      !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Uninstall ${APPLICATION_NAME}"
242      !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
243      StrCpy $R0 "2"
244
245   reinst_start:
246      !insertmacro INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
247FunctionEnd
248
249Function PageLeaveReinstall
250   !insertmacro INSTALLOPTIONS_READ $R1 "NSIS.InstallOptions.ini" "Field 2" "State"
251   StrCmp $R0 "1" 0 +2
252   StrCmp $R1 "1" reinst_uninstall reinst_done
253   StrCmp $R0 "2" 0 +3
254   StrCmp $R1 "1" reinst_done reinst_uninstall
255   reinst_uninstall:
256      ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "UninstallString"
257      HideWindow
258      ClearErrors
259      ExecWait '$R1 _?=$INSTDIR'
260      IfErrors no_remove_uninstaller
261      IfFileExists "$INSTDIR\${APPLICATION_NAME}.exe" no_remove_uninstaller
262      Delete $R1
263      RMDir $INSTDIR
264   no_remove_uninstaller:
265      StrCmp $R0 "2" 0 +3
266      UAC::Unload
267      Quit
268      BringToFront
269   reinst_done:
270FunctionEnd
271
272##############################################################################
273#                                                                            #
274#   INSTALLER SECTIONS                                                       #
275#                                                                            #
276##############################################################################
277Section "${APPLICATION_NAME}" SEC_TOMAHAWK_PLAYER
278   SectionIn 1 2 3 RO
279   SetDetailsPrint listonly
280
281   SetDetailsPrint textonly
282   DetailPrint "Installing ${APPLICATION_NAME} essentials."
283   SetDetailsPrint listonly
284   SetOutPath "$INSTDIR"
285
286   !ifdef INSTALL_PATH
287        ;Main executable.
288        File "${INSTALL_PATH}\bin\${APPLICATION_NAME}.exe"
289
290        File "${INSTALL_PATH}\bin\${TARGET_NAME}_crash_reporter.exe"
291
292        File "${INSTALL_PATH}\bin\lib${TARGET_NAME}.dll"
293        File "${INSTALL_PATH}\bin\lib${TARGET_NAME}-widgets.dll"
294        File "${INSTALL_PATH}\bin\lib${TARGET_NAME}-playdarapi.dll"
295
296        ; plugins
297        File "${INSTALL_PATH}\lib\lib${TARGET_NAME}_*_*.dll"
298   !endif
299   !ifndef INSTALL_PATH
300        ;Main executable.
301        File "${BUILD_PATH}\${APPLICATION_NAME}.exe"
302
303        File "${BUILD_PATH}\${TARGET_NAME}_crash_reporter.exe"
304
305        File "${BUILD_PATH}\lib${TARGET_NAME}.dll"
306        File "${BUILD_PATH}\lib${TARGET_NAME}-widgets.dll"
307        File "${BUILD_PATH}\lib${TARGET_NAME}-playdarapi.dll"
308
309        ; plugins
310        File "${BUILD_PATH}\lib${TARGET_NAME}_*_*.dll"
311   !endif
312
313   ;License & release notes.
314   File "@CPACK_RESOURCE_FILE_LICENSE@"
315   File /oname=NOTES.txt ${NSI_PATH}\RELEASE_NOTES.txt
316
317   ;QT stuff:
318    File "${QT_DLL_PATH}\Qt5Network.dll"
319    File "${QT_DLL_PATH}\Qt5Qml.dll"
320    File "${QT_DLL_PATH}\Qt5Sql.dll"
321    File "${QT_DLL_PATH}\Qt5Xml.dll"
322    File "${QT_DLL_PATH}\Qt5Core.dll"
323    File "${QT_DLL_PATH}\Qt5OpenGL.dll"
324    File "${QT_DLL_PATH}\Qt5Quick.dll"
325    File "${QT_DLL_PATH}\Qt5Svg.dll"
326    File "${QT_DLL_PATH}\Qt5Widgets.dll"
327    File "${QT_DLL_PATH}\Qt5Gui.dll"
328    File "${QT_DLL_PATH}\Qt5PrintSupport.dll"
329    File "${QT_DLL_PATH}\Qt5Sensors.dll"
330    File "${QT_DLL_PATH}\Qt5WebKit.dll"
331    File "${QT_DLL_PATH}\Qt5WinExtras.dll"
332    File "${QT_DLL_PATH}\Qt5WebKit.dll"
333    File "${QT_DLL_PATH}\Qt5WebKitWidgets.dll"
334    File "${QT_DLL_PATH}\Qt5Multimedia.dll"
335    File "${QT_DLL_PATH}\Qt5MultimediaWidgets.dll"
336    File "${QT_DLL_PATH}\Qt5Positioning.dll"
337
338    ;Qt deps
339    File "${QT_DLL_PATH}\libpcre16-0.dll"
340    File "${QT_DLL_PATH}\libxml2-2.dll"
341    File "${QT_DLL_PATH}\libxslt-1.dll"
342    File "${QT_DLL_PATH}\libEGL.dll"
343    File "${QT_DLL_PATH}\libGLESv2.dll"
344    File "${QT_DLL_PATH}\libwebp-5.dll"
345    File "${QT_DLL_PATH}\icuuc56.dll"
346    File "${QT_DLL_PATH}\icudata56.dll"
347    File "${QT_DLL_PATH}\icui18n56.dll"
348
349    ;SQLite driver
350    SetOutPath "$INSTDIR\sqldrivers"
351    File "${SQLITE_DLL_PATH}\qsqlite.dll"
352    SetOutPath "$INSTDIR"
353    File "${MINGW_BIN}\libsqlite3-0.dll"
354
355    ;Qt platform plugins
356    SetOutPath "$INSTDIR\platforms"
357     File "${MINGW_LIB}/qt5/plugins/platforms/qwindows.dll"
358    SetOutPath "$INSTDIR"
359
360    ;Image plugins
361    SetOutPath "$INSTDIR\imageformats"
362    File "${IMAGEFORMATS_DLL_PATH}\qgif.dll"
363    File "${IMAGEFORMATS_DLL_PATH}\qjpeg.dll"
364    File "${IMAGEFORMATS_DLL_PATH}\qsvg.dll"
365    SetOutPath "$INSTDIR"
366
367    ;Qt qml plugins
368    SetOutPath "$INSTDIR\QtQuick.2"
369    File /r /x *.debug "${QT_QML_PATH}\QtQuick.2\*"
370    SetOutPath "$INSTDIR\QtQuick\Window.2"
371    File /r /x *.debug "${QT_QML_PATH}\QtQuick\Window.2\*"
372    SetOutPath "$INSTDIR"
373
374    ;Cygwin/c++ stuff
375    File "${MINGW_BIN}\libgcc_s_sjlj-1.dll"
376    File "${MINGW_BIN}\libstdc++-6.dll"
377
378    ;VLC
379    File "${VLC_BIN}\libvlc.dll"
380    File "${VLC_BIN}\libvlccore.dll"
381    SetOutPath "$INSTDIR\plugins"
382    File /r "${VLC_PLUGIN_PATH}\*.dll"
383    SetOutPath "$INSTDIR"
384
385    ; Other
386    File "${MINGW_BIN}\libtag.dll"
387    File "${MINGW_BIN}\libpng16-16.dll"
388    File "${MINGW_BIN}\libjpeg-8.dll"
389    File "${MINGW_BIN}\zlib1.dll"
390    File "${MINGW_BIN}\libfreetype-6.dll"
391    File "${MINGW_BIN}\libglib-2.0-0.dll"
392    File "${MINGW_BIN}\libharfbuzz-0.dll"
393
394    ; ANGLE
395    File "${MINGW_BIN}\D3DCompiler_43.dll"
396
397    File "${MINGW_BIN}\libechonest5.dll"
398    File "${MINGW_BIN}\liblastfm5.dll"
399    File "${MINGW_BIN}\libquazip5.dll"
400    File "${MINGW_BIN}\libqt5keychain.dll"
401
402    ; GnuTLS
403    File "${MINGW_BIN}\libgnutls-28.dll"
404    File "${MINGW_BIN}\libtasn1-6.dll"
405    File "${MINGW_BIN}\libgmp-10.dll"
406    File "${MINGW_BIN}\libhogweed-4-1.dll"
407    File "${MINGW_BIN}\libintl-8.dll"
408    File "${MINGW_BIN}\libnettle-6-1.dll"
409    File "${MINGW_BIN}\libp11-kit-0.dll"
410    File "${MINGW_BIN}\libffi-6.dll"
411
412    ; Snorenotify
413    File "${MINGW_BIN}\SnoreToast.exe"
414    File "${MINGW_BIN}\libsnore-qt5.dll"
415    File "${MINGW_BIN}\libsnoresettings-qt5.dll"
416    File "${MINGW_BIN}\snoresettings.exe"
417    File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_backend_growl.dll"
418    File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_settings_backend_growl.dll"
419    File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_backend_snarl.dll"
420    File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_settings_backend_snarl.dll"
421    File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_backend_snore.dll"
422    File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_settings_backend_snore.dll"
423    File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_backend_windowstoast.dll"
424
425    ; Snoregrowl
426    File "${MINGW_BIN}\libsnoregrowl++.dll"
427    File "${MINGW_BIN}\libsnoregrowl.dll"
428
429   ; Jabber
430    File "${MINGW_BIN}\libjreen-qt5.dll"
431    File "${MINGW_BIN}\libidn-11.dll"
432    File "${MINGW_BIN}\libgsasl-7.dll"
433    File "${MINGW_BIN}\libqca-qt5.dll"
434    SetOutPath "$INSTDIR\crypto"
435    File "${MINGW_LIB}\qca-qt5\crypto\libqca-ossl.dll"
436    SetOutPath "$INSTDIR"
437    File "${MINGW_BIN}\libssl-10.dll"
438    File "${MINGW_BIN}\libcrypto-10.dll"
439
440    ; LucenePlusPlus
441    File "${MINGW_BIN}\liblucene++.dll"
442    File "${MINGW_BIN}\libboost_system-mt.dll"
443    File "${MINGW_BIN}\libboost_filesystem-mt.dll"
444    File "${MINGW_BIN}\libboost_iostreams-mt.dll"
445    File "${MINGW_BIN}\libboost_regex-mt.dll"
446    File "${MINGW_BIN}\libboost_thread-mt.dll"
447    File "${MINGW_BIN}\libbz2-1.dll"
448
449    File "${MINGW_BIN}\libqtsparkle-qt5.dll"
450    File "${MINGW_BIN}\libKF5Attica.dll"
451SectionEnd
452
453SectionGroup "Shortcuts"
454
455!ifdef OPTION_SECTION_SC_START_MENU
456   ${MementoSection} "Start Menu Program Group" SEC_START_MENU
457      SectionIn 1 2
458      SetDetailsPrint textonly
459      DetailPrint "Adding shortcuts for the ${APPLICATION_NAME} program group to the Start Menu."
460      SetDetailsPrint listonly
461      SetShellVarContext all
462      RMDir /r "$SMPROGRAMS\${APPLICATION_NAME}"
463      CreateDirectory "$SMPROGRAMS\${APPLICATION_NAME}"
464      CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\LICENSE.lnk" "$INSTDIR\LICENSE.txt"
465      CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\Notification Settings.lnk" "$INSTDIR\snoresettings.exe" "-a ${APPLICATION_NAME}"
466      !insertmacro SnoreShortcut "$SMPROGRAMS\${APPLICATION_NAME}\${APPLICATION_NAME}.lnk" "$INSTDIR\${APPLICATION_NAME}.exe" "${AppUserModelId}"
467      CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\Release notes.lnk" "$INSTDIR\NOTES.txt"
468      CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
469      SetShellVarContext current
470   ${MementoSectionEnd}
471!endif
472
473!ifdef OPTION_SECTION_SC_DESKTOP
474   ${MementoSection} "Desktop Shortcut" SEC_DESKTOP
475      SectionIn 1 2
476      SetDetailsPrint textonly
477      DetailPrint "Creating Desktop Shortcuts"
478      SetDetailsPrint listonly
479      CreateShortCut "$DESKTOP\${APPLICATION_NAME}.lnk" "$INSTDIR\${APPLICATION_NAME}.exe"
480   ${MementoSectionEnd}
481!endif
482
483!ifdef OPTION_SECTION_SC_QUICK_LAUNCH
484   ${MementoSection} "Quick Launch Shortcut" SEC_QUICK_LAUNCH
485      SectionIn 1 2
486      SetDetailsPrint textonly
487      DetailPrint "Creating Quick Launch Shortcut"
488      SetDetailsPrint listonly
489      CreateShortCut "$QUICKLAUNCH\${APPLICATION_NAME}.lnk" "$INSTDIR\${APPLICATION_NAME}.exe"
490   ${MementoSectionEnd}
491!endif
492
493SectionGroupEnd
494
495${MementoSectionDone}
496
497; Installer section descriptions
498;--------------------------------
499!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
500!insertmacro MUI_DESCRIPTION_TEXT ${SEC_TOMAHAWK_PLAYER} "${APPLICATION_NAME} essentials."
501!insertmacro MUI_DESCRIPTION_TEXT ${SEC_START_MENU} "${APPLICATION_NAME} program group."
502!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} "Desktop shortcut for ${APPLICATION_NAME}."
503!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QUICK_LAUNCH} "Quick Launch shortcut for ${APPLICATION_NAME}."
504!insertmacro MUI_FUNCTION_DESCRIPTION_END
505
506Section -post
507
508   ;Uninstaller file.
509   SetDetailsPrint textonly
510   DetailPrint "Writing Uninstaller"
511   SetDetailsPrint listonly
512   WriteUninstaller $INSTDIR\uninstall.exe
513
514   ;Registry keys required for installer version handling and uninstaller.
515   SetDetailsPrint textonly
516   DetailPrint "Writing Installer Registry Keys"
517   SetDetailsPrint listonly
518
519   ;Version numbers used to detect existing installation version for comparisson.
520   WriteRegStr HKLM "Software\${APPLICATION_NAME}" "" $INSTDIR
521   WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionMajor" "${VER_MAJOR}"
522   WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionMinor" "${VER_MINOR}"
523   WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionRevision" "${REVISION}"
524   WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionBuild" "${VER_BUILD}"
525
526   ;Add or Remove Programs entry.
527   WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
528   WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "InstallLocation" "$INSTDIR"
529   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "DisplayName" "${APPLICATION_NAME}"
530   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "Publisher" "@TOMAHAWK_ORGANIZATION_DOMAIN@"
531   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"
532   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "DisplayVersion" "${VERSION}"
533   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "VersionMajor" "${VER_MAJOR}"
534   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "VersionMinor" "${VER_MINOR}.${REVISION}"
535   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "URLInfoAbout" "http://@TOMAHAWK_ORGANIZATION_DOMAIN@/"
536   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "HelpLink" "http://@TOMAHAWK_ORGANIZATION_DOMAIN@/"
537   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "NoModify" "1"
538   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "NoRepair" "1"
539
540   ; Register tomahawk:// protocol handler
541   WriteRegStr HKCR "tomahawk" "" "URL:Tomahawk Protocol"
542   WriteRegStr HKCR "tomahawk" "URL Protocol" ""
543   WriteRegStr HKCR "tomahawk\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
544   WriteRegStr HKCR "tomahawk\shell" "" "open"
545   WriteRegStr HKCR "tomahawk\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
546
547   ; Register file associations
548   WriteRegStr HKCR ".mp3" "" "MPEG Audio Layer 3"
549   WriteRegStr HKCR ".mp3\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
550   WriteRegStr HKCR ".mp3\shell" "" "open"
551   WriteRegStr HKCR ".mp3\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
552
553   WriteRegStr HKCR ".oga" "" "Ogg Audio File"
554   WriteRegStr HKCR ".oga\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
555   WriteRegStr HKCR ".oga\shell" "" "open"
556   WriteRegStr HKCR ".oga\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
557
558   WriteRegStr HKCR ".ogg" "" "Ogg Audio File"
559   WriteRegStr HKCR ".ogg\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
560   WriteRegStr HKCR ".ogg\shell" "" "open"
561   WriteRegStr HKCR ".ogg\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
562
563   WriteRegStr HKCR ".opus" "" "OPUS File"
564   WriteRegStr HKCR ".opus\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
565   WriteRegStr HKCR ".opus\shell" "" "open"
566   WriteRegStr HKCR ".opus\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
567
568   WriteRegStr HKCR ".mp4" "" "AAC File"
569   WriteRegStr HKCR ".mp4\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
570   WriteRegStr HKCR ".mp4\shell" "" "open"
571   WriteRegStr HKCR ".mp4\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
572
573   WriteRegStr HKCR ".aac" "" "AAC File"
574   WriteRegStr HKCR ".aac\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
575   WriteRegStr HKCR ".aac\shell" "" "open"
576   WriteRegStr HKCR ".aac\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
577
578   WriteRegStr HKCR ".m4a" "" "AAC File"
579   WriteRegStr HKCR ".m4a\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
580   WriteRegStr HKCR ".m4a\shell" "" "open"
581   WriteRegStr HKCR ".m4a\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
582
583   WriteRegStr HKCR ".mpc" "" "Musepack Audio File"
584   WriteRegStr HKCR ".mpc\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
585   WriteRegStr HKCR ".mpc\shell" "" "open"
586   WriteRegStr HKCR ".mpc\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
587
588   WriteRegStr HKCR ".wma" "" "Windows Media Audio"
589   WriteRegStr HKCR ".wma\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
590   WriteRegStr HKCR ".wma\shell" "" "open"
591   WriteRegStr HKCR ".wma\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
592
593   WriteRegStr HKCR ".aiff" "" "AIFF File"
594   WriteRegStr HKCR ".aiff\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
595   WriteRegStr HKCR ".aiff\shell" "" "open"
596   WriteRegStr HKCR ".aiff\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
597
598   WriteRegStr HKCR ".aif" "" "AIFF File"
599   WriteRegStr HKCR ".aif\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
600   WriteRegStr HKCR ".aif\shell" "" "open"
601   WriteRegStr HKCR ".aif\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
602
603   WriteRegStr HKCR ".wv" "" "WavePack Audio File"
604   WriteRegStr HKCR ".wv\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
605   WriteRegStr HKCR ".wv\shell" "" "open"
606   WriteRegStr HKCR ".wv\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
607
608   WriteRegStr HKCR ".flac" "" "FLAC Audio File"
609   WriteRegStr HKCR ".flac\DefaultIcon" "" "$INSTDIR\${APPLICATION_NAME}.exe,1"
610   WriteRegStr HKCR ".flac\shell" "" "open"
611   WriteRegStr HKCR ".flac\shell\open\command" "" '"$INSTDIR\${APPLICATION_NAME}.exe" "%1"'
612
613   SetDetailsPrint textonly
614   DetailPrint "Finsihed."
615SectionEnd
616
617##############################################################################
618#                                                                            #
619#   UNINSTALLER SECTION                                                      #
620#                                                                            #
621##############################################################################
622
623Var UnPageUserAppDataDialog
624Var UnPageUserAppDataCheckbox
625Var UnPageUserAppDataCheckbox_State
626Var UnPageUserAppDataEditBox
627
628Function un.UnPageUserAppData
629   !insertmacro MUI_HEADER_TEXT "Uninstall ${APPLICATION_NAME}" "Remove ${APPLICATION_NAME}'s data folder from your computer."
630   nsDialogs::Create /NOUNLOAD 1018
631   Pop $UnPageUserAppDataDialog
632
633   ${If} $UnPageUserAppDataDialog == error
634      Abort
635   ${EndIf}
636
637   ${NSD_CreateLabel} 0 0 100% 12u "Do you want to delete ${APPLICATION_NAME}'s data folder?"
638   Pop $0
639
640   ${NSD_CreateText} 0 13u 100% 12u "$LOCALAPPDATA\${APPLICATION_NAME}"
641   Pop $UnPageUserAppDataEditBox
642   SendMessage $UnPageUserAppDataEditBox ${EM_SETREADONLY} 1 0
643
644   ${NSD_CreateLabel} 0 46u 100% 24u "Leave unchecked to keep the data folder for later use or check to delete the data folder."
645   Pop $0
646
647   ${NSD_CreateCheckbox} 0 71u 100% 8u "Yes, delete this data folder."
648   Pop $UnPageUserAppDataCheckbox
649
650   nsDialogs::Show
651FunctionEnd
652
653Function un.UnPageUserAppDataLeave
654   ${NSD_GetState} $UnPageUserAppDataCheckbox $UnPageUserAppDataCheckbox_State
655FunctionEnd
656
657Section Uninstall
658   IfFileExists "$INSTDIR\${APPLICATION_NAME}.exe" tomahawk_installed
659      MessageBox MB_YESNO "It does not appear that ${APPLICATION_NAME} is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES tomahawk_installed
660      Abort "Uninstall aborted by user"
661   tomahawk_installed:
662
663   ;Delete registry keys.
664   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}"
665   DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionBuild"
666   DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionMajor"
667   DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionMinor"
668   DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionRevision"
669   DeleteRegValue HKLM "Software\${APPLICATION_NAME}" ""
670   DeleteRegKey HKLM "Software\${APPLICATION_NAME}"
671
672   ;DeleteRegKey HKCR "Software\${APPLICATION_NAME}"
673   ;DeleteRegKey HKCR "Software\${APPLICATION_NAME}Spotify"
674   DeleteRegKey HKCR "${APPLICATION_NAME}"
675
676   ;Start menu shortcuts.
677   !ifdef OPTION_SECTION_SC_START_MENU
678      SetShellVarContext all
679      RMDir /r "$SMPROGRAMS\${APPLICATION_NAME}"
680      SetShellVarContext current
681   !endif
682
683   ;Desktop shortcut.
684   !ifdef OPTION_SECTION_SC_DESKTOP
685      IfFileExists "$DESKTOP\${APPLICATION_NAME}.lnk" 0 +2
686         Delete "$DESKTOP\${APPLICATION_NAME}.lnk"
687   !endif
688
689   ;Quick Launch shortcut.
690   !ifdef OPTION_SECTION_SC_QUICK_LAUNCH
691      IfFileExists "$QUICKLAUNCH\${APPLICATION_NAME}.lnk" 0 +2
692         Delete "$QUICKLAUNCH\${APPLICATION_NAME}.lnk"
693   !endif
694
695   ;Remove all the Program Files.
696   RMDir /r $INSTDIR
697
698   ;Uninstall User Data if option is checked, otherwise skip.
699   ${If} $UnPageUserAppDataCheckbox_State == ${BST_CHECKED}
700      RMDir /r "$LOCALAPPDATA\${APPLICATION_NAME}"
701   ${EndIf}
702
703   SetDetailsPrint textonly
704   DetailPrint "Finsihed."
705SectionEnd
706
707##############################################################################
708#                                                                            #
709#   NSIS Installer Event Handler Functions                                   #
710#                                                                            #
711##############################################################################
712
713Function .onInit
714   !insertmacro INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
715
716   ;Remove Quick Launch option from Windows 7, as no longer applicable - usually.
717   ${IfNot} ${AtMostWinVista}
718      SectionSetText ${SEC_QUICK_LAUNCH} "Quick Launch Shortcut (N/A)"
719      SectionSetFlags ${SEC_QUICK_LAUNCH} ${SF_RO}
720      SectionSetInstTypes ${SEC_QUICK_LAUNCH} 0
721   ${EndIf}
722
723   ${MementoSectionRestore}
724
725   UAC_Elevate:
726      UAC::RunElevated
727      StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
728      StrCmp 0 $0 0 UAC_Err ; Error?
729      StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
730      Quit
731
732   UAC_Err:
733      MessageBox MB_ICONSTOP "Unable to elevate, error $0"
734      Abort
735
736   UAC_ElevationAborted:
737      Abort
738
739   UAC_Success:
740      StrCmp 1 $3 +4 ;Admin?
741      StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
742      MessageBox MB_ICONSTOP "This installer requires admin access, try again"
743      goto UAC_Elevate
744
745   ;Prevent multiple instances.
746   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkInstaller") i .r1 ?e'
747   Pop $R0
748   StrCmp $R0 0 +3
749      MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
750      Abort
751
752   ;Use available InstallLocation when possible. This is useful in the uninstaller
753   ;via re-install, which would otherwise use a default location - a bug.
754   ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "InstallLocation"
755   StrCmp $R0 "" SkipSetInstDir
756   StrCpy $INSTDIR $R0
757   SkipSetInstDir:
758
759   ;Shutdown Tomahawk in case Add/Remove re-installer option used.
760   Call EnsureTomahawkShutdown
761FunctionEnd
762
763Function .onInstSuccess
764   ${MementoSectionSave}
765   UAC::Unload ;Must call unload!
766FunctionEnd
767
768Function .onInstFailed
769   UAC::Unload ;Must call unload!
770FunctionEnd
771
772##############################################################################
773#                                                                            #
774#   NSIS Uninstaller Event Handler Functions                                 #
775#                                                                            #
776##############################################################################
777
778Function un.onInit
779   UAC_Elevate:
780      UAC::RunElevated
781      StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
782      StrCmp 0 $0 0 UAC_Err ; Error?
783      StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
784      Quit
785
786   UAC_Err:
787      MessageBox MB_ICONSTOP "Unable to elevate, error $0"
788      Abort
789
790   UAC_ElevationAborted:
791      Abort
792
793   UAC_Success:
794      StrCmp 1 $3 +4 ;Admin?
795      StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
796      MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again"
797      goto UAC_Elevate
798
799   ;Prevent multiple instances.
800   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkUninstaller") i .r1 ?e'
801   Pop $R0
802   StrCmp $R0 0 +3
803      MessageBox MB_OK|MB_ICONEXCLAMATION "This uninstaller is already running."
804      Abort
805FunctionEnd
806
807Function un.onUnInstSuccess
808   UAC::Unload ;Must call unload!
809FunctionEnd
810
811Function un.onUnInstFailed
812   UAC::Unload ;Must call unload!
813FunctionEnd