

//---------------------------------------------------------------------------
// The Installed event is sent after the feature Network_Drive
// is installed.
//---------------------------------------------------------------------------
 
export prototype Network_Driver_Installed();
function Network_Driver_Installed()
   STRING InstallName,InstallCommand,Guid,ProductName,ProductVersion,TimeOutSecoundsStrFormat;
   BOOL Install1Succsess;
begin  

WriteToLogFile("****************Network_Driver_Installed********  " ,0,1); 
WriteToLogFile("" ,0,1); 

 if (SYSINFO.bIsWow64)then  
    ProductName = NETWORK_INSTALLER_64 ;
	InstallCommand = NETWORK_INSTALLER_64_FULL_PATH;
 else
	ProductName = NETWORK_INSTALLER_32 ;
	InstallCommand = NETWORK_INSTALLER_32_FULL_PATH;
 endif;
   
    //added StrSub in rev 48858 and removed now again because it sent exec flow to repair mode
	//StrSub ( InstallName, ProductName, 0, StrFind (ProductName, "_") ); 
	   
	WriteToLogFile("InstallCommand="+InstallCommand +"InstallName="+InstallName  ,0,1); 
	if !(IsUpgrade ) then 		
		//if(!IsDriverInstaled(InstallName)) then  	          
			 WriteToLogFile("if !IsDriverInstaled("+InstallName+")then" ,0,1); 
		     Install1Succsess =  LounchNestedInstallationMSI(InstallCommand + " Tcp1323Opts=1 "); 
			 WriteToLogFile("LounchNestedInstallationMSI("+InstallCommand+")" ,0,1); 
		//else
		//	 WriteToLogFile("if IsDriverInstaled("+InstallName+")then" ,0,1); 
		//     Install1Succsess =  LounchNestedRepairMSI(InstallCommand); 
		//	 WriteToLogFile("LounchNestedInstallationMSI("+InstallCommand+")" ,0,1); 
		//endif;	 	
		          
		if(!Install1Succsess) then 			         
		
		   	 SetInstallKey(ProductName,FALSE,FALSE); 
		    // MessageBox("Failure Install",1);
		else
			//if (gOldVerNetworkIsInstalled)then 
			 	//RemoveFromAddRemoveMSI("pvDrvSetup");
			//endif; 
		endif;  
	else 	
	 
		//if(!IsDriverInstaled(InstallName)) then  	          
			Install1Succsess =  LounchNestedInstallationMSI(InstallCommand);
			WriteToLogFile("if !IsDriverInstaled("+InstallName+")then" ,0,1);  
		//else
		//    Install1Succsess =  LounchNestedRepairMSI(InstallCommand); 
		//    WriteToLogFile("if IsDriverInstaled("+InstallName+")then" ,0,1); 
		//endif; 
endif;	
		if (IsSilentMode) then 
			WriteToLogFile("IsSilentMode = TRUE" ,0,1); 
		endif;
			      
	if (Install1Succsess) then
	     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Network ...............OK\n";
	else
	     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Network ...............ERROR\n"    ; 
	endif;		         
			
end; 
//---------------------------------------------------------------------------
// The Installed event is sent after the feature Agent_Driver
// is installed.
//---------------------------------------------------------------------------
 
export prototype Agent_Driver_Installed();
function Agent_Driver_Installed()
 STRING InstallName,InstallCommand,Guid,ProductName,ProductVersion,TimeOutSecoundsStrFormat;
   BOOL Install1Succsess;
begin 
    
	 WriteToLogFile("****************Agent_Driver_Installed******** " ,0,2); 
	 WriteToLogFile("",0,2); 
	 if (SYSINFO.bIsWow64)then  
        ProductName = AGENT_INSTALLER_64 ;
	    InstallCommand = AGENT_INSTALLER_64_FULL_PATH;
     else
	    ProductName = AGENT_INSTALLER_32 ;
	    InstallCommand = AGENT_INSTALLER_32_FULL_PATH;
     endif;	   
	 //ProductName = AGENT_INSTALLER_32 ;
	 //InstallCommand = AGENT_INSTALLER_32_FULL_PATH;
	 WriteToLogFile("InstallCommand="+InstallCommand +"InstallName="+InstallName  ,0,1); 
	 
	 
	 Install1Succsess =  LounchNestedInstallationMSI(InstallCommand); 
	 WriteToLogFile("LounchNestedInstallationMSI("+InstallCommand+")" ,0,1); 
	 IsForceReboot = TRUE;   
	 if (Install1Succsess) then
	     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Agent ...................OK\n"  ;
	 else
	     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Agent ...................ERROR\n"  ;
	 endif;	
