source: smplayer/trunk/setup/smplayer.win32.nsi@ 124

Last change on this file since 124 was 124, checked in by Silvan Scherrer, 13 years ago

SMPlayer: 0.7.1 trunk update

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