windows: fix resource files and backwards compat dll names
[deb_libcec.git] / project / libCEC.nsi
index bff402d882ca277d9e7823309380c8135fc7f52e..36ade3b420eeb452b80dcb91398bd3335df57346 100644 (file)
@@ -1,5 +1,5 @@
 ;libCEC installer
-;Copyright (C) 2012 Pulse-Eight Ltd.
+;Copyright (C) 2011-2013 Pulse-Eight Ltd.
 ;http://www.pulse-eight.com/
 
 !include "MUI2.nsh"
@@ -7,7 +7,7 @@
 !include "LogicLib.nsh"
 !include "x64.nsh"
 
-Name "Pulse-Eight USB-CEC Adapter"
+Name "Pulse-Eight libCEC version 2.1.1"
 OutFile "..\build\libCEC-installer.exe"
 
 XPStyle on
@@ -15,9 +15,11 @@ InstallDir "$PROGRAMFILES\Pulse-Eight\USB-CEC Adapter"
 InstallDirRegKey HKLM "Software\Pulse-Eight\USB-CEC Adapter software" ""
 RequestExecutionLevel admin
 Var StartMenuFolder
+Var VSRedistSetupError
+Var VSRedistInstalled
 
-!define MUI_FINISHPAGE_LINK "Visit http://www.pulse-eight.com/ for more information."
-!define MUI_FINISHPAGE_LINK_LOCATION "http://www.pulse-eight.com/"
+!define MUI_FINISHPAGE_LINK "Visit http://libcec.pulse-eight.com/ for more information."
+!define MUI_FINISHPAGE_LINK_LOCATION "http://libcec.pulse-eight.com/"
 !define MUI_ABORTWARNING  
 
 !insertmacro MUI_PAGE_WELCOME
@@ -40,11 +42,11 @@ Var StartMenuFolder
 
 !insertmacro MUI_LANGUAGE "English"
 
-InstType "USB-CEC driver & libCEC"
-InstType "USB-CEC driver only"
+InstType "USB-CEC Driver & libCEC"
+InstType "USB-CEC Driver Only"
 InstType "Full installation"
 
-Section "USB-CEC driver" SecDriver
+Section "USB-CEC Driver" SecDriver
   SetShellVarContext current
   SectionIn RO
   SectionIn 1 2 3
@@ -53,12 +55,19 @@ Section "USB-CEC driver" SecDriver
   ReadRegStr $1 HKCU "Software\libCEC" ""
   ${If} $1 != ""
     MessageBox MB_OK \
-         "A previous libCEC and USB-CEC driver was found. This update requires the old version to be uninstalled. Press OK to uninstall the old version."
+         "A previous libCEC and USB-CEC Driver was found. This update requires the old version to be uninstalled. Press OK to uninstall the old version."
     ExecWait '"$1\Uninstall.exe" /S _?=$1'
        Delete "$1\Uninstall.exe"
        RMDir "$1"
   ${EndIf}
 
+  ; Delete libcec.dll and libcec.x64.dll from the system directory
+  ; Let a seperate installer do this, when we need it
+  Delete "$SYSDIR\libcec.dll"
+  ${If} ${RunningX64}
+    Delete "$SYSDIR\libcec.x64.dll"
+  ${EndIf}
+
   ; Copy to the installation directory
   SetOutPath "$INSTDIR"
   File "..\AUTHORS"
@@ -119,8 +128,10 @@ Section "libCEC" SecLibCec
   File "..\ChangeLog"
   File "..\README"
   File "..\build\*.dll"
+  File "..\build\*.xml"
   SetOutPath "$INSTDIR\x64"
   File /nonfatal "..\build\x64\*.dll"
+  File /nonfatal "..\build\x64\*.xml"
 
   ; Copy to XBMC\system
   ReadRegStr $1 HKCU "Software\XBMC" ""
@@ -132,32 +143,25 @@ Section "libCEC" SecLibCec
   ; Copy the headers
   SetOutPath "$INSTDIR\include"
   File /r /x *.so "..\include\cec*.*"
-
-  ; Copy libcec.dll and libcec.x64.dll to the system directory
-  SetOutPath "$SYSDIR"
-  File "..\build\libcec.dll"
-  ${If} ${RunningX64}
-    File /nonfatal "..\build\x64\libcec.x64.dll"
-  ${EndIf}
 SectionEnd
 
