added DetectAdapters() method, that returns all device information for detected adapt...
[deb_libcec.git] / project / libCEC.nsi
CommitLineData
09054f70 1;libCEC installer
d4954fb7 2;Copyright (C) 2012 Pulse-Eight Ltd.
09054f70
LOK
3;http://www.pulse-eight.com/
4
5!include "MUI2.nsh"
6!include "nsDialogs.nsh"
7!include "LogicLib.nsh"
8!include "x64.nsh"
9
6fb1aefd 10Name "Pulse-Eight libCEC version 2.0.5"
4d760b54 11OutFile "..\build\libCEC-installer.exe"
09054f70
LOK
12
13XPStyle on
8dfe215b
LOK
14InstallDir "$PROGRAMFILES\Pulse-Eight\USB-CEC Adapter"
15InstallDirRegKey HKLM "Software\Pulse-Eight\USB-CEC Adapter software" ""
09054f70
LOK
16RequestExecutionLevel admin
17Var StartMenuFolder
b80ca2f2
MK
18Var VSRedistSetupError
19Var VSRedistInstalled
09054f70 20
c4b862b6
ME
21!define MUI_FINISHPAGE_LINK "Visit http://libcec.pulse-eight.com/ for more information."
22!define MUI_FINISHPAGE_LINK_LOCATION "http://libcec.pulse-eight.com/"
09054f70
LOK
23!define MUI_ABORTWARNING
24
25!insertmacro MUI_PAGE_WELCOME
26!insertmacro MUI_PAGE_LICENSE "..\COPYING"
d4954fb7 27!insertmacro MUI_PAGE_COMPONENTS
09054f70
LOK
28!insertmacro MUI_PAGE_DIRECTORY
29
8dfe215b
LOK
30!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
31!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Pulse-Eight\USB-CEC Adapter sofware"
09054f70
LOK
32!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
33!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
34
35!insertmacro MUI_PAGE_INSTFILES
36!insertmacro MUI_PAGE_FINISH
37
38!insertmacro MUI_UNPAGE_WELCOME
39!insertmacro MUI_UNPAGE_CONFIRM
40!insertmacro MUI_UNPAGE_INSTFILES
41!insertmacro MUI_UNPAGE_FINISH
42
43!insertmacro MUI_LANGUAGE "English"
44
c4b862b6
ME
45InstType "USB-CEC Driver & libCEC"
46InstType "USB-CEC Driver Only"
d4954fb7 47InstType "Full installation"
09054f70 48
c4b862b6 49Section "USB-CEC Driver" SecDriver
09054f70
LOK
50 SetShellVarContext current
51 SectionIn RO
d4954fb7 52 SectionIn 1 2 3
4d760b54 53
8dfe215b
LOK
54 ; Uninstall the old unsigned software if it's found
55 ReadRegStr $1 HKCU "Software\libCEC" ""
56 ${If} $1 != ""
57 MessageBox MB_OK \
c4b862b6 58 "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."
8dfe215b
LOK
59 ExecWait '"$1\Uninstall.exe" /S _?=$1'
60 Delete "$1\Uninstall.exe"
61 RMDir "$1"
62 ${EndIf}
63
71b6af0a
LOK
64 ; Delete libcec.dll and libcec.x64.dll from the system directory
65 ; Let a seperate installer do this, when we need it
66 Delete "$SYSDIR\libcec.dll"
67 ${If} ${RunningX64}
68 Delete "$SYSDIR\libcec.x64.dll"
69 ${EndIf}
70
4d760b54 71 ; Copy to the installation directory
09054f70
LOK
72 SetOutPath "$INSTDIR"
73 File "..\AUTHORS"
09054f70 74 File "..\COPYING"
f6562fae 75
8dfe215b 76 ; Copy the driver installer
09054f70 77 SetOutPath "$INSTDIR\driver"
8dfe215b 78 File "..\build\p8-usbcec-driver-installer.exe"
4d760b54 79
09054f70 80 ;Store installation folder
8dfe215b 81 WriteRegStr HKLM "Software\Pulse-Eight\USB-CEC Adapter software" "" $INSTDIR
09054f70
LOK
82
83 ;Create uninstaller
84 WriteUninstaller "$INSTDIR\Uninstall.exe"
85
86 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
87 SetOutPath "$INSTDIR"
88
89 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
8dfe215b 90 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Pulse-Eight USB-CEC Adapter software.lnk" "$INSTDIR\Uninstall.exe" \
09054f70 91 "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \
8dfe215b 92 "" "Uninstall Pulse-Eight USB-CEC Adapter software."
09054f70
LOK
93
94 WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url" "InternetShortcut" "URL" "http://www.pulse-eight.com/"
95 !insertmacro MUI_STARTMENU_WRITE_END
d4954fb7 96
09054f70 97 ;add entry to add/remove programs
8dfe215b
LOK
98 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
99 "DisplayName" "Pulse-Eight USB-CEC Adapter software"
100 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
09054f70 101 "UninstallString" "$INSTDIR\uninstall.exe"
8dfe215b 102 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
09054f70 103 "NoModify" 1
8dfe215b 104 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
09054f70 105 "NoRepair" 1
8dfe215b 106 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
09054f70 107 "InstallLocation" "$INSTDIR"
8dfe215b 108 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
09054f70 109 "DisplayIcon" "$INSTDIR\cec-client.exe,0"
8dfe215b
LOK
110 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
111 "Publisher" "Pulse-Eight Limited"
112 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
09054f70 113 "HelpLink" "http://www.pulse-eight.com/"
8dfe215b 114 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
09054f70
LOK
115 "URLInfoAbout" "http://www.pulse-eight.com"
116
117 ;install driver
8dfe215b
LOK
118 ExecWait '"$INSTDIR\driver\p8-usbcec-driver-installer.exe" /S'
119 Delete "$INSTDIR\driver\p8-usbcec-driver-installer.exe"
09054f70
LOK
120SectionEnd
121
d4954fb7
LOK
122Section "libCEC" SecLibCec
123 SetShellVarContext current
124 SectionIn 1 3
125
126 ; Copy to the installation directory
127 SetOutPath "$INSTDIR"
128 File "..\ChangeLog"
129 File "..\README"
130 File "..\build\*.dll"
8fe82f39 131 File "..\build\*.xml"
d4954fb7
LOK
132 SetOutPath "$INSTDIR\x64"
133 File /nonfatal "..\build\x64\*.dll"
8fe82f39 134 File /nonfatal "..\build\x64\*.xml"
d4954fb7
LOK
135
136 ; Copy to XBMC\system
137 ReadRegStr $1 HKCU "Software\XBMC" ""
138 ${If} $1 != ""
139 SetOutPath "$1\system"
140 File "..\build\libcec.dll"
141 ${EndIf}
142
143 ; Copy the headers
144 SetOutPath "$INSTDIR\include"
145 File /r /x *.so "..\include\cec*.*"
d4954fb7
LOK
146SectionEnd
147
c4b862b6 148Section "CEC Debug Client" SecCecClient
d4954fb7
LOK
149 SetShellVarContext current
150 SectionIn 3
151
152 ; Copy to the installation directory
153 SetOutPath "$INSTDIR"
f017f3c4 154 File /x p8-usbcec-driver-installer.exe /x cec-tray.exe "..\build\*.exe"
d4954fb7 155 SetOutPath "$INSTDIR\x64"
f017f3c4 156 File /nonfatal /x cec-tray.exe "..\build\x64\*.exe"
d4954fb7
LOK
157
158 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
159 SetOutPath "$INSTDIR"
160
161 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
d4954fb7
LOK
162 ${If} ${RunningX64}
163 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" "$INSTDIR\x64\cec-client.x64.exe" \
164 "" "$INSTDIR\cec-client.x64.exe" 0 SW_SHOWNORMAL \
165 "" "Start the CEC Test client (x64)."
c9549d35
LOK
166 ${Else}
167 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk" "$INSTDIR\cec-client.exe" \
168 "" "$INSTDIR\cec-client.exe" 0 SW_SHOWNORMAL \
169 "" "Start the CEC Test client."
d4954fb7
LOK
170 ${EndIf}
171 !insertmacro MUI_STARTMENU_WRITE_END
172
173SectionEnd
174
b521303c 175Section "libCEC Tray Application" SecCecTray
10c03f2c
LOK
176 SetShellVarContext current
177 SectionIn 1 3
178
b521303c
LOK
179 ; Uninstall previous beta builds of the tray application
180 ReadRegStr $1 HKLM "Software\Pulse-Eight\libCECTray" ""
181 ${If} $1 != ""
182 MessageBox MB_OK \
183 "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."
184 ExecWait '"$1\Uninstall.exe" /S _?=$1'
185 Delete "$1\Uninstall.exe"
186 ${EndIf}
187
188 ; Replace cec-config-gui.exe
189 Delete "$INSTDIR\cec-config-gui.exe"
190 ${If} ${RunningX64}
191 Delete "$INSTDIR\x64\cec-config-gui.exe"
192 ${EndIf}
193 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration.lnk"
194 ${If} ${RunningX64}
195 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration (x64).lnk"
196 ${EndIf}
197
10c03f2c
LOK
198 ; Copy to the installation directory
199 SetOutPath "$INSTDIR"
f017f3c4 200 File "..\build\cec-tray.exe"
10c03f2c 201 SetOutPath "$INSTDIR\x64"
f017f3c4 202 File /nonfatal "..\build\x64\cec-tray.exe"
10c03f2c
LOK
203
204 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
205 SetOutPath "$INSTDIR"
206
207 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
10c03f2c 208 ${If} ${RunningX64}
f017f3c4
LOK
209 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\libCEC Tray (x64).lnk" "$INSTDIR\x64\cec-tray.exe" \
210 "" "$INSTDIR\x64\cec-tray.exe" 0 SW_SHOWNORMAL \
211 "" "Start the libCEC Tray (x64)."
c9549d35 212 ${Else}
f017f3c4
LOK
213 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\libCEC Tray.lnk" "$INSTDIR\cec-tray.exe" \
214 "" "$INSTDIR\cec-tray.exe" 0 SW_SHOWNORMAL \
215 "" "Start the libCEC Tray."
10c03f2c
LOK
216 ${EndIf}
217 !insertmacro MUI_STARTMENU_WRITE_END
218
219SectionEnd
220
b80ca2f2
MK
221!define REDISTRIBUTABLE_SECTIONNAME "Microsoft Visual C++ 2010 Redistributable Package"
222Section "" SecVCRedist
223 SetShellVarContext current
224 SectionIn 1 3
225
226
227 ${If} $VSRedistInstalled != "Yes"
228 ; Download redistributable
229 SetOutPath "$TEMP\vc20XX"
230 ${If} ${RunningX64}
231 NSISdl::download http://packages.pulse-eight.net/windows/vcredist_x64.exe vcredist_x64.exe
232 ExecWait '"$TEMP\vc20XX\vcredist_x64.exe" /q' $VSRedistSetupError
233 ${Else}
234 NSISdl::download http://packages.pulse-eight.net/windows/vcredist_x86.exe vcredist_x86.exe
235 ExecWait '"$TEMP\vc20XX\vcredist_x86.exe" /q' $VSRedistSetupError
236 ${Endif}
237 RMDIR /r "$TEMP\vc20XX"
238 ${Endif}
239
240SectionEnd
241
242Function .onInit
243
244 ; SP0 x86
245 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{196BB40D-1578-3D01-B289-BEFC77A11A1E}" "Version"
246 ${If} $1 != ""
247 StrCpy $VSRedistInstalled "Yes"
248 ${Endif}
249
250 ; SP0 x64
251 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}" "Version"
252 ${If} $1 != ""
253 StrCpy $VSRedistInstalled "Yes"
254 ${Endif}
255
256 ; SP0 ia64
257 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C1A35166-4301-38E9-BA67-02823AD72A1B}" "Version"
258 ${If} $1 != ""
259 StrCpy $VSRedistInstalled "Yes"
260 ${Endif}
261
262 ; SP1 x86
263 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}" "Version"
264 ${If} $1 != ""
265 StrCpy $VSRedistInstalled "Yes"
266 ${Endif}
267
268 ; SP1 x64
269 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1D8E6291-B0D5-35EC-8441-6616F567A0F7}" "Version"
270 ${If} $1 != ""
271 StrCpy $VSRedistInstalled "Yes"
272 ${Endif}
273
274 ; SP1 ia64
275 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}" "Version"
276 ${If} $1 != ""
277 StrCpy $VSRedistInstalled "Yes"
278 ${Endif}
279
280 ${If} $VSRedistInstalled == "Yes"
281 !insertMacro UnSelectSection ${SecVCRedist}
282 SectionSetText ${SecVCRedist} ""
283 ${Else}
284 !insertMacro SelectSection ${SecVCRedist}
285 SectionSetText ${SecVCRedist} "${REDISTRIBUTABLE_SECTIONNAME}"
286 ${Endif}
287
288FunctionEnd
289
09054f70
LOK
290;--------------------------------
291;Uninstaller Section
292
293Section "Uninstall"
294
295 SetShellVarContext current
296
09054f70 297 Delete "$INSTDIR\AUTHORS"
10c03f2c 298 Delete "$INSTDIR\*.exe"
09054f70
LOK
299 Delete "$INSTDIR\ChangeLog"
300 Delete "$INSTDIR\COPYING"
7879fa15 301 Delete "$INSTDIR\*.dll"
f00ff009 302 Delete "$INSTDIR\*.lib"
8fe82f39 303 Delete "$INSTDIR\*.xml"
4d760b54
LOK
304 Delete "$INSTDIR\x64\*.dll"
305 Delete "$INSTDIR\x64\*.lib"
10c03f2c 306 Delete "$INSTDIR\x64\*.exe"
8fe82f39 307 Delete "$INSTDIR\x64\*.xml"
09054f70 308 Delete "$INSTDIR\README"
71b6af0a
LOK
309 Delete "$SYSDIR\libcec.dll"
310 ${If} ${RunningX64}
311 Delete "$SYSDIR\libcec.x64.dll"
312 ${EndIf}
8dfe215b
LOK
313
314 ; Uninstall the driver
315 ReadRegStr $1 HKLM "Software\Pulse-Eight\USB-CEC Adapter driver" ""
316 ${If} $1 != ""
317 ExecWait '"$1\Uninstall.exe" /S _?=$1'
318 ${EndIf}
09054f70
LOK
319
320 RMDir /r "$INSTDIR\include"
321 Delete "$INSTDIR\Uninstall.exe"
322 RMDir /r "$INSTDIR"
8dfe215b 323 RMDir "$PROGRAMFILES\Pulse-Eight"
09054f70
LOK
324
325 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
f017f3c4 326 Delete "$SMPROGRAMS\$StartMenuFolder\libCEC Tray.lnk"
10c03f2c 327 ${If} ${RunningX64}
f017f3c4 328 Delete "$SMPROGRAMS\$StartMenuFolder\libCEC Tray (x64).lnk"
10c03f2c 329 ${EndIf}
09054f70 330 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk"
f00ff009
LOK
331 ${If} ${RunningX64}
332 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk"
333 ${EndIf}
8dfe215b 334 Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Pulse-Eight USB-CEC Adapter software.lnk"
09054f70 335 Delete "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url"
8dfe215b 336 RMDir "$SMPROGRAMS\$StartMenuFolder"
09054f70 337
203f618e 338 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter software"
8dfe215b
LOK
339 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter driver"
340 DeleteRegKey /ifempty HKLM "Software\Pulse-Eight\USB-CEC Adapter software"
341 DeleteRegKey /ifempty HKLM "Software\Pulse-Eight"
09054f70 342SectionEnd