end;       
//---------------------------------------------------------------------------
// The Installed event is sent after the feature Spice_Driver
// is installed.
//---------------------------------------------------------------------------
 
export prototype Spice_Driver_Installed();
function Spice_Driver_Installed()
   STRING InstallName,InstallCommand,Guid,ProductName,ProductVersion,TimeOutSecoundsStrFormat;
   BOOL Install1Succsess;
 
begin

 WriteToLogFile("****************Spice_Driver_Installed********  " ,0,2); 
 WriteToLogFile("" ,0,2);
 
 if (SYSINFO.bIsWow64)then  
        ProductName = SPICE_INSTALLER_64 ;
	    InstallCommand = SPICE_INSTALLER_64_FULL_PATH;
 else
	    ProductName = SPICE_INSTALLER_32 ;
	    InstallCommand = SPICE_INSTALLER_32_FULL_PATH;
 endif;	 
  		
 WriteToLogFile("InstallCommand= "+ InstallCommand +"InstallName= "+ProductName ,0,1); 
 Install1Succsess =  LounchNestedInstallationMSI(InstallCommand); 
 WriteToLogFile("LounchNestedInstallationMSI("+InstallCommand+")" ,0,1); 
 if (IsUpgrade ) then
 	RemoveUnWantedEntriesFromPendingFileRenameOperations();
 endif; 
 if (Install1Succsess) then
	     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Spice ...................OK\n"  ;
 else
	     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Spice ...................ERROR\n"      ;
 endif;	
end; 

//---------------------------------------------------------------------------
// The Installed event is sent after the feature Spice_Agent
// is installed.
//---------------------------------------------------------------------------
 
export prototype Spice_Agent_Installed();
function Spice_Agent_Installed()
   STRING InstallName,InstallCommand,Guid,ProductName,ProductVersion,TimeOutSecoundsStrFormat;
   BOOL Install1Succsess;
begin
	WriteToLogFile("****************Spice_Agent_Installed********  " ,0,2); 
 	WriteToLogFile("" ,0,2);
 
 	if (SYSINFO.bIsWow64)then  
        ProductName = SPICE_AGENT_INSTALLER_64 ;
	    InstallCommand = SPICE_AGENT_INSTALLER_64_FULL_PATH;
 	else
	    ProductName = SPICE_AGENT_INSTALLER_32 ;
	    InstallCommand = SPICE_AGENT_INSTALLER_32_FULL_PATH;
 	endif;	 
  		
 	WriteToLogFile("InstallCommand= "+ InstallCommand +"InstallName= "+ProductName ,0,1); 
 	Install1Succsess =  LounchNestedInstallationMSI(InstallCommand); 
 	WriteToLogFile("LounchNestedInstallationMSI("+InstallCommand+")" ,0,1); 
 	if (IsUpgrade ) then
 		RemoveUnWantedEntriesFromPendingFileRenameOperations();
 	endif; 
 	if (Install1Succsess) then
	     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Spice-Agent .........OK\n"  ;
 	else
	     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Spice-Agent .........ERROR\n"      ;
 	endif;	
end;

//---------------------------------------------------------------------------
// The Installed event is sent after the feature USB_Driver
// is installed.
//---------------------------------------------------------------------------
 
export prototype USB_Driver_Installed();
function USB_Driver_Installed()
	STRING InstallName,InstallCommand,Guid,ProductName,ProductVersion,TimeOutSecoundsStrFormat;
	BOOL Install1Succsess;
begin

	WriteToLogFile("****************USB_Driver_Installed********  " ,0,2); 
	WriteToLogFile("" ,0,2);
	
	ProductName = USB_INSTALLER_32 ;
	InstallCommand = USB_INSTALLER_32_FULL_PATH;   
	WriteToLogFile("InstallCommand="+InstallCommand +"InstallName="+ProductName  ,0,1); 
	Install1Succsess =  LounchNestedInstallationMSI(InstallCommand); 
	if (Install1Succsess) then
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-USB .....................OK\n"      ;
	else
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-USB .....................ERROR\n"        ;
	endif;	