-Section "CEC debug client" SecCecClient
+Section "CEC Debug Client" SecCecClient
   SetShellVarContext current
   SectionIn 3
 
   ; Copy to the installation directory
   SetOutPath "$INSTDIR"
-  File /x p8-usbcec-driver-installer.exe /x cec-config-gui.exe "..\build\*.exe"
+  File /x p8-usbcec-driver-installer.exe /x cec-tray.exe "..\build\*.exe"
   SetOutPath "$INSTDIR\x64"
-  File /nonfatal /x cec-config-gui.exe "..\build\x64\*.exe"
+  File /nonfatal "..\build\x64\*.exe"
 
   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
   SetOutPath "$INSTDIR"
 
   CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
   ${If} ${RunningX64}
-    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" "$INSTDIR\x64\cec-client.x64.exe" \
-      "" "$INSTDIR\cec-client.x64.exe" 0 SW_SHOWNORMAL \
+    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" "$INSTDIR\x64\cec-client.exe" \
+      "" "$INSTDIR\x64\cec-client.exe" 0 SW_SHOWNORMAL \
       "" "Start the CEC Test client (x64)."
   ${Else}
     CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk" "$INSTDIR\cec-client.exe" \
@@ -168,33 +172,121 @@ Section "CEC debug client" SecCecClient
     
 SectionEnd
 
-Section "CEC configuration tool" SecCecConfig
+Section "libCEC Tray Application" SecCecTray
   SetShellVarContext current
   SectionIn 1 3
 
+  ; Uninstall previous beta builds of the tray application
+  ReadRegStr $1 HKLM "Software\Pulse-Eight\libCECTray" ""
+  ${If} $1 != ""
+    MessageBox MB_OK \
+         "A previous beta build of the libCEC Tray Application was found. Press OK to uninstall the old version. Do not uninstall the driver when asked to. Thank you for participating in the beta test."
+    ExecWait '"$1\Uninstall.exe" /S _?=$1'
+       Delete "$1\Uninstall.exe"
+  ${EndIf}
+
+  ; Replace cec-config-gui.exe
+  Delete "$INSTDIR\cec-config-gui.exe"
+  ${If} ${RunningX64}
+    Delete "$INSTDIR\x64\cec-config-gui.exe"
+  ${EndIf}
+  Delete "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration.lnk"
+  ${If} ${RunningX64}
+    Delete "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration (x64).lnk"
+  ${EndIf}
+
   ; Copy to the installation directory
   SetOutPath "$INSTDIR"
-  File "..\build\cec-config-gui.exe"
+  File "..\build\cec-tray.exe"
   SetOutPath "$INSTDIR\x64"
-  File /nonfatal "..\build\x64\cec-config-gui.exe"
+  File /nonfatal "..\build\x64\cec-tray.exe"
 
   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
   SetOutPath "$INSTDIR"
 
   CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
   ${If} ${RunningX64}
-    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration (x64).lnk" "$INSTDIR\x64\cec-config-gui.exe" \
-      "" "$INSTDIR\x64\cec-config-gui.exe" 0 SW_SHOWNORMAL \
-      "" "Start the CEC Adapter Configuration tool (x64)."
+    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\libCEC Tray (x64).lnk" "$INSTDIR\x64\cec-tray.exe" \
+      "" "$INSTDIR\x64\cec-tray.exe" 0 SW_SHOWNORMAL \
+      "" "Start the libCEC Tray (x64)."
   ${Else}
-    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration.lnk" "$INSTDIR\cec-config-gui.exe" \
-      "" "$INSTDIR\cec-config-gui.exe" 0 SW_SHOWNORMAL \
-      "" "Start the CEC Adapter Configuration tool."
+    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\libCEC Tray.lnk" "$INSTDIR\cec-tray.exe" \
+      "" "$INSTDIR\cec-tray.exe" 0 SW_SHOWNORMAL \
+      "" "Start the libCEC Tray."
   ${EndIf}
   !insertmacro MUI_STARTMENU_WRITE_END  
     
 SectionEnd
 
