              ; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Lasso @VERSION@"
!define PRODUCT_VERSION "2.4"
!define PRODUCT_PUBLISHER "Entr'ouvert"
!define PRODUCT_WEB_SITE "http://lasso.entrouvert.org/"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"


SetCompressor bzip2

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE "..\..\COPYING"
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"


; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Lasso-@VERSION_UNDERSCORED@.win32-py2.4.exe"
ShowInstDetails show
ShowUnInstDetails show

Function .onInit
  !insertmacro MUI_LANGDLL_DISPLAY
  ReadRegStr $INSTDIR HKLM SOFTWARE\Python\PythonCore\2.4\InstallPath ""

  IfErrors 0 +2
    Call NoPython24
  FileOpen $0 $SYSDIR\@DLL_FILENAME@ r
  IfErrors 0 +2
    Call NoLasso
  FileClose $0
                   
FunctionEnd
         
Section "-Lasso python module" SEC01
  SetOutPath "$INSTDIR\DLLs"
  SetOverwrite ifnewer
  File "..\msvc\python\Release\_lasso.dll"
  SetOutPath "$INSTDIR\Lib"
  File "..\..\python\lasso.py"
SectionEnd

Section /o "Lasso python module with debugging symbols" SEC02
  SetOutPath "$INSTDIR\DLLs"
  File "..\msvc\python\Debug\_lasso_d.dll"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\Lib\lasso_uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Lib\lasso_uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
  WriteRegStr HKLM "SOFTWARE\Python\Lasso\2.4\@VERSION@\InstallPath" "" "$INSTDIR"
SectionEnd


Function un.onUninstSuccess
  HideWindow
	StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
		MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfuly uninstalled."
	StrCmp $LANGUAGE ${LANG_FRENCH} 0 +2
          MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) a été désinstallé avec succès de votre ordinateur."
FunctionEnd

Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
	StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
		MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to uninstall $(^Name)?" IDYES +4
	StrCmp $LANGUAGE ${LANG_FRENCH} 0 +2  
               MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Êtes-vous certains de vouloir désinstaller totalement $(^Name) et tous ses composants ?" IDYES +2
  Abort         
FunctionEnd

Function NoPython24
	StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
		MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "You do not seem to have Python 2.4 installed, are you sure you want to continue ?" IDYES +4
	StrCmp $LANGUAGE ${LANG_FRENCH} 0 +2
		MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Vous semblez ne pas avoir Python 2.4 d'installé, êtes-vous sûr de vouloir continuer ?" IDYES +2
        Abort

FunctionEnd

Function NoLasso
	StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
		MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "You do not seem to have LASSO-3 C Library installed, are you sure you want to continue ?" IDYES +4
	StrCmp $LANGUAGE ${LANG_FRENCH} 0 +2
		MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Vous semblez ne pas avoir la bibliothèque C LASSO-3 d'installé, êtes-vous sûr de vouloir continuer ?" IDYES +2
        Abort

FunctionEnd

Section Uninstall
  Delete "$INSTDIR\Lib\lasso_uninst.exe"
  Delete "$INSTDIR\DLLs\_lasso_d.dll"
  Delete "$INSTDIR\Lib\lasso.py"
  Delete "$INSTDIR\Lib\lasso.pyc"
  Delete "$INSTDIR\DLLs\_lasso.dll"


  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "SOFTWARE\Python\Lasso\2.4\@VERSION@"
  DeleteRegKey /ifempty HKLM "SOFTWARE\Python\Lasso\2.4"
  DeleteRegKey /ifempty HKLM "SOFTWARE\Python\Lasso"


  SetAutoClose true
SectionEnd
