[vlc-commits] nsis: allow changes in file association after installation (fix #4323)

Ludovic Fauvet git at videolan.org
Tue Feb 11 19:48:42 CET 2014


vlc | branch: master | Ludovic Fauvet <etix at videolan.org> | Tue Feb 11 15:55:22 2014 +0100| [b85e854c079c8ac255b62d77f9090df6612de7a9] | committer: Ludovic Fauvet

nsis: allow changes in file association after installation (fix #4323)

The extensions registration is now split in two:
- All supported extensions are registered during install
- Only the selected extensions are effectively associated with VLC

This allows the user to modify file association (even for extensions
not selected during installation) from the VLC preferences.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b85e854c079c8ac255b62d77f9090df6612de7a9
---

 extras/package/win32/NSIS/helpers/extensions.nsh |   50 +++++++++++-----------
 extras/package/win32/NSIS/vlc.win32.nsi.in       |    3 +-
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/extras/package/win32/NSIS/helpers/extensions.nsh b/extras/package/win32/NSIS/helpers/extensions.nsh
index f12e688..cd3646d 100644
--- a/extras/package/win32/NSIS/helpers/extensions.nsh
+++ b/extras/package/win32/NSIS/helpers/extensions.nsh
@@ -2,8 +2,8 @@
 ; 1. File type associations ;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-;; Function that registers one extension for VLC
-Function RegisterExtension
+;; Function that associates one extension with VLC
+Function AssociateExtension
   ; back up old value for extension $R0 (eg. ".opt")
   ReadRegStr $1 HKCR "$R0" ""
   StrCmp $1 "" NoBackup
@@ -11,13 +11,17 @@ Function RegisterExtension
     WriteRegStr HKCR "$R0" "VLC.backup" $1
 NoBackup:
   WriteRegStr HKCR "$R0" "" "VLC$R0"
-  ReadRegStr $0 HKCR "VLC$R0" ""
+FunctionEnd
+
+;; Function that registers one extension for VLC
+Function RegisterExtension
   WriteRegStr HKCR "VLC$R0" "" "VLC media file ($R0)"
   WriteRegStr HKCR "VLC$R0\shell" "" "Open"
   WriteRegStr HKCR "VLC$R0\shell\Open" "" $ShellAssociation_Play
   WriteRegStr HKCR "VLC$R0\shell\Open" "MultiSelectModel" "Player"
   WriteRegStr HKCR "VLC$R0\shell\Open\command" "" '"$INSTDIR\vlc.exe" --started-from-file "%1"'
   WriteRegStr HKCR "VLC$R0\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
+  WriteRegStr HKCR "Applications\vlc.exe\SupportedTypes" ${EXT} ""
 
   ${If} ${AtLeastWinVista}
     WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations" "$R0" "VLC$R0"
@@ -26,14 +30,6 @@ FunctionEnd
 
 ;; Function that registers one skin extension for VLC
 Function RegisterSkinExtension
-  ; back up old value for extension $R0 (eg. ".opt")
-  ReadRegStr $1 HKCR "$R0" ""
-  StrCmp $1 "" NoBackup
-    StrCmp $1 "VLC$R0" "NoBackup"
-    WriteRegStr HKCR "$R0" "VLC.backup" $1
-NoBackup:
-  WriteRegStr HKCR "$R0" "" "VLC$R0"
-  ReadRegStr $0 HKCR "VLC$R0" ""
   WriteRegStr HKCR "VLC$R0" "" "VLC skin file ($R0)"
   WriteRegStr HKCR "VLC$R0\shell" "" "Open"
   WriteRegStr HKCR "VLC$R0\shell\Open" "" ""
@@ -68,7 +64,7 @@ FunctionEnd
     SectionIn 1 3
     Push $R0
     StrCpy $R0 ${EXT}
-    Call RegisterExtension
+    Call AssociateExtension
     Pop $R0
   ${MementoSectionEnd}
 !macroend
@@ -78,20 +74,30 @@ FunctionEnd
     SectionIn 1 3
     Push $R0
     StrCpy $R0 ${EXT}
-    Call RegisterSkinExtension
+    Call AssociateExtension
     Pop $R0
   ${MementoSectionEnd}
 !macroend
 
-!macro UnRegisterExtensionSection TYPE EXT
+!macro RegisterExtensionMacro TYPE EXT
   Push $R0
   StrCpy $R0 ${EXT}
-  Call un.RegisterExtension
+  Call RegisterExtension
   Pop $R0
 !macroend
 
-!macro WriteRegStrSupportedTypes TYPE EXT
-  WriteRegStr HKCR Applications\vlc.exe\SupportedTypes ${EXT} ""
+!macro RegisterSkinExtensionMacro TYPE EXT
+  Push $R0
+  StrCpy $R0 ${EXT}
+  Call RegisterSkinExtension
+  Pop $R0
+!macroend
+
+!macro UnRegisterExtensionSection TYPE EXT
+  Push $R0
+  StrCpy $R0 ${EXT}
+  Call un.RegisterExtension
+  Pop $R0
 !macroend
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -247,10 +253,7 @@ FunctionEnd
 !macroend
 
 !macro AddContextMenu TYPE EXT
-  Push $R0
-  ReadRegStr $R0 HKCR ${EXT} ""
-  !insertmacro AddContextMenuExt $R0
-  Pop $R0
+  !insertmacro AddContextMenuExt VLC${EXT}
 !macroend
 
 !macro DeleteContextMenuExt EXT
@@ -259,10 +262,7 @@ FunctionEnd
 !macroend
 
 !macro DeleteContextMenu TYPE EXT
-  Push $R0
-  ReadRegStr $R0 HKCR ${EXT} ""
-  !insertmacro DeleteContextMenuExt $R0
-  Pop $R0
+  !insertmacro DeleteContextMenuExt VLC${EXT}
 !macroend
 
 
diff --git a/extras/package/win32/NSIS/vlc.win32.nsi.in b/extras/package/win32/NSIS/vlc.win32.nsi.in
index ac0b711..4bf78e5 100644
--- a/extras/package/win32/NSIS/vlc.win32.nsi.in
+++ b/extras/package/win32/NSIS/vlc.win32.nsi.in
@@ -213,7 +213,8 @@ ${MementoSection} $Name_Section01 SEC01
   WriteRegStr HKCR Applications\vlc.exe "FriendlyAppName" "VLC media player"
   WriteRegStr HKCR Applications\vlc.exe\shell\Open "" $ContextMenuEntry_PlayWith
   WriteRegStr HKCR Applications\vlc.exe\shell\Open\command "" '"$INSTDIR\vlc.exe" --started-from-file "%1"'
-  !insertmacro MacroAllExtensions WriteRegStrSupportedTypes
+  !insertmacro MacroAllExtensions RegisterExtensionMacro
+  !insertmacro MacroSkinExtensions RegisterSkinExtensionMacro
 
   ; Windows default programs Registration
   ; Vista and above detection



More information about the vlc-commits mailing list