secureswitools/swisistools/source/interpretsislib/xmlgenerator.cpp
changeset 25 98b66e4fb0be
parent 0 ba25891c3a9e
child 50 c6e8afe0ba85
child 60 245df5276b97
equal deleted inserted replaced
24:84a16765cd86 25:98b66e4fb0be
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-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".
    65 
    65 
    66 CXmlGenerator::~CXmlGenerator()
    66 CXmlGenerator::~CXmlGenerator()
    67 	{}
    67 	{}
    68 
    68 
    69 
    69 
    70 void CXmlGenerator::WritePreProvisionDetails(const std::wstring aXmlFileName, const XmlDetails::TScrPreProvisionDetail& aPreProvisionDetail)
    70 void CXmlGenerator::WritePreProvisionDetails(const std::wstring aXmlFileName, 
       
    71 												const XmlDetails::TScrPreProvisionDetail& aPreProvisionDetail,
       
    72 												int& aRomApplication
       
    73 												)
    71 	{
    74 	{
    72 	try 
    75 	try 
    73 		{
    76 		{
    74 		XMLPlatformUtils::Initialize();
    77 		XMLPlatformUtils::Initialize();
    75 		static_fn_auto_ptr<xmlPlatform> xmlPlatformTerm(&XMLPlatformUtils::Terminate);
    78 		static_fn_auto_ptr<xmlPlatform> xmlPlatformTerm(&XMLPlatformUtils::Terminate);
   110 		for(compIter = aPreProvisionDetail.iComponents.begin(); compIter != aPreProvisionDetail.iComponents.end() ; ++compIter)
   113 		for(compIter = aPreProvisionDetail.iComponents.begin(); compIter != aPreProvisionDetail.iComponents.end() ; ++compIter)
   111 			{
   114 			{
   112 			DOMElement*  component = domDocument->createElement(L"Component");
   115 			DOMElement*  component = domDocument->createElement(L"Component");
   113 			rootElement->appendChild(component);
   116 			rootElement->appendChild(component);
   114 
   117 
   115 			WriteComponent(component,domDocument.get(), *compIter);
   118 			WriteComponent(component,domDocument.get(), *compIter, aRomApplication);
   116 			}
   119 			}
   117 		
   120 		
   118 		// do the serialization through DOMWriter::writeNode();
   121 		// do the serialization through DOMWriter::writeNode();
   119 		domWriter->writeNode(outputFile.get(), *domDocument.get());
   122 		domWriter->writeNode(outputFile.get(), *domDocument.get());
   120 		
   123 		
   161 		 aDomWriter->setFeature(XMLUni::fgDOMXMLDeclaration, true);
   164 		 aDomWriter->setFeature(XMLUni::fgDOMXMLDeclaration, true);
   162 	
   165 	
   163 	aDomWriter->setEncoding(L"UTF-16");
   166 	aDomWriter->setEncoding(L"UTF-16");
   164 	}
   167 	}
   165 
   168 
   166 void CXmlGenerator::WriteComponent( DOMElement* aRootElement, DOMDocument* aDocument, const XmlDetails::TScrPreProvisionDetail::TComponent& aComponent)
   169 void CXmlGenerator::WriteComponent( DOMElement* aRootElement, DOMDocument* aDocument, 
   167 	{
   170 										const XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   171 										int& aRomApplication
       
   172 										)
       
   173 	{
       
   174 
       
   175 	if (aRomApplication) 
       
   176 	{
       
   177 		int isRomApplication = 1;
       
   178 		std::wstring isRomApp = Utils::IntegerToWideString(isRomApplication);
       
   179 		AddChildElement(aRootElement, aDocument, L"RomApplication", isRomApp.c_str());
       
   180 	}
       
   181 	
   168 	std::wstring isRemovable = Utils::IntegerToWideString(aComponent.iComponentDetails.iIsRemovable);
   182 	std::wstring isRemovable = Utils::IntegerToWideString(aComponent.iComponentDetails.iIsRemovable);
   169 	AddChildElement(aRootElement, aDocument, L"Removable", isRemovable.c_str() );
   183 	AddChildElement(aRootElement, aDocument, L"Removable", isRemovable.c_str() );
   170 	
   184 	
   171 	std::wstring size = Utils::Int64ToWideString(aComponent.iComponentDetails.iSize);
   185 	std::wstring size = Utils::Int64ToWideString(aComponent.iComponentDetails.iSize);
   172 	AddChildElement(aRootElement, aDocument, L"Size", size.c_str() );
   186 	AddChildElement(aRootElement, aDocument, L"Size", size.c_str() );
   189 	WriteComponentProperties(aRootElement, aDocument, aComponent.iComponentProperties);
   203 	WriteComponentProperties(aRootElement, aDocument, aComponent.iComponentProperties);
   190 
   204 
   191 	WriteComponentFiles(aRootElement, aDocument, aComponent.iComponentFiles);
   205 	WriteComponentFiles(aRootElement, aDocument, aComponent.iComponentFiles);
   192 
   206 
   193 	WriteComponentDependencies(aRootElement, aDocument, aComponent.iComponentDependency);
   207 	WriteComponentDependencies(aRootElement, aDocument, aComponent.iComponentDependency);
       
   208 
       
   209 	WriteAppRegInfo(aRootElement, aDocument, aComponent.iApplicationRegistrationInfo);
       
   210 
   194 	}
   211 	}
   195 
   212 
   196 void CXmlGenerator::WriteComponentVersion
   213 void CXmlGenerator::WriteComponentVersion
   197 				(
   214 				(
   198 				DOMElement* aRootElement, 
   215 				DOMElement* aRootElement, 
   258 		compPropRoot->setAttribute(L"Name", compPropIter->iName.c_str());
   275 		compPropRoot->setAttribute(L"Name", compPropIter->iName.c_str());
   259 		
   276 		
   260 		}
   277 		}
   261 	}
   278 	}
   262 
   279 
       
   280 
       
   281 /**
       
   282  * Writes Class TAppRegistrationInfo Info in XML. 
       
   283  */
       
   284 
       
   285 void CXmlGenerator::WriteAppRegInfo	
       
   286 					( 
       
   287 						DOMElement* aRootElement, DOMDocument* aDocument, 
       
   288 						const std::vector<AppRegistrationInfo>& aAppRegInfo 
       
   289 					)
       
   290 {
       
   291 	std::vector<AppRegistrationInfo>::const_iterator compFileIter;
       
   292 	for( compFileIter = aAppRegInfo.begin() ; compFileIter != aAppRegInfo.end() ; ++compFileIter)
       
   293 	{
       
   294 		DOMElement* compFileRoot = AddTag(aRootElement, aDocument, L"ApplicationRegistrationInfo");
       
   295 
       
   296 		WriteAppAttributes(compFileRoot, aDocument, compFileIter->iApplicationAttribute);
       
   297 
       
   298 		const std::vector<AppOpaqueDataType>& aAppOpaqueDataType = compFileIter->iOpaqueDataType;
       
   299 		std::vector<AppOpaqueDataType>::const_iterator fileAppOpaqueDataType;
       
   300 
       
   301 		for( fileAppOpaqueDataType = aAppOpaqueDataType.begin() ; fileAppOpaqueDataType != aAppOpaqueDataType.end() ; ++fileAppOpaqueDataType)
       
   302 		{
       
   303 			if(0 == fileAppOpaqueDataType->iServiceUid)
       
   304 			{
       
   305 				DOMElement* filePropValueRoot = AddTag(compFileRoot, aDocument, L"OpaqueData");
       
   306 				AddChildElement(filePropValueRoot,aDocument, L"Data", fileAppOpaqueDataType->iOpaqueData.c_str());
       
   307 				std::wstring iLocale = Utils::IntegerToWideString(fileAppOpaqueDataType->iLocale);
       
   308 				AddChildElement(filePropValueRoot,aDocument, L"OpaqueLocale", iLocale.c_str());
       
   309 			}
       
   310 		}
       
   311 
       
   312 		for(vector<std::wstring>::iterator mimeiter = compFileIter->iFileOwnershipInfo.begin() ; mimeiter != compFileIter->iFileOwnershipInfo.end() ; ++mimeiter )
       
   313 		{
       
   314 			DOMElement* filePropRoot = AddTag(compFileRoot, aDocument, L"FileOwnershipinfo");
       
   315 
       
   316 			AddChildElement(filePropRoot,aDocument, L"FileName",  mimeiter->c_str());
       
   317 		}
       
   318 
       
   319 		WriteAppServiceInfo(compFileRoot, aDocument, compFileIter->iApplicationServiceInfo, compFileIter->iOpaqueDataType);
       
   320 		WriteAppLocalizableInfo(compFileRoot, aDocument, compFileIter->iApplicationLocalizableInfo);
       
   321 	}
       
   322 }
       
   323 
       
   324 /**
       
   325  * Writes Class TAppLocalizableInfo Info in XML. 
       
   326  */
       
   327 
       
   328 void CXmlGenerator::WriteAppLocalizableInfo	
       
   329 					( 
       
   330 						DOMElement* aRootElement, DOMDocument* aDocument, 
       
   331 						const std::vector<AppLocalizableInfo>& aAppLocalizableInfo
       
   332 					)
       
   333 {
       
   334 	std::vector<AppLocalizableInfo>::const_iterator filePropIter;
       
   335 	for( filePropIter = aAppLocalizableInfo.begin() ; filePropIter != aAppLocalizableInfo.end() ; ++filePropIter)
       
   336 	{
       
   337 		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationLocalizableInfo");
       
   338 
       
   339 		WriteAppLocalizableAttribute(filePropRoot, aDocument, filePropIter->iLocalizableAttribute);
       
   340 		WriteAppLocalizableViewData(filePropRoot, aDocument, filePropIter->iViewData);
       
   341 	}
       
   342 }
       
   343 
       
   344 /**
       
   345  * Writes Class TAppLocalizableAttribute Info in XML. 
       
   346  */
       
   347 
       
   348 void CXmlGenerator::WriteAppLocalizableAttribute	
       
   349 					( 
       
   350 						DOMElement* aRootElement, DOMDocument* aDocument, 
       
   351 						const std::vector<AppLocalizableAttribute>& aAppLocalizableAttribute 
       
   352 					)
       
   353 {
       
   354 	std::vector<AppLocalizableAttribute>::const_iterator filePropIter;
       
   355 	for( filePropIter = aAppLocalizableAttribute.begin() ; filePropIter != aAppLocalizableAttribute.end() ; ++filePropIter)
       
   356 	{
       
   357 		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"LocalizableAttribute");
       
   358 		DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"LocalizableAttribute_Value");
       
   359 
       
   360 		if(filePropIter->iIsIntValue)
       
   361 		{
       
   362 			AddChildElement(filePropValueRoot, aDocument, L"LocalizableAttribute_IntValue", filePropIter->iValue.c_str());
       
   363 		}
       
   364 		else
       
   365 		{
       
   366 			AddChildElement(filePropValueRoot, aDocument, L"LocalizableAttribute_StrValue", filePropIter->iValue.c_str());
       
   367 		}
       
   368 		filePropRoot->setAttribute(L"Name", filePropIter->iName.c_str());
       
   369 	}
       
   370 }
       
   371 
       
   372 /**
       
   373  * Writes Class TAppViewData Info in XML. 
       
   374  */
       
   375 
       
   376  void CXmlGenerator::WriteAppLocalizableViewData 
       
   377 					 ( 
       
   378 						 DOMElement* aRootElement, DOMDocument* aDocument, 
       
   379 						 const std::vector<AppViewData>& aAppViewData 
       
   380 					 )
       
   381  {
       
   382 	 std::vector<AppViewData>::const_iterator filePropIter;
       
   383 	 for( filePropIter = aAppViewData.begin() ; filePropIter != aAppViewData.end() ; ++filePropIter)
       
   384 	 {
       
   385 		 DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ViewData");
       
   386 		 WriteAppLocalizableViewDataAttributes(filePropRoot, aDocument, filePropIter->iViewDataAttributes);
       
   387 	 }
       
   388  }
       
   389 
       
   390  void CXmlGenerator::WriteAppLocalizableViewDataAttributes 
       
   391 					 ( 
       
   392 						 DOMElement* aRootElement, DOMDocument* aDocument, 
       
   393 						 const std::vector<AppViewDataAttributes>& aAppViewDataAttributes 
       
   394 					 )
       
   395  {
       
   396 	 std::vector<AppViewDataAttributes>::const_iterator filePropIter;
       
   397 	 for( filePropIter = aAppViewDataAttributes.begin() ; filePropIter != aAppViewDataAttributes.end() ; ++filePropIter)
       
   398 	 {
       
   399 		 DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ViewDataAttribute");
       
   400 		 DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"ViewData_Value");
       
   401  
       
   402 		 if(filePropIter->iIsIntValue)
       
   403 		 {
       
   404 			 AddChildElement(filePropValueRoot, aDocument, L"ViewData_IntValue", filePropIter->iValue.c_str());
       
   405 		 }
       
   406 		 else
       
   407 		 {
       
   408 			 AddChildElement(filePropValueRoot, aDocument, L"ViewData_StrValue", filePropIter->iValue.c_str());
       
   409 		 }
       
   410 		 filePropRoot->setAttribute(L"Name", filePropIter->iName.c_str());
       
   411 	 }
       
   412  }
       
   413 
       
   414 /**
       
   415  * Writes Class TAppServiceInfo Info in XML. 
       
   416  */
       
   417 
       
   418 void CXmlGenerator::WriteAppServiceInfo	
       
   419 					( 
       
   420 						DOMElement* aRootElement, DOMDocument* aDocument, 
       
   421 						const std::vector<AppServiceInfo>& aAppServiceInfo,
       
   422 						const std::vector<AppOpaqueDataType>& aAppOpaqueData 
       
   423 					)
       
   424 {
       
   425 	std::vector<AppServiceInfo>::const_iterator filePropIter;
       
   426 	std::vector<AppOpaqueDataType>::const_iterator fileAppPropIter;
       
   427 	for( filePropIter = aAppServiceInfo.begin() ; filePropIter != aAppServiceInfo.end() ; ++filePropIter)
       
   428 	{
       
   429 		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationServiceInfo");
       
   430 	
       
   431 		std::wstring iUid = Utils::IntegerToWideString(filePropIter->iUid);
       
   432 		AddChildElement(filePropRoot,aDocument, L"Uid", iUid.c_str());
       
   433 
       
   434 		for( fileAppPropIter = aAppOpaqueData.begin() ; fileAppPropIter != aAppOpaqueData.end() ; ++fileAppPropIter)
       
   435 		{
       
   436 			if(filePropIter->iUid == fileAppPropIter->iServiceUid)
       
   437 			{
       
   438 				if(!fileAppPropIter->iOpaqueData.empty())
       
   439 				{
       
   440 					DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"ServiceOpaqueData");
       
   441 					AddChildElement(filePropValueRoot,aDocument, L"ServiceData", fileAppPropIter->iOpaqueData.c_str());
       
   442 					std::wstring iLocale = Utils::IntegerToWideString(fileAppPropIter->iLocale);
       
   443 					AddChildElement(filePropValueRoot,aDocument, L"ServiceOpaqueLocale", iLocale.c_str());
       
   444 				}
       
   445 			}
       
   446 		}
       
   447 
       
   448 		WriteAppDataType(filePropRoot, aDocument, filePropIter->iDataType);
       
   449 	}
       
   450 }
       
   451 
       
   452 /**
       
   453  * Writes Class TDataType Info in XML. 
       
   454  */
       
   455 
       
   456 void CXmlGenerator::WriteAppDataType	
       
   457 					( 
       
   458 						DOMElement* aRootElement, DOMDocument* aDocument, 
       
   459 						const std::vector<AppDataType>& aAppDataType 
       
   460 					)
       
   461 {
       
   462 	std::vector<AppDataType>::const_iterator filePropIter;
       
   463 	for( filePropIter = aAppDataType.begin() ; filePropIter != aAppDataType.end() ; ++filePropIter)
       
   464 	{
       
   465 		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationDataType");
       
   466 
       
   467 		std::wstring iPriority = Utils::IntegerToWideString(filePropIter->iPriority);
       
   468 		AddChildElement(filePropRoot,aDocument, L"Priority", iPriority.c_str());
       
   469 		AddChildElement(filePropRoot, aDocument, L"Type", filePropIter->iType.c_str());
       
   470 	}
       
   471 }
       
   472 
       
   473 /**
       
   474  * Writes Class TApplicationAttribute Info in XML. 
       
   475  */
       
   476 
       
   477 void CXmlGenerator::WriteAppAttributes	
       
   478 					( 
       
   479 						DOMElement* aRootElement, DOMDocument* aDocument, 
       
   480 						const std::vector<ApplicationAttribute>& aAppAttributes 
       
   481 					)
       
   482 {
       
   483 	std::vector<ApplicationAttribute>::const_iterator filePropIter;
       
   484 	for( filePropIter = aAppAttributes.begin() ; filePropIter != aAppAttributes.end() ; ++filePropIter)
       
   485 	{
       
   486 		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationAttribute");
       
   487 		DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"ApplicationAttribute_Value");
       
   488 
       
   489 		if(filePropIter->iIsIntValue)
       
   490 		{
       
   491 			AddChildElement(filePropValueRoot, aDocument, L"ApplicationAttribute_IntValue", filePropIter->iValue.c_str());
       
   492 		}
       
   493 		else
       
   494 		{
       
   495 			AddChildElement(filePropValueRoot, aDocument, L"ApplicationAttribute_StrValue", filePropIter->iValue.c_str());
       
   496 		}
       
   497 		filePropRoot->setAttribute(L"Name", filePropIter->iName.c_str());
       
   498 	}
       
   499 }
       
   500 
       
   501 /**
       
   502  * Writes Class TApplicationProperty Info in XML. 
       
   503  */
       
   504 void CXmlGenerator::WriteAppProperty	
       
   505 					( 
       
   506 						DOMElement* aRootElement, DOMDocument* aDocument, 
       
   507 						const std::vector<AppProperty>& aAppProperty 
       
   508 					)
       
   509 {
       
   510 	std::vector<AppProperty>::const_iterator filePropIter;
       
   511 	for( filePropIter = aAppProperty.begin() ; filePropIter != aAppProperty.end() ; ++filePropIter)
       
   512 	{
       
   513 		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationProperty");
       
   514 
       
   515 
       
   516 		std::wstring iLocale = Utils::IntegerToWideString(filePropIter->iLocale);
       
   517 		AddChildElement(filePropRoot,aDocument, L"Locale", iLocale.c_str());
       
   518 
       
   519 		AddChildElement(filePropRoot,aDocument, L"Name", filePropIter->iName.c_str());
       
   520 
       
   521 		std::wstring iServiceUid = Utils::IntegerToWideString(filePropIter->iServiceUid);
       
   522 		AddChildElement(filePropRoot,aDocument, L"ServiceUid", iServiceUid.c_str());
       
   523 
       
   524 		std::wstring iIntValue = Utils::IntegerToWideString(filePropIter->iIntValue);
       
   525 		AddChildElement(filePropRoot,aDocument, L"IntValue", iIntValue.c_str());
       
   526 
       
   527 		AddChildElement(filePropRoot, aDocument, L"StrValue", filePropIter->iStrValue.c_str());
       
   528 
       
   529 		std::wstring iIsStr8Bit = Utils::IntegerToWideString(filePropIter->iIsStr8Bit);
       
   530 		AddChildElement(filePropRoot,aDocument, L"IsStr8Bit", iIsStr8Bit.c_str());
       
   531 
       
   532 	}
       
   533 }
       
   534 
   263 void CXmlGenerator::WriteComponentFiles	
   535 void CXmlGenerator::WriteComponentFiles	
   264 					( 
   536 					( 
   265 						DOMElement* aRootElement, DOMDocument* aDocument, 
   537 						DOMElement* aRootElement, DOMDocument* aDocument, 
   266 						const std::vector<ComponentFile>& aComponentFiles 
   538 						const std::vector<ComponentFile>& aComponentFiles 
   267 					)
   539 					)