end;
//---------------------------------------------------------------------------
// The Installed event is sent after the feature SSO_Driver
// is installed.
//---------------------------------------------------------------------------
 
export prototype SSO_Driver_Installed();
function SSO_Driver_Installed()
STRING msglog,OrigGina,svValue,RedHatKey,MicrosoftKey,InstallName,InstallCommand,Guid,ProductName,ProductVersion,TimeOutSecoundsStrFormat;
BOOL Install1Succsess;
number ret,nvType,nvSize;
begin
WriteToLogFile("****************SSO_Driver_Installed********  " ,0,1); 
WriteToLogFile("" ,0,1); 

if (SYSINFO.bIsWow64)then  
        ProductName = SSO_INSTALLER_64 ;
		InstallCommand = SSO_INSTALLER_64_FULL_PATH;  
else
	    ProductName = SSO_INSTALLER_32 ;
		InstallCommand = SSO_INSTALLER_32_FULL_PATH;  
endif;

WriteToLogFile("InstallCommand="+InstallCommand +"InstallName="+ProductName  ,0,1); 
Install1Succsess =  LounchNestedInstallationMSI(InstallCommand); 
Sprintf(msglog,"%d =  LounchNestedInstallationMSI(%s);",Install1Succsess,InstallCommand);
//MessageBox( msglog,1);
if (Install1Succsess) then
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-SSO .....................OK\n"      ;
else
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-SSO .....................ERROR\n"       ;
endif;	

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      ----------------------------------------------
//      This section should be removed from Post GA
//      ----------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if !(SYSINFO.bIsWow64)then 
	if (Is ( FILE_EXISTS, WINSYSDIR ^"GinaSSO.dll" ) = 1) then
	   MicrosoftKey = "SOFTWARE\\MICROSOFT\\Windows NT\\CurrentVersion\\Winlogon";
	   RedHatKey = "SOFTWARE\\RedHat\\SSO";  
	   ret = RegDBGetKeyValueEx ( MicrosoftKey, "GinaDLL", nvType, svValue, nvSize ); 
	   if (ret = 0 ) then
	            if (svValue = "GinaSSO.dll") then 
	               
	            else 
	               OrigGina = svValue;
	               ret = RegDBSetKeyValueEx(RedHatKey, "OriginalCustomGina",REGDB_STRING , OrigGina, -1 ); 
	            endif;   
	   endif;     
	   ret = RegDBSetKeyValueEx(MicrosoftKey, "GinaDLL",REGDB_STRING , "GinaSSO.dll", -1 ); 
   endif;
endif;
end ;

//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// SSO_Driver is uninstalled.
//---------------------------------------------------------------------------
 
export prototype SSO_Driver_UnInstalling();
function SSO_Driver_UnInstalling()
    STRING InstallName,InstallCommand,ProductName,ProductVersion;
    BOOL Install1Succsess;
    STRING svSubStr,Guid;  
	number nLocation;
begin

      ProductName = SSO_INSTALLER_32 ;
      nLocation = StrFind (ProductName, "_"); 
	  StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(svSubStr); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// Network_Driver is uninstalled.
//---------------------------------------------------------------------------
 
export prototype Network_Driver_UnInstalling();
function Network_Driver_UnInstalling()
    STRING InstallName,InstallCommand,ProductName,ProductVersion;
	BOOL Install1Succsess;
	STRING svSubStr,Guid;  
	number nLocation;
begin   
      if (SYSINFO.bIsWow64)then  
         ProductName = NETWORK_INSTALLER_64 ;
      else
      	ProductName = NETWORK_INSTALLER_32 ; 
      endif; 
      nLocation = StrFind (ProductName, "_"); 
	  StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(svSubStr); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// Agent_Driver is uninstalled.
//---------------------------------------------------------------------------
 
export prototype Agent_Driver_UnInstalling();
function Agent_Driver_UnInstalling()
    STRING InstallName,InstallCommand,ProductName,ProductVersion;
	BOOL Install1Succsess;
	STRING svSubStr,Guid;  
	number nLocation;