+!define REDISTRIBUTABLE_SECTIONNAME "Microsoft Visual C++ 2010 Redistributable Package"
+Section "" SecVCRedist
+  SetShellVarContext current
+  SectionIn 1 3
+
+
+  ${If} $VSRedistInstalled != "Yes"
+    ; Download redistributable
+    SetOutPath "$TEMP\vc20XX"
+    ${If} ${RunningX64}
+      NSISdl::download http://packages.pulse-eight.net/windows/vcredist_x64.exe vcredist_x64.exe
+      ExecWait '"$TEMP\vc20XX\vcredist_x64.exe" /q' $VSRedistSetupError
+    ${Else}
+      NSISdl::download http://packages.pulse-eight.net/windows/vcredist_x86.exe vcredist_x86.exe
+      ExecWait '"$TEMP\vc20XX\vcredist_x86.exe" /q' $VSRedistSetupError
+    ${Endif}
+    RMDIR /r "$TEMP\vc20XX"
+  ${Endif}
+
+SectionEnd
+
+Function .onInit
+
+  ; SP0 x86
+  ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{196BB40D-1578-3D01-B289-BEFC77A11A1E}" "Version"
+  ${If} $1 != ""
+    StrCpy $VSRedistInstalled "Yes"
+  ${Endif}
+
+  ; SP0 x64
+  ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}" "Version"
+  ${If} $1 != ""
+    StrCpy $VSRedistInstalled "Yes"
+  ${Endif}
+
+  ; SP0 ia64
+  ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C1A35166-4301-38E9-BA67-02823AD72A1B}" "Version"
+  ${If} $1 != ""
+    StrCpy $VSRedistInstalled "Yes"
+  ${Endif}
+
+  ; SP1 x86
+  ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}" "Version"
+  ${If} $1 != ""
+    StrCpy $VSRedistInstalled "Yes"
+  ${Endif}
+
+  ; SP1 x64
+  ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1D8E6291-B0D5-35EC-8441-6616F567A0F7}" "Version"
+  ${If} $1 != ""
+    StrCpy $VSRedistInstalled "Yes"
+  ${Endif}
+
+  ; SP1 ia64
+  ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}" "Version"
+  ${If} $1 != ""
+    StrCpy $VSRedistInstalled "Yes"
+  ${Endif}
+
+  ${If} $VSRedistInstalled == "Yes"
+    !insertMacro UnSelectSection ${SecVCRedist}
+    SectionSetText ${SecVCRedist} ""
+  ${Else}
+    !insertMacro SelectSection ${SecVCRedist}
+    SectionSetText ${SecVCRedist} "${REDISTRIBUTABLE_SECTIONNAME}"
+  ${Endif}
+
+FunctionEnd
+
 ;--------------------------------
 ;Uninstaller Section
 
@@ -208,10 +300,16 @@ Section "Uninstall"
   Delete "$INSTDIR\COPYING"
   Delete "$INSTDIR\*.dll"
   Delete "$INSTDIR\*.lib"
+  Delete "$INSTDIR\*.xml"
   Delete "$INSTDIR\x64\*.dll"
   Delete "$INSTDIR\x64\*.lib"
   Delete "$INSTDIR\x64\*.exe"
+  Delete "$INSTDIR\x64\*.xml"
   Delete "$INSTDIR\README"
+  Delete "$SYSDIR\libcec.dll"
+  ${If} ${RunningX64}
+    Delete "$SYSDIR\libcec.x64.dll"
+  ${EndIf}
 
   ; Uninstall the driver
   ReadRegStr $1 HKLM "Software\Pulse-Eight\USB-CEC Adapter driver" ""
@@ -225,9 +323,9 @@ Section "Uninstall"
   RMDir "$PROGRAMFILES\Pulse-Eight"
   
   !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
-  Delete "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration.lnk"
+  Delete "$SMPROGRAMS\$StartMenuFolder\libCEC Tray.lnk"
   ${If} ${RunningX64}
-    Delete "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration (x64).lnk"
+    Delete "$SMPROGRAMS\$StartMenuFolder\libCEC Tray (x64).lnk"
   ${EndIf}
   Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk"
   ${If} ${RunningX64}
@@ -237,7 +335,7 @@ Section "Uninstall"
   Delete "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url"
   RMDir "$SMPROGRAMS\$StartMenuFolder"
 
-  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware"
+  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter software"
   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter driver"
   DeleteRegKey /ifempty HKLM "Software\Pulse-Eight\USB-CEC Adapter software"
   DeleteRegKey /ifempty HKLM "Software\Pulse-Eight"