; opennap-ng.nsi
Name "opennap-ng_0.47-1"
OutFile "opennap-ng_0.47-1.exe"
InstallDir $PROGRAMFILES\opennap-ng
InstallDirRegKey HKLM SOFTWARE\opennap-ng "Install_Dir"

ComponentText "Thank you for choosing the Next Generation Open Source Napster Server! Please select which options you want installed."
DirText "Please choose a directory to install in to:"

LicenseText "Now I like this ;'). Please do read *all* of it! This is what Linux is all about..."
LicenseData "Copying"

AutoCloseWindow true
ShowInstDetails show

; $9 = counter
; $8 = DLL
; $7 = ini
Function .onInit
  SetOutPath $TEMP
  File /oname=spltmp.bmp "opennap-ng.bmp"
  File /oname=spltmp.wav "opennap-ng.wav"
  File /oname=spltmp.exe "C:\program files\nsis\splash.exe"
  ExecWait '"$TEMP\spltmp.exe" 3000 $HWNDPARENT $TEMP\spltmp'
  Delete $TEMP\spltmp.exe
  Delete $TEMP\spltmp.bmp
  Delete $TEMP\spltmp.wav
;  StrCpy $9 0
;  GetTempFileName $8
;  GetTempFileName $7
;  File /oname=$8 InstallOptions.dll
;  File /oname=$7 "opennap-ng.ini"
FunctionEnd

;Function .onNextPage
;  StrCmp $9 1 good
;    IntOp $9 $9 + 1
;    Return
;  good:
;  Call RunConfigure
;  Pop $0
;  StrCmp $0 "cancel" "" nocancel
;    Call Cleanup
;    Quit
;  nocancel:
;  StrCmp $0 "back" "" noback
;    Abort
;  noback:
;  IntOp $9 $9 + 1
;FunctionEnd

;Function .onPrevPage
;  StrCmp $9 2 good
;    IntOp $9 $9 - 1
;    Return
;  good:
;  Call RunConfigure
;  Pop $0
;  StrCmp $0 "cancel" "" nocancel
;    Call Cleanup
;    Quit
;  nocancel:
;  StrCmp $0 "back" back
;    Abort
;  back:
;  IntOp $9 $9 - 1
;FunctionEnd

;Function RunConfigure
;  Push $7
;  CallInstDLL $8 dialog
;  SetOutPath $TEMP
;  File "release\mkpass.exe"
;  ReadINIStr $1 $7 "Field 4" State
;  ReadINIStr $2 $7 "Field 5" State
;  ExecWait '"$TEMP\mkpass.exe" "$2" > $TEMP\mkpass'
;  MessageBox MB_OK "returned $R0"
;FunctionEnd

;Function .onInstSuccess
;Call Cleanup
;FunctionEnd

;Function .onInstFailed
;Call Cleanup
;FunctionEnd

;Function .onUserAbort
;Call Cleanup
;FunctionEnd

;Function Cleanup
;  Delete $8
;  Delete $7
;FunctionEnd

Section "opennap-ng (mandatory :)"
  SetOutPath $INSTDIR
  File "release\opennap.exe"
  File "release\setup.exe"
  File "release\mkpass.exe"
  File "zlib.dll"
;  File "cygwin1.dll"
;  File "cygz.dll"
  File /oname=config "config"
;  File /oname=users "..\doc\examples\sample.users"
  File /oname=motd "motd"
;  File /oname=filter "..\doc\examples\sample.filter"
;  File /oname=servers "..\doc\examples\sample.servers"
  File "..\doc\manual.html"
  WriteRegStr HKLM SOFTWARE\opennap-ng "Install_Dir" "$INSTDIR"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\opennap-ng" "DisplayName" "Opennap-NG (remove only)"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\opennap-ng" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteUninstaller "uninstall.exe"
SectionEnd

Section "Start Menu Shortcuts"
  CreateDirectory "$SMPROGRAMS\Opennap-NG"
  CreateShortCut "$SMPROGRAMS\Opennap-NG\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\Opennap-NG\Opennap-NG.lnk" "$INSTDIR\opennap.exe" "" "$INSTDIR\opennap.exe" 0
  CreateShortCut "$SMPROGRAMS\Opennap-NG\Setup.lnk" "$INSTDIR\setup.exe" "" "$INSTDIR\setup.exe" 0
  CreateShortCut "$SMPROGRAMS\Opennap-NG\Manual.lnk" "$INSTDIR\manual.html" "" "$INSTDIR\manual.html" 0
  CreateShortCut "$SMPROGRAMS\Opennap-NG\Edit Config.lnk" "c:\windows\notepad.exe" "$INSTDIR\config" "c:\windows\notepad.exe" 0
SectionEnd

UninstallText "This will uninstall Opennap-NG 0.47. Are You Sure??? It will delete *ALL* files in your opennap-ng dir."
Section "Uninstall"
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\opennap-ng"
  DeleteRegKey HKLM SOFTWARE\opennap-ng
  Delete $INSTDIR\opennap.exe
  Delete $INSTDIR\setup.exe
  Delete $INSTDIR\mkpass.exe
  Delete $INSTDIR\zlib.dll
;  Delete $INSTDIR\cygwin1.dll
;  Delete $INSTDIR\cygz.dll
  Delete $INSTDIR\config
  Delete $INSTDIR\users
  Delete $INSTDIR\servers
  Delete $INSTDIR\filter
  Delete $INSTDIR\block
  Delete $INSTDIR\motd
  Delete $INSTDIR\bans
  Delete $INSTDIR\channels
  Delete $INSTDIR\limit
  Delete $INSTDIR\pid
  Delete $INSTDIR\manual.html
  Delete $INSTDIR\uninstall.exe
  Delete "$SMPROGRAMS\Opennap-NG\*.*"
  RMDir "$SMPROGRAMS\Opennap-NG"
  RMDir "$INSTDIR"
SectionEnd

; eof