begin
  
      ProductName = AGENT_INSTALLER_32 ;
      nLocation = StrFind (ProductName, "_"); 
	  StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(svSubStr); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// Balloon_Driver is uninstalled.
//---------------------------------------------------------------------------
 
export prototype Balloon_Driver_UnInstalling();
function Balloon_Driver_UnInstalling()
begin 

  
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// USB_Driver is uninstalled.
//---------------------------------------------------------------------------
 
export prototype USB_Driver_UnInstalling();
function USB_Driver_UnInstalling()
STRING InstallName,InstallCommand,ProductName,ProductVersion;
	BOOL Install1Succsess;
	STRING svSubStr,Guid;  
	number nLocation;
begin
      ProductName = USB_INSTALLER_32 ;
      nLocation = StrFind (ProductName, "_"); 
	  StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(svSubStr); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;	
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// Spice_Driver is uninstalled.
//---------------------------------------------------------------------------
 
export prototype Spice_Driver_UnInstalling();
function Spice_Driver_UnInstalling()
	 
	    STRING InstallName,InstallCommand,ProductName,ProductVersion;
		BOOL Install1Succsess;
		STRING svSubStr,Guid;  
		number nLocation;
begin	
	  if (SYSINFO.bIsWow64)then
	     
        ProductName = SPICE_INSTALLER_64 ;
	    
 	   else
	    ProductName = SPICE_INSTALLER_32 ;
	    
      endif;	
	  nLocation = StrFind (ProductName, "_"); 
	 // StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(ProductName); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;	

end; 

//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// Spice_Agent is uninstalled.
//---------------------------------------------------------------------------
 
export prototype Spice_Agent_UnInstalling();
function Spice_Agent_UnInstalling()	 
	    STRING InstallName,InstallCommand,ProductName,ProductVersion;
		BOOL Install1Succsess;
		STRING svSubStr,Guid;  
		number nLocation;
begin	
	  ProductName = SPICE_AGENT_INSTALLER_32 ; 
	  
	  nLocation = StrFind (ProductName, "_"); 
	  StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(svSubStr); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;	

end;

//---------------------------------------------------------------------------
// The Installed event is sent after the feature Viostor
// is installed.
//---------------------------------------------------------------------------
 
export prototype Viostor_Installed();
function Viostor_Installed()
 STRING InstallName,InstallCommand,Guid,ProductName,ProductVersion,TimeOutSecoundsStrFormat;
   BOOL Install1Succsess;
begin 
    
	 WriteToLogFile("****************Viostor_Installed******** " ,0,2); 
	 WriteToLogFile("",0,2); 
	 if (SYSINFO.bIsWow64)then  
        ProductName = VIOSTOR_INSTALLER_64 ;
	    InstallCommand = VIOSTOR_INSTALLER_64_FULL_PATH;
     else
	    ProductName = VIOSTOR_INSTALLER_32 ;
	    InstallCommand = VIOSTOR_INSTALLER_32_FULL_PATH;
     endif;	   
	 //ProductName = AGENT_INSTALLER_32 ;
	 //InstallCommand = AGENT_INSTALLER_32_FULL_PATH;
	 WriteToLogFile("InstallCommand="+InstallCommand +"InstallName="+InstallName  ,0,1); 
	 
	 Install1Succsess =  LounchNestedInstallationMSI(InstallCommand); 
	 WriteToLogFile("LounchNestedInstallationMSI("+InstallCommand+")" ,0,1); 
	 IsForceReboot = TRUE;  
	 if (Install1Succsess) then
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Block ...................OK\n"      ;
	 else
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV-Block ...................ERROR\n"        ;
	 endif;	

end;       
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// Viostor is uninstalled.
//---------------------------------------------------------------------------
 
export prototype Viostor_UnInstalling();
function Viostor_UnInstalling() 
        STRING InstallName,InstallCommand,ProductName,ProductVersion;
		BOOL Install1Succsess;
		STRING svSubStr,Guid;  
		number nLocation;
begin           
    //we will not remove driver for VIStore never
	/*  ProductName = VIOSTOR_INSTALLER_32 ;
	  nLocation = StrFind (ProductName, "_"); 
	  StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(svSubStr); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;	
      */
