1;Installer script for win32/win64 SMPlayer
2;Written by redxii (redxii@users.sourceforge.net)
3;Tested/Developed with Unicode NSIS 2.46.5/3.01
4
5; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation
6!macro !defineifexist _VAR_NAME _FILE_NAME
7  !tempfile _TEMPFILE
8  !ifdef NSIS_WIN32_MAKENSIS
9    ; Windows - cmd.exe
10    !system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
11  !else
12    ; Posix - sh
13    !system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi'
14  !endif
15  !include '${_TEMPFILE}'
16  !delfile '${_TEMPFILE}'
17  !undef _TEMPFILE
18!macroend
19!define !defineifexist "!insertmacro !defineifexist"
20
21!ifndef VER_MAJOR | VER_MINOR | VER_BUILD
22  !error "Version information not defined (or incomplete). You must define: VER_MAJOR, VER_MINOR, VER_BUILD."
23!endif
24
25;Use this to make 3.0+ mandatory
26;!if 0x2999999 >= "${NSIS_PACKEDVERSION}"
27;!error "NSIS 3.0 or higher required"
28;!endif
29
30!if ${NSIS_PACKEDVERSION} > 0x2999999
31  Unicode true
32!endif
33
34;--------------------------------
35;Compressor
36
37  SetCompressor /SOLID lzma
38  SetCompressorDictSize 32
39
40;--------------------------------
41;Additional plugin folders
42
43  !addplugindir .
44  !addincludedir .
45
46;--------------------------------
47;Defines
48
49!ifdef VER_REVISION
50  !define SMPLAYER_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}.${VER_REVISION}"
51  !define SMPLAYER_PRODUCT_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}.${VER_REVISION}"
52!else ifndef VER_REVISION
53  !define SMPLAYER_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}"
54  !define SMPLAYER_PRODUCT_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}.0"
55!endif
56
57  !define SMPLAYER_BUILD_DIR "smplayer-build"
58  !define SMPLAYER_REG_KEY "Software\SMPlayer"
59  !define SMPLAYER_APP_PATHS_KEY "Software\Microsoft\Windows\CurrentVersion\App Paths\smplayer.exe"
60  !define SMPLAYER_DEF_PROGS_KEY "Software\Clients\Media\SMPlayer"
61
62  !define SMPLAYER_UNINST_EXE "uninst.exe"
63  !define SMPLAYER_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SMPlayer"
64
65  !define STATUS_DLL_NOT_FOUND "-1073741515"
66
67  ${!defineifexist} COMPILED_WITH_QT4 ${SMPLAYER_BUILD_DIR}\QtCore4.dll
68
69  ; Not the same as Qt, check file properties of the webkit dll if unsure
70!ifndef QT_WEBKIT_VERSION
71  !ifdef COMPILED_WITH_QT4
72    ; Qt Webkit version in 4.8.7
73    !define QT_WEBKIT_VERSION "4.9.4.0"
74  !else
75    !define QT_WEBKIT_VERSION "5.6.1.0"
76  !endif
77!endif
78
79;--------------------------------
80;General
81
82  ;Name and file
83  Name "SMPlayer ${SMPLAYER_VERSION}"
84  BrandingText "SMPlayer for Windows v${SMPLAYER_VERSION}"
85!ifdef WIN64
86  !ifdef COMPILED_WITH_QT4
87    OutFile "output\smplayer-${SMPLAYER_VERSION}-x64-Qt4.exe"
88  !else
89    OutFile "output\smplayer-${SMPLAYER_VERSION}-x64.exe"
90  !endif
91!else
92  !ifdef COMPILED_WITH_QT4
93    OutFile "output\smplayer-${SMPLAYER_VERSION}-win32-Qt4.exe"
94  !else
95    OutFile "output\smplayer-${SMPLAYER_VERSION}-win32.exe"
96  !endif
97!endif
98
99  ;Version tab properties
100  VIProductVersion "${SMPLAYER_PRODUCT_VERSION}"
101  VIAddVersionKey "ProductName" "SMPlayer"
102  VIAddVersionKey "ProductVersion" "${SMPLAYER_VERSION}"
103  VIAddVersionKey "FileVersion" "${SMPLAYER_VERSION}"
104  VIAddVersionKey "LegalCopyright" ""
105!ifdef WIN64
106  VIAddVersionKey "FileDescription" "SMPlayer Installer (64-bit)"
107!else
108  VIAddVersionKey "FileDescription" "SMPlayer Installer (32-bit)"
109!endif
110
111  ;Default installation folder
112!ifdef WIN64
113  InstallDir "$PROGRAMFILES64\SMPlayer"
114!else
115  InstallDir "$PROGRAMFILES\SMPlayer"
116!endif
117
118  ;Get installation folder from registry if available
119  InstallDirRegKey HKLM "${SMPLAYER_REG_KEY}" "Path"
120
121  ;Vista+ XML manifest, does not affect older OSes
122  RequestExecutionLevel admin
123
124  ShowInstDetails show
125  ShowUnInstDetails show
126
127;--------------------------------
128;Variables
129
130  Var Dialog_Reinstall
131  Var Inst_Type
132  Var Previous_Version
133  Var Previous_Version_State
134  Var Reinstall_ChgSettings
135  Var Reinstall_ChgSettings_State
136  Var Reinstall_Message
137  Var Reinstall_OverwriteButton
138  Var Reinstall_OverwriteButton_State
139  Var Reinstall_RemoveSettings
140  Var Reinstall_RemoveSettings_State
141  Var Reinstall_Uninstall
142  Var Reinstall_UninstallButton
143  Var Reinstall_UninstallButton_State
144!ifndef WIN64
145  Var Restore_Codecs
146!endif
147  ;Var Restore_YTDL
148  Var Restore_SMTube
149  Var SMPlayer_Path
150  Var SMPlayer_UnStrPath
151  Var SMPlayer_StartMenuFolder
152
153  Var Qt_Core_Source_Version
154  Var Qt_Core_Installed_Version
155  Var Qt_WebKit_Installed_Version
156
157  ;Var YTDL_Exit_Code
158
159  Var MMEngineFlags
160
161;--------------------------------
162;Interface Settings
163
164  ;Installer/Uninstaller icons
165  !define MUI_ICON "smplayer-orange-installer.ico"
166  !define MUI_UNICON "smplayer-orange-uninstaller.ico"
167
168  ;Misc
169  !define MUI_WELCOMEFINISHPAGE_BITMAP "smplayer-orange-wizard.bmp"
170  !define MUI_UNWELCOMEFINISHPAGE_BITMAP "smplayer-orange-wizard-un.bmp"
171  !define MUI_ABORTWARNING
172
173  ;Welcome page
174  !define MUI_WELCOMEPAGE_TITLE $(WelcomePage_Title)
175  !define MUI_WELCOMEPAGE_TEXT $(WelcomePage_Text)
176
177  ;License page
178  !define MUI_LICENSEPAGE_RADIOBUTTONS
179
180  ;Components page
181  !define MUI_COMPONENTSPAGE_SMALLDESC
182
183  ;Finish page
184  !define MUI_FINISHPAGE_LINK "http://www.smplayer.info"
185  !define MUI_FINISHPAGE_LINK_LOCATION "http://www.smplayer.info"
186  !define MUI_FINISHPAGE_NOREBOOTSUPPORT
187  !define MUI_FINISHPAGE_RUN $INSTDIR\smplayer.exe
188  !define MUI_FINISHPAGE_RUN_NOTCHECKED
189  !define MUI_FINISHPAGE_SHOWREADME $INSTDIR\Release_notes.txt
190  !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
191
192  ;Language Selection Dialog Settings
193  !define MUI_LANGDLL_REGISTRY_ROOT HKLM
194  !define MUI_LANGDLL_REGISTRY_KEY "${SMPLAYER_UNINST_KEY}"
195  !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
196
197  ;Memento Settings
198  !define MEMENTO_REGISTRY_ROOT HKLM
199  !define MEMENTO_REGISTRY_KEY "${SMPLAYER_REG_KEY}"
200
201  ;Start Menu Settings
202  !define MUI_STARTMENUPAGE_DEFAULTFOLDER "SMPlayer"
203  !define MUI_STARTMENUPAGE_NODISABLE
204  !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
205  !define MUI_STARTMENUPAGE_REGISTRY_KEY "${SMPLAYER_UNINST_KEY}"
206  !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "NSIS:StartMenu"
207
208;--------------------------------
209;Include Modern UI and functions
210
211  !include MUI2.nsh
212  !include FileFunc.nsh
213  !include Memento.nsh
214  !include nsDialogs.nsh
215  !include Sections.nsh
216  !include WinVer.nsh
217  !include WordFunc.nsh
218  !include x64.nsh
219
220;--------------------------------
221;Pages
222
223  ;Install pages
224  #Welcome
225  !insertmacro MUI_PAGE_WELCOME
226
227  #License
228  !insertmacro MUI_PAGE_LICENSE "license.txt"
229
230  #Upgrade/Reinstall
231  Page custom PageReinstall PageReinstallLeave
232
233  #Components
234  !define MUI_PAGE_CUSTOMFUNCTION_PRE PageComponentsPre
235  !insertmacro MUI_PAGE_COMPONENTS
236
237  #Install Directory
238  !define MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
239  !insertmacro MUI_PAGE_DIRECTORY
240
241  #Start Menu
242  !define MUI_PAGE_CUSTOMFUNCTION_PRE PageStartMenuPre
243  !insertmacro MUI_PAGE_STARTMENU "SMP_SMenu" $SMPlayer_StartMenuFolder
244
245  !insertmacro MUI_PAGE_INSTFILES
246  !insertmacro MUI_PAGE_FINISH
247
248  ;Uninstall pages
249  !define MUI_PAGE_CUSTOMFUNCTION_PRE un.ConfirmPagePre
250  !insertmacro MUI_UNPAGE_CONFIRM
251  !insertmacro MUI_UNPAGE_INSTFILES
252  !insertmacro MUI_UNPAGE_FINISH
253
254;--------------------------------
255;Languages
256
257  !insertmacro MUI_LANGUAGE "English"
258  !insertmacro MUI_LANGUAGE "Albanian"
259  ;!insertmacro MUI_LANGUAGE "Amharic"
260  !insertmacro MUI_LANGUAGE "Arabic"
261  !insertmacro MUI_LANGUAGE "Basque"
262  !insertmacro MUI_LANGUAGE "Bulgarian"
263  !insertmacro MUI_LANGUAGE "Catalan"
264  !insertmacro MUI_LANGUAGE "Croatian"
265  !insertmacro MUI_LANGUAGE "Czech"
266  !insertmacro MUI_LANGUAGE "Danish"
267  !insertmacro MUI_LANGUAGE "Dutch"
268  !insertmacro MUI_LANGUAGE "Farsi"
269  !insertmacro MUI_LANGUAGE "Finnish"
270  !insertmacro MUI_LANGUAGE "French"
271  !insertmacro MUI_LANGUAGE "German"
272  !insertmacro MUI_LANGUAGE "Greek"
273  !insertmacro MUI_LANGUAGE "Hebrew"
274  !insertmacro MUI_LANGUAGE "Hungarian"
275  !insertmacro MUI_LANGUAGE "Italian"
276  !insertmacro MUI_LANGUAGE "Japanese"
277  !insertmacro MUI_LANGUAGE "Korean"
278  !insertmacro MUI_LANGUAGE "Malay"
279  !insertmacro MUI_LANGUAGE "Norwegian"
280  !insertmacro MUI_LANGUAGE "NorwegianNynorsk"
281  !insertmacro MUI_LANGUAGE "Polish"
282  !insertmacro MUI_LANGUAGE "Portuguese"
283  !insertmacro MUI_LANGUAGE "PortugueseBR"
284  !insertmacro MUI_LANGUAGE "Romanian"
285  !insertmacro MUI_LANGUAGE "Russian"
286  !insertmacro MUI_LANGUAGE "Serbian"
287  !insertmacro MUI_LANGUAGE "SimpChinese"
288  !insertmacro MUI_LANGUAGE "Slovak"
289  !insertmacro MUI_LANGUAGE "Slovenian"
290  !insertmacro MUI_LANGUAGE "Spanish"
291  !insertmacro MUI_LANGUAGE "Thai"
292  !insertmacro MUI_LANGUAGE "TradChinese"
293  !insertmacro MUI_LANGUAGE "Ukrainian"
294  !insertmacro MUI_LANGUAGE "Galician"
295  !insertmacro MUI_LANGUAGE "Indonesian"
296  !insertmacro MUI_LANGUAGE "Turkish"
297  !insertmacro MUI_LANGUAGE "Vietnamese"
298
299;Custom translations for setup
300
301  !insertmacro LANGFILE_INCLUDE "translations\english.nsh"
302  !insertmacro LANGFILE_INCLUDE "translations\albanian.nsh"
303  ;!insertmacro LANGFILE_INCLUDE "translations\amharic.nsh"
304  !insertmacro LANGFILE_INCLUDE "translations\arabic.nsh"
305  !insertmacro LANGFILE_INCLUDE "translations\basque.nsh"
306  !insertmacro LANGFILE_INCLUDE "translations\bulgarian.nsh"
307  !insertmacro LANGFILE_INCLUDE "translations\catalan.nsh"
308  !insertmacro LANGFILE_INCLUDE "translations\croatian.nsh"
309  !insertmacro LANGFILE_INCLUDE "translations\czech.nsh"
310  !insertmacro LANGFILE_INCLUDE "translations\danish.nsh"
311  !insertmacro LANGFILE_INCLUDE "translations\dutch.nsh"
312  !insertmacro LANGFILE_INCLUDE "translations\farsi.nsh"
313  !insertmacro LANGFILE_INCLUDE "translations\finnish.nsh"
314  !insertmacro LANGFILE_INCLUDE "translations\french.nsh"
315  !insertmacro LANGFILE_INCLUDE "translations\german.nsh"
316  !insertmacro LANGFILE_INCLUDE "translations\greek.nsh"
317  !insertmacro LANGFILE_INCLUDE "translations\hebrew.nsh"
318  !insertmacro LANGFILE_INCLUDE "translations\hungarian.nsh"
319  !insertmacro LANGFILE_INCLUDE "translations\italian.nsh"
320  !insertmacro LANGFILE_INCLUDE "translations\japanese.nsh"
321  !insertmacro LANGFILE_INCLUDE "translations\korean.nsh"
322  !insertmacro LANGFILE_INCLUDE "translations\malay.nsh"
323  !insertmacro LANGFILE_INCLUDE "translations\norwegian_nb.nsh"
324  !insertmacro LANGFILE_INCLUDE "translations\norwegian_nn.nsh"
325  !insertmacro LANGFILE_INCLUDE "translations\polish.nsh"
326  !insertmacro LANGFILE_INCLUDE "translations\portuguese.nsh"
327  !insertmacro LANGFILE_INCLUDE "translations\portuguesebrazil.nsh"
328  !insertmacro LANGFILE_INCLUDE "translations\romanian.nsh"
329  !insertmacro LANGFILE_INCLUDE "translations\russian.nsh"
330  !insertmacro LANGFILE_INCLUDE "translations\serbian.nsh"
331  !insertmacro LANGFILE_INCLUDE "translations\simpchinese.nsh"
332  !insertmacro LANGFILE_INCLUDE "translations\slovak.nsh"
333  !insertmacro LANGFILE_INCLUDE "translations\slovenian.nsh"
334  !insertmacro LANGFILE_INCLUDE "translations\spanish.nsh"
335  !insertmacro LANGFILE_INCLUDE "translations\thai.nsh"
336  !insertmacro LANGFILE_INCLUDE "translations\tradchinese.nsh"
337  !insertmacro LANGFILE_INCLUDE "translations\ukrainian.nsh"
338  !insertmacro LANGFILE_INCLUDE "translations\galician.nsh"
339  !insertmacro LANGFILE_INCLUDE "translations\indonesian.nsh"
340  !insertmacro LANGFILE_INCLUDE "translations\turkish.nsh"
341  !insertmacro LANGFILE_INCLUDE "translations\vietnamese.nsh"
342
343;--------------------------------
344;Reserve Files
345
346  ;These files should be inserted before other files in the data block
347  ;Keep these lines before any File command
348  ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
349
350  !insertmacro MUI_RESERVEFILE_LANGDLL
351!if ! ${NSIS_PACKEDVERSION} > 0x2999999
352  ReserveFile /nonfatal "${NSISDIR}\Plugins\UserInfo.dll"
353!else
354  ReserveFile /nonfatal "${NSISDIR}\Plugins\x86-unicode\UserInfo.dll"
355!endif
356
357;--------------------------------
358;Installer Sections
359
360;--------------------------------
361;Main SMPlayer files
362Section $(Section_SMPlayer) SecSMPlayer
363
364  SectionIn RO
365
366  ${If} $Reinstall_Uninstall == 1
367
368    ${If} $Reinstall_UninstallButton_State == 1
369      Exec '"$SMPlayer_UnStrPath" /X'
370      Quit
371    ${ElseIf} $Reinstall_OverwriteButton_State == 1
372
373!ifndef WIN64
374      Call Backup_Codecs
375!endif
376      ;Call Backup_YTDL
377      ;Call Backup_SMTube
378
379      ${If} "$INSTDIR" == "$SMPlayer_Path"
380        ExecWait '"$SMPlayer_UnStrPath" /S /R _?=$SMPlayer_Path'
381      ${Else}
382        ExecWait '"$SMPlayer_UnStrPath" /S /R'
383      ${EndIf}
384
385      Sleep 2500
386
387    ${EndIf}
388
389  ${EndIf}
390
391  SetOutPath "$INSTDIR"
392  File "${SMPLAYER_BUILD_DIR}\*"
393
394  ;SMPlayer docs
395  SetOutPath "$INSTDIR\docs"
396  File /r "${SMPLAYER_BUILD_DIR}\docs\*.*"
397
398  ;Qt imageformats
399  SetOutPath "$INSTDIR\imageformats"
400  File /nonfatal /r "${SMPLAYER_BUILD_DIR}\imageformats\*.*"
401
402  ;Open fonts
403  ; SetOutPath "$INSTDIR\open-fonts"
404  ; File /r "${SMPLAYER_BUILD_DIR}\open-fonts\*.*"
405
406  ;Qt platforms and styles (Qt 5+)
407!ifndef COMPILED_WITH_QT4
408  SetOutPath "$INSTDIR\platforms"
409  File /nonfatal /r "${SMPLAYER_BUILD_DIR}\platforms\*.*"
410
411  SetOutPath "$INSTDIR\styles"
412  File /nonfatal /r "${SMPLAYER_BUILD_DIR}\styles\*.*"
413!endif
414
415  ;SMPlayer key shortcuts
416  SetOutPath "$INSTDIR\shortcuts"
417  File /r "${SMPLAYER_BUILD_DIR}\shortcuts\*.*"
418
419SectionEnd
420
421;--------------------------------
422;Shortcuts
423SectionGroup $(ShortcutGroupTitle)
424
425  ${MementoSection} $(Section_DesktopShortcut) SecDesktopShortcut
426
427    SetOutPath "$INSTDIR"
428    CreateShortCut "$DESKTOP\SMPlayer.lnk" "$INSTDIR\smplayer.exe"
429
430  ${MementoSectionEnd}
431
432  ${MementoSection} $(Section_StartMenu) SecStartMenuShortcut
433
434    SetOutPath "$INSTDIR"
435    !insertmacro MUI_STARTMENU_WRITE_BEGIN SMP_SMenu
436      CreateDirectory "$SMPROGRAMS\$SMPlayer_StartMenuFolder"
437      CreateShortCut "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMPlayer.lnk" "$INSTDIR\smplayer.exe"
438      ${If} $Restore_SMTube == 1
439        CreateShortCut "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMTube.lnk" "$INSTDIR\smtube.exe"
440      ${EndIf}
441      WriteINIStr    "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMPlayer on the Web.url" "InternetShortcut" "URL" "http://www.smplayer.info"
442      CreateShortCut "$SMPROGRAMS\$SMPlayer_StartMenuFolder\Uninstall SMPlayer.lnk" "$INSTDIR\${SMPLAYER_UNINST_EXE}"
443    !insertmacro MUI_STARTMENU_WRITE_END
444
445  ${MementoSectionEnd}
446
447SectionGroupEnd
448
449;--------------------------------
450;MPlayer & MPV
451SectionGroup $(MPlayerMPVGroupTitle)
452
453  ${MementoSection} "MPlayer" SecMPlayer
454
455    SetOutPath "$INSTDIR\mplayer"
456    File /r "${SMPLAYER_BUILD_DIR}\mplayer\*.*"
457
458  ${MementoSectionEnd}
459
460  ${MementoSection} "MPV" SecMPV
461
462  SetOutPath "$INSTDIR\mpv"
463  File /r "${SMPLAYER_BUILD_DIR}\mpv\*.*"
464
465  ${MementoSectionEnd}
466
467SectionGroupEnd
468
469/*
470;--------------------------------
471;Youtube-dl
472${MementoSection} $(Section_YTDL) SecYTDL
473
474  SetOutPath "$INSTDIR\mpv"
475
476  IfFileExists "$PLUGINSDIR\youtube-dl.exe" 0 YTDL
477    CopyFiles /SILENT "$PLUGINSDIR\youtube-dl.exe" "$INSTDIR\mpv"
478
479    ;DetailPrint $(YTDL_Update_Check)
480    NsExec::ExecToLog '"$INSTDIR\mpv\youtube-dl.exe" -U'
481
482    Goto check_ytdl
483
484  YTDL:
485  INetC::get /CONNECTTIMEOUT 30000 /POPUP "" "https://yt-dl.org/latest/youtube-dl.exe" "$INSTDIR\mpv\youtube-dl.exe" /END
486  Pop $R0
487  StrCmp $R0 "OK" +3 0
488    DetailPrint $(YTDL_DL_Failed)
489    MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(YTDL_DL_Retry) /SD IDCANCEL IDRETRY YTDL IDCANCEL skip_ytdl
490
491  check_ytdl:
492    NsExec::Exec '"$INSTDIR\mpv\youtube-dl.exe" --version'
493    Pop $YTDL_Exit_Code
494
495    ${If} $YTDL_Exit_Code != "0"
496      DetailPrint $(YTDL_Error_Msg1)
497        ${If} $YTDL_Exit_Code == "${STATUS_DLL_NOT_FOUND}"
498          DetailPrint $(YTDL_Error_Msg2)
499        ${EndIf}
500
501      Sleep 5000
502    ${EndIf}
503
504  skip_ytdl:
505
506${MementoSectionEnd}
507*/
508
509;--------------------------------
510;Icon themes
511${MementoSection} $(Section_IconThemes) SecThemes
512
513  SetOutPath "$INSTDIR\themes"
514  File /r "${SMPLAYER_BUILD_DIR}\themes\*.*"
515
516${MementoSectionEnd}
517
518;--------------------------------
519;Translations
520${MementoSection} $(Section_Translations) SecTranslations
521
522  SetOutPath "$INSTDIR\translations"
523  File /r "${SMPLAYER_BUILD_DIR}\translations\*.*"
524
525${MementoSectionEnd}
526
527Section -RestorePrograms
528
529  ${If} $Restore_SMTube == 1
530    DetailPrint $(Info_SMTube_Restore)
531    CreateDirectory "$INSTDIR\docs\smtube"
532    CreateDirectory "$INSTDIR\translations"
533    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\smtube.exe" "$INSTDIR"
534    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\docs\smtube\*" "$INSTDIR\docs\smtube"
535    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\translations\*" "$INSTDIR\translations"
536!ifdef COMPILED_WITH_QT4
537    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\QtWebKit4.dll" "$INSTDIR"
538!else
539    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\icuin*.dll" "$INSTDIR"
540    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\icuuc*.dll" "$INSTDIR"
541    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\icudt*.dll" "$INSTDIR"
542    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5WebKit.dll" "$INSTDIR"
543    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5Sql.dll" "$INSTDIR"
544    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5Qml.dll" "$INSTDIR"
545    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5Quick.dll" "$INSTDIR"
546    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5Positioning.dll" "$INSTDIR"
547    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5Multimedia.dll" "$INSTDIR"
548    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5Sensors.dll" "$INSTDIR"
549    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5WebChannel.dll" "$INSTDIR"
550    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5WebKitWidgets.dll" "$INSTDIR"
551    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5OpenGL.dll" "$INSTDIR"
552    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5PrintSupport.dll" "$INSTDIR"
553    CopyFiles /SILENT "$PLUGINSDIR\smtubebak\Qt5MultimediaWidgets.dll" "$INSTDIR"
554!endif
555  ${EndIf}
556
557!ifndef WIN64
558  ${If} $Restore_Codecs == 1
559    DetailPrint $(Info_Codecs_Restore)
560    CopyFiles /SILENT "$PLUGINSDIR\codecbak\*" "$INSTDIR\mplayer\codecs"
561  ${EndIf}
562!endif
563
564SectionEnd
565
566;--------------------------------
567;Install/Uninstall information
568Section -Post
569
570  ;Uninstall file
571  WriteUninstaller "$INSTDIR\${SMPLAYER_UNINST_EXE}"
572
573  ;Store installed path & version
574  WriteRegStr HKLM "${SMPLAYER_REG_KEY}" "Path" "$INSTDIR"
575  WriteRegStr HKLM "${SMPLAYER_REG_KEY}" "Version" "${SMPLAYER_VERSION}"
576
577  ;Allows user to use 'start smplayer.exe'
578  WriteRegStr HKLM "${SMPLAYER_APP_PATHS_KEY}" "" "$INSTDIR\smplayer.exe"
579  WriteRegStr HKLM "${SMPLAYER_APP_PATHS_KEY}" "Path" "$INSTDIR"
580
581  ;Default Programs Registration (Vista & later)
582  ${If} ${AtLeastWinVista}
583    Call RegisterDefaultPrograms
584  ${EndIf}
585
586  ;Registry Uninstall information
587!ifdef WIN64
588  !ifdef COMPILED_WITH_QT4
589    WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayName" "$(^Name) (x64) (Qt4)"
590  !else
591    WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayName" "$(^Name) (x64)"
592  !endif
593!else
594  !ifdef COMPILED_WITH_QT4
595    WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayName" "$(^Name) (Qt4)"
596  !else
597    WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayName" "$(^Name)"
598  !endif
599!endif
600  WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayIcon" "$INSTDIR\smplayer.exe"
601  WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayVersion" "${SMPLAYER_VERSION}"
602  WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "HelpLink" "http://www.smplayer.info/forum"
603  WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "Publisher" "Ricardo Villalba"
604  WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "UninstallString" "$INSTDIR\${SMPLAYER_UNINST_EXE}"
605  WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "URLInfoAbout" "http://www.smplayer.info"
606  WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "URLUpdateInfo" "http://www.smplayer.info"
607  WriteRegDWORD HKLM "${SMPLAYER_UNINST_KEY}" "NoModify" "1"
608  WriteRegDWORD HKLM "${SMPLAYER_UNINST_KEY}" "NoRepair" "1"
609
610  ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
611  IntFmt $0 "0x%08X" $0
612  WriteRegDWORD HKLM "${SMPLAYER_UNINST_KEY}" "EstimatedSize" "$0"
613
614  DetailPrint $(Info_Cleaning_Fontconfig)
615  SetDetailsPrint none
616  Delete "$LOCALAPPDATA\fontconfig\cache\CACHEDIR.TAG"
617  Delete "$LOCALAPPDATA\fontconfig\cache\*.cache*"
618  RMDir "$LOCALAPPDATA\fontconfig\cache"
619  RMDir "$LOCALAPPDATA\fontconfig"
620  SetDetailsPrint both
621
622  ${If} $Reinstall_RemoveSettings_State == 1
623    DetailPrint $(Info_Cleaning_SMPlayer)
624    SetDetailsPrint none
625    NsExec::Exec '"$INSTDIR\smplayer.exe" -delete-config'
626    SetDetailsPrint both
627  ${EndIf}
628
629  Sleep 2500
630
631!ifdef VER_REVISION
632  SetAutoClose false
633!endif
634
635SectionEnd
636
637${MementoSectionDone}
638
639;--------------------------------
640;Section descriptions
641!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
642  !insertmacro MUI_DESCRIPTION_TEXT ${SecSMPlayer} $(Section_SMPlayer_Desc)
643  !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortcut} $(Section_DesktopShortcut_Desc)
644  !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortcut} $(Section_StartMenu_Desc)
645  !insertmacro MUI_DESCRIPTION_TEXT ${SecMPlayer} $(Section_MPlayer_Desc)
646  !insertmacro MUI_DESCRIPTION_TEXT ${SecMPV} $(Section_MPV_Desc)
647  ;!insertmacro MUI_DESCRIPTION_TEXT ${SecYTDL} $(Section_YTDL_Desc)
648  !insertmacro MUI_DESCRIPTION_TEXT ${SecThemes} $(Section_IconThemes_Desc)
649  !insertmacro MUI_DESCRIPTION_TEXT ${SecTranslations} $(Section_Translations_Desc)
650!insertmacro MUI_FUNCTION_DESCRIPTION_END
651
652;--------------------------------
653;Macros
654
655!macro MacroAllExtensions _action
656  !insertmacro ${_action} ".3gp"
657  !insertmacro ${_action} ".aac"
658  !insertmacro ${_action} ".ac3"
659  !insertmacro ${_action} ".ape"
660  !insertmacro ${_action} ".asf"
661  !insertmacro ${_action} ".avi"
662  !insertmacro ${_action} ".bik"
663  !insertmacro ${_action} ".bin"
664  !insertmacro ${_action} ".dat"
665  !insertmacro ${_action} ".divx"
666  !insertmacro ${_action} ".dts"
667  !insertmacro ${_action} ".dv"
668  !insertmacro ${_action} ".dvr-ms"
669  !insertmacro ${_action} ".f4v"
670  !insertmacro ${_action} ".flac"
671  !insertmacro ${_action} ".flv"
672  !insertmacro ${_action} ".hdmov"
673  !insertmacro ${_action} ".iso"
674  !insertmacro ${_action} ".m1v"
675  !insertmacro ${_action} ".m2t"
676  !insertmacro ${_action} ".m2ts"
677  !insertmacro ${_action} ".mts"
678  !insertmacro ${_action} ".m2v"
679  !insertmacro ${_action} ".m3u"
680  !insertmacro ${_action} ".m3u8"
681  !insertmacro ${_action} ".m4a"
682  !insertmacro ${_action} ".m4v"
683  !insertmacro ${_action} ".mka"
684  !insertmacro ${_action} ".mkv"
685  !insertmacro ${_action} ".mov"
686  !insertmacro ${_action} ".mp3"
687  !insertmacro ${_action} ".mp4"
688  !insertmacro ${_action} ".mpeg"
689  !insertmacro ${_action} ".mpg"
690  !insertmacro ${_action} ".mpv"
691  !insertmacro ${_action} ".mqv"
692  !insertmacro ${_action} ".nsv"
693  !insertmacro ${_action} ".oga"
694  !insertmacro ${_action} ".ogg"
695  !insertmacro ${_action} ".ogm"
696  !insertmacro ${_action} ".ogv"
697  !insertmacro ${_action} ".ogx"
698  !insertmacro ${_action} ".pls"
699  !insertmacro ${_action} ".ra"
700  !insertmacro ${_action} ".ram"
701  !insertmacro ${_action} ".rec"
702  !insertmacro ${_action} ".rm"
703  !insertmacro ${_action} ".rmvb"
704  !insertmacro ${_action} ".smk"
705  !insertmacro ${_action} ".swf"
706  !insertmacro ${_action} ".thd"
707  !insertmacro ${_action} ".ts"
708  !insertmacro ${_action} ".vcd"
709  !insertmacro ${_action} ".vfw"
710  !insertmacro ${_action} ".vob"
711  !insertmacro ${_action} ".vp8"
712  !insertmacro ${_action} ".wav"
713  !insertmacro ${_action} ".webm"
714  !insertmacro ${_action} ".wma"
715  !insertmacro ${_action} ".wmv"
716  !insertmacro ${_action} ".wtv"
717!macroend
718
719!macro WriteRegStrSupportedTypes EXT
720  WriteRegStr HKLM  "${SMPLAYER_DEF_PROGS_KEY}\Capabilities\FileAssociations" ${EXT} "MPlayerFileVideo"
721!macroend
722
723!macro MacroRemoveSMPlayer
724  ;Delete desktop and start menu shortcuts
725  SetDetailsPrint textonly
726  DetailPrint $(Info_Del_Shortcuts)
727  SetDetailsPrint listonly
728
729  SetShellVarContext all
730  Delete "$DESKTOP\SMPlayer.lnk"
731  Delete "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMPlayer.lnk"
732  Delete "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMTube.lnk"
733  Delete "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMPlayer on the Web.url"
734  Delete "$SMPROGRAMS\$SMPlayer_StartMenuFolder\Uninstall SMPlayer.lnk"
735  RMDir "$SMPROGRAMS\$SMPlayer_StartMenuFolder"
736
737  ;Delete directories recursively except for main directory
738  ;Do not recursively delete $INSTDIR
739  SetDetailsPrint textonly
740  DetailPrint $(Info_Del_Files)
741  SetDetailsPrint listonly
742
743  RMDir /r "$INSTDIR\docs"
744  RMDir /r "$INSTDIR\imageformats"
745  RMDir /r "$INSTDIR\mplayer"
746  RMDir /r "$INSTDIR\mpv"
747  RMDir /r "$INSTDIR\platforms"
748  RMDir /r "$INSTDIR\shortcuts"
749  RMDir /r "$INSTDIR\themes"
750  RMDir /r "$INSTDIR\translations"
751  RMDir /r "$INSTDIR\styles"
752
753  ;Txt
754  Delete "$INSTDIR\*.txt"
755
756  ;Binaries
757  Delete "$INSTDIR\*.exe"
758  Delete "$INSTDIR\*.dll"
759
760  ;Delete registry keys
761  SetDetailsPrint textonly
762  DetailPrint $(Info_Del_Registry)
763  SetDetailsPrint listonly
764
765  DeleteRegKey HKLM "${SMPLAYER_REG_KEY}"
766  DeleteRegKey HKLM "${SMPLAYER_APP_PATHS_KEY}"
767  DeleteRegKey HKLM "${SMPLAYER_DEF_PROGS_KEY}"
768  DeleteRegKey HKLM "${SMPLAYER_UNINST_KEY}"
769  DeleteRegKey HKCR "MPlayerFileVideo"
770  DeleteRegValue HKLM "Software\RegisteredApplications" "SMPlayer"
771
772  SetDetailsPrint both
773!macroend
774
775;--------------------------------
776;Shared functions
777
778!ifdef USE_RUNCHECK
779!macro RunCheckMacro UN
780Function ${UN}RunCheck
781
782    retry_runcheck:
783    FindWindow $0 "QWidget" "SMPlayer"
784    StrCmp $0 0 notRunning
785      MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(SMPlayer_Is_Running) /SD IDCANCEL IDRETRY retry_runcheck
786      Abort
787    notrunning:
788
789FunctionEnd
790!macroend
791!insertmacro RunCheckMacro ""
792!insertmacro RunCheckMacro "un."
793!endif
794
795;--------------------------------
796;Installer functions
797
798Function .onInit
799
800!ifdef COMPILED_WITH_QT4
801  MessageBox MB_YESNO|MB_ICONEXCLAMATION "This build is compiled with Qt4 and is provided for compatibility with legacy CPUs (those without SSE2 or later instruction set support). If you do not meet these requirements, it is recommended to use the normal Qt5 releases.$\r$\n$\r$\nProceed with the installation?" /SD IDYES IDYES installoldcpu
802    Abort
803  installoldcpu:
804!endif
805
806  ${Unless} ${AtLeastWinVista}
807  ${AndUnless} ${AtLeastServicePack} 2
808    MessageBox MB_YESNO|MB_ICONSTOP $(OS_Not_Supported_VistaRequired) /SD IDNO IDYES installonoldwindows
809    Abort
810  installonoldwindows:
811  ${EndIf}
812
813!ifdef WIN64
814  ${IfNot} ${RunningX64}
815    MessageBox MB_OK|MB_ICONSTOP $(Win64_Required)
816    Abort
817  ${EndIf}
818
819  SetRegView 32
820  ClearErrors
821  ReadRegStr $R0 HKLM "${SMPLAYER_UNINST_KEY}" "UninstallString"
822
823  IfErrors +3 0
824    MessageBox MB_OK|MB_ICONSTOP $(Existing_32bitInst)
825    Abort
826
827  SetRegView 64
828!else
829  ${If} ${RunningX64}
830    SetRegView 64
831    ClearErrors
832    ReadRegStr $R0 HKLM "${SMPLAYER_UNINST_KEY}" "UninstallString"
833
834    IfErrors +3 0
835      MessageBox MB_OK|MB_ICONSTOP $(Existing_64bitInst)
836      Abort
837
838    SetRegView 32
839  ${EndIf}
840!endif
841
842  ;Check if setup is already running
843  System::Call 'kernel32::CreateMutexW(i 0, i 0, t "SMPlayerSetup") i .r1 ?e'
844  Pop $R0
845
846  StrCmp $R0 0 +3
847    MessageBox MB_OK|MB_ICONEXCLAMATION $(Installer_Is_Running)
848    Abort
849
850!ifdef USE_RUNCHECK
851  ;Check if SMPlayer is running
852  ;Allow skipping check using /NORUNCHECK
853  ${GetParameters} $R0
854  ${GetOptions} $R0 "/NORUNCHECK" $R1
855  IfErrors 0 +2
856    Call RunCheck
857!endif
858
859  ;Check for admin on < Vista
860  UserInfo::GetAccountType
861  Pop $R0
862  ${If} $R0 != "admin"
863    MessageBox MB_OK|MB_ICONSTOP $(Installer_No_Admin)
864    Abort
865  ${EndIf}
866
867  ;Setup language selection
868  !insertmacro MUI_LANGDLL_DISPLAY
869
870  Call LoadPreviousSettings
871
872  Call CheckPreviousVersion
873
874  SetShellVarContext all
875
876FunctionEnd
877
878Function .onInstSuccess
879
880  ${MementoSectionSave}
881
882  ${IfNot} ${Silent}
883    ExecShell "open" "http://www.smplayer.info/post-install.php?version=${SMPLAYER_VERSION}"
884  ${Endif}
885
886FunctionEnd
887
888Function .onInstFailed
889
890  SetDetailsPrint textonly
891  DetailPrint $(Info_RollBack)
892  SetDetailsPrint listonly
893
894  !insertmacro MacroRemoveSMPlayer
895
896  Delete "$INSTDIR\${SMPLAYER_UNINST_EXE}"
897  RMDir "$INSTDIR"
898
899FunctionEnd
900
901Function .onSelChange
902
903  ${Unless} ${SectionIsSelected} ${SecMPlayer}
904  ${AndUnless} ${SectionIsSelected} ${SecMPV}
905    !insertmacro SelectSection ${SecMPlayer}
906  ${EndUnless}
907
908FunctionEnd
909
910Function CheckPreviousVersion
911
912  ClearErrors
913  ReadRegStr $Previous_Version HKLM "${SMPLAYER_REG_KEY}" "Version"
914  ReadRegStr $SMPlayer_UnStrPath HKLM "${SMPLAYER_UNINST_KEY}" "UninstallString"
915  ReadRegStr $SMPlayer_Path HKLM "${SMPLAYER_REG_KEY}" "Path"
916
917  ${IfNot} ${Errors}
918    StrCpy $Reinstall_Uninstall 1
919    !ifdef WIN64
920    ;Workaround for InstallDirRegKey on 64-bit
921    StrCpy $INSTDIR $SMPlayer_Path
922    !endif
923
924    ;Since we can't get input from a silent install to initialize the variables, prefer upgrading
925    ${If} ${Silent}
926      StrCpy $Reinstall_UninstallButton_State 0
927      StrCpy $Reinstall_OverwriteButton_State 1
928    ${EndIf}
929
930    Call RetrieveQtVersions
931  ${EndIf}
932
933  /* $Previous_Version_State Assignments:
934  $Previous_Version_State=0  This installer is the same version as the installed copy
935  $Previous_Version_State=1  A newer version than this installer is already installed
936  $Previous_Version_State=2  An older version than this installer is already installed */
937  ${VersionCompare} $Previous_Version ${SMPLAYER_VERSION} $Previous_Version_State
938
939  ${If} $Previous_Version_State == 0
940    StrCpy $Inst_Type $(Type_Reinstall)
941  ${ElseIf} $Previous_Version_State == 1
942    StrCpy $Inst_Type $(Type_Downgrade)
943  ${ElseIf} $Previous_Version_State == 2
944    StrCpy $Inst_Type $(Type_Upgrade)
945  ${EndIf}
946
947FunctionEnd
948
949!ifndef WIN64
950Function Backup_Codecs
951
952  ${IfNot} ${SectionIsSelected} ${SecMPlayer}
953    Return
954  ${EndIf}
955
956  IfFileExists "$SMPlayer_Path\mplayer\codecs\*.dll" 0 NoBackup
957    DetailPrint $(Info_Codecs_Backup)
958    CreateDirectory "$PLUGINSDIR\codecbak"
959    CopyFiles /SILENT "$SMPlayer_Path\mplayer\codecs\*" "$PLUGINSDIR\codecbak"
960    StrCpy $Restore_Codecs 1
961    Return
962  NoBackup:
963    StrCpy $Restore_Codecs 0
964
965FunctionEnd
966!endif
967
968/*
969Function Backup_YTDL
970
971  ${IfNot} ${SectionIsSelected} ${SecMPV}
972    Return
973  ${EndIf}
974
975  IfFileExists "$SMPlayer_Path\mpv\youtube-dl.exe" 0 NoBackup
976    CopyFiles /SILENT "$SMPlayer_Path\mpv\youtube-dl.exe" "$PLUGINSDIR\youtube-dl.exe"
977
978    StrCpy $Restore_YTDL 1
979    Return
980  NoBackup:
981    StrCpy $Restore_YTDL 0
982
983FunctionEnd
984*/
985
986Function Backup_SMTube
987
988  IfFileExists "$SMPlayer_Path\smtube.exe" 0 NoBackup
989    StrCmp "${QT_WEBKIT_VERSION}" "$Qt_WebKit_Installed_Version" 0 QtVerMismatch
990    DetailPrint $(Info_SMTube_Backup)
991    CreateDirectory "$PLUGINSDIR\smtubebak\translations"
992    CreateDirectory "$PLUGINSDIR\smtubebak\docs\smtube"
993    CopyFiles /SILENT "$SMPlayer_Path\smtube.exe" "$PLUGINSDIR\smtubebak"
994    CopyFiles /SILENT "$SMPlayer_Path\docs\smtube\*" "$PLUGINSDIR\smtubebak\docs\smtube"
995    CopyFiles /SILENT "$SMPlayer_Path\translations\smtube*.qm" "$PLUGINSDIR\smtubebak\translations"
996!ifdef COMPILED_WITH_QT4
997    CopyFiles /SILENT "$SMPlayer_Path\QtWebKit4.dll" "$PLUGINSDIR\smtubebak"
998!else
999    CopyFiles /SILENT "$SMPlayer_Path\icuin*.dll" "$PLUGINSDIR\smtubebak"
1000    CopyFiles /SILENT "$SMPlayer_Path\icuuc*.dll" "$PLUGINSDIR\smtubebak"
1001    CopyFiles /SILENT "$SMPlayer_Path\icudt*.dll" "$PLUGINSDIR\smtubebak"
1002    CopyFiles /SILENT "$SMPlayer_Path\Qt5WebKit.dll" "$PLUGINSDIR\smtubebak"
1003    CopyFiles /SILENT "$SMPlayer_Path\Qt5Sql.dll" "$PLUGINSDIR\smtubebak"
1004    CopyFiles /SILENT "$SMPlayer_Path\Qt5Qml.dll" "$PLUGINSDIR\smtubebak"
1005    CopyFiles /SILENT "$SMPlayer_Path\Qt5Quick.dll" "$PLUGINSDIR\smtubebak"
1006    CopyFiles /SILENT "$SMPlayer_Path\Qt5Positioning.dll" "$PLUGINSDIR\smtubebak"
1007    CopyFiles /SILENT "$SMPlayer_Path\Qt5Multimedia.dll" "$PLUGINSDIR\smtubebak"
1008    CopyFiles /SILENT "$SMPlayer_Path\Qt5Sensors.dll" "$PLUGINSDIR\smtubebak"
1009    CopyFiles /SILENT "$SMPlayer_Path\Qt5WebChannel.dll" "$PLUGINSDIR\smtubebak"
1010    CopyFiles /SILENT "$SMPlayer_Path\Qt5WebKitWidgets.dll" "$PLUGINSDIR\smtubebak"
1011    CopyFiles /SILENT "$SMPlayer_Path\Qt5OpenGL.dll" "$PLUGINSDIR\smtubebak"
1012    CopyFiles /SILENT "$SMPlayer_Path\Qt5PrintSupport.dll" "$PLUGINSDIR\smtubebak"
1013    CopyFiles /SILENT "$SMPlayer_Path\Qt5MultimediaWidgets.dll" "$PLUGINSDIR\smtubebak"
1014!endif
1015    StrCpy $Restore_SMTube 1
1016    Return
1017  QtVerMismatch:
1018    DetailPrint $(SMTube_Incompatible_Msg1)
1019    ;DetailPrint $(SMTube_Incompatible_Msg2)
1020    Sleep 15000
1021  NoBackup:
1022    StrCpy $Restore_SMTube 0
1023
1024FunctionEnd
1025
1026Function LoadPreviousSettings
1027
1028  ;Gets previous start menu folder name
1029  !insertmacro MUI_STARTMENU_GETFOLDER "SMP_SMenu" $SMPlayer_StartMenuFolder
1030
1031  ${MementoSectionRestore}
1032
1033  ${If} ${AtMostWinXP}
1034    IntOp $MMEngineFlags ${SF_SELECTED} | ${SF_RO}
1035    !insertmacro UnSelectSection ${SecMPV}
1036    SectionSetFlags ${SecMPlayer} $MMEngineFlags
1037    SectionSetFlags ${SecMPV} ${SF_RO}
1038  ${EndIf}
1039
1040FunctionEnd
1041
1042Function PageReinstall
1043
1044  ${If} $Reinstall_Uninstall != 1
1045    Abort
1046  ${EndIf}
1047
1048  nsDialogs::Create /NOUNLOAD 1018
1049  Pop $Dialog_Reinstall
1050
1051  nsDialogs::SetRTL $(^RTL)
1052
1053  !insertmacro MUI_HEADER_TEXT $(Reinstall_Header_Text) $(Reinstall_Header_SubText)
1054
1055  ${NSD_CreateLabel} 0 0 225u 8u $(Reinstall_Msg1)
1056
1057  ${NSD_CreateText} 10u 15u 290u 14u "$SMPlayer_Path"
1058  Pop $R0
1059
1060  ${NSD_CreateLabel} 0 40u 100u 8u $(Reinstall_Msg2)
1061
1062  ${NSD_CreateRadioButton} 10u 58u 200u 8u $(Reinstall_Overwrite)
1063  Pop $Reinstall_OverwriteButton
1064  ${NSD_CreateRadioButton} 10u 73u 200u 8u $(Reinstall_Uninstall)
1065  Pop $Reinstall_UninstallButton
1066
1067  ${NSD_CreateCheckBox} 0 90u 100% 8u $(Reinstall_Msg4)
1068  Pop $Reinstall_ChgSettings
1069
1070  ${NSD_CreateCheckBox} 0 102u 100% 8u $(Reinstall_Msg5)
1071  Pop $Reinstall_RemoveSettings
1072
1073  ${NSD_CreateLabel} 0 121u 100% 16u
1074  Pop $Reinstall_Message
1075
1076  SendMessage $Reinstall_OverwriteButton ${BM_SETCHECK} 1 0
1077  EnableWindow $R0 0
1078
1079  ${If} $Reinstall_ChgSettings_State == 1
1080    SendMessage $Reinstall_ChgSettings ${BM_SETCHECK} 1 0
1081  ${Endif}
1082
1083  ${If} $Reinstall_RemoveSettings_State == 1
1084    SendMessage $Reinstall_RemoveSettings ${BM_SETCHECK} 1 0
1085  ${Endif}
1086
1087  ${NSD_OnClick} $Reinstall_OverwriteButton PageReinstallUpdate
1088  ${NSD_OnClick} $Reinstall_UninstallButton PageReinstallUpdate
1089  ${NSD_OnClick} $Reinstall_ChgSettings PageReinstallUpdate
1090  ${NSD_OnClick} $Reinstall_RemoveSettings RemoveSettingsUpdate
1091
1092  Call PageReinstallUpdate
1093
1094  nsDialogs::Show
1095
1096FunctionEnd
1097
1098Function PageReinstallLeave
1099
1100  ${NSD_GetState} $Reinstall_OverwriteButton $Reinstall_OverwriteButton_State
1101  ${NSD_GetState} $Reinstall_UninstallButton $Reinstall_UninstallButton_State
1102  ${NSD_GetState} $Reinstall_ChgSettings $Reinstall_ChgSettings_State
1103  ${NSD_GetState} $Reinstall_RemoveSettings $Reinstall_RemoveSettings_State
1104
1105FunctionEnd
1106
1107Function RemoveSettingsUpdate
1108
1109  ${NSD_GetState} $Reinstall_RemoveSettings $Reinstall_RemoveSettings_State
1110
1111  ${If} $Reinstall_RemoveSettings_State == 1
1112    MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 $(Remove_Settings_Confirmation) /SD IDNO IDYES reset_done
1113      ${NSD_SetState} $Reinstall_RemoveSettings 0
1114    reset_done:
1115  ${EndIf}
1116
1117FunctionEnd
1118
1119Function PageReinstallUpdate
1120
1121  ${NSD_GetState} $Reinstall_OverwriteButton $Reinstall_OverwriteButton_State
1122  ${NSD_GetState} $Reinstall_UninstallButton $Reinstall_UninstallButton_State
1123  ${NSD_GetState} $Reinstall_ChgSettings $Reinstall_ChgSettings_State
1124
1125  ${If} $Reinstall_OverwriteButton_State == 1
1126
1127    EnableWindow $Reinstall_ChgSettings 1
1128    EnableWindow $Reinstall_RemoveSettings 1
1129
1130    GetDlgItem $R0 $HWNDPARENT 1
1131    ${If} $Reinstall_ChgSettings_State != 1
1132      SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(StartBtn)"
1133      ${NSD_SetText} $Reinstall_Message $(Reinstall_Msg3_1)
1134    ${ElseIf} $Reinstall_ChgSettings_State == 1
1135      SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(^NextBtn)"
1136      ${NSD_SetText} $Reinstall_Message $(Reinstall_Msg3_2)
1137    ${EndIf}
1138
1139  ${ElseIf} $Reinstall_UninstallButton_State == 1
1140
1141    EnableWindow $Reinstall_ChgSettings 0
1142    ${NSD_SetState} $Reinstall_ChgSettings 0
1143
1144    EnableWindow $Reinstall_RemoveSettings 0
1145    ${NSD_SetState} $Reinstall_RemoveSettings 0
1146
1147    GetDlgItem $R0 $HWNDPARENT 1
1148    SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(^UninstallBtn)"
1149
1150    ${NSD_SetText} $Reinstall_Message $(Reinstall_Msg3_3)
1151
1152  ${EndIf}
1153
1154FunctionEnd
1155
1156Function PageComponentsPre
1157
1158  ${If} $Reinstall_Uninstall == 1
1159  ${AndIf} $Reinstall_ChgSettings_State != 1
1160    Abort
1161  ${EndIf}
1162
1163FunctionEnd
1164
1165Function PageDirectoryPre
1166
1167  ${If} $Reinstall_Uninstall == 1
1168  ${AndIf} $Reinstall_ChgSettings_State != 1
1169    Abort
1170  ${EndIf}
1171
1172FunctionEnd
1173
1174Function PageStartMenuPre
1175
1176  ${If} $Reinstall_Uninstall == 1
1177  ${AndIf} $Reinstall_ChgSettings_State != 1
1178    Abort
1179  ${EndIf}
1180
1181  ${IfNot} ${SectionIsSelected} ${SecStartMenuShortcut}
1182    Abort
1183  ${EndIf}
1184
1185FunctionEnd
1186
1187Function RetrieveQtVersions
1188
1189  ; Get version of Qt5Core.dll from the build sources (smplayer-build/smplayer-build64)
1190  ClearErrors
1191!ifdef COMPILED_WITH_QT4
1192  GetDLLVersionLocal ${SMPLAYER_BUILD_DIR}\QtCore4.dll $R0 $R1
1193!else
1194  GetDLLVersionLocal ${SMPLAYER_BUILD_DIR}\Qt5Core.dll $R0 $R1
1195!endif
1196  IntOp $R2 $R0 / 0x00010000
1197  IntOp $R3 $R0 & 0x0000FFFF
1198  IntOp $R4 $R1 / 0x00010000
1199  IntOp $R5 $R1 & 0x0000FFFF
1200  StrCpy $Qt_Core_Source_Version "$R2.$R3.$R4.$R5"
1201  ;MessageBox MB_OK "Qt Core source version:  $Qt_Core_Source_Version"
1202
1203  ; Get version of Qt Core.dll that is already installed
1204  ClearErrors
1205  GetDLLVersion "$INSTDIR\Qt5Core.dll" $R0 $R1
1206  IfErrors 0 +2
1207    GetDLLVersion "$INSTDIR\QtCore4.dll" $R0 $R1
1208
1209  IntOp $R2 $R0 / 0x00010000
1210  IntOp $R3 $R0 & 0x0000FFFF
1211  IntOp $R4 $R1 / 0x00010000
1212  IntOp $R5 $R1 & 0x0000FFFF
1213  StrCpy $Qt_Core_Installed_Version "$R2.$R3.$R4.$R5"
1214  ;MessageBox MB_OK "Qt Core installed version:  $Qt_Core_Installed_Version"
1215
1216  ; Get version of Qt WebKit.dll that is already installed
1217  ClearErrors
1218  GetDLLVersion "$INSTDIR\Qt5WebKit.dll" $R0 $R1
1219  IfErrors 0 +2
1220    GetDLLVersion "$INSTDIR\QtWebKit4.dll" $R0 $R1
1221
1222  IntOp $R2 $R0 / 0x00010000
1223  IntOp $R3 $R0 & 0x0000FFFF
1224  IntOp $R4 $R1 / 0x00010000
1225  IntOp $R5 $R1 & 0x0000FFFF
1226  StrCpy $Qt_WebKit_Installed_Version "$R2.$R3.$R4.$R5"
1227  ;MessageBox MB_OK "Qt WebKit installed version:  $Qt_WebKit_Installed_Version"
1228
1229FunctionEnd
1230
1231Function RegisterDefaultPrograms
1232
1233  WriteRegStr HKCR "MPlayerFileVideo\DefaultIcon" "" '"$INSTDIR\smplayer.exe",1'
1234  WriteRegStr HKCR "MPlayerFileVideo\shell\enqueue" "" "Enqueue in SMPlayer"
1235  WriteRegStr HKCR "MPlayerFileVideo\shell\enqueue\command" "" '"$INSTDIR\smplayer.exe" -add-to-playlist "%1"'
1236  WriteRegStr HKCR "MPlayerFileVideo\shell\open" "FriendlyAppName" "SMPlayer Media Player"
1237  WriteRegStr HKCR "MPlayerFileVideo\shell\open\command" "" '"$INSTDIR\smplayer.exe" "%1"'
1238
1239  ;Modify the list of extensions added in the MacroAllExtensions macro
1240  WriteRegStr HKLM "${SMPLAYER_DEF_PROGS_KEY}" "" "SMPlayer"
1241  WriteRegStr HKLM "${SMPLAYER_DEF_PROGS_KEY}\Capabilities" "ApplicationDescription" $(Application_Description)
1242  WriteRegStr HKLM "${SMPLAYER_DEF_PROGS_KEY}\Capabilities" "ApplicationName" "SMPlayer"
1243  WriteRegStr HKLM "Software\RegisteredApplications" "SMPlayer" "${SMPLAYER_DEF_PROGS_KEY}\Capabilities"
1244  !insertmacro MacroAllExtensions WriteRegStrSupportedTypes
1245
1246FunctionEnd
1247
1248/*************************************** Uninstaller *******************************************/
1249
1250Section Uninstall
1251
1252  ;Make sure SMPlayer is installed from where the uninstaller is being executed.
1253  IfFileExists "$INSTDIR\smplayer.exe" +2
1254    Abort $(Uninstaller_InvalidDirectory)
1255
1256  SetDetailsPrint textonly
1257  DetailPrint $(Info_Rest_Assoc)
1258  SetDetailsPrint listonly
1259
1260  ;Don't restore file associations if reinstalling
1261  ${un.GetParameters} $R0
1262  ${un.GetOptionsS} $R0 "/R" $R1
1263
1264  IfErrors 0 +2
1265  ExecWait '"$INSTDIR\smplayer.exe" -uninstall'
1266
1267  !insertmacro MacroRemoveSMPlayer
1268
1269  Delete "$INSTDIR\${SMPLAYER_UNINST_EXE}"
1270  RMDir "$INSTDIR"
1271
1272SectionEnd
1273
1274;--------------------------------
1275;Required functions
1276
1277!insertmacro un.GetParameters
1278!insertmacro un.GetOptions
1279
1280;--------------------------------
1281;Uninstaller functions
1282
1283Function un.onInit
1284
1285!ifdef WIN64
1286  ${IfNot} ${RunningX64}
1287    MessageBox MB_OK|MB_ICONSTOP $(Uninstaller_64bitOnly)
1288    Abort
1289  ${EndIf}
1290
1291  SetRegView 64
1292!endif
1293
1294  ;Check for admin on < Vista
1295  UserInfo::GetAccountType
1296  Pop $R0
1297  ${If} $R0 != "admin"
1298    MessageBox MB_OK|MB_ICONSTOP $(Uninstaller_No_Admin)
1299    Abort
1300  ${EndIf}
1301
1302!ifdef USE_RUNCHECK
1303  ;Check if SMPlayer is running
1304  ;Allow skipping check using /NORUNCHECK
1305  ${un.GetParameters} $R0
1306  ${un.GetOptions} $R0 "/NORUNCHECK" $R1
1307  IfErrors 0 +2
1308    Call un.RunCheck
1309!endif
1310
1311  ;Gets start menu folder name
1312  !insertmacro MUI_STARTMENU_GETFOLDER "SMP_SMenu" $SMPlayer_StartMenuFolder
1313
1314  ;Get the stored language preference
1315  !insertmacro MUI_UNGETLANGUAGE
1316
1317FunctionEnd
1318
1319Function un.ConfirmPagePre
1320
1321  ${un.GetParameters} $R0
1322
1323  ${un.GetOptionsS} $R0 "/X" $R1
1324  ${Unless} ${Errors}
1325    Abort
1326  ${EndUnless}
1327
1328FunctionEnd
1329