source: smplayer/trunk/setup/smplayer.nsi@ 156

Last change on this file since 156 was 156, checked in by Silvan Scherrer, 11 years ago

SMPlayer: update trunk to 0.8.6

File size: 31.5 KB
Line 
1;Installer script for win32/win64 SMPlayer
2;Written by redxii (redxii@users.sourceforge.net)
3;Tested/Developed with Unicode NSIS 2.46.5
4
5!ifndef VER_MAJOR | VER_MINOR | VER_BUILD
6 !error "Version information not defined (or incomplete). You must define: VER_MAJOR, VER_MINOR, VER_BUILD."
7!endif
8
9;--------------------------------
10;Compressor
11
12 SetCompressor /SOLID lzma
13 SetCompressorDictSize 32
14
15;--------------------------------
16;Additional plugin folders
17
18 !addplugindir .
19 !addincludedir .
20
21;--------------------------------
22;Defines
23
24!ifdef VER_REVISION
25 !define SMPLAYER_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}.${VER_REVISION}"
26 !define SMPLAYER_PRODUCT_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}.${VER_REVISION}"
27!else ifndef VER_REVISION
28 !define SMPLAYER_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}"
29 !define SMPLAYER_PRODUCT_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}.0"
30!endif
31
32!ifdef WIN64
33 !define SMPLAYER_BUILD_DIR "smplayer-build64"
34!else
35 !define SMPLAYER_BUILD_DIR "smplayer-build"
36!endif
37
38 !define SMPLAYER_REG_KEY "Software\SMPlayer"
39 !define SMPLAYER_APP_PATHS_KEY "Software\Microsoft\Windows\CurrentVersion\App Paths\smplayer.exe"
40 !define SMPLAYER_DEF_PROGS_KEY "Software\Clients\Media\SMPlayer"
41
42 !define SMPLAYER_UNINST_EXE "uninst.exe"
43 !define SMPLAYER_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SMPlayer"
44
45 !define CODEC_VERSION "windows-essential-20071007"
46
47;--------------------------------
48;General
49
50 ;Name and file
51 Name "SMPlayer ${SMPLAYER_VERSION}"
52 BrandingText "SMPlayer for Windows v${SMPLAYER_VERSION}"
53!ifdef WIN64
54 OutFile "output\smplayer-${SMPLAYER_VERSION}-x64.exe"
55!else
56 OutFile "output\smplayer-${SMPLAYER_VERSION}-win32.exe"
57!endif
58
59 ;Version tab properties
60 VIProductVersion "${SMPLAYER_PRODUCT_VERSION}"
61 VIAddVersionKey "ProductName" "SMPlayer"
62 VIAddVersionKey "ProductVersion" "${SMPLAYER_VERSION}"
63 VIAddVersionKey "FileVersion" "${SMPLAYER_VERSION}"
64 VIAddVersionKey "LegalCopyright" ""
65!ifdef WIN64
66 VIAddVersionKey "FileDescription" "SMPlayer Installer (64-bit)"
67!else
68 VIAddVersionKey "FileDescription" "SMPlayer Installer (32-bit)"
69!endif
70
71 ;Default installation folder
72!ifdef WIN64
73 InstallDir "$PROGRAMFILES64\SMPlayer"
74!else
75 InstallDir "$PROGRAMFILES\SMPlayer"
76!endif
77
78 ;Get installation folder from registry if available
79 InstallDirRegKey HKLM "${SMPLAYER_REG_KEY}" "Path"
80
81 ;Vista+ XML manifest, does not affect older OSes
82 RequestExecutionLevel admin
83
84 ShowInstDetails show
85 ShowUnInstDetails show
86
87;--------------------------------
88;Variables
89
90 Var Dialog_Reinstall
91 Var Inst_Type
92 Var Previous_Version
93 Var Previous_Version_State
94 Var Reinstall_ChgSettings
95 Var Reinstall_ChgSettings_State
96 Var Reinstall_Message
97 Var Reinstall_OverwriteButton
98 Var Reinstall_OverwriteButton_State
99 Var Reinstall_RemoveSettings
100 Var Reinstall_RemoveSettings_State
101 Var Reinstall_Uninstall
102 Var Reinstall_UninstallButton
103 Var Reinstall_UninstallButton_State
104 Var Restore_Codecs
105 Var SMPlayer_Path
106 Var SMPlayer_UnStrPath
107 Var SMPlayer_StartMenuFolder
108
109;--------------------------------
110;Interface Settings
111
112 ;Installer/Uninstaller icons
113 !define MUI_ICON "smplayer-orange-installer.ico"
114 !define MUI_UNICON "smplayer-orange-uninstaller.ico"
115
116 ;Misc
117 !define MUI_WELCOMEFINISHPAGE_BITMAP "smplayer-orange-wizard.bmp"
118 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "smplayer-orange-wizard-un.bmp"
119 !define MUI_ABORTWARNING
120
121 ;Welcome page
122 !define MUI_WELCOMEPAGE_TITLE $(WelcomePage_Title)
123 !define MUI_WELCOMEPAGE_TEXT $(WelcomePage_Text)
124
125 ;License page
126 !define MUI_LICENSEPAGE_RADIOBUTTONS
127
128 ;Components page
129 !define MUI_COMPONENTSPAGE_SMALLDESC
130
131 ;Finish page
132 !define MUI_FINISHPAGE_LINK "http://smplayer.sourceforge.net"
133 !define MUI_FINISHPAGE_LINK_LOCATION "http://smplayer.sourceforge.net"
134 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
135 !define MUI_FINISHPAGE_RUN $INSTDIR\smplayer.exe
136 !define MUI_FINISHPAGE_RUN_NOTCHECKED
137 !define MUI_FINISHPAGE_SHOWREADME $INSTDIR\Release_notes.txt
138 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
139
140 ;Language Selection Dialog Settings
141 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
142 !define MUI_LANGDLL_REGISTRY_KEY "${SMPLAYER_UNINST_KEY}"
143 !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
144
145 ;Memento Settings
146 !define MEMENTO_REGISTRY_ROOT HKLM
147 !define MEMENTO_REGISTRY_KEY "${SMPLAYER_REG_KEY}"
148
149 ;Start Menu Settings
150 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "SMPlayer"
151 !define MUI_STARTMENUPAGE_NODISABLE
152 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
153 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${SMPLAYER_UNINST_KEY}"
154 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "NSIS:StartMenu"
155
156;--------------------------------
157;Include Modern UI and functions
158
159 !include MUI2.nsh
160 !include FileFunc.nsh
161 !include Memento.nsh
162 !include nsDialogs.nsh
163 !include Sections.nsh
164 !include WinVer.nsh
165 !include WordFunc.nsh
166 !include x64.nsh
167
168;--------------------------------
169;Pages
170
171 ;Install pages
172 #Welcome
173 !insertmacro MUI_PAGE_WELCOME
174
175 #License
176 !insertmacro MUI_PAGE_LICENSE "license.txt"
177
178 #Upgrade/Reinstall
179 Page custom PageReinstall PageReinstallLeave
180
181 #Components
182 !define MUI_PAGE_CUSTOMFUNCTION_PRE PageComponentsPre
183 !insertmacro MUI_PAGE_COMPONENTS
184
185 #Install Directory
186 !define MUI_PAGE_CUSTOMFUNCTION_PRE PageDirectoryPre
187 !insertmacro MUI_PAGE_DIRECTORY
188
189 #Start Menu
190 !define MUI_PAGE_CUSTOMFUNCTION_PRE PageStartMenuPre
191 !insertmacro MUI_PAGE_STARTMENU "SMP_SMenu" $SMPlayer_StartMenuFolder
192
193 !insertmacro MUI_PAGE_INSTFILES
194 !insertmacro MUI_PAGE_FINISH
195
196 ;Uninstall pages
197 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.ConfirmPagePre
198 !insertmacro MUI_UNPAGE_CONFIRM
199 !insertmacro MUI_UNPAGE_INSTFILES
200 !insertmacro MUI_UNPAGE_FINISH
201
202;--------------------------------
203;Languages
204
205 !insertmacro MUI_LANGUAGE "English"
206 !insertmacro MUI_LANGUAGE "Basque"
207 !insertmacro MUI_LANGUAGE "Catalan"
208 !insertmacro MUI_LANGUAGE "Croatian"
209 !insertmacro MUI_LANGUAGE "Czech"
210 !insertmacro MUI_LANGUAGE "Danish"
211 !insertmacro MUI_LANGUAGE "Dutch"
212 !insertmacro MUI_LANGUAGE "Finnish"
213 !insertmacro MUI_LANGUAGE "French"
214 !insertmacro MUI_LANGUAGE "German"
215 !insertmacro MUI_LANGUAGE "Hebrew"
216 !insertmacro MUI_LANGUAGE "Hungarian"
217 !insertmacro MUI_LANGUAGE "Italian"
218 !insertmacro MUI_LANGUAGE "Japanese"
219 !insertmacro MUI_LANGUAGE "Korean"
220 !insertmacro MUI_LANGUAGE "Norwegian"
221 !insertmacro MUI_LANGUAGE "Polish"
222 !insertmacro MUI_LANGUAGE "Portuguese"
223 !insertmacro MUI_LANGUAGE "Russian"
224 !insertmacro MUI_LANGUAGE "SimpChinese"
225 !insertmacro MUI_LANGUAGE "Slovak"
226 !insertmacro MUI_LANGUAGE "Slovenian"
227 !insertmacro MUI_LANGUAGE "Spanish"
228 !insertmacro MUI_LANGUAGE "Thai"
229 !insertmacro MUI_LANGUAGE "TradChinese"
230
231;Custom translations for setup
232
233 !insertmacro LANGFILE_INCLUDE "translations\english.nsh"
234 !insertmacro LANGFILE_INCLUDE "translations\basque.nsh"
235 !insertmacro LANGFILE_INCLUDE "translations\catalan.nsh"
236 !insertmacro LANGFILE_INCLUDE "translations\croatian.nsh"
237 !insertmacro LANGFILE_INCLUDE "translations\czech.nsh"
238 !insertmacro LANGFILE_INCLUDE "translations\danish.nsh"
239 !insertmacro LANGFILE_INCLUDE "translations\dutch.nsh"
240 !insertmacro LANGFILE_INCLUDE "translations\finnish.nsh"
241 !insertmacro LANGFILE_INCLUDE "translations\french.nsh"
242 !insertmacro LANGFILE_INCLUDE "translations\german.nsh"
243 !insertmacro LANGFILE_INCLUDE "translations\hebrew.nsh"
244 !insertmacro LANGFILE_INCLUDE "translations\hungarian.nsh"
245 !insertmacro LANGFILE_INCLUDE "translations\italian.nsh"
246 !insertmacro LANGFILE_INCLUDE "translations\japanese.nsh"
247 !insertmacro LANGFILE_INCLUDE "translations\korean.nsh"
248 !insertmacro LANGFILE_INCLUDE "translations\norwegian.nsh"
249 !insertmacro LANGFILE_INCLUDE "translations\polish.nsh"
250 !insertmacro LANGFILE_INCLUDE "translations\portuguese.nsh"
251 !insertmacro LANGFILE_INCLUDE "translations\russian.nsh"
252 !insertmacro LANGFILE_INCLUDE "translations\simpchinese.nsh"
253 !insertmacro LANGFILE_INCLUDE "translations\slovak.nsh"
254 !insertmacro LANGFILE_INCLUDE "translations\slovenian.nsh"
255 !insertmacro LANGFILE_INCLUDE "translations\spanish.nsh"
256 !insertmacro LANGFILE_INCLUDE "translations\thai.nsh"
257 !insertmacro LANGFILE_INCLUDE "translations\tradchinese.nsh"
258
259;--------------------------------
260;Reserve Files
261
262 ;These files should be inserted before other files in the data block
263 ;Keep these lines before any File command
264 ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
265
266 !insertmacro MUI_RESERVEFILE_LANGDLL
267 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
268
269;--------------------------------
270;Installer Sections
271
272;--------------------------------
273;Main SMPlayer files
274Section $(Section_SMPlayer) SecSMPlayer
275
276 SectionIn RO
277
278 ${If} $Reinstall_Uninstall == 1
279
280 ${If} $Reinstall_UninstallButton_State == 1
281 Exec '"$SMPlayer_UnStrPath" /X'
282 Quit
283 ${ElseIf} $Reinstall_OverwriteButton_State == 1
284
285 Call Backup_Codecs
286
287 ${If} "$INSTDIR" == "$SMPlayer_Path"
288 ExecWait '"$SMPlayer_UnStrPath" /S /R _?=$SMPlayer_Path'
289 ${Else}
290 ExecWait '"$SMPlayer_UnStrPath" /S /R'
291 ${EndIf}
292
293 Sleep 2500
294
295 ${EndIf}
296
297 ${EndIf}
298
299 SetOutPath "$INSTDIR"
300 File "${SMPLAYER_BUILD_DIR}\*"
301
302 ;SMPlayer docs
303 SetOutPath "$INSTDIR\docs"
304 File /r "${SMPLAYER_BUILD_DIR}\docs\*.*"
305
306 ;Qt imageformats
307 SetOutPath "$INSTDIR\imageformats"
308 File /r "${SMPLAYER_BUILD_DIR}\imageformats\*.*"
309
310 ;SMPlayer key shortcuts
311 SetOutPath "$INSTDIR\shortcuts"
312 File /r "${SMPLAYER_BUILD_DIR}\shortcuts\*.*"
313
314 SetOutPath "$PLUGINSDIR"
315 File 7za.exe
316
317 ;Initialize to 0 if don't exist (based on error flag)
318 ReadRegDWORD $R0 HKLM "${SMPLAYER_REG_KEY}" Installed_MPlayer
319 ${If} ${Errors}
320 WriteRegDWORD HKLM "${SMPLAYER_REG_KEY}" Installed_MPlayer 0x0
321 ${EndIf}
322
323 ReadRegDWORD $R0 HKLM "${SMPLAYER_REG_KEY}" Installed_Codecs
324 ${If} ${Errors}
325 WriteRegDWORD HKLM "${SMPLAYER_REG_KEY}" Installed_Codecs 0x0
326 ${EndIf}
327
328SectionEnd
329
330;--------------------------------
331;Shortcuts
332SectionGroup $(ShortcutGroupTitle)
333
334 ${MementoSection} $(Section_DesktopShortcut) SecDesktopShortcut
335
336 SetOutPath "$INSTDIR"
337 CreateShortCut "$DESKTOP\SMPlayer.lnk" "$INSTDIR\smplayer.exe"
338
339 ${MementoSectionEnd}
340
341 ${MementoSection} $(Section_StartMenu) SecStartMenuShortcut
342
343 SetOutPath "$INSTDIR"
344 !insertmacro MUI_STARTMENU_WRITE_BEGIN SMP_SMenu
345 CreateDirectory "$SMPROGRAMS\$SMPlayer_StartMenuFolder"
346 CreateShortCut "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMPlayer.lnk" "$INSTDIR\smplayer.exe"
347 CreateShortCut "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMTube.lnk" "$INSTDIR\smtube.exe"
348 WriteINIStr "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMPlayer on the Web.url" "InternetShortcut" "URL" "http://smplayer.sourceforge.net"
349 CreateShortCut "$SMPROGRAMS\$SMPlayer_StartMenuFolder\Uninstall SMPlayer.lnk" "$INSTDIR\${SMPLAYER_UNINST_EXE}"
350 !insertmacro MUI_STARTMENU_WRITE_END
351
352 ${MementoSectionEnd}
353
354SectionGroupEnd
355
356;--------------------------------
357;MPlayer & MPlayer Codecs
358SectionGroup $(MPlayerGroupTitle)
359
360 Section $(Section_MPlayer) SecMPlayer
361
362 SectionIn RO
363
364 SetOutPath "$INSTDIR\mplayer"
365 File /r /x mplayer.exe /x mencoder.exe /x mplayer64.exe /x mencoder64.exe "${SMPLAYER_BUILD_DIR}\mplayer\*.*"
366!ifdef WIN64
367 File /oname=mplayer.exe "${SMPLAYER_BUILD_DIR}\mplayer\mplayer64.exe"
368!else
369 File "${SMPLAYER_BUILD_DIR}\mplayer\mplayer.exe"
370!endif
371
372 WriteRegDWORD HKLM "${SMPLAYER_REG_KEY}" Installed_MPlayer 0x1
373
374 SectionEnd
375
376 Section /o $(Section_MPlayerCodecs) SecCodecs
377
378!ifdef WIN64
379 SectionIn RO
380!endif
381
382 AddSize 22931
383
384 ${If} $Restore_Codecs == 1
385 DetailPrint $(Info_Codecs_Restore)
386 CopyFiles /SILENT "$PLUGINSDIR\codecbak\*" "$INSTDIR\mplayer\codecs"
387 Goto check_codecs
388 ${ElseIf} ${FileExists} "$EXEDIR\${CODEC_VERSION}.zip"
389 CopyFiles /SILENT "$EXEDIR\${CODEC_VERSION}.zip" "$PLUGINSDIR"
390 Goto extract_codecs
391 ${EndIf}
392
393 retry_codecs_dl:
394
395 DetailPrint $(Codecs_DL_Msg)
396!ifndef USE_NSISDL
397 inetc::get /CONNECTTIMEOUT 15000 /RESUME "" /BANNER $(Codecs_DL_Msg) /CAPTION $(Codecs_DL_Msg) \
398 "http://www.mplayerhq.hu/MPlayer/releases/codecs/${CODEC_VERSION}.zip" \
399 "$PLUGINSDIR\${CODEC_VERSION}.zip" /END
400 Pop $R0
401 StrCmp $R0 OK +4 0
402!else
403 NSISdl::download /TIMEOUT=15000 \
404 "http://www.mplayerhq.hu/MPlayer/releases/codecs/${CODEC_VERSION}.zip" \
405 "$PLUGINSDIR\${CODEC_VERSION}.zip" /END
406 Pop $R0
407 StrCmp $R0 "success" +4 0
408!endif
409 DetailPrint $(Codecs_DL_Failed)
410 MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(Codecs_DL_Retry) /SD IDCANCEL IDRETRY retry_codecs_dl
411 Goto check_codecs
412
413 extract_codecs:
414
415 DetailPrint $(Info_Files_Extract)
416 nsExec::Exec '"$PLUGINSDIR\7za.exe" x "$PLUGINSDIR\${CODEC_VERSION}.zip" -y -o"$PLUGINSDIR"'
417
418 CreateDirectory "$INSTDIR\mplayer\codecs"
419 CopyFiles /SILENT "$PLUGINSDIR\${CODEC_VERSION}\*" "$INSTDIR\mplayer\codecs"
420
421 check_codecs:
422
423 IfFileExists "$INSTDIR\mplayer\codecs\*.dll" 0 codecsInstFailed
424 WriteRegDWORD HKLM "${SMPLAYER_REG_KEY}" Installed_Codecs 0x1
425 Goto done
426 codecsInstFailed:
427 DetailPrint $(Codecs_Inst_Failed)
428 WriteRegDWORD HKLM "${SMPLAYER_REG_KEY}" Installed_Codecs 0x0
429 Sleep 5000
430
431 done:
432
433 SectionEnd
434
435SectionGroupEnd
436
437;--------------------------------
438;Icon themes
439${MementoSection} $(Section_IconThemes) SecThemes
440
441 SetOutPath "$INSTDIR\themes"
442 File /r "${SMPLAYER_BUILD_DIR}\themes\*.*"
443
444${MementoSectionEnd}
445
446;--------------------------------
447;Translations
448${MementoSection} $(Section_Translations) SecTranslations
449
450 SetOutPath "$INSTDIR\translations"
451 File /r "${SMPLAYER_BUILD_DIR}\translations\*.*"
452
453${MementoSectionEnd}
454
455Section /o $(Reinstall_Msg5) SecResetSettings
456
457 NsExec::Exec '"$INSTDIR\smplayer.exe" -delete-config'
458
459SectionEnd
460
461;--------------------------------
462;Install/Uninstall information
463Section -Post
464
465 ;Uninstall file
466 WriteUninstaller "$INSTDIR\${SMPLAYER_UNINST_EXE}"
467
468 ;Store installed path & version
469 WriteRegStr HKLM "${SMPLAYER_REG_KEY}" "Path" "$INSTDIR"
470 WriteRegStr HKLM "${SMPLAYER_REG_KEY}" "Version" "${SMPLAYER_VERSION}"
471
472 ;Allows user to use 'start smplayer.exe'
473 WriteRegStr HKLM "${SMPLAYER_APP_PATHS_KEY}" "" "$INSTDIR\smplayer.exe"
474 WriteRegStr HKLM "${SMPLAYER_APP_PATHS_KEY}" "Path" "$INSTDIR"
475
476 ;Default Programs Registration (Vista & later)
477 ${If} ${AtLeastWinVista}
478 Call RegisterDefaultPrograms
479 ${EndIf}
480
481 ;Registry Uninstall information
482!ifdef WIN64
483 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayName" "$(^Name) (x64)"
484!else
485 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayName" "$(^Name)"
486!endif
487 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayIcon" "$INSTDIR\smplayer.exe"
488 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "DisplayVersion" "${SMPLAYER_VERSION}"
489 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "HelpLink" "http://smplayer.sourceforge.net/forum"
490 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "Publisher" "Ricardo Villalba"
491 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "UninstallString" "$INSTDIR\${SMPLAYER_UNINST_EXE}"
492 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "URLInfoAbout" "http://smplayer.sourceforge.net"
493 WriteRegStr HKLM "${SMPLAYER_UNINST_KEY}" "URLUpdateInfo" "http://smplayer.sourceforge.net"
494 WriteRegDWORD HKLM "${SMPLAYER_UNINST_KEY}" "NoModify" "1"
495 WriteRegDWORD HKLM "${SMPLAYER_UNINST_KEY}" "NoRepair" "1"
496
497SectionEnd
498
499${MementoSectionDone}
500
501;--------------------------------
502;Section descriptions
503!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
504 !insertmacro MUI_DESCRIPTION_TEXT ${SecSMPlayer} $(Section_SMPlayer_Desc)
505 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortcut} $(Section_DesktopShortcut_Desc)
506 !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortcut} $(Section_StartMenu_Desc)
507 !insertmacro MUI_DESCRIPTION_TEXT ${SecMPlayer} $(Section_MPlayer_Desc)
508 !insertmacro MUI_DESCRIPTION_TEXT ${SecCodecs} $(Section_MPlayerCodecs_Desc)
509 !insertmacro MUI_DESCRIPTION_TEXT ${SecThemes} $(Section_IconThemes_Desc)
510 !insertmacro MUI_DESCRIPTION_TEXT ${SecTranslations} $(Section_Translations_Desc)
511 !insertmacro MUI_DESCRIPTION_TEXT ${SecResetSettings} $(Section_ResetSettings_Desc)
512!insertmacro MUI_FUNCTION_DESCRIPTION_END
513
514;--------------------------------
515;Macros
516
517!macro MacroAllExtensions _action
518 !insertmacro ${_action} ".3gp"
519 !insertmacro ${_action} ".aac"
520 !insertmacro ${_action} ".ac3"
521 !insertmacro ${_action} ".ape"
522 !insertmacro ${_action} ".asf"
523 !insertmacro ${_action} ".avi"
524 !insertmacro ${_action} ".bik"
525 !insertmacro ${_action} ".bin"
526 !insertmacro ${_action} ".dat"
527 !insertmacro ${_action} ".divx"
528 !insertmacro ${_action} ".dts"
529 !insertmacro ${_action} ".dv"
530 !insertmacro ${_action} ".dvr-ms"
531 !insertmacro ${_action} ".f4v"
532 !insertmacro ${_action} ".flac"
533 !insertmacro ${_action} ".flv"
534 !insertmacro ${_action} ".hdmov"
535 !insertmacro ${_action} ".iso"
536 !insertmacro ${_action} ".m1v"
537 !insertmacro ${_action} ".m2t"
538 !insertmacro ${_action} ".m2ts"
539 !insertmacro ${_action} ".mts"
540 !insertmacro ${_action} ".m2v"
541 !insertmacro ${_action} ".m3u"
542 !insertmacro ${_action} ".m3u8"
543 !insertmacro ${_action} ".m4a"
544 !insertmacro ${_action} ".m4v"
545 !insertmacro ${_action} ".mka"
546 !insertmacro ${_action} ".mkv"
547 !insertmacro ${_action} ".mov"
548 !insertmacro ${_action} ".mp3"
549 !insertmacro ${_action} ".mp4"
550 !insertmacro ${_action} ".mpeg"
551 !insertmacro ${_action} ".mpg"
552 !insertmacro ${_action} ".mpv"
553 !insertmacro ${_action} ".mqv"
554 !insertmacro ${_action} ".nsv"
555 !insertmacro ${_action} ".oga"
556 !insertmacro ${_action} ".ogg"
557 !insertmacro ${_action} ".ogm"
558 !insertmacro ${_action} ".ogv"
559 !insertmacro ${_action} ".ogx"
560 !insertmacro ${_action} ".pls"
561 !insertmacro ${_action} ".ra"
562 !insertmacro ${_action} ".ram"
563 !insertmacro ${_action} ".rec"
564 !insertmacro ${_action} ".rm"
565 !insertmacro ${_action} ".rmvb"
566 !insertmacro ${_action} ".smk"
567 !insertmacro ${_action} ".swf"
568 !insertmacro ${_action} ".thd"
569 !insertmacro ${_action} ".ts"
570 !insertmacro ${_action} ".vcd"
571 !insertmacro ${_action} ".vfw"
572 !insertmacro ${_action} ".vob"
573 !insertmacro ${_action} ".vp8"
574 !insertmacro ${_action} ".wav"
575 !insertmacro ${_action} ".webm"
576 !insertmacro ${_action} ".wma"
577 !insertmacro ${_action} ".wmv"
578 !insertmacro ${_action} ".wtv"
579!macroend
580
581!macro WriteRegStrSupportedTypes EXT
582 WriteRegStr HKLM "${SMPLAYER_DEF_PROGS_KEY}\Capabilities\FileAssociations" ${EXT} "MPlayerFileVideo"
583!macroend
584
585!macro MacroRemoveSMPlayer
586 ;Delete desktop and start menu shortcuts
587 SetDetailsPrint textonly
588 DetailPrint $(Info_Del_Shortcuts)
589 SetDetailsPrint listonly
590
591 SetShellVarContext all
592 Delete "$DESKTOP\SMPlayer.lnk"
593 Delete "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMPlayer.lnk"
594 Delete "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMTube.lnk"
595 Delete "$SMPROGRAMS\$SMPlayer_StartMenuFolder\SMPlayer on the Web.url"
596 Delete "$SMPROGRAMS\$SMPlayer_StartMenuFolder\Uninstall SMPlayer.lnk"
597 RMDir "$SMPROGRAMS\$SMPlayer_StartMenuFolder"
598
599 ;Delete directories recursively except for main directory
600 ;Do not recursively delete $INSTDIR
601 SetDetailsPrint textonly
602 DetailPrint $(Info_Del_Files)
603 SetDetailsPrint listonly
604
605 RMDir /r "$INSTDIR\docs"
606 RMDir /r "$INSTDIR\imageformats"
607 RMDir /r "$INSTDIR\mplayer"
608 RMDir /r "$INSTDIR\shortcuts"
609 RMDir /r "$INSTDIR\themes"
610 RMDir /r "$INSTDIR\translations"
611 Delete "$INSTDIR\*.txt"
612 Delete "$INSTDIR\libgcc_s_dw2-1.dll"
613 Delete "$INSTDIR\libwinpthread-1.dll"
614 Delete "$INSTDIR\mingwm10.dll"
615 Delete "$INSTDIR\zlib1.dll"
616 Delete "$INSTDIR\Qt*.dll"
617 Delete "$INSTDIR\sample.avi"
618 Delete "$INSTDIR\smplayer.exe"
619 Delete "$INSTDIR\smtube.exe"
620 Delete "$INSTDIR\dxlist.exe"
621
622 ;Delete registry keys
623 SetDetailsPrint textonly
624 DetailPrint $(Info_Del_Registry)
625 SetDetailsPrint listonly
626
627 DeleteRegKey HKLM "${SMPLAYER_REG_KEY}"
628 DeleteRegKey HKLM "${SMPLAYER_APP_PATHS_KEY}"
629 DeleteRegKey HKLM "${SMPLAYER_DEF_PROGS_KEY}"
630 DeleteRegKey HKLM "${SMPLAYER_UNINST_KEY}"
631 DeleteRegKey HKCR "MPlayerFileVideo"
632 DeleteRegValue HKLM "Software\RegisteredApplications" "SMPlayer"
633
634 SetDetailsPrint both
635!macroend
636
637;--------------------------------
638;Shared functions
639
640!ifdef USE_RUNCHECK
641!macro RunCheckMacro UN
642Function ${UN}RunCheck
643
644 retry_runcheck:
645 FindWindow $0 "QWidget" "SMPlayer"
646 StrCmp $0 0 notRunning
647 MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(SMPlayer_Is_Running) /SD IDCANCEL IDRETRY retry_runcheck
648 Abort
649 notrunning:
650
651FunctionEnd
652!macroend
653!insertmacro RunCheckMacro ""
654!insertmacro RunCheckMacro "un."
655!endif
656
657;--------------------------------
658;Installer functions
659
660Function .onInit
661
662 ${Unless} ${AtLeastWinXP}
663 MessageBox MB_YESNO|MB_ICONSTOP $(OS_Not_Supported) /SD IDNO IDYES installonoldwindows
664 Abort
665 installonoldwindows:
666 ${EndIf}
667
668!ifdef WIN64
669 ${IfNot} ${RunningX64}
670 MessageBox MB_OK|MB_ICONSTOP $(Win64_Required)
671 Abort
672 ${EndIf}
673
674 SetRegView 32
675 ClearErrors
676 ReadRegStr $R0 HKLM "${SMPLAYER_UNINST_KEY}" "UninstallString"
677
678 IfErrors +3 0
679 MessageBox MB_OK|MB_ICONSTOP $(Existing_32bitInst)
680 Abort
681
682 SetRegView 64
683!else
684 ${If} ${RunningX64}
685 SetRegView 64
686 ClearErrors
687 ReadRegStr $R0 HKLM "${SMPLAYER_UNINST_KEY}" "UninstallString"
688
689 IfErrors +3 0
690 MessageBox MB_OK|MB_ICONSTOP $(Existing_64bitInst)
691 Abort
692
693 SetRegView 32
694 ${EndIf}
695!endif
696
697 ;Check if setup is already running
698 System::Call 'kernel32::CreateMutexW(i 0, i 0, t "SMPlayerSetup") i .r1 ?e'
699 Pop $R0
700
701 StrCmp $R0 0 +3
702 MessageBox MB_OK|MB_ICONEXCLAMATION $(Installer_Is_Running)
703 Abort
704
705!ifdef USE_RUNCHECK
706 ;Check if SMPlayer is running
707 ;Allow skipping check using /NORUNCHECK
708 ${GetParameters} $R0
709 ${GetOptions} $R0 "/NORUNCHECK" $R1
710 IfErrors 0 +2
711 Call RunCheck
712!endif
713
714 ;Check for admin on < Vista
715 UserInfo::GetAccountType
716 Pop $R0
717 ${If} $R0 != "admin"
718 MessageBox MB_OK|MB_ICONSTOP $(Installer_No_Admin)
719 Abort
720 ${EndIf}
721
722 Call LoadPreviousSettings
723
724 ;Setup language selection
725 !insertmacro MUI_LANGDLL_DISPLAY
726
727 Call CheckPreviousVersion
728
729 SetShellVarContext all
730
731FunctionEnd
732
733Function .onInstSuccess
734
735 ${MementoSectionSave}
736
737/*
738 ${Unless} $Reinstall_Uninstall == 1
739 ExecShell "open" "http://smplayer.sourceforge.net/thank-you.php?version=${SMPLAYER_VERSION}"
740 ${EndIf}
741*/
742
743FunctionEnd
744
745Function .onInstFailed
746
747 SetDetailsPrint textonly
748 DetailPrint $(Info_RollBack)
749 SetDetailsPrint listonly
750
751 !insertmacro MacroRemoveSMPlayer
752
753 Delete "$INSTDIR\${SMPLAYER_UNINST_EXE}"
754 RMDir "$INSTDIR"
755
756FunctionEnd
757
758/* Function un.onUninstSuccess
759
760 ;Don't launch uninstall page if reinstalling
761 ${un.GetParameters} $R0
762 ${un.GetOptionsS} $R0 "/R" $R1
763
764 IfErrors 0 +2
765 ExecShell "open" "http://smplayer.sourceforge.net/uninstall.php?version=${SMPLAYER_VERSION}"
766
767FunctionEnd */
768
769Function CheckPreviousVersion
770
771 ClearErrors
772 ReadRegStr $Previous_Version HKLM "${SMPLAYER_REG_KEY}" "Version"
773 ReadRegStr $SMPlayer_UnStrPath HKLM "${SMPLAYER_UNINST_KEY}" "UninstallString"
774 ReadRegStr $SMPlayer_Path HKLM "${SMPLAYER_REG_KEY}" "Path"
775
776 ${IfNot} ${Errors}
777 StrCpy $Reinstall_Uninstall 1
778 ${EndIf}
779
780 /* $Previous_Version_State Assignments:
781 $Previous_Version_State=0 This installer is the same version as the installed copy
782 $Previous_Version_State=1 A newer version than this installer is already installed
783 $Previous_Version_State=2 An older version than this installer is already installed */
784 ${VersionCompare} $Previous_Version ${SMPLAYER_VERSION} $Previous_Version_State
785
786 ${If} $Previous_Version_State == 0
787 StrCpy $Inst_Type $(Type_Reinstall)
788 ${ElseIf} $Previous_Version_State == 1
789 StrCpy $Inst_Type $(Type_Downgrade)
790 ${ElseIf} $Previous_Version_State == 2
791 StrCpy $Inst_Type $(Type_Upgrade)
792 ${EndIf}
793
794FunctionEnd
795
796Function Backup_Codecs
797
798 ${IfNot} ${SectionIsSelected} ${SecCodecs}
799 Return
800 ${EndIf}
801
802 IfFileExists "$SMPlayer_Path\mplayer\codecs\*.dll" 0 NoBackup
803 DetailPrint $(Info_Codecs_Backup)
804 CreateDirectory "$PLUGINSDIR\codecbak"
805 CopyFiles /SILENT "$SMPlayer_Path\mplayer\codecs\*" "$PLUGINSDIR\codecbak"
806 StrCpy $Restore_Codecs 1
807 Return
808 NoBackup:
809 StrCpy $Restore_Codecs 0
810
811FunctionEnd
812
813Function LoadPreviousSettings
814
815 ;MPlayer codecs section doesn't use Memento so we need to restore it manually
816 ;32-bit only
817!ifdef WIN64
818 !insertmacro UnSelectSection ${SecCodecs}
819!else
820 ReadRegDWORD $R0 HKLM "${SMPLAYER_REG_KEY}" "Installed_Codecs"
821 ${If} $R0 == 1
822 !insertmacro SelectSection ${SecCodecs}
823 ${EndIf}
824!endif
825
826 ;Gets start menu folder name
827 !insertmacro MUI_STARTMENU_GETFOLDER "SMP_SMenu" $SMPlayer_StartMenuFolder
828
829 ${MementoSectionRestore}
830
831FunctionEnd
832
833Function PageReinstall
834
835 ${If} $Reinstall_Uninstall != 1
836 Abort
837 ${EndIf}
838
839 nsDialogs::Create /NOUNLOAD 1018
840 Pop $Dialog_Reinstall
841
842 nsDialogs::SetRTL $(^RTL)
843
844 !insertmacro MUI_HEADER_TEXT $(Reinstall_Header_Text) $(Reinstall_Header_SubText)
845
846 ${NSD_CreateLabel} 0 0 225u 8u $(Reinstall_Msg1)
847
848 ${NSD_CreateText} 10u 15u 290u 14u "$SMPlayer_Path"
849 Pop $R0
850
851 ${NSD_CreateLabel} 0 40u 100u 8u $(Reinstall_Msg2)
852
853 ${NSD_CreateRadioButton} 10u 58u 200u 8u $(Reinstall_Overwrite)
854 Pop $Reinstall_OverwriteButton
855 ${NSD_CreateRadioButton} 10u 73u 200u 8u $(Reinstall_Uninstall)
856 Pop $Reinstall_UninstallButton
857
858 ${NSD_CreateCheckBox} 0 90u 100% 8u $(Reinstall_Msg4)
859 Pop $Reinstall_ChgSettings
860
861 ${NSD_CreateCheckBox} 0 102u 100% 8u $(Reinstall_Msg5)
862 Pop $Reinstall_RemoveSettings
863
864 ${NSD_CreateLabel} 0 121u 100% 16u
865 Pop $Reinstall_Message
866
867 SendMessage $Reinstall_OverwriteButton ${BM_SETCHECK} 1 0
868 EnableWindow $R0 0
869
870 ${If} $Reinstall_ChgSettings_State == 1
871 SendMessage $Reinstall_ChgSettings ${BM_SETCHECK} 1 0
872 ${Endif}
873
874 ${If} $Reinstall_RemoveSettings_State == 1
875 SendMessage $Reinstall_RemoveSettings ${BM_SETCHECK} 1 0
876 ${Endif}
877
878 ${NSD_OnClick} $Reinstall_OverwriteButton PageReinstallUpdate
879 ${NSD_OnClick} $Reinstall_UninstallButton PageReinstallUpdate
880 ${NSD_OnClick} $Reinstall_ChgSettings PageReinstallUpdate
881
882 Call PageReinstallUpdate
883
884 nsDialogs::Show
885
886FunctionEnd
887
888Function PageReinstallLeave
889
890 ${NSD_GetState} $Reinstall_OverwriteButton $Reinstall_OverwriteButton_State
891 ${NSD_GetState} $Reinstall_UninstallButton $Reinstall_UninstallButton_State
892 ${NSD_GetState} $Reinstall_ChgSettings $Reinstall_ChgSettings_State
893 ${NSD_GetState} $Reinstall_RemoveSettings $Reinstall_RemoveSettings_State
894
895 ${If} $Reinstall_RemoveSettings_State == 1
896 !insertmacro SelectSection ${SecResetSettings}
897 ${EndIf}
898
899FunctionEnd
900
901Function PageReinstallUpdate
902
903 ${NSD_GetState} $Reinstall_OverwriteButton $Reinstall_OverwriteButton_State
904 ${NSD_GetState} $Reinstall_UninstallButton $Reinstall_UninstallButton_State
905 ${NSD_GetState} $Reinstall_ChgSettings $Reinstall_ChgSettings_State
906
907 ${If} $Reinstall_OverwriteButton_State == 1
908
909 EnableWindow $Reinstall_ChgSettings 1
910 EnableWindow $Reinstall_RemoveSettings 1
911
912 GetDlgItem $R0 $HWNDPARENT 1
913 ${If} $Reinstall_ChgSettings_State != 1
914 SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(StartBtn)"
915 ${NSD_SetText} $Reinstall_Message $(Reinstall_Msg3_1)
916 ${ElseIf} $Reinstall_ChgSettings_State == 1
917 SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(^NextBtn)"
918 ${NSD_SetText} $Reinstall_Message $(Reinstall_Msg3_2)
919 ${EndIf}
920
921 ${ElseIf} $Reinstall_UninstallButton_State == 1
922
923 EnableWindow $Reinstall_ChgSettings 0
924 ${NSD_SetState} $Reinstall_ChgSettings 0
925
926 EnableWindow $Reinstall_RemoveSettings 0
927 ${NSD_SetState} $Reinstall_RemoveSettings 0
928
929 GetDlgItem $R0 $HWNDPARENT 1
930 SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(^UninstallBtn)"
931
932 ${NSD_SetText} $Reinstall_Message $(Reinstall_Msg3_3)
933
934 ${EndIf}
935
936FunctionEnd
937
938Function PageComponentsPre
939
940 ${If} $Reinstall_Uninstall == 1
941 ${AndIf} $Reinstall_ChgSettings_State != 1
942 Abort
943 ${EndIf}
944
945FunctionEnd
946
947Function PageDirectoryPre
948
949 ${If} $Reinstall_Uninstall == 1
950 ${AndIf} $Reinstall_ChgSettings_State != 1
951 Abort
952 ${EndIf}
953
954FunctionEnd
955
956Function PageStartMenuPre
957
958 ${If} $Reinstall_Uninstall == 1
959 ${AndIf} $Reinstall_ChgSettings_State != 1
960 Abort
961 ${EndIf}
962
963 ${IfNot} ${SectionIsSelected} ${SecStartMenuShortcut}
964 Abort
965 ${EndIf}
966
967FunctionEnd
968
969Function RegisterDefaultPrograms
970
971 WriteRegStr HKCR "MPlayerFileVideo\DefaultIcon" "" '"$INSTDIR\smplayer.exe",1'
972 WriteRegStr HKCR "MPlayerFileVideo\shell\enqueue" "" "Enqueue in SMPlayer"
973 WriteRegStr HKCR "MPlayerFileVideo\shell\enqueue\command" "" '"$INSTDIR\smplayer.exe" -add-to-playlist "%1"'
974 WriteRegStr HKCR "MPlayerFileVideo\shell\open" "FriendlyAppName" "SMPlayer Media Player"
975 WriteRegStr HKCR "MPlayerFileVideo\shell\open\command" "" '"$INSTDIR\smplayer.exe" "%1"'
976
977 ;Modify the list of extensions added in the MacroAllExtensions macro
978 WriteRegStr HKLM "${SMPLAYER_DEF_PROGS_KEY}" "" "SMPlayer"
979 WriteRegStr HKLM "${SMPLAYER_DEF_PROGS_KEY}\Capabilities" "ApplicationDescription" $(Application_Description)
980 WriteRegStr HKLM "${SMPLAYER_DEF_PROGS_KEY}\Capabilities" "ApplicationName" "SMPlayer"
981 WriteRegStr HKLM "Software\RegisteredApplications" "SMPlayer" "${SMPLAYER_DEF_PROGS_KEY}\Capabilities"
982 !insertmacro MacroAllExtensions WriteRegStrSupportedTypes
983
984FunctionEnd
985
986/*************************************** Uninstaller *******************************************/
987
988Section Uninstall
989
990 ;Make sure SMPlayer is installed from where the uninstaller is being executed.
991 IfFileExists $INSTDIR\smplayer.exe smplayer_installed
992 MessageBox MB_YESNO $(Uninstaller_NotInstalled) /SD IDNO IDYES smplayer_installed
993 Abort $(Uninstaller_Aborted)
994
995 smplayer_installed:
996
997 SetDetailsPrint textonly
998 DetailPrint $(Info_Rest_Assoc)
999 SetDetailsPrint listonly
1000
1001 ;Don't restore file associations if reinstalling
1002 ${un.GetParameters} $R0
1003 ${un.GetOptionsS} $R0 "/R" $R1
1004
1005 IfErrors 0 +2
1006 ExecWait '"$INSTDIR\smplayer.exe" -uninstall'
1007
1008 !insertmacro MacroRemoveSMPlayer
1009
1010 Delete "$INSTDIR\${SMPLAYER_UNINST_EXE}"
1011 RMDir "$INSTDIR"
1012
1013SectionEnd
1014
1015;--------------------------------
1016;Required functions
1017
1018!insertmacro un.GetParameters
1019!insertmacro un.GetOptions
1020
1021;--------------------------------
1022;Uninstaller functions
1023
1024Function un.onInit
1025
1026!ifdef WIN64
1027 ${IfNot} ${RunningX64}
1028 MessageBox MB_OK|MB_ICONSTOP $(Uninstaller_64bitOnly)
1029 Abort
1030 ${EndIf}
1031
1032 SetRegView 64
1033!endif
1034
1035 ;Check for admin on < Vista
1036 UserInfo::GetAccountType
1037 Pop $R0
1038 ${If} $R0 != "admin"
1039 MessageBox MB_OK|MB_ICONSTOP $(Uninstaller_No_Admin)
1040 Abort
1041 ${EndIf}
1042
1043!ifdef USE_RUNCHECK
1044 ;Check if SMPlayer is running
1045 ;Allow skipping check using /NORUNCHECK
1046 ${un.GetParameters} $R0
1047 ${un.GetOptions} $R0 "/NORUNCHECK" $R1
1048 IfErrors 0 +2
1049 Call un.RunCheck
1050!endif
1051
1052 ;Gets start menu folder name
1053 !insertmacro MUI_STARTMENU_GETFOLDER "SMP_SMenu" $SMPlayer_StartMenuFolder
1054
1055 ;Get the stored language preference
1056 !insertmacro MUI_UNGETLANGUAGE
1057
1058FunctionEnd
1059
1060Function un.ConfirmPagePre
1061
1062 ${un.GetParameters} $R0
1063
1064 ${un.GetOptionsS} $R0 "/X" $R1
1065 ${Unless} ${Errors}
1066 Abort
1067 ${EndUnless}
1068
1069FunctionEnd
Note: See TracBrowser for help on using the repository browser.