/*
http://get.geo.opera.com/pub/opera/desktop/27.0.1689.66/win/Opera_27.0.1689.66_Setup.exe
http://blogs.opera.com/desktop/
*/
!define RELEASURL	"http://get.geo.opera.com/pub/opera/desktop"
!define APPSIZE	"95000" # kB
!define DLVER 	"MultiVersion"
!define APPVER 	"0.0.0.0"
!define APPNAME "Opera Chrome"
!define APP 	"OperaChrome"
!define DLNAME	"Opera"
!define APPLANG	"Multilingual_Online"
!define FOLDER	"OperaPortable"
!define FINISHRUN ; Delete if not Finish pages
!define INPUTBOX ; Delete if no InputBox
!define SOURCES ; Delete if no Sources

SetCompressor /SOLID lzma
SetCompressorDictSize 32

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

!insertmacro MUI_LANGUAGE "Belarusian"
!insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Lithuanian"
!insertmacro MUI_LANGUAGE "Macedonian"
!insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "NorwegianNynorsk"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"

Var InputVer
Var VER
Function nsDialogsPage
	nsDialogs::Create 1018
	Pop $0
	${NSD_CreateLabel} 0 0 100% 12u "Enter Version Number:"
	Pop $0
	${NSD_CreateText} 0 13u 100% 12u ""
	Pop $InputVer
	nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
	${NSD_GetText} $InputVer $R0
StrCmp $R0 "" 0 +3
	MessageBox MB_ICONEXCLAMATION `You must enter a version number!`
Abort
	StrCpy $VER "$R0"
FunctionEnd

Section "${APPNAME} Portable" main
SectionIn RO

	RMDir "/r" "$TEMP\${APP}PortableTemp"
	CreateDirectory "$TEMP\${APP}PortableTemp"
	Dialer::GetConnectedState
	Pop $0
StrCmp $0 "online" +3
	MessageBox MB_USERICON "You are $0: you can't download Setup to extract files!"
	Abort
	inetc::get "${RELEASURL}/$VER/win/Opera_$VER_Setup.exe" "$TEMP\${APP}PortableTemp\${APP}Setup.exe" /END
	Pop $0
StrCmp $0 "OK" +3
	MessageBox MB_USERICON "Download of ${APP}Setup.exe: $0"
	Abort
	SetOutPath "$INSTDIR"
	File "..\..\..\${FOLDER}\${APP}Portable.exe"
	SetOutPath "$INSTDIR\App\DefaultData\${APP}"
	File "Preferences"
	File "Bookmarks"

	File "/oname=$TEMP\${APP}PortableTemp\7za.exe" "..\_Include\7-Zip\7za.exe"
DetailPrint "Installing ${APPNAME} Portable"
	nsExec::Exec `"$TEMP\${APP}PortableTemp\7za.exe" x "$TEMP\${APP}PortableTemp\${APP}Setup.exe" -aoa -o"$INSTDIR\App\${APP}"`
	Delete "$INSTDIR\App\${APP}\launcher.exe"
	SetOutPath "$INSTDIR\App\${APP}"
	File "installer_prefs.json"
	File "Preferences"

!ifdef DESCRIPTION
Call AppInfo
!endif
!ifdef SOURCES
Call Sources
	SetOutPath "$INSTDIR\Other\_Include\7-Zip"
	File "..\_Include\7-Zip\7za.exe"
	SetOutPath "$INSTDIR\Other\Source"
	File "Preferences"
	File "installer_prefs.json"
!endif
!ifdef SOURCES & DESCRIPTION
Call SourceInfo
!endif

SectionEnd

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

