secureswitools/swisistools/source/interpretsislib/installer.cpp
changeset 42 d17dc5398051
parent 33 8110bf1194d1
child 50 c6e8afe0ba85
equal deleted inserted replaced
37:6e7b00453237 42:d17dc5398051
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   253 	throw InterpretSisError(L"Generating stub SIS file for " + shortName +
   253 	throw InterpretSisError(L"Generating stub SIS file for " + shortName +
   254 				L" (PU type) is not supported", SIS_NOT_SUPPORTED);
   254 				L" (PU type) is not supported", SIS_NOT_SUPPORTED);
   255 	}
   255 	}
   256 }
   256 }
   257 
   257 
       
   258 void Installer::ProcessConditionalBlockWarnings(const CSISInstallBlock& aInstallBlock, 
       
   259 											  ExpressionEvaluator& aEvaluator,
       
   260 											  const SisFile& aFile
       
   261 											  ) 
       
   262 	{
       
   263 	const CSISArray<CSISIf, CSISFieldRoot::ESISIf>& ifs = aInstallBlock.Ifs();
       
   264 	for (int i = 0; i < ifs.size(); ++i)
       
   265 		{
       
   266 		const CSISIf& ifBlock = ifs[i];
       
   267 
       
   268 		if (ifBlock.WasteOfSpace())
       
   269 			{
       
   270 			return;
       
   271 			}
       
   272 
       
   273 		// Main expression
       
   274 		if ( aEvaluator.Evaluate(ifBlock.Expression(),false).BoolValue() )
       
   275 			{
       
   276 			ProcessInstallBlockWarnings(ifBlock.InstallBlock(), aFile);
       
   277 			ProcessConditionalBlockWarnings(ifBlock.InstallBlock(), aEvaluator, aFile);
       
   278 			continue;
       
   279 			}
       
   280 		
       
   281 		int elseCount = ifBlock.ElseIfCount();
       
   282 		for (int i = 0; i < elseCount; ++i)
       
   283 			{
       
   284 			const CSISElseIf& elseIfBlock = ifBlock.ElseIf(i) ;
       
   285 			if ( aEvaluator.Evaluate(elseIfBlock.Expression(),false).BoolValue())
       
   286 				{
       
   287 				ProcessInstallBlockWarnings(elseIfBlock.InstallBlock(), aFile);
       
   288 				ProcessConditionalBlockWarnings(elseIfBlock.InstallBlock(), aEvaluator, aFile);
       
   289 				break;	// Stop processing else if blocks
       
   290 				}
       
   291 			}
       
   292 		} 
       
   293 	}
       
   294 
       
   295 void Installer::ProcessInstallBlockWarnings(const CSISInstallBlock& aInstallBlock, const SisFile& aFile)
       
   296 	{
       
   297 	aFile.ProcessEmbeddedFileWarning(aInstallBlock);
       
   298 	
       
   299 	std::string error;
       
   300 	bool result = aFile.ProcessInstallOptionsWarning(aInstallBlock,error);	
       
   301 	if(result == false)
       
   302 		{
       
   303 		std::string x;
       
   304 		throw InvalidSis(Ucs2ToUtf8(aFile.GetPackageName(),x),
       
   305 			error, SIS_NOT_SUPPORTED);
       
   306 		}
       
   307 	}
   258 
   308 
   259 TInt Installer::Install(const InstallSISFile& aInstallSISFile)
   309 TInt Installer::Install(const InstallSISFile& aInstallSISFile)
   260 {
   310 {
   261 	SisFile file(aInstallSISFile.iFileName);
   311 	SisFile file(aInstallSISFile.iFileName);
   262 
   312 
   271 		}
   321 		}
   272 
   322 
   273 	// check file is acceptable
   323 	// check file is acceptable
   274 	file.CheckValid();
   324 	file.CheckValid();
   275 
   325 
       
   326 	const CSISController& ctrl = file.GetController();	
       
   327 	ProcessConditionalBlockWarnings(ctrl.InstallBlock(), *iExpressionEvaluator, file);
       
   328 	
   276 	if (!DependenciesOk(file))
   329 	if (!DependenciesOk(file))
   277 	{
   330 	{
   278 		return MISSING_DEPENDENCY;
   331 		return MISSING_DEPENDENCY;
   279 	}
   332 	}
   280 
   333