3
!define INSPECTOR_VERSION "0.2.0"
4
!define INSTALLER_VERSION "beta5"
5
!define GTK_RUNTIME_INSTALLER "gtk2-runtime*.exe"
6
!define GTK_MIN_VERSION "2.6.10"
7
!define GTK_REG_KEY "SOFTWARE\GTK\2.0"
8
!define GTK_DEFAULT_INSTALL_PATH "$COMMONFILES\GTK\2.0"
16
; global configuration
18
SetCompressor /SOLID lzma
20
Name "UPnP Inspector ${INSPECTOR_VERSION}"
21
OutFile "UPnPInspector-${INSPECTOR_VERSION}-${INSTALLER_VERSION}-setup.exe"
23
InstallDir "$PROGRAMFILES\UPnPInspector"
29
!include "Sections.nsh"
31
!include "LogicLib.nsh"
33
!include "FileFunc.nsh"
34
!insertmacro GetParameters
35
!insertmacro GetOptions
36
!insertmacro GetParent
38
!include "WordFunc.nsh"
39
!insertmacro VersionCompare
41
!insertmacro un.WordFind
43
!define MUI_Icon "inspector-icon.ico"
45
; -----------------------------------
47
!define MUI_ABORTWARNING
49
!define MUI_FINISHPAGE_NOAUTOCLOSE
50
!define MUI_FINISHPAGE_RUN "$INSTDIR\upnp-inspector.exe"
52
!define MUI_PAGE_CUSTOMFUNCTION_PRE preWelcomePage
53
!insertmacro MUI_PAGE_WELCOME
56
!define MUI_PAGE_CUSTOMFUNCTION_PRE preGtkDirPage
57
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE postGtkDirPage
58
;!define MUI_DIRECTORYPAGE_VARIABLE $GTK_FOLDER
59
!insertmacro MUI_PAGE_COMPONENTS
61
!insertmacro MUI_PAGE_DIRECTORY
62
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
63
!insertmacro MUI_PAGE_INSTFILES
64
!insertmacro MUI_PAGE_FINISH
66
!insertmacro MUI_LANGUAGE "English"
69
LangString DESC_SecDummy ${LANG_ENGLISH} "UPnP Inspector ${INSPECTOR_VERSION}"
70
LangString GTK_SECTION_DESCRIPTION ${LANG_ENGLISH} "GTK+ Package. To be installed if you dont have pre installed GTK+"
72
;Assign language strings to sections
73
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
74
!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
75
!insertmacro MUI_DESCRIPTION_TEXT ${SecGtk} $(GTK_SECTION_DESCRIPTION)
76
!insertmacro MUI_FUNCTION_DESCRIPTION_END
78
Section "Inspector" SecDummy
82
WriteUninstaller "$INSTDIR\uninstall.exe"
84
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
86
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
87
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
88
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\UPnP Inspector.lnk" "$INSTDIR\upnp-inspector.exe"
89
!insertmacro MUI_STARTMENU_WRITE_END
93
;--------------------------------
94
;GTK+ Runtime Install Section
96
Section "Gtk Installer" SecGtk
98
Call CheckUserInstallRights
103
File /oname=gtk-runtime.exe ${GTK_RUNTIME_INSTALLER}
110
StrCmp $R0 "0" have_gtk
111
StrCmp $R0 "1" upgrade_gtk
112
StrCmp $R0 "2" upgrade_gtk
113
;StrCmp $R0 "3" no_gtk no_gtk
116
StrCmp $R1 "NONE" gtk_no_install_rights
118
ExecWait '"$TEMP\gtk-runtime.exe" /L=$LANGUAGE $ISSILENT /D=$GTK_FOLDER'
119
IfErrors gtk_install_error done
122
StrCpy $GTK_FOLDER $R6
123
StrCmp $R0 "2" +2 ; Upgrade isn't optional
124
MessageBox MB_YESNO $(GTK_UPGRADE_PROMPT) /SD IDYES IDNO done
126
ExecWait '"$TEMP\gtk-runtime.exe" /L=$LANGUAGE $ISSILENT /D=$GTK_FOLDER'
127
IfErrors gtk_install_error done
130
Delete "$TEMP\gtk-runtime.exe"
131
MessageBox MB_OK $(GTK_INSTALL_ERROR) /SD IDOK
135
StrCpy $GTK_FOLDER $R6
136
StrCmp $R1 "NONE" done ; If we have no rights, we can't re-install
137
; Even if we have a sufficient version of GTK+, we give user choice to re-install.
139
ExecWait '"$TEMP\gtk-runtime.exe" /L=$LANGUAGE $ISSILENT'
140
IfErrors gtk_install_error
143
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144
; end got_install rights
146
gtk_no_install_rights:
147
; Install GTK+ to the inspector directory
148
StrCpy $GTK_FOLDER $INSTDIR
150
ExecWait '"$TEMP\gtk-runtime.exe" /L=$LANGUAGE $ISSILENT /D=$GTK_FOLDER'
151
IfErrors gtk_install_error
154
CopyFiles /FILESONLY "$GTK_FOLDER\bin\*.dll" $GTK_FOLDER
156
IfErrors gtk_install_error
157
Delete "$GTK_FOLDER\bin\*.dll"
159
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
160
; end gtk_no_install_rights
163
Delete "$TEMP\gtk-runtime.exe"
164
SectionEnd ; end of GTK+ section
169
Delete "$INSTDIR\*.*"
173
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
175
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
176
Delete "$SMPROGRAMS\$StartMenuFolder\UPnP Inspector.lnk"
177
RMDir "$SMPROGRAMS\$StartMenuFolder"
182
; ---------------- HELPERS ------------
183
; Borrowed from the great pidgin project
189
; 0 - We have the correct version
190
; Second Pop: Key where Version was found
191
; 1 - We have an old version that should work, prompt user for optional upgrade
192
; Second Pop: HKLM or HKCU depending on where GTK was found.
193
; 2 - We have an old version that needs to be upgraded
194
; Second Pop: HKLM or HKCU depending on where GTK was found.
195
; 3 - We don't have Gtk+ at all
196
; Second Pop: "NONE, HKLM or HKCU" depending on our rights..
200
; - Check what user rights we have (HKLM or HKCU)
202
; - Only check HKLM key for GTK+
203
; - If installed to HKLM, check it and return.
205
; - First check HKCU key for GTK+
206
; - if good or bad exists stop and ret.
207
; - If no hkcu gtk+ install, check HKLM
208
; - If HKLM ver exists but old, return as if no ver exits.
216
Call CheckUserInstallRights
218
StrCmp $1 "HKLM" check_hklm
219
StrCmp $1 "HKCU" check_hkcu check_hklm
221
ReadRegStr $0 HKCU ${GTK_REG_KEY} "Version"
223
StrCmp $0 "" check_hklm have_gtk
226
ReadRegStr $0 HKLM ${GTK_REG_KEY} "Version"
228
StrCmp $0 "" no_gtk have_gtk
231
; GTK+ is already installed; check version.
232
; Change this to not even run the GTK installer if this version is already installed.
233
${VersionCompare} ${GTK_INSTALL_VERSION} $0 $3
234
IntCmp $3 1 +1 good_version good_version
235
${VersionCompare} ${GTK_MIN_VERSION} $0 $3
237
; Bad version. If hklm ver and we have hkcu or no rights.. return no gtk
238
StrCmp $1 "NONE" no_gtk ; if no rights.. can't upgrade
239
StrCmp $1 "HKCU" 0 +2 ; if HKLM can upgrade..
240
StrCmp $2 "HKLM" no_gtk ; have hkcu rights.. if found hklm ver can't upgrade..
243
Push "1" ; Optional Upgrade
245
Push "2" ; Mandatory Upgrade
249
StrCmp $2 "HKLM" have_hklm_gtk have_hkcu_gtk
252
ReadRegStr $0 HKCU ${GTK_REG_KEY} "Path"
253
Goto good_version_cont
256
ReadRegStr $0 HKLM ${GTK_REG_KEY} "Path"
257
Goto good_version_cont
260
Push $0 ; The path to existing GTK+
270
; The top two items on the stack are what we want to return
279
Function preWelcomePage
288
IntCmp $R0 1 gtk_selection_done gtk_not_mandatory
289
; Make the GTK+ Section RO if it is required.
290
!insertmacro SetSectionFlag ${SecGtk} ${SF_RO}
291
Goto gtk_selection_done
293
; Don't select the GTK+ section if we already have this version or newer installed
294
!insertmacro UnselectSection ${SecGtk}
297
; If on Win95/98/ME warn them that the GTK+ version wont work
299
!insertmacro UnselectSection ${SecGtk}
300
!insertmacro SetSectionFlag ${SecGtk} ${SF_RO}
301
MessageBox MB_OK $(GTK_WINDOWS_INCOMPATIBLE) /SD IDOK
302
IntCmp $R0 1 done done ; Upgrade isn't optional - abort if we don't have a suitable version
313
Function preGtkDirPage
320
IntCmp $R0 2 +2 +2 no_gtk
321
StrCmp $R0 "3" no_gtk no_gtk
323
; Don't show dir selector.. Upgrades are done to existing path..
329
StrCmp $R1 "NONE" 0 no_gtk_cont
330
; Got no install rights..
336
StrCmp $R1 "HKCU" 0 hklm1
337
${GetParent} $SMPROGRAMS $R0
339
StrCpy $R0 "$R0\GTK\2.0"
342
StrCpy $R0 "${GTK_DEFAULT_INSTALL_PATH}"
345
StrCpy $name "GTK+ ${GTK_INSTALL_VERSION}"
346
StrCpy $GTK_FOLDER $R0
351
Function postGtkDirPage
356
StrCmp $R0 "0" 0 done
357
MessageBox MB_OK $(GTK_BAD_INSTALL_PATH) /SD IDOK
364
!macro CheckUserInstallRightsMacro UN
365
Function ${UN}CheckUserInstallRights
372
UserInfo::GetAccountType
375
StrCmp $1 "Admin" 0 +3
378
StrCmp $1 "Power" 0 +3
381
StrCmp $1 "User" 0 +3
384
StrCmp $1 "Guest" 0 +3
400
!insertmacro CheckUserInstallRightsMacro ""
401
!insertmacro CheckUserInstallRightsMacro "un."
406
; Push $0 ; Path string
408
; Pop $0 ; 0 - Bad path 1 - Good path
415
IfFileExists $0 dir_exists
416
StrCpy $1 $0 ; save last
419
; IfFileExists "C:" on xp returns true and on win2k returns false
420
; So we're done in such a case..
421
IntCmp $2 2 loop_done
422
; GetParent of "C:" returns ""
423
IntCmp $2 0 loop_done
427
StrCpy $1 "$0\GaImFooB"
428
; Check if we can create dir on this drive..
431
IfErrors DirBad DirGood
435
FileOpen $1 "$0\pidginfoo.bar" w
436
IfErrors PathBad PathGood
448
Delete "$0\pidginfoo.bar"
456
Delete "$0\pidginfoo.bar"
462
Exch 3 ; The top of the stack contains the output variable
468
Function .onVerifyInstDir
473
StrCmp $0 "0" 0 dir_good