/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Test.nsi

	This file is in Windows Latin 1, DOS linefeeds format so that non-ASCII
	characters will be encoded properly.

	Version History

		$Id$
		15 Jan 2007	mtc		Original version.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

!verbose 2

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Includes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
!include "LogicLib.nsh"			;// Simplified logical control structures.
!include "Sections.nsh"			;// Section management.
!include "WinMessages.nsh"		;// Windows messages.

/*$$$
!include "CMSLIb.nsh"			; CrystalMaker functions.
	!insertmacro GetContextDocsFolder
$$$*/
	
/*
Files which should be inserted before other files in the data block. Keep
these lines before any File command. Only for solid compression (by default,
solid compression is enabled for BZIP2 and LZMA).
*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Macros
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Constants & Globals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Pages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
Page instfiles

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Language Macros
	
	These must be defined *after* the MUI pages have been defined.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Japanese.nlf"

LangString ^ComponentsText ${LANG_ENGLISH} "English component page"
LangString ^ComponentsText ${LANG_JAPANESE} "Japanese component page"

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	String Table

	This must be defined *after* the initial MUI macro declarations.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Global settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
Name "Test"
OutFile "Test.exe"
ShowInstDetails show
XPStyle on

/*
Starting with Windows Vista, all executables should be marked with the
required execution level. Since we do not require system-level access, we set
ourselves to user level.
*/
RequestExecutionLevel highest

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Installer Sections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
Section -Pre
	/*
	Does nothing for now.
	*/
SectionEnd	;// Pre

Section "-Run Test" TEST
	/*
	We use the $0 and $1 registers for temporary results.
	*/
	Push $0
	Push $1

	ClearErrors
	BringToFront

	/*
	For now, we always install for the current user.
	*/
	SetShellVarContext current
	
	/*
	Generate the standard paths for various folders.
	*/
	SetShellVarContext current
	ExpandEnvStrings $0 "%USERNAME%"
	DetailPrint "user name = $0"
	DetailPrint "current AppData = $APPDATA"
	DetailPrint "current Documents = $DOCUMENTS"
	DetailPrint "current SMPrograms = $SMPROGRAMS"
	DetailPrint "current Desktop = $DESKTOP"
	DetailPrint "current StartMenu = $STARTMENU"
	DetailPrint "current InstDir = $PROGRAMFILES"
	DetailPrint "current CommonFiles = $COMMONFILES"
	DetailPrint "current SMStartUp = $SMSTARTUP"
	DetailPrint "current LocalAppData = $LOCALAPPDATA"
	DetailPrint "current Profile = $PROFILE"
	
	/*$$$
	Push 0
	Call GetContextDocsFolder
	Pop $0
	DetailPrint "user's Documents = $0"
	$$$*/
	
	UserInfo::GetName
	${Unless} ${Errors}
		Pop $0
		
		DetailPrint "GetName() returned $0"
	
		UserInfo::GetAccountType
		Pop $0
	
		DetailPrint "GetAccountType() returned $0"

	${EndUnless}
	
	DetailPrint "====="
	
	SetShellVarContext all
	ExpandEnvStrings $0 "%USERNAME%"
	DetailPrint "user name = $0"
	DetailPrint "allusers AppData = $APPDATA"
	DetailPrint "allusers Documents = $DOCUMENTS"
	DetailPrint "allusers SMPrograms = $SMPROGRAMS"
	DetailPrint "allusers Desktop = $DESKTOP"
	DetailPrint "allusers StartMenu = $STARTMENU"
	DetailPrint "allusers InstDir = $PROGRAMFILES"
	DetailPrint "allusers CommonFiles = $COMMONFILES"
	DetailPrint "allusers SMStartUp = $SMSTARTUP"
	DetailPrint "allusers LocalAppData = $LOCALAPPDATA"
	DetailPrint "allusers Profile = $PROFILE"
	
	/*$$$
	Push 1
	Call GetContextDocsFolder
	Pop $0
	DetailPrint "allusers (Common) Documents = $0"
	$$$*/

	UserInfo::GetName
	${Unless} ${Errors}
		Pop $0
		
		DetailPrint "GetName() returned $0"
	
		UserInfo::GetAccountType
		Pop $0
	
		DetailPrint "GetAccountType() returned $0"

	${EndUnless}
	
	SetShellVarContext current

	Pop $0
	Pop $1
SectionEnd


Section -Post
	BringToFront
SectionEnd	;// Post

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

Function .onInit
MessageBox MB_OK "HI there!"

	;Language selection
	
	;Languages
	Push ""
	Push ${LANG_ENGLISH}
	Push "English"
	Push ${LANG_JAPANESE}
	Push "Japanese"
	
	Push A
	
	LangDLL::LangDialog "Installer Language" "Please select a Language"
	
	Pop $LANGUAGE
	StrCmp $LANGUAGE "cancel" 0 +2
	Abort
	
FunctionEnd

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
;// End of CMSUmbrella.nsi