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

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

SMPlayer trunk: built 0.8.0

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