]> git.sesse.net Git - vlc/blob - extras/package/win32/vlc.win32.nsi.in
l10n: New languages in Nsis
[vlc] / extras / package / win32 / vlc.win32.nsi.in
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; NSIS installer script for vlc ;
3 ; (http://nsis.sourceforge.net) ;
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5
6 !include "languages\declaration.nsh"
7
8 !define PRODUCT_NAME "VLC media player"
9 !define VERSION @VERSION@
10 !define PRODUCT_VERSION @VERSION@
11 !define PRODUCT_GROUP "VideoLAN"
12 !define PRODUCT_PUBLISHER "VideoLAN Team"
13 !define PRODUCT_WEB_SITE "http://www.videolan.org"
14 !define PRODUCT_DIR_REGKEY "Software\VideoLAN\VLC"
15 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
16 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
17 !define PRODUCT_ID "{ea92ef52-afe4-4212-bacb-dfe9fca94cd6}"
18
19 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
20 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_DIR_REGKEY}"
21 !define MUI_LANGDLL_REGISTRY_VALUENAME "Language"
22
23 @FILE_LIBVLCCORE_DLL@
24 @FILE_LIBVLC_DLL@
25
26 ;;;;;;;;;;;;;;;;;;;;;;;;;
27 ; General configuration ;
28 ;;;;;;;;;;;;;;;;;;;;;;;;;
29
30 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
31 OutFile ..\vlc-${VERSION}-win32.exe
32 InstallDir "$PROGRAMFILES\VideoLAN\VLC"
33 InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
34 !ifdef NSIS_LZMA_COMPRESS_WHOLE
35 SetCompressor lzma
36 !else
37 SetCompressor /SOLID lzma
38 !endif
39
40 ;ShowInstDetails show
41 ;ShowUnInstDetails show
42 SetOverwrite ifnewer
43 CRCCheck on
44 BrandingText "${PRODUCT_GROUP} ${PRODUCT_NAME}"
45
46 InstType $Name_InstTypeRecommended
47 InstType $Name_InstTypeMinimum
48 InstType $Name_InstTypeFull
49
50 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
51 ; NSIS Modern User Interface configuration ;
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
53
54 ; MUI 1.67 compatible ------
55   !include "MUI.nsh"
56
57 ; MUI Settings
58   !define MUI_ABORTWARNING
59   !define MUI_ICON "vlc.ico"
60   !define MUI_UNICON "vlc.ico"
61   !define MUI_COMPONENTSPAGE_SMALLDESC
62
63 ; Installer pages
64   ; Welcome page
65     !define MUI_WELCOMEPAGE_TITLE_3LINES
66     !insertmacro MUI_PAGE_WELCOME
67   ; License page
68     !insertmacro MUI_PAGE_LICENSE "COPYING.txt"
69   ; Components page
70     !insertmacro MUI_PAGE_COMPONENTS
71   ; Directory page
72     !insertmacro MUI_PAGE_DIRECTORY
73   ; Instfiles page
74     !insertmacro MUI_PAGE_INSTFILES
75   ; Finish page
76     !define MUI_FINISHPAGE_RUN "$INSTDIR\vlc.exe"
77     !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"
78     !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
79     !define MUI_FINISHPAGE_LINK $Link_VisitWebsite
80     !define MUI_FINISHPAGE_LINK_LOCATION "http://www.videolan.org/vlc/"
81     !define MUI_FINISHPAGE_NOREBOOTSUPPORT
82     !insertmacro MUI_PAGE_FINISH
83
84 ; Uninstaller pages
85     !insertmacro MUI_UNPAGE_CONFIRM
86     !insertmacro MUI_UNPAGE_COMPONENTS
87     !insertmacro MUI_UNPAGE_INSTFILES
88     !insertmacro MUI_UNPAGE_FINISH
89
90 ; Language files
91   !insertmacro MUI_LANGUAGE "English" # first language is the default language
92   !insertmacro MUI_LANGUAGE "French"
93   !insertmacro MUI_LANGUAGE "German"
94   !insertmacro MUI_LANGUAGE "Spanish"
95   !insertmacro MUI_LANGUAGE "SimpChinese"
96   !insertmacro MUI_LANGUAGE "TradChinese"
97   !insertmacro MUI_LANGUAGE "Japanese"
98   !insertmacro MUI_LANGUAGE "Korean"
99   !insertmacro MUI_LANGUAGE "Italian"
100   !insertmacro MUI_LANGUAGE "Dutch"
101   !insertmacro MUI_LANGUAGE "Danish"
102   !insertmacro MUI_LANGUAGE "Swedish"
103   !insertmacro MUI_LANGUAGE "Norwegian"
104   !insertmacro MUI_LANGUAGE "Finnish"
105   !insertmacro MUI_LANGUAGE "Greek"
106   !insertmacro MUI_LANGUAGE "Russian"
107   !insertmacro MUI_LANGUAGE "Portuguese"
108   !insertmacro MUI_LANGUAGE "Arabic"
109   !insertmacro MUI_LANGUAGE "Polish"
110   !insertmacro MUI_LANGUAGE "Romanian"
111   !insertmacro MUI_LANGUAGE "Slovak"
112   !insertmacro MUI_LANGUAGE "Czech"
113   !insertmacro MUI_LANGUAGE "Hungarian"
114
115 ; Reserve files for solid compression
116   !insertmacro MUI_RESERVEFILE_LANGDLL
117   !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
118
119 ; MUI end ------
120
121 ;;;;;;;;;;;;;;;;;;;;;;;
122 ; Macro and Functions ;
123 ;;;;;;;;;;;;;;;;;;;;;;;
124
125 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
126 ; 1. File type associations ;
127 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
128
129 ;; Function that register one extension for VLC
130 Function RegisterExtension
131   ; back up old value for extension $R0 (eg. ".opt")
132   ReadRegStr $1 HKCR "$R0" ""
133   StrCmp $1 "" NoBackup
134     StrCmp $1 "VLC$R0" "NoBackup"
135     WriteRegStr HKCR "$R0" "VLC.backup" $1
136 NoBackup:
137   WriteRegStr HKCR "$R0" "" "VLC$R0"
138   ReadRegStr $0 HKCR "VLC$R0" ""
139   WriteRegStr HKCR "VLC$R0" "" "VLC media file ($R0)"
140   WriteRegStr HKCR "VLC$R0\shell" "" "Play"
141   WriteRegStr HKCR "VLC$R0\shell\Play" "" $ShellAssociation_Play
142   WriteRegStr HKCR "VLC$R0\shell\Play\command" "" '"$INSTDIR\vlc.exe" --started-from-file "%1"'
143   WriteRegStr HKCR "VLC$R0\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
144
145 ;;; Vista Only part
146   ; Vista detection
147   ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
148   StrCpy $R2 $R1 3
149   StrCmp $R2 '6.0' ForVista ToEnd
150 ForVista:
151   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations" "$R0" "VLC$R0"
152
153 ToEnd:
154 FunctionEnd
155
156 ;; Function that removes one extension that VLC owns.
157 Function un.RegisterExtension
158   ;start of restore script
159   ReadRegStr $1 HKCR "$R0" ""
160   StrCmp $1 "VLC$R0" 0 NoOwn ; only do this if we own it
161     ; Read the old value from Backup
162     ReadRegStr $1 HKCR "$R0" "VLC.backup"
163     StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
164       DeleteRegKey HKCR "$R0"
165     Goto NoOwn
166 Restore:
167       WriteRegStr HKCR "$R0" "" $1
168       DeleteRegValue HKCR "$R0" "VLC.backup"
169 NoOwn:
170     DeleteRegKey HKCR "VLC$R0" ;Delete key with association settings
171     DeleteRegKey HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations\VLC$R0" ; for vista
172 FunctionEnd
173
174 !macro RegisterExtensionSection EXT
175   Section ${EXT}
176     SectionIn 1 3
177     Push $R0
178     StrCpy $R0 ${EXT}
179     Call RegisterExtension
180     Pop $R0
181   SectionEnd
182 !macroend
183
184 !macro UnRegisterExtensionSection EXT
185   Push $R0
186   StrCpy $R0 ${EXT}
187   Call un.RegisterExtension
188   Pop $R0
189 !macroend
190
191 !macro WriteRegStrSupportedTypes EXT
192   WriteRegStr HKCR Applications\vlc.exe\SupportedTypes ${EXT} ""
193 !macroend
194
195 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
196 ; Extension lists  Macros                    ;
197 ; Those macros calls the previous functions  ;
198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
199
200 !macro MacroAudioExtensions _action
201   !insertmacro ${_action} ".a52"
202   !insertmacro ${_action} ".aac"
203   !insertmacro ${_action} ".ac3"
204   !insertmacro ${_action} ".dts"
205   !insertmacro ${_action} ".flac"
206   !insertmacro ${_action} ".m4a"
207   !insertmacro ${_action} ".m4p"
208   !insertmacro ${_action} ".mka"
209   !insertmacro ${_action} ".mod"
210   !insertmacro ${_action} ".mp1"
211   !insertmacro ${_action} ".mp2"
212   !insertmacro ${_action} ".mp3"
213   !insertmacro ${_action} ".oma"
214   !insertmacro ${_action} ".oga"
215   !insertmacro ${_action} ".spx"
216   !insertmacro ${_action} ".wav"
217   !insertmacro ${_action} ".wma"
218   !insertmacro ${_action} ".wv"
219   !insertmacro ${_action} ".xm"
220 !macroend
221
222 !macro MacroVideoExtensions _action
223   !insertmacro ${_action} ".asf"
224   !insertmacro ${_action} ".avi"
225   !insertmacro ${_action} ".divx"
226   !insertmacro ${_action} ".dv"
227   !insertmacro ${_action} ".flv"
228   !insertmacro ${_action} ".gxf"
229   !insertmacro ${_action} ".m1v"
230   !insertmacro ${_action} ".m2v"
231   !insertmacro ${_action} ".m2ts"
232   !insertmacro ${_action} ".m4v"
233   !insertmacro ${_action} ".mkv"
234   !insertmacro ${_action} ".mov"
235   !insertmacro ${_action} ".mp4"
236   !insertmacro ${_action} ".mpeg"
237   !insertmacro ${_action} ".mpeg1"
238   !insertmacro ${_action} ".mpeg2"
239   !insertmacro ${_action} ".mpeg4"
240   !insertmacro ${_action} ".mpg"
241   !insertmacro ${_action} ".mts"
242   !insertmacro ${_action} ".mxf"
243   !insertmacro ${_action} ".nuv"
244   !insertmacro ${_action} ".ogg"
245   !insertmacro ${_action} ".ogm"
246   !insertmacro ${_action} ".ogx"
247   !insertmacro ${_action} ".ogv"
248   !insertmacro ${_action} ".rmvb"
249   !insertmacro ${_action} ".ts"
250   !insertmacro ${_action} ".vob"
251   !insertmacro ${_action} ".wmv"
252 !macroend
253
254 !macro MacroOtherExtensions _action
255   !insertmacro ${_action} ".asx"
256   !insertmacro ${_action} ".bin"
257   !insertmacro ${_action} ".cue"
258   !insertmacro ${_action} ".m3u"
259   !insertmacro ${_action} ".pls"
260   !insertmacro ${_action} ".vlc"
261   !insertmacro ${_action} ".xspf"
262 !macroend
263
264 ; One macro to rule them all
265 !macro MacroAllExtensions _action
266   !insertmacro MacroAudioExtensions ${_action}
267   !insertmacro MacroVideoExtensions ${_action}
268   !insertmacro MacroOtherExtensions ${_action}
269 !macroend
270
271 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
272 ; 2. Context menu entries ;
273 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
274
275 ; Generic function for adding the context menu for one ext.
276 !macro AddContextMenuExt EXT
277   WriteRegStr HKCR ${EXT}\shell\PlayWithVLC "" $ContextMenuEntry_PlayWith
278   WriteRegStr HKCR ${EXT}\shell\PlayWithVLC\command "" '"$INSTDIR\vlc.exe" --started-from-file --no-playlist-enqueue "%1"'
279
280   WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC "" $ContextMenuEntry_AddToPlaylist
281   WriteRegStr HKCR ${EXT}\shell\AddToPlaylistVLC\command "" '"$INSTDIR\vlc.exe" --started-from-file --playlist-enqueue "%1"'
282 !macroend
283
284 !macro AddContextMenu EXT
285   Push $R0
286   ReadRegStr $R0 HKCR ${EXT} ""
287   !insertmacro AddContextMenuExt $R0
288   Pop $R0
289 !macroend
290
291 !macro DeleteContextMenuExt EXT
292   DeleteRegKey HKCR ${EXT}\shell\PlayWithVLC
293   DeleteRegKey HKCR ${EXT}\shell\AddToPlaylistVLC
294 !macroend
295
296 !macro DeleteContextMenu EXT
297   Push $R0
298   ReadRegStr $R0 HKCR ${EXT} ""
299   !insertmacro DeleteContextMenuExt $R0
300   Pop $R0
301 !macroend
302
303 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
304 ; 3. Delete prefs and cache ;
305 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
306
307 !macro delprefs
308   StrCpy $0 0
309   !define Index 'Line${__LINE__}'
310   "${Index}-Loop:"
311   ; FIXME
312   ; this will loop through all the logged users and "virtual" windows users
313   ; (it looks like users are only present in HKEY_USERS when they are logged in)
314     ClearErrors
315     EnumRegKey $1 HKU "" $0
316     StrCmp $1 "" "${Index}-End"
317     IntOp $0 $0 + 1
318     ReadRegStr $2 HKU "$1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" AppData
319     StrCmp $2 "" "${Index}-Loop"
320     RMDir /r "$2\vlc"
321     Goto "${Index}-Loop"
322   "${Index}-End:"
323   !undef Index
324 !macroend
325
326 ;;;;;;;;;;;;;;;
327 ; 4. Logging  ;
328 ;;;;;;;;;;;;;;;
329 Var UninstallLog
330 !macro OpenUninstallLog
331   FileOpen $UninstallLog "$INSTDIR\uninstall.log" a
332   FileSeek $UninstallLog 0 END
333 !macroend
334
335 !macro CloseUninstallLog
336   FileClose $UninstallLog
337   SetFileAttributes "$INSTDIR\uninstall.log" HIDDEN
338 !macroend
339
340 ;;;;;;;;;;;;;;;;;;;;
341 ; 5. Installations ;
342 ;;;;;;;;;;;;;;;;;;;;
343 !macro InstallFile FILEREGEX
344   File "${FILEREGEX}"
345   !define Index 'Line${__LINE__}'
346   FindFirst $0 $1 "$INSTDIR\${FILEREGEX}"
347   StrCmp $0 "" "${Index}-End"
348   "${Index}-Loop:"
349     StrCmp $1 "" "${Index}-End"
350     FileWrite $UninstallLog "$1$\r$\n"
351     FindNext $0 $1
352     Goto "${Index}-Loop"
353   "${Index}-End:"
354   !undef Index
355 !macroend
356
357 !macro InstallFolder FOLDER
358   File /r "${FOLDER}"
359   Push "${FOLDER}"
360   Call InstallFolderInternal
361 !macroend
362
363 Function InstallFolderInternal
364   Pop $9
365   !define Index 'Line${__LINE__}'
366   FindFirst $0 $1 "$INSTDIR\$9\*"
367   StrCmp $0 "" "${Index}-End"
368   "${Index}-Loop:"
369     StrCmp $1 "" "${Index}-End"
370     StrCmp $1 "." "${Index}-Next"
371     StrCmp $1 ".." "${Index}-Next"
372     IfFileExists "$9\$1\*" 0 "${Index}-Write"
373       Push $0
374       Push $9
375       Push "$9\$1"
376       Call InstallFolderInternal
377       Pop $9
378       Pop $0
379       Goto "${Index}-Next"
380     "${Index}-Write:"
381     FileWrite $UninstallLog "$9\$1$\r$\n"
382     "${Index}-Next:"
383     FindNext $0 $1
384     Goto "${Index}-Loop"
385   "${Index}-End:"
386   !undef Index
387 FunctionEnd
388 ;;; End of Macros
389
390
391 ;;;;;;;;;;;;;;;;;;;;;;
392 ; Installer sections ;
393 ; The CORE of the    ;
394 ; installer          ;
395 ;;;;;;;;;;;;;;;;;;;;;;
396   
397 Section $Name_Section01 SEC01
398   SectionIn 1 2 3 RO
399   SetShellVarContext all
400   SetOutPath "$INSTDIR"
401
402   !insertmacro OpenUninstallLog
403
404   ; VLC.exe, libvlc.dll
405   !insertmacro InstallFile vlc.exe
406   !insertmacro InstallFile vlc.exe.manifest
407
408   ; All dlls
409   !insertmacro InstallFile *.dll
410
411   ; Text files
412   !insertmacro InstallFile *.txt
413
414   ; Subfolders
415   !insertmacro InstallFolder plugins
416   !insertmacro InstallFolder locale
417   !insertmacro InstallFolder osdmenu
418   !insertmacro InstallFolder skins
419   !insertmacro InstallFolder http
420   !insertmacro InstallFolder lua
421
422   ; URLs
423   WriteIniStr "$INSTDIR\${PRODUCT_GROUP} Website.url" "InternetShortcut" "URL" \
424     "${PRODUCT_WEB_SITE}"
425   FileWrite $UninstallLog "${PRODUCT_GROUP} Website.url$\r$\n"
426   WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" \
427     "${PRODUCT_WEB_SITE}/doc/"
428   FileWrite $UninstallLog "Documentation.url$\r$\n"
429   WriteIniStr "$INSTDIR\New_Skins.url" "InternetShortcut" "URL" \
430     "${PRODUCT_WEB_SITE}/vlc/skins.php"
431   FileWrite $UninstallLog "New_Skins.url$\r$\n"
432
433   !insertmacro CloseUninstallLog
434
435   ; Add VLC to "recomended programs" for the following extensions
436   WriteRegStr HKCR Applications\vlc.exe "" ""
437   WriteRegStr HKCR Applications\vlc.exe "FriendlyAppName" "VLC media player"
438   WriteRegStr HKCR Applications\vlc.exe\shell\Play "" $ContextMenuEntry_PlayWith
439   WriteRegStr HKCR Applications\vlc.exe\shell\Play\command "" \
440     '"$INSTDIR\vlc.exe" --started-from-file "%1"'
441   !insertmacro MacroAllExtensions WriteRegStrSupportedTypes
442
443 ; Vista Registration
444   ; Vista detection
445   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
446   StrCpy $R1 $R0 3
447   StrCmp $R1 '6.0' lbl_vista lbl_done
448
449   lbl_vista:
450   WriteRegStr HKLM "Software\RegisteredApplications" "VLC" "Software\Clients\Media\VLC\Capabilities"
451   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationName" "VLC media player"
452   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationDescription" "VLC - The video swiss knife"
453
454   lbl_done:
455 SectionEnd
456
457 Section $Name_Section02a SEC02a
458   SectionIn 1 2 3
459   CreateDirectory "$SMPROGRAMS\VideoLAN"
460   CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings"
461   CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Audio"
462   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to DirectX (default).lnk" \
463     "$INSTDIR\vlc.exe" "--aout aout_directx --save-config vlc://quit"
464   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Audio\Set Audio mode to Waveout.lnk" \
465     "$INSTDIR\vlc.exe" "--aout waveout --save-config vlc://quit"
466   CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Interface"
467   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Skinnable.lnk" \
468     "$INSTDIR\vlc.exe" "-I skins --save-config vlc://quit"
469   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Interface\Set Main Interface to Qt (default).lnk" \
470     "$INSTDIR\vlc.exe" "-I qt --save-config vlc://quit"
471   CreateDirectory "$SMPROGRAMS\VideoLAN\Quick Settings\Video"
472   ; FIXME add detection for Vista. Direct3D will be default there, for all others it's DirectX
473   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D.lnk" \
474     "$INSTDIR\vlc.exe" "--vout direct3d --overlay --directx-hw-yuv --save-config vlc://quit"
475   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to Direct3D (no hardware acceleration).lnk" \
476     "$INSTDIR\vlc.exe" "--vout direct3d --overlay --no-directx-hw-yuv --save-config vlc://quit"
477   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX.lnk" \
478     "$INSTDIR\vlc.exe" "--vout directx --overlay --directx-hw-yuv --save-config vlc://quit"
479   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no hardware acceleration).lnk" \
480     "$INSTDIR\vlc.exe" "--vout directx --no-overlay --no-directx-hw-yuv --save-config vlc://quit"
481   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to DirectX (no video overlay).lnk" \
482     "$INSTDIR\vlc.exe" "--vout directx --no-overlay --directx-hw-yuv --save-config vlc://quit"
483   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Video\Set Video mode to OpenGL.lnk" \
484     "$INSTDIR\vlc.exe" "--vout opengl --overlay --save-config vlc://quit"
485   CreateShortCut "$SMPROGRAMS\VideoLAN\Quick Settings\Reset VLC media player preferences and cache files.lnk" \
486     "$INSTDIR\vlc.exe" "--reset-config --reset-plugins-cache vlc://quit"
487   CreateShortCut "$SMPROGRAMS\VideoLAN\Documentation.lnk" \
488     "$INSTDIR\Documentation.url"
489   CreateShortCut "$SMPROGRAMS\VideoLAN\Release Notes.lnk" \
490     "$INSTDIR\NEWS.txt" ""
491   CreateShortCut "$SMPROGRAMS\VideoLAN\${PRODUCT_GROUP} Website.lnk" \
492     "$INSTDIR\${PRODUCT_GROUP} Website.url"
493   CreateShortCut "$SMPROGRAMS\VideoLAN\VLC media player.lnk" \
494     "$INSTDIR\vlc.exe" ""
495 SectionEnd
496
497 Section $Name_Section02b SEC02b
498   SectionIn 1 2 3
499   CreateShortCut "$DESKTOP\VLC media player.lnk" \
500     "$INSTDIR\vlc.exe" ""
501 SectionEnd
502
503 Section /o $Name_Section03 SEC03
504   SectionIn 3
505
506   SetOutPath "$INSTDIR"
507   !insertmacro OpenUninstallLog
508   !insertmacro InstallFile mozilla\npvlc.dll
509   !insertmacro InstallFile mozilla\npvlc.dll.manifest
510   !insertmacro CloseUninstallLog
511
512   !define Moz "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
513   WriteRegStr HKLM ${Moz} "Description" "VLC Multimedia Plugin"
514   WriteRegStr HKLM ${Moz} "Path" "$INSTDIR\npvlc.dll"
515   WriteRegStr HKLM ${Moz} "Product" "VLC media player"
516   WriteRegStr HKLM ${Moz} "Vendor" "VideoLAN"
517   WriteRegStr HKLM ${Moz} "Version" "${VERSION}"
518
519  ; for very old version of mozilla, these lines may be needed
520  ;Push $R0
521  ;Push $R1
522  ;Push $R2
523
524  ;!define Index 'Line${__LINE__}'
525  ;StrCpy $R1 "0"
526
527  ;"${Index}-Loop:"
528
529  ;  ; Check for Key
530  ;  EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
531  ;  StrCmp $R0 "" "${Index}-End"
532  ;  IntOp $R1 $R1 + 1
533  ;  ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
534  ;  StrCmp $R2 "" "${Index}-Loop" ""
535
536  ;  CopyFiles "$INSTDIR\npvlc.dll" "$R2"
537  ;  !ifdef LIBVLC_DLL
538  ;  CopyFiles ${LIBVLC_DLL} "$R2"
539  ;  !endif
540  ;  !ifdef LIBVLC_CONTROL_DLL
541  ;  CopyFiles ${LIBVLC_CONTROL_DLL} "$R2"
542  ;  !endif
543  ;  Goto "${Index}-Loop"
544
545  ;"${Index}-End:"
546  ;!undef Index
547
548 SectionEnd
549
550 Section $Name_Section04 SEC04
551   SectionIn 3
552   SetOutPath "$INSTDIR"
553   !insertmacro OpenUninstallLog
554   !insertmacro InstallFile activex\axvlc.dll
555   !insertmacro InstallFile activex\axvlc.dll.manifest
556   !insertmacro CloseUninstallLog
557   RegDLL "$INSTDIR\axvlc.dll"
558 SectionEnd
559
560 SectionGroup /e !$Name_Section06 SEC05
561   SectionGroup $Name_SectionGroupAudio
562     !insertmacro MacroAudioExtensions RegisterExtensionSection
563   SectionGroupEnd
564   SectionGroup $Name_SectionGroupVideo
565     !insertmacro MacroVideoExtensions RegisterExtensionSection
566   SectionGroupEnd
567   SectionGroup $Name_SectionGroupOther
568     !insertmacro MacroOtherExtensions RegisterExtensionSection
569   SectionGroupEnd
570 SectionGroupEnd
571
572
573 Section $Name_Section05 SEC06
574   SectionIn 1 2 3
575   WriteRegStr HKCR "AudioCD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
576   WriteRegStr HKCR "AudioCD\shell\PlayWithVLC\command" "" \
577     '"$INSTDIR\vlc.exe" --started-from-file "cdda://%1"'
578   WriteRegStr HKCR "DVD\shell\PlayWithVLC" "" $ContextMenuEntry_PlayWith
579   WriteRegStr HKCR "DVD\shell\PlayWithVLC\command" "" \
580     '"$INSTDIR\vlc.exe" --started-from-file "dvd://%1"'
581
582   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival" ""
583   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Action" $Action_OnArrivalDVD
584   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
585   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeProgID" "VLC.DVDMovie"
586   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeVerb" "play"
587   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Provider" "VideoLAN VLC media player"
588
589   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival" ""
590   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Action" $Action_OnArrivalAudioCD
591   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
592   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeProgID" "VLC.CDAudio"
593   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeVerb" "play"
594   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Provider" "VideoLAN VLC media player"
595   WriteRegStr HKCR "VLC.DVDMovie" "" "VLC DVD Movie"
596   WriteRegStr HKCR "VLC.DVDMovie\shell" "" "Play"
597   WriteRegStr HKCR "VLC.DVDMovie\shell\Play\command" "" \
598     '"$INSTDIR\vlc.exe" --started-from-file "dvd://%1"'
599   WriteRegStr HKCR "VLC.DVDMovie\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
600   WriteRegStr HKCR "VLC.CDAudio" "" "VLC CD Audio"
601   WriteRegStr HKCR "VLC.CDAudio\shell" "" "Play"
602   WriteRegStr HKCR "VLC.CDAudio\shell\Play\command" "" \
603     '"$INSTDIR\vlc.exe" --started-from-file "cdda://%1"'
604   WriteRegStr HKCR "VLC.CDAudio\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
605
606 SectionEnd
607
608 Section $Name_Section07 SEC07
609   SectionIn 1 3
610   !insertmacro MacroAllExtensions AddContextMenu
611   !insertmacro AddContextMenuExt "Directory"
612 SectionEnd
613
614 Section $Name_Section08 SEC08
615   !insertmacro delprefs
616 SectionEnd
617
618 ; Installer section descriptions
619 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
620   !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $Desc_Section01
621   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02a} $Desc_Section02a
622   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02b} $Desc_Section02b
623   !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $Desc_Section03
624   !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $Desc_Section04
625   !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} $Desc_Section05
626   !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} $Desc_Section06
627   !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} $Desc_Section07
628   !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} $Desc_Section08
629 !insertmacro MUI_FUNCTION_DESCRIPTION_END
630
631 ;;; Start function
632 Function .onInit
633   !insertmacro MUI_LANGDLL_DISPLAY
634
635   !include "languages\english.nsh"
636   StrCmp $LANGUAGE ${LANG_FRENCH} French 0
637   StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
638   StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
639   StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
640   StrCmp $LANGUAGE ${LANG_FINNISH} Finnish EndLanguageCmp
641   French:
642   !include "languages\french.nsh"
643   Goto EndLanguageCmp
644   Italian:
645   !include "languages\italian.nsh"
646   Goto EndLanguageCmp
647   Hungarian:
648   !include "languages\hungarian.nsh"
649   Goto EndLanguageCmp
650   Romanian:
651   !include "languages\romanian.nsh"
652   Goto EndLanguageCmp
653   Finnish:
654   !include "languages\finnish.nsh"
655   EndLanguageCmp:
656
657   ReadRegStr $R0  ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
658   "UninstallString"
659   StrCmp $R0 "" done
660
661   MessageBox MB_YESNO|MB_ICONEXCLAMATION $Message_AlreadyInstalled IDNO done
662
663   ;Run the uninstaller
664   ;uninst:
665     ClearErrors
666     ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
667   done:
668
669 FunctionEnd
670
671 ;; End function
672 Section -Post
673   WriteUninstaller "$INSTDIR\uninstall.exe"
674   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "InstallDir" $INSTDIR
675   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "Version" "${VERSION}"
676   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\vlc.exe"
677
678   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
679     "DisplayName" "$(^Name)"
680   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
681     "UninstallString" "$INSTDIR\uninstall.exe"
682   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
683     "DisplayIcon" "$INSTDIR\vlc.exe"
684   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
685     "DisplayVersion" "${PRODUCT_VERSION}"
686   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
687     "URLInfoAbout" "${PRODUCT_WEB_SITE}"
688   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
689     "Publisher" "${PRODUCT_PUBLISHER}"
690 SectionEnd
691
692 ;;;;;;;;;;;;;;;;;;;;;;;;
693 ; Uninstaller sections ;
694 ;;;;;;;;;;;;;;;;;;;;;;;;
695
696 ; TrimNewlines (copied from NSIS documentation)
697 ; input, top of stack  (e.g. whatever$\r$\n)
698 ; output, top of stack (replaces, with e.g. whatever)
699 ; modifies no other variables.
700
701 Function un.TrimNewlines
702  Exch $R0
703  Push $R1
704  Push $R2
705  StrCpy $R1 0
706
707  loop:
708    IntOp $R1 $R1 - 1
709    StrCpy $R2 $R0 1 $R1
710    StrCmp $R2 "$\r" loop
711    StrCmp $R2 "$\n" loop
712    IntOp $R1 $R1 + 1
713    IntCmp $R1 0 no_trim_needed
714    StrCpy $R0 $R0 $R1
715
716  no_trim_needed:
717    Pop $R2
718    Pop $R1
719    Exch $R0
720 FunctionEnd
721
722 Function un.RemoveEmptyDirs
723   Pop $9
724   !define Index 'Line${__LINE__}'
725   FindFirst $0 $1 "$INSTDIR$9*"
726   StrCmp $0 "" "${Index}-End"
727   "${Index}-Loop:"
728     StrCmp $1 "" "${Index}-End"
729     StrCmp $1 "." "${Index}-Next"
730     StrCmp $1 ".." "${Index}-Next"
731       Push $0
732       Push $1
733       Push $9
734       Push "$9$1\"
735       Call un.RemoveEmptyDirs
736       Pop $9
737       Pop $1
738       Pop $0
739     "${Index}-Remove:"
740     RMDir "$INSTDIR$9$1"
741     "${Index}-Next:"
742     FindNext $0 $1
743     Goto "${Index}-Loop"
744   "${Index}-End:"
745   FindClose $0
746   !undef Index
747 FunctionEnd
748
749 Section "un.$Name_Section91" SEC91
750   SectionIn 1 2 3 RO
751   SetShellVarContext all
752
753   !insertmacro MacroAllExtensions DeleteContextMenu
754   !insertmacro MacroAllExtensions UnRegisterExtensionSection
755   !insertmacro DeleteContextMenuExt "Directory"
756
757   ;remove activex plugin
758   UnRegDLL "$INSTDIR\axvlc.dll"
759   Delete /REBOOTOK "$INSTDIR\axvlc.dll"
760   Delete /REBOOTOK "$INSTDIR\axvlc.dll.manifest"
761
762   ;remove mozilla plugin
763   Push $R0
764   Push $R1
765   Push $R2
766
767   !define Index 'Line${__LINE__}'
768   StrCpy $R1 "0"
769
770   "${Index}-Loop:"
771
772     ; Check for Key
773     EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
774     StrCmp $R0 "" "${Index}-End"
775     IntOp $R1 $R1 + 1
776     ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
777     StrCmp $R2 "" "${Index}-Loop" ""
778
779     ; old files (0.8.5 and before) that may be lying around
780     Delete /REBOOTOK "$R2\npvlc.dll"
781     Delete /REBOOTOK "$R2\libvlc.dll"
782     Delete /REBOOTOK "$R2\vlcintf.xpt"
783     Goto "${Index}-Loop"
784
785   "${Index}-End:"
786   !undef Index
787   Delete /REBOOTOK "$INSTDIR\npvlc.dll"
788   Delete /REBOOTOK "$INSTDIR\npvlc.dll.manifest"
789
790   RMDir "$SMPROGRAMS\VideoLAN"
791   RMDir /r $SMPROGRAMS\VideoLAN
792
793   FileOpen $UninstallLog "$INSTDIR\uninstall.log" r
794   UninstallLoop:
795     ClearErrors
796     FileRead $UninstallLog $R0
797     IfErrors UninstallEnd
798     Push $R0
799     Call un.TrimNewLines
800     Pop $R0
801     Delete "$INSTDIR\$R0"
802     Goto UninstallLoop
803   UninstallEnd:
804   FileClose $UninstallLog
805   Delete "$INSTDIR\uninstall.log"
806   Delete "$INSTDIR\uninstall.exe"
807   Push "\"
808   Call un.RemoveEmptyDirs
809   RMDir "$INSTDIR"
810
811   DeleteRegKey HKLM Software\VideoLAN
812
813   DeleteRegKey HKCR Applications\vlc.exe
814   DeleteRegKey HKCR AudioCD\shell\PlayWithVLC
815   DeleteRegKey HKCR DVD\shell\PlayWithVLC
816   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayDVDMovieOnArrival" "VLCPlayDVDMovieOnArrival"
817   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival
818   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival"
819   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival
820   DeleteRegKey HKLM Software\Clients\Media\VLC
821   DeleteRegKey HKCR "VLC.MediaFile"
822
823   DeleteRegKey HKLM \
824     "SOFTWARE\MozillaPlugins\@videolan.org/vlc,version=${VERSION}"
825
826   DeleteRegKey HKLM \
827     "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
828
829   Delete "$DESKTOP\VLC media player.lnk"
830
831   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
832   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
833   SetAutoClose true
834 SectionEnd
835
836 Section /o "un.$Name_Section92" SEC92
837   !insertmacro delprefs
838 SectionEnd
839
840 ; Uninstaller section descriptions
841 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
842   !insertmacro MUI_DESCRIPTION_TEXT ${SEC91} $Desc_Section91
843   !insertmacro MUI_DESCRIPTION_TEXT ${SEC92} $Desc_Section92
844 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END
845
846 ;Function un.onUninstSuccess
847 ;  HideWindow
848 ;  MessageBox MB_ICONINFORMATION|MB_OK \
849 ;    "$(^Name) was successfully removed from your computer."
850 ;FunctionEnd
851
852 Function un.onInit
853   !insertmacro MUI_UNGETLANGUAGE
854   
855   !include "languages\english.nsh"
856   StrCmp $LANGUAGE ${LANG_FRENCH} French 0
857   StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
858   StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
859   StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
860   StrCmp $LANGUAGE ${LANG_FINNISH} Finnish EndLanguageCmp
861   French:
862   !include "languages\french.nsh"
863   Goto EndLanguageCmp
864   Italian:
865   !include "languages\italian.nsh"
866   Goto EndLanguageCmp
867   Hungarian:
868   !include "languages\hungarian.nsh"
869   Goto EndLanguageCmp
870   Romanian:
871   !include "languages\romanian.nsh"
872   Goto EndLanguageCmp
873   Finnish:
874   !include "languages\finnish.nsh"
875   EndLanguageCmp:
876   
877 FunctionEnd