end;
//---------------------------------------------------------------------------
// The Installed event is sent after the feature Vioseral
// is installed.
//---------------------------------------------------------------------------
 
export prototype Vioseral_Installed();
function Vioseral_Installed()
 STRING InstallName,InstallCommand,Guid,ProductName,ProductVersion,TimeOutSecoundsStrFormat;
   BOOL Install1Succsess;
begin 
	 WriteToLogFile("****************Vioserial_Installed******** " ,0,2); 
	 WriteToLogFile("",0,2); 
	 if (SYSINFO.bIsWow64)then  
        ProductName = VIOSERIAL_INSTALLER_64 ;
	    InstallCommand = VIOSERIAL_INSTALLER_64_FULL_PATH;
     else
	    ProductName = VIOSERIAL_INSTALLER_32 ;
	    InstallCommand = VIOSERIAL_INSTALLER_32_FULL_PATH;
     endif;	   
	 WriteToLogFile("InstallCommand="+InstallCommand +"InstallName="+InstallName  ,0,1); 
	 
	 Install1Succsess =  LounchNestedInstallationMSI(InstallCommand); 
	 WriteToLogFile("LounchNestedInstallationMSI("+InstallCommand+")" ,0,1); 
	 IsForceReboot = TRUE;  
	 if (Install1Succsess) then
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV VirtIO-Serial ..........OK\n"      ;
	 else
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV VirtIO-Serial ..........ERROR\n"        ;
	 endif;	
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// Vioseral is uninstalled.
//---------------------------------------------------------------------------
 
export prototype Vioseral_UnInstalling();
function Vioseral_UnInstalling()
        STRING InstallName,InstallCommand,ProductName,ProductVersion;
		BOOL Install1Succsess;
		STRING svSubStr,Guid;  
		number nLocation;
begin           
	  ProductName = VIOSERIAL_INSTALLER_32 ;
	  nLocation = StrFind (ProductName, "_"); 
	  StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(svSubStr); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;	
end;
//---------------------------------------------------------------------------
// The Installed event is sent after the feature Balloon
// is installed.
//---------------------------------------------------------------------------
 
export prototype Balloon_Installed();
function Balloon_Installed()
string ProductName,InstallCommand;   
BOOL Install1Succsess;
begin  
     WriteToLogFile("****************Balloon_Installed******** " ,0,2); 
	 WriteToLogFile("",0,2); 
	 if (SYSINFO.bIsWow64)then  
        ProductName = BALLOON_INSTALLER_64 ;
	    InstallCommand = BALLOON_INSTALLER_64_FULL_PATH;
     else
	    ProductName = BALLOON_INSTALLER_32 ;
	    InstallCommand = BALLOON_INSTALLER_32_FULL_PATH;
     endif;	   
	 WriteToLogFile("InstallCommand="+InstallCommand ,0,1); 
	 
	 Install1Succsess =  LounchNestedInstallationMSI(InstallCommand); 
	 WriteToLogFile("LounchNestedInstallationMSI("+InstallCommand+")" ,0,1); 
	 IsForceReboot = TRUE;  
    if (Install1Succsess) then
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV Balloon .....................OK\n"      ;
	 else
		     gListOfSucssesInstalls = gListOfSucssesInstalls + "RHEV Balloon......... ..........ERROR\n"        ;
	 endif;	
end;
//---------------------------------------------------------------------------
// The UnInstalling event is sent just before the feature 
// Balloon is uninstalled.
//---------------------------------------------------------------------------
 
export prototype Balloon_UnInstalling();
function Balloon_UnInstalling()
   STRING InstallName,InstallCommand,ProductName,ProductVersion;
		BOOL Install1Succsess;
		STRING svSubStr,Guid;  
		number nLocation;
begin           
	  ProductName = BALLOON_INSTALLER_32 ;
	  nLocation = StrFind (ProductName, "_"); 
	  StrSub ( svSubStr, ProductName, 0, nLocation ); 
	
	  Guid =  WM_GetGuidForMsi(svSubStr); 
	  if  !(Guid = "") then 
      	Install1Succsess = LounchNestedUninstaledMSI(Guid);
      endif;
end;



 
