/*
http://www.srware.net/downloads/srware_iron.exe
http://www.srware.net/downloads/srware_iron64.exe

*/
!define RELEASURL	"http://www.srware.net/downloads"
!define APPSETUP	"srware_iron.exe"
!define APPSETUP64	"srware_iron64.exe"
!define APPSIZE	"148000" # kB
!define INNO ; Delete if setup not Inno
!define DLVER	"Online"
!define APPVER 	"0.0.0.0"
!define APPNAME "SRWare Iron"
!define APP 	"Iron"
!define DLNAME	"Iron"
!define APPLANG	"32-64-bit_Multilingual"
!define FOLDER	"ChromePortable"
!define FINISHRUN
!define OPTIONS ; Delete if no Components
!define SOURCES

SetCompressor /SOLID lzma
SetCompressorDictSize 32

!include "..\_Include\Installer.nsh"
!include "LogicLib.nsh"
!include "x64.nsh"

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Arabic"
!insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "SpanishInternational"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Farsi"
!insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Hebrew"
!insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "Indonesian"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Lithuanian"
!insertmacro MUI_LANGUAGE "Latvian"
!insertmacro MUI_LANGUAGE "Malay"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Slovenian"
!insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Thai"
!insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"

Section "${APPNAME} Portable 32 bit" main
; SectionIn RO
DetailPrint "Installing ${APPNAME} Portable 32 bit"
${If} ${FileExists} "$EXEDIR\${APPSETUP}"
	nsExec::Exec `"$TEMP\${APP}PortableTemp\innounp.exe" -x -d"$TEMP\${APP}PortableTemp\Temp" "$EXEDIR\${APPSETUP}"`
${Else}
Call CheckConnected
	inetc::get "${RELEASURL}/${APPSETUP}" "$TEMP\${APP}PortableTemp\${APPSETUP}" /END
	Pop $0
StrCmp $0 "OK" +3
	MessageBox MB_ICONEXCLAMATION "${APPSETUP} not found in $EXEDIR and download: $0"
	Abort
	nsExec::Exec `"$TEMP\${APP}PortableTemp\innounp.exe" -x -d"$TEMP\${APP}PortableTemp\Temp" "$TEMP\${APP}PortableTemp\${APPSETUP}"`
${EndIf}

DetailPrint "Installing ${APPNAME} Portable 32 bit"

	SetOutPath "$INSTDIR"
		File "..\..\..\${FOLDER}\${APP}Portable.exe"
	SetOutPath "$INSTDIR\App\DefaultData\${APP}\Default"
		File "Default\Preferences"
		File "Default\Bookmarks"

Delete "$TEMP\${APP}PortableTemp\Temp\{app}\DefaultBrowser.exe"
Delete "$TEMP\${APP}PortableTemp\Temp\{app}\iron.exe"
	SetOutPath "$INSTDIR\App\${APP}"
	CopyFiles /SILENT "$TEMP\${APP}PortableTemp\Temp\{app}\*.*" "$INSTDIR\App\${APP}\"

!ifdef DESCRIPTION
Call AppInfo
!endif
!ifdef SOURCES
Call Sources
	SetOutPath "$INSTDIR\Other\_Include\InnoUnp"
	File "..\_Include\InnoUnp\innounp.exe"
	SetOutPath "$INSTDIR\Other\Source\Default"
		File "Default\Preferences"
!endif
!ifdef SOURCES & DESCRIPTION
Call SourceInfo
!endif

	SectionEnd

Function .onGUIEnd
	RMDir "/r" "$TEMP\${APP}PortableTemp"
FunctionEnd

Section /o "${APPNAME} Portable 64 bit" x64
DetailPrint "Installing ${APPNAME} Portable 64 bit"
${If} ${FileExists} "$EXEDIR\${APPSETUP64}"
	nsExec::Exec `"$TEMP\${APP}PortableTemp\innounp.exe" -x -d"$TEMP\${APP}PortableTemp\Temp64" "$EXEDIR\${APPSETUP64}"`
${Else}
Call CheckConnected
	inetc::get "${RELEASURL}/${APPSETUP64}" "$TEMP\${APP}PortableTemp\${APPSETUP64}" /END
	Pop $0
StrCmp $0 "OK" +3
	MessageBox MB_ICONEXCLAMATION "${APPSETUP} not found in $EXEDIR and download: $0"
	Abort
	nsExec::Exec `"$TEMP\${APP}PortableTemp\innounp.exe" -x -d"$TEMP\${APP}PortableTemp\Temp64" "$TEMP\${APP}PortableTemp\${APPSETUP64}"`
${EndIf}

DetailPrint "Installing ${APPNAME} Portable 64 bit"

	SetOutPath "$INSTDIR"
		File "..\..\..\${FOLDER}\${APP}Portable.exe"
	SetOutPath "$INSTDIR\App\DefaultData\${APP}\Default"
		File "Default\Preferences"
		File "Default\Bookmarks"

Delete "$TEMP\${APP}PortableTemp\Temp64\{app}\DefaultBrowser.exe"
Delete "$TEMP\${APP}PortableTemp\Temp64\{app}\iron.exe"
	SetOutPath "$INSTDIR\App\${APP}64"
	CopyFiles /SILENT "$TEMP\${APP}PortableTemp\Temp64\{app}\*.*" "$INSTDIR\App\${APP}64\"

SectionEnd

Function Init
SectionSetSize ${x64} 176000 # kB
${If} ${RunningX64}
SectionSetFlags ${x64} 1
${Else}
${EndIf}
FunctionEnd
