//===========================================================================
//
//  File Name:    Setup.rul
//
//  Description:  Blank setup main script file
//
//  Comments:     Blank setup is an empty setup project. If you want to
//				  create a new project via. step-by step instructions use the
//				  Project Assistant.
//
//===========================================================================

// Included header files ----------------------------------------------------
#include "ifx.h"

// Note: In order to have your InstallScript function executed as a custom
// action by the Windows Installer, it must be prototyped as an 
// entry-point function.

// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
    
/* export prototype MyFunction(HWND); */
//export prototype SetUILevel(HWND);

/*
function OnBegin()
begin
	if (MODE = SILENTMODE) then
		//MessageBox("SetUILevel - SILENTMODE", INFORMATION);
		SilentWriteData("INIT", "TEST", DATA_STRING, "aho", 0);
	else  
		MessageBox("SetUILevel - NORMALMODE", INFORMATION);
	endif;
end;
*/

/*                   
function SetUILevel(hInstance)
begin
	if (MODE = SILENTMODE ) then
		MsiSetProperty(hInstance, "UILevel", "2");
	else
		MsiSetProperty(hInstance, "UILevel", "5");
	endif;
end;
*/	
                      
function OnFirstUIBefore() 
	number nResult, nSetupType, nvSize;
begin                               

	nSetupType = COMPLETE;

Dlg_Start:     
	// Beginning of dialogs label
	  
Dlg_SdWelcome:
	nResult = SdWelcome("", "");
	if (nResult = BACK) goto Dlg_Start;

Dlg_SdLicense:
	nResult = SdLicense2Rtf("", "", "", "License.rtf", FALSE);
	if (nResult = BACK) goto Dlg_SdWelcome;

/*
if ( MODE = NORMALMODE ) then                           
Dlg_SdAskDestPath:
	nResult = SdAskDestPath("", "", INSTALLDIR, 0);
	if (nResult = BACK) goto Dlg_SdLicense;
endif;
*/

/*
Dlg_SetupType:    
    nResult = SetupType2("", "", "", nSetupType, 0);
    if (nResult = BACK) goto Dlg_SdAskDestPath;
    nSetupType = nResult;

Dlg_SdFeatureTree: 
	if (nSetupType = CUSTOM) then
		nResult = SdFeatureTree("", "", INSTALLDIR, "", 2);
		if (nResult = BACK) goto Dlg_SetupType;
	endif;
*/

Dlbg_SdStartCopy2:
	nResult = SdStartCopy2("", "");  
	
	if (nResult = BACK) goto Dlg_SdLicense;
    // Added in IS 2009 - Set appropriate StatusEx static text.
    SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
    if ( SELECTED_LANGUAGE = 0x0C04 ) then
         SetStatusExStaticText( @ID_STRING7 );
    endif;

    // setup default status
    Enable(STATUSEX);
 
end;

function OnMaintUIBefore()
    NUMBER nResult, nType;  
    
begin
	if (MODE = SILENTMODE) then   
		nType = REPAIR;
	else 
		if (ADDREMOVE) then
			if (REMOVEONLY) then
				nType = REMOVEALL;
			else
				nType = REPAIR;
			endif;
/*		else
			Disable(BACKBUTTON);
	  		nType = SdWelcomeMaint("", "", REMOVEALL);
 	 		Enable(BACKBUTTON);  
*/
 	 	endif;
	endif;
	
	if (nType = REMOVEALL) then 
		FeatureRemoveAll();
	else
		FeatureReinstall();
	endif;
	
// Added in IS 2009 - Set appropriate StatusEx static text.
    SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REPAIR ) );
	if ( SELECTED_LANGUAGE = 0x0C04 ) then
         SetStatusExStaticText( @ID_STRING7 );
    endif;	    
    Enable(STATUSEX);
          
end; 
                         
                                             
//---------------------------------------------------------------------------
// OnCanceling
//
// The OnCanceling event is sent when the installation is cancelled, 
// usually as result of end user clicking Cancel button of a dialog or
// pressing Esc key. Calling Do(EXIT) will also trigger this event.
//---------------------------------------------------------------------------
function OnCanceling()

STRING svCANCEL_MSG;
STRING svCANCEL_TITLE;

begin  
 if ( SELECTED_LANGUAGE = 0x0C04 ) then  
         svCANCEL_MSG = @ID_STRING8;
         svCANCEL_TITLE = @ID_STRING9;
  else
  		 svCANCEL_MSG = SdLoadString(SD_STR_ONCANCELING_MSG);
  		 svCANCEL_TITLE = SdLoadString(SD_STR_ONCANCELING_MSG);
  endif;
 if (IDYES = SprintfBox(MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON2, 
//                           SdLoadString(SD_STR_ONCANCELING_TITLE), 
//                           SdLoadString(SD_STR_ONCANCELING_MSG))) then
                           svCANCEL_TITLE, 
                           svCANCEL_MSG )) then 
		EndCurrentDialog();
		Enable(USE_LOADED_SKIN);
		abort;
	endif;
end;              

//---------------------------------------------------------------------------
// OnMaintUIAfter
//
// The OnMaintUIAfter event called by the framework after the file transfer
// of the setup when the setup is running in maintenance mode. By default
// this event displays UI that informs the end user that the maintenance setup
// has been completed successfully.
//---------------------------------------------------------------------------
function OnMaintUIAfter()
    STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
    NUMBER bOpt1, bOpt2;
begin
	Disable(STATUSEX);
    
    if( REMOVEALLMODE ) then
        szTitle = SdLoadString(IFX_SDFINISH_REMOVE_TITLE);
        szMsg1 = SdLoadString(IFX_SDFINISH_REMOVE_MSG1);
        if ( SELECTED_LANGUAGE = 0x0C04 ) then  
            szTitle = @ID_STRING10;
            szMsg1 =  @ID_STRING11;
        endif;
        
    else
        szTitle = SdLoadString(IFX_SDFINISH_MAINT_TITLE);    
        szMsg1  = SdLoadString(IFX_SDFINISH_MAINT_MSG1);
        if ( SELECTED_LANGUAGE = 0x0C04 ) then  
            szTitle = @ID_STRING12;
            szMsg1 =  @ID_STRING13;
        endif;    
    endif;

	bOpt1   = FALSE;
    bOpt2   = FALSE;    

    if ( BATCH_INSTALL ) then
    	SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
    else    
       	SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bOpt1 , bOpt2 );
    endif;
end;
//---------------------------------------------------------------------------
// OnResumeUIAfter
//
// The OnResumeUIBefore event is called when end user runs installation that is
// performing a resumed install. Usually this happens by specifying a property
// like REINSTALL or ADDLOCAL at the command line when the  product is already
// installed. In the handler, installation usually displays UI that will
// inform end user that Reinstallation has been completed successfully.
//---------------------------------------------------------------------------
function OnResumeUIAfter()
    STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
    NUMBER bOpt1, bOpt2;
begin
	Disable(STATUSEX);

	szTitle = SdLoadString(IDS_IFX_SDFINISH_UPDATE_TITLE);    
    szMsg1  = SdLoadString(IDS_IFX_SDFINISH_UPDATE_MSG1); 
    if ( SELECTED_LANGUAGE = 0x0C04 ) then  
            szTitle = @ID_STRING14;
            szMsg1 =  @ID_STRING15;
    endif;
	bOpt1   = FALSE;
    bOpt2   = FALSE;

    if ( BATCH_INSTALL ) then
    	SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
    else    
       	SdFinish ( szTitle , szMsg1 , szMsg2 , szOption1 , szOption2 , bOpt1 , bOpt2 );
    endif;
end;


                                             