secureswitools/swisistools/source/interpretsislib/sisfile.cpp
branchRCL_3
changeset 81 42552535c1ac
parent 73 79647526f98c
equal deleted inserted replaced
73:79647526f98c 81:42552535c1ac
   114 	}
   114 	}
   115 
   115 
   116 bool SisFile::GetInstallableFiles(InstallableFiles& aFiles, 
   116 bool SisFile::GetInstallableFiles(InstallableFiles& aFiles, 
   117 								  ExpressionEvaluator& aEvaluator,
   117 								  ExpressionEvaluator& aEvaluator,
   118 								  const std::wstring& aDrivePath,
   118 								  const std::wstring& aDrivePath,
   119 								  int aInstallingDrive,
   119 								  int aInstallingDrive) const
   120 								  const int aSystemDrive,
       
   121 								  const bool aGenerateRomStub) const
       
   122 {
   120 {
   123 	bool success = true;
   121 	bool success = true;
   124 	
   122 	
   125 	CSISInfo::TSISInstallationType installType = iContents.Controller().SISInfo().InstallationType();
   123 	CSISInfo::TSISInstallationType installType = iContents.Controller().SISInfo().InstallationType();
   126 	int count = iContents.SisData().DataUnitCount();
   124 	int count = iContents.SisData().DataUnitCount();
   141 			{
   139 			{
   142 			// for PA stub sis files no file data present,
   140 			// for PA stub sis files no file data present,
   143 			// aFiles will be filled with only file descriptions of files, empty file data
   141 			// aFiles will be filled with only file descriptions of files, empty file data
   144 			if (NULL != dataUnit && fileDes.Operation() != CSISFileDescription::EOpNull)
   142 			if (NULL != dataUnit && fileDes.Operation() != CSISFileDescription::EOpNull)
   145 				{
   143 				{
   146 				aFiles.push_back(new InstallableFile(fileDes, new CSISFileData(dataUnit->FileData(fileDes.FileIndex())), aDrivePath, aInstallingDrive, aSystemDrive, aGenerateRomStub));		
   144 				aFiles.push_back(new InstallableFile(fileDes, new CSISFileData(dataUnit->FileData(fileDes.FileIndex())), aDrivePath, aInstallingDrive));		
   147 				}
   145 				}
   148 			else 
   146 			else 
   149 				{
   147 				{
   150 				// SIS files will not be present in PA stubs
   148 				// SIS files will not be present in PA stubs
   151 				aFiles.push_back( new InstallableFile(fileDes,aDrivePath,aInstallingDrive, aSystemDrive, aGenerateRomStub));		
   149 				aFiles.push_back( new InstallableFile(fileDes,aDrivePath,aInstallingDrive));		
   152 				}
   150 				}
   153 			}
   151 			}
   154 		}
   152 		}
   155 
   153 
   156 	// process main controller - data unit 0
   154 	// process main controller - data unit 0
   157 	const CSISInstallBlock& installBlock = iContents.Controller().InstallBlock();
   155 	const CSISInstallBlock& installBlock = iContents.Controller().InstallBlock();
   158 
   156 
   159 	ProcessInstallBlock(installBlock, aFiles, aEvaluator, aDrivePath, aInstallingDrive, aSystemDrive, aGenerateRomStub);
   157 	ProcessInstallBlock(installBlock, aFiles, aEvaluator, aDrivePath, aInstallingDrive);
   160 
   158 
   161 	return success;
   159 	return success;
   162 }
   160 }
   163 
   161 
   164 bool SisFile::HasEmbedded() const
   162 bool SisFile::HasEmbedded() const
   204 
   202 
   205 	failed = failed || !success;
   203 	failed = failed || !success;
   206 
   204 
   207 	if (failed)
   205 	if (failed)
   208 		{
   206 		{
   209 		std::string x = wstring2string(this->GetPackageName());
   207 		std::string x;
   210 		throw InvalidSis(x, error, SIS_NOT_SUPPORTED);
   208 		throw InvalidSis(Ucs2ToUtf8(this->GetPackageName(),x),
       
   209 			error, SIS_NOT_SUPPORTED);
   211 		}
   210 		}
   212 	}
   211 	}
   213 
   212 
   214 bool SisFile::ProcessInstallOptionsWarning(const CSISInstallBlock& aInstallBlock, std::string& aError)
   213 bool SisFile::ProcessInstallOptionsWarning(const CSISInstallBlock& aInstallBlock, std::string& aError)
   215 	{
   214 	{
   230         case CSISFileDescription::EOpRun:
   229         case CSISFileDescription::EOpRun:
   231         	{
   230         	{
   232 				const CSISFileDescription::TSISInstOption operationOptions = fD.OperationOptions();
   231 				const CSISFileDescription::TSISInstOption operationOptions = fD.OperationOptions();
   233 				if(operationOptions & CSISFileDescription::EInstFileRunOptionByMimeType)
   232 				if(operationOptions & CSISFileDescription::EInstFileRunOptionByMimeType)
   234 				{
   233 				{
   235 					LWARN(L"File " << target.c_str() << L" contains \"Run-Using-MIME\" option that will be ignored.");
   234 					LWARN(L"File " << target << L" contains \"Run-Using-MIME\" option that will be ignored.");
   236 				}
   235 				}
   237 				if((operationOptions & CSISFileDescription::EInstFileRunOptionInstall) \
   236 				if((operationOptions & CSISFileDescription::EInstFileRunOptionInstall) \
   238 						&& (operationOptions & CSISFileDescription::EInstFileRunOptionUninstall))
   237 						&& (operationOptions & CSISFileDescription::EInstFileRunOptionUninstall))
   239 				{
   238 				{
   240 					LWARN(L"File " << target.c_str() << L" contains \"RUN-BOTH\" option that will be ignored.");			
   239 					LWARN(L"File " << target << L" contains \"RUN-BOTH\" option that will be ignored.");			
   241 				}
   240 				}
   242 				else if(operationOptions & CSISFileDescription::EInstFileRunOptionInstall)
   241 				else if(operationOptions & CSISFileDescription::EInstFileRunOptionInstall)
   243 				{
   242 				{
   244 					LWARN(L"File " << target.c_str() << L" contains \"Run-On-Install\" option that will be ignored.");			
   243 					LWARN(L"File " << target << L" contains \"Run-On-Install\" option that will be ignored.");			
   245 				}
   244 				}
   246 				else if(operationOptions & CSISFileDescription::EInstFileRunOptionUninstall)
   245 				else if(operationOptions & CSISFileDescription::EInstFileRunOptionUninstall)
   247 				{
   246 				{
   248 					LWARN(L"File " << target.c_str() << L" contains \"Run-On-Uninstall\" option that will be ignored.");			
   247 					LWARN(L"File " << target << L" contains \"Run-On-Uninstall\" option that will be ignored.");			
   249 				}
   248 				}
   250 				if(operationOptions & CSISFileDescription::EInstFileRunOptionBeforeShutdown)
   249 				if(operationOptions & CSISFileDescription::EInstFileRunOptionBeforeShutdown)
   251 				{
   250 				{
   252 					LWARN(L"File " << target.c_str() << L" contains \"Run-Before-Shutdown\" option that will be ignored.");			
   251 					LWARN(L"File " << target << L" contains \"Run-Before-Shutdown\" option that will be ignored.");			
   253 				}
   252 				}
   254                 if(operationOptions & CSISFileDescription::EInstFileRunOptionAfterInstall)
   253                 if(operationOptions & CSISFileDescription::EInstFileRunOptionAfterInstall)
   255 				{
   254 				{
   256 					LWARN(L"File " << target.c_str() << L" contains \"Run-After-Install\" option that will be ignored.");			
   255 					LWARN(L"File " << target << L" contains \"Run-After-Install\" option that will be ignored.");			
   257 				}
   256 				}
   258 				LWARN(L"File " << target.c_str() << L" contains \"File-Run\" option that will be ignored.");			
   257 				LWARN(L"File " << target << L" contains \"File-Run\" option that will be ignored.");			
   259 			}
   258 			}
   260             success = true;
   259             success = true;
   261             break;
   260             break;
   262         case CSISFileDescription::EOpText:
   261         case CSISFileDescription::EOpText:
   263         	LWARN(L"File " << target.c_str() << L" contains \"Display Text\" option that will be ignored." );
   262         	LWARN(L"File " << target << L" contains \"Display Text\" option that will be ignored." );
   264             success = true;
   263             success = true;
   265             break;
   264             break;
   266         case CSISFileDescription::EOpNull:
   265         case CSISFileDescription::EOpNull:
   267 		case CSISFileDescription::EOpNone:
       
   268             success = true;
   266             success = true;
   269             break;
   267             break;
   270         default:
   268         default:
   271             success = false;
   269             success = false;
   272             break;
   270             break;
   276     		{
   274     		{
   277 			aError += "SIS File contains install options : "+operation;
   275 			aError += "SIS File contains install options : "+operation;
   278 			break;
   276 			break;
   279 	    	}
   277 	    	}
   280 		}
   278 		}
   281 	return success;
       
   282 	}
   279 	}
   283 
   280 
   284 
   281 
   285 std::wstring SisFile::GetVendorName() const
   282 std::wstring SisFile::GetVendorName() const
   286 	{
   283 	{
   371 	}
   368 	}
   372 
   369 
   373 void SisFile::GetInstallableFiles(	InstallableFiles& aFiles, 
   370 void SisFile::GetInstallableFiles(	InstallableFiles& aFiles, 
   374 									const CSISInstallBlock& aInstallBlock, 
   371 									const CSISInstallBlock& aInstallBlock, 
   375 									const std::wstring& aDrivePath,
   372 									const std::wstring& aDrivePath,
   376 									int aInstallingDrive,
   373 									int aInstallingDrive) const
   377 									const int aSystemDrive,
       
   378 									const bool aGenerateRomStub) const
       
   379 	{
   374 	{
   380 	CSISInfo::TSISInstallationType installType = iContents.Controller().SISInfo().InstallationType();
   375 	CSISInfo::TSISInstallationType installType = iContents.Controller().SISInfo().InstallationType();
   381 	const CSISDataUnit* dataUnit = NULL;
   376 	const CSISDataUnit* dataUnit = NULL;
   382 	
   377 	
   383 	if (installType ==  CSISInfo::EInstInstallation || installType == CSISInfo::EInstAugmentation || installType == CSISInfo::EInstPartialUpgrade)
   378 	if (installType ==  CSISInfo::EInstInstallation || installType == CSISInfo::EInstAugmentation || installType == CSISInfo::EInstPartialUpgrade)
   400 		// for PA stub sis files no file data present,
   395 		// for PA stub sis files no file data present,
   401 		// aFiles will be filled with only file descriptions of files, empty file data
   396 		// aFiles will be filled with only file descriptions of files, empty file data
   402 		if (NULL != dataUnit && fileDes.Operation() != CSISFileDescription::EOpNull)
   397 		if (NULL != dataUnit && fileDes.Operation() != CSISFileDescription::EOpNull)
   403 			{
   398 			{
   404 			const CSISFileData& filedataref = dataUnit->FileData(fileDes.FileIndex());
   399 			const CSISFileData& filedataref = dataUnit->FileData(fileDes.FileIndex());
   405 			aFiles.push_back(new InstallableFile(fileDes, new CSISFileData(dataUnit->FileData(fileDes.FileIndex())), aDrivePath, aInstallingDrive, aSystemDrive, aGenerateRomStub));
   400 			aFiles.push_back(new InstallableFile(fileDes, new CSISFileData(dataUnit->FileData(fileDes.FileIndex())), aDrivePath, aInstallingDrive));
   406 			}
   401 			}
   407 		else // for stubs, no file data
   402 		else // for stubs, no file data
   408 			{
   403 			{
   409 			aFiles.push_back(new InstallableFile(fileDes, aDrivePath, aInstallingDrive, aSystemDrive, aGenerateRomStub));
   404 			aFiles.push_back(new InstallableFile(fileDes, aDrivePath, aInstallingDrive));
   410 			}
   405 			}
   411 		}
   406 		}
   412 	}
   407 	}
   413 
   408 
   414 void SisFile::ProcessInstallBlock(const CSISInstallBlock& aInstallBlock, 
   409 void SisFile::ProcessInstallBlock(const CSISInstallBlock& aInstallBlock, 
   415 								  InstallableFiles& aFiles, 
   410 								  InstallableFiles& aFiles, 
   416 								  ExpressionEvaluator& aEvaluator, 
   411 								  ExpressionEvaluator& aEvaluator, 
   417 								  const std::wstring& aDrivePath,
   412 								  const std::wstring& aDrivePath,
   418 								  int aInstallingDrive,
   413 								  int aInstallingDrive) const
   419 								  const int aSystemDrive,
   414 	{
   420 								  const bool aGenerateRomStub) const
   415 	GetInstallableFiles(aFiles, aInstallBlock, aDrivePath, aInstallingDrive);
   421 	{
       
   422 	GetInstallableFiles(aFiles, aInstallBlock, aDrivePath, aInstallingDrive, aSystemDrive,aGenerateRomStub);
       
   423 
   416 
   424 	const CSISArray<CSISIf, CSISFieldRoot::ESISIf>& ifs = aInstallBlock.Ifs();
   417 	const CSISArray<CSISIf, CSISFieldRoot::ESISIf>& ifs = aInstallBlock.Ifs();
   425 	for (int i = 0; i < ifs.size(); ++i)
   418 	for (int i = 0; i < ifs.size(); ++i)
   426 		{
   419 		{
   427 		const CSISIf& ifBlock = ifs[i];
   420 		const CSISIf& ifBlock = ifs[i];
   428 
   421 
   429 		if (ifBlock.WasteOfSpace())
   422 		if (ifBlock.WasteOfSpace())
   430 			{
   423 			{
       
   424 			std::string x;
   431 			std::string error = "corrupt SIS file";
   425 			std::string error = "corrupt SIS file";
   432 			std::string x = wstring2string(this->GetPackageName());
   426 			throw InvalidSis(Ucs2ToUtf8(this->GetPackageName(),x), error, INVALID_SIS);
   433 			throw InvalidSis(x, error, INVALID_SIS);
       
   434 			}
   427 			}
   435 
   428 
   436 		// Main expression
   429 		// Main expression
   437 		const ExpressionResult expressionResult = aEvaluator.Evaluate( ifBlock.Expression() );
   430 		const ExpressionResult expressionResult = aEvaluator.Evaluate( ifBlock.Expression() );
   438 		const bool processBlock = expressionResult.BoolValue();
   431 		const bool processBlock = expressionResult.BoolValue();
   439 		if ( processBlock )
   432 		if ( processBlock )
   440 			{
   433 			{
   441 			ProcessInstallBlock(ifBlock.InstallBlock(), aFiles, aEvaluator, aDrivePath, aInstallingDrive, aSystemDrive, aGenerateRomStub);
   434 			ProcessInstallBlock(ifBlock.InstallBlock(), aFiles, aEvaluator, aDrivePath, aInstallingDrive);
   442 			continue;
   435 			continue;
   443 			}
   436 			}
   444 		
   437 		
   445 		int elseCount = ifBlock.ElseIfCount();
   438 		int elseCount = ifBlock.ElseIfCount();
   446 		for (int i = 0; i < elseCount; ++i)
   439 		for (int i = 0; i < elseCount; ++i)
   447 			{
   440 			{
   448 			const CSISElseIf& ifElseBlock = ifBlock.ElseIf(i) ;
   441 			const CSISElseIf& ifElseBlock = ifBlock.ElseIf(i) ;
   449 			if ( aEvaluator.Evaluate(ifElseBlock.Expression()).BoolValue())
   442 			if ( aEvaluator.Evaluate(ifElseBlock.Expression()).BoolValue())
   450 				{
   443 				{
   451 				ProcessInstallBlock(ifElseBlock.InstallBlock(), aFiles, aEvaluator, aDrivePath, aInstallingDrive, aSystemDrive, aGenerateRomStub);
   444 				ProcessInstallBlock(ifElseBlock.InstallBlock(), aFiles, aEvaluator, aDrivePath, aInstallingDrive);
   452 				break;	// Stop processing else if blocks
   445 				break;	// Stop processing else if blocks
   453 				}
   446 				}
   454 			// Process the rest of the files
   447 			// Process the rest of the files
   455 			GetInstallableFiles(aFiles, ifElseBlock.InstallBlock(), aDrivePath, aInstallingDrive, aSystemDrive, aGenerateRomStub);
   448 			GetInstallableFiles(aFiles, ifElseBlock.InstallBlock(), aDrivePath, aInstallingDrive);
   456 			}
   449 			}
   457 		} 
   450 		} 
   458 	}
   451 	}
   459 
   452 
   460 PackageUids SisFile::GetEmbeddedPackageUids() const
   453 PackageUids SisFile::GetEmbeddedPackageUids() const
   505 	CSISContents contents = iContents;
   498 	CSISContents contents = iContents;
   506 	contents.SetStub(CSISContents::EStubPreInstalled);
   499 	contents.SetStub(CSISContents::EStubPreInstalled);
   507 	contents.WriteSIS(aFileName);
   500 	contents.WriteSIS(aFileName);
   508 	}
   501 	}
   509 
   502 
   510 void SisFile::MakeSISRomStub(std::wstring& aFileName)
       
   511 	{
       
   512 	CSISContents contents = iContents;
       
   513 	contents.SetStub(CSISContents::EStubROM);
       
   514 	contents.WriteSIS(aFileName);
       
   515 	}
       
   516