secureswitools/swisistools/source/dbmanager/dblayer.cpp
changeset 25 98b66e4fb0be
parent 0 ba25891c3a9e
child 33 8110bf1194d1
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".
    35 typedef std::vector<std::string>::iterator StringIterator;
    35 typedef std::vector<std::string>::iterator StringIterator;
    36 typedef std::vector<std::string>::const_iterator ConstStringIterator;
    36 typedef std::vector<std::string>::const_iterator ConstStringIterator;
    37 typedef std::vector<std::wstring>::const_iterator ConstWstringIterator;
    37 typedef std::vector<std::wstring>::const_iterator ConstWstringIterator;
    38 typedef std::vector<XmlDetails::TScrEnvironmentDetails>::const_iterator ScrEnvIterator;
    38 typedef std::vector<XmlDetails::TScrEnvironmentDetails>::const_iterator ScrEnvIterator;
    39 typedef std::vector<XmlDetails::TScrEnvironmentDetails::TLocalizedSoftwareTypeName>::const_iterator ScrEnvLocSwTypeNameIterator;
    39 typedef std::vector<XmlDetails::TScrEnvironmentDetails::TLocalizedSoftwareTypeName>::const_iterator ScrEnvLocSwTypeNameIterator;
       
    40 typedef std::vector<XmlDetails::TScrEnvironmentDetails::TCustomAcessList>::const_iterator ScrEnvCustomAccessIterator;
    40 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponent>::const_iterator CompIterator;
    41 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponent>::const_iterator CompIterator;
    41 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponentLocalizable>::const_iterator CompLocIterator;
    42 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponentLocalizable>::const_iterator CompLocIterator;
    42 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponentProperty>::const_iterator CompPropIterator;
    43 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponentProperty>::const_iterator CompPropIterator;
    43 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponentFile>::const_iterator CompFileIter;
    44 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponentFile>::const_iterator CompFileIter;
    44 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty>::const_iterator FilePropIterator;
    45 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty>::const_iterator FilePropIterator;
       
    46 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo>::const_iterator CompApplicationRegistrationInfoIterator;
       
    47 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppAttribute>::const_iterator ApplicationAttributeIterator;
       
    48 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TDataType>::const_iterator ApplicationDataTypeIterator;
       
    49 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppServiceInfo>::const_iterator ApplicationServiceInfoIterator;
       
    50 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo>::const_iterator ApplicationLocalizableInfoIterator;
       
    51 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TLocalizableAttribute>::const_iterator LocalizableAttributeIterator;
       
    52 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TViewData>::const_iterator ViewDataIterator;
       
    53 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TViewData::TViewDataAttributes>::const_iterator ViewDataAttributeIterator;
       
    54 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppProperty>::const_iterator ApplicationPropertyIterator;
       
    55 
    45 
    56 
    46 const int KMaxDrives=26;
    57 const int KMaxDrives=26;
    47 
    58 
    48 CDbLayer::CDbLayer(const std::string& aDllPath, const std::string& aSqlDbName)
    59 CDbLayer::CDbLayer(const std::string& aDllPath, const std::string& aSqlDbName)
    49 	{
    60 	{
    85 
    96 
    86 void CDbLayer::PopulatePreProvisionDetails(const XmlDetails::TScrPreProvisionDetail& aPreProvisionDetailList)
    97 void CDbLayer::PopulatePreProvisionDetails(const XmlDetails::TScrPreProvisionDetail& aPreProvisionDetailList)
    87 	{
    98 	{
    88 	try
    99 	try
    89 		{
   100 		{
       
   101 		LOGENTER("CDbLayer::PopulatePreProvisionDetails()");
    90 		AddPreProvisionDetails(aPreProvisionDetailList);
   102 		AddPreProvisionDetails(aPreProvisionDetailList);
    91 		}
   103 		}
    92 		catch(CException& aException)
   104 		catch(CException& aException)
    93 			{
   105 			{
    94 			std::string rollbackTransaction("ROLLBACK;");
   106 			std::string rollbackTransaction("ROLLBACK;");
    95 			ExecuteStatement(rollbackTransaction);
   107 			ExecuteStatement(rollbackTransaction);
    96 			std::string errMsg = "Failed to populate SCR database with environment details.";
   108 			std::string errMsg = "Failed to populate SCR database with pre provision details.";
    97 			LOGERROR(aException.GetMessageA());
   109 			LOGERROR(aException.GetMessageA());
    98 			throw CException(errMsg,ExceptionCodes::ESqlCorrupt);
   110 			throw CException(errMsg,ExceptionCodes::ESqlCorrupt);
    99 			}
   111 			}
   100 	}
   112 	}
   101 
   113 
   108 	aStatement->Reset();
   120 	aStatement->Reset();
   109 	}
   121 	}
   110 
   122 
   111 void CDbLayer::PopulateDatabase(const std::vector<XmlDetails::TScrEnvironmentDetails>& aScrEnvDetails)
   123 void CDbLayer::PopulateDatabase(const std::vector<XmlDetails::TScrEnvironmentDetails>& aScrEnvDetails)
   112 	{
   124 	{
   113 	std::string insertSoftwareType("INSERT INTO SoftwareTypes(SoftwareTypeId,SifPluginUid,InstallerSecureId,ExecutionLayerSecureId) VALUES(?,?,?,?);");
   125 	LOGENTER("CDbLayer::PopulateDatabase()");
       
   126 	std::string insertSoftwareType("INSERT INTO SoftwareTypes(SoftwareTypeId,SifPluginUid,LauncherExecutable) VALUES(?,?,?);");
   114 	std::auto_ptr<CStatement> stmtSwType(iScrDbHandler->PrepareStatement(insertSoftwareType));
   127 	std::auto_ptr<CStatement> stmtSwType(iScrDbHandler->PrepareStatement(insertSoftwareType));
       
   128 	
       
   129 	std::string insertSTWithoutLE("INSERT INTO SoftwareTypes(SoftwareTypeId,SifPluginUid) VALUES(?,?);");
       
   130 	std::auto_ptr<CStatement> stmtSwTypeWithoutLE(iScrDbHandler->PrepareStatement(insertSTWithoutLE));
       
   131 	
       
   132     std::string insertCustomAccessList("INSERT INTO CustomAccessList(SoftwareTypeId,SecureId,AccessMode) VALUES(?,?,?);");
       
   133 	std::auto_ptr<CStatement> stmtCustomAccessList(iScrDbHandler->PrepareStatement(insertCustomAccessList));
   115 	
   134 	
   116 	std::string insertSwTypeName("INSERT INTO SoftwareTypeNames(SoftwareTypeId,Locale,Name) VALUES(?,?,?);");
   135 	std::string insertSwTypeName("INSERT INTO SoftwareTypeNames(SoftwareTypeId,Locale,Name) VALUES(?,?,?);");
   117 	std::auto_ptr<CStatement> stmtSwTypeName(iScrDbHandler->PrepareStatement(insertSwTypeName));
   136 	std::auto_ptr<CStatement> stmtSwTypeName(iScrDbHandler->PrepareStatement(insertSwTypeName));
   118 		
   137 		
   119 	std::string insertMimeType("INSERT INTO MimeTypes(SoftwareTypeId,MimeType) VALUES(?,?);");
   138 	std::string insertMimeType("INSERT INTO MimeTypes(SoftwareTypeId,MimeType) VALUES(?,?);");
   120 	std::auto_ptr<CStatement> stmtMimeType(iScrDbHandler->PrepareStatement(insertMimeType));
   139 	std::auto_ptr<CStatement> stmtMimeType(iScrDbHandler->PrepareStatement(insertMimeType));
   121 
   140 
   122 	for(ScrEnvIterator aScrEnvIterator = aScrEnvDetails.begin(); aScrEnvIterator != aScrEnvDetails.end(); ++aScrEnvIterator)
   141 	for(ScrEnvIterator aScrEnvIterator = aScrEnvDetails.begin(); aScrEnvIterator != aScrEnvDetails.end(); ++aScrEnvIterator)
   123 		{
   142 		{
   124 		unsigned int swTypeId = Util::Crc32(aScrEnvIterator->iUniqueSoftwareTypeName.c_str(),aScrEnvIterator->iUniqueSoftwareTypeName.length()*2);
   143 		unsigned int swTypeId = Util::Crc32(aScrEnvIterator->iUniqueSoftwareTypeName.c_str(),aScrEnvIterator->iUniqueSoftwareTypeName.length()*2);
       
   144 		if (!aScrEnvIterator->iLauncherExecutable.empty())
       
   145 		{
   125 		stmtSwType->BindInt(1, swTypeId);
   146 		stmtSwType->BindInt(1, swTypeId);
   126 		stmtSwType->BindInt(2, aScrEnvIterator->iSifPluginUid);
   147 		stmtSwType->BindInt(2, aScrEnvIterator->iSifPluginUid);
   127 		stmtSwType->BindInt(3, aScrEnvIterator->iInstallerSid);
   148 		stmtSwType->BindStr(3, aScrEnvIterator->iLauncherExecutable);
   128 		stmtSwType->BindInt(4, aScrEnvIterator->iExecutionLayerSid);
       
   129 		stmtSwType->ExecuteStatement();
   149 		stmtSwType->ExecuteStatement();
   130 		stmtSwType->Reset();
   150 		stmtSwType->Reset();
       
   151 		}
       
   152 		else
       
   153 		{
       
   154 		stmtSwTypeWithoutLE->BindInt(1, swTypeId);
       
   155 		stmtSwTypeWithoutLE->BindInt(2, aScrEnvIterator->iSifPluginUid);
       
   156 		stmtSwTypeWithoutLE->ExecuteStatement();
       
   157 		stmtSwTypeWithoutLE->Reset();
       
   158 		}
   131 		// First insert unique sw type name
   159 		// First insert unique sw type name
   132 		const TInt uniqueSwTypeNameLocale = 0;
   160 		const TInt uniqueSwTypeNameLocale = 0;
   133 		ExecuteSwTypeNameStatement(stmtSwTypeName, swTypeId, uniqueSwTypeNameLocale, aScrEnvIterator->iUniqueSoftwareTypeName);
   161 		ExecuteSwTypeNameStatement(stmtSwTypeName, swTypeId, uniqueSwTypeNameLocale, aScrEnvIterator->iUniqueSoftwareTypeName);
   134 		// Then, insert localized sw type names.
   162 		// Then, insert localized sw type names.
   135 		for(ScrEnvLocSwTypeNameIterator swTypeNameIter = aScrEnvIterator->iLocalizedSoftwareTypeNames.begin(); swTypeNameIter != aScrEnvIterator->iLocalizedSoftwareTypeNames.end(); ++swTypeNameIter)
   163 		for(ScrEnvLocSwTypeNameIterator swTypeNameIter = aScrEnvIterator->iLocalizedSoftwareTypeNames.begin(); swTypeNameIter != aScrEnvIterator->iLocalizedSoftwareTypeNames.end(); ++swTypeNameIter)
   136 			{
   164 			{
   137 			ExecuteSwTypeNameStatement(stmtSwTypeName, swTypeId, swTypeNameIter->iLocale, swTypeNameIter->iName);
   165 			ExecuteSwTypeNameStatement(stmtSwTypeName, swTypeId, swTypeNameIter->iLocale, swTypeNameIter->iName);
   138 			}
   166 			}
       
   167                 
       
   168         for(ScrEnvCustomAccessIterator customAccessIter = aScrEnvIterator->iCustomAcessList.begin(); customAccessIter != aScrEnvIterator->iCustomAcessList.end(); ++customAccessIter)
       
   169 			{
       
   170         	stmtCustomAccessList->BindInt(1, swTypeId);
       
   171             stmtCustomAccessList->BindInt(2, customAccessIter->iSecureId);
       
   172             stmtCustomAccessList->BindInt(3, customAccessIter->iAccessMode);
       
   173             stmtCustomAccessList->ExecuteStatement();
       
   174             stmtCustomAccessList->Reset();
       
   175 			}
       
   176 		
   139 		for(ConstWstringIterator mimeIter= aScrEnvIterator->iMIMEDetails.begin(); mimeIter != aScrEnvIterator->iMIMEDetails.end(); ++mimeIter)
   177 		for(ConstWstringIterator mimeIter= aScrEnvIterator->iMIMEDetails.begin(); mimeIter != aScrEnvIterator->iMIMEDetails.end(); ++mimeIter)
   140 			{
   178 			{
   141 			stmtMimeType->BindInt(1, swTypeId);
   179 			stmtMimeType->BindInt(1, swTypeId);
   142 			stmtMimeType->BindStr(2, *mimeIter);
   180 			stmtMimeType->BindStr(2, *mimeIter);
   143 			stmtMimeType->ExecuteStatement();
   181 			stmtMimeType->ExecuteStatement();
   144 			stmtMimeType->Reset();
   182 			stmtMimeType->Reset();
   145 			}
   183 			}
   146 		}
   184 		}
       
   185 	LOGEXIT("CDbLayer::PopulateDatabase()");
   147 
   186 
   148 	}
   187 	}
   149 
   188 
   150 void CDbLayer::AddPreProvisionDetails(const XmlDetails::TScrPreProvisionDetail& aPreProvisionDetailList)
   189 void CDbLayer::AddPreProvisionDetails(const XmlDetails::TScrPreProvisionDetail& aPreProvisionDetailList)
   151 	{
   190 	{
       
   191 	LOGENTER("CDbLayer::AddPreProvisionDetails()");
   152 	for(CompIterator aCompIterator = aPreProvisionDetailList.iComponents.begin(); aCompIterator != aPreProvisionDetailList.iComponents.end(); ++aCompIterator)
   192 	for(CompIterator aCompIterator = aPreProvisionDetailList.iComponents.begin(); aCompIterator != aPreProvisionDetailList.iComponents.end(); ++aCompIterator)
   153 		{	
   193 		{	
   154 		std::string beginTransaction("BEGIN;");
   194 		std::string beginTransaction("BEGIN;");
   155 		ExecuteStatement(beginTransaction);
   195 		ExecuteStatement(beginTransaction);
   156 		
   196 		
   157 		AddComponentDetails(*aCompIterator, aPreProvisionDetailList.iSoftwareTypeName);
   197 		int componentId = 0;
   158 		int componentId = iScrDbHandler->LastInsertedId();
   198 		if (!AddComponentDetails(*aCompIterator, aPreProvisionDetailList.iSoftwareTypeName))
   159 		AddComponentLocalizables(componentId,aCompIterator->iComponentLocalizables);
   199 			{
   160 		AddComponentProperties(componentId,aCompIterator->iComponentProperties);
   200 			componentId = iScrDbHandler->LastInsertedId();
   161 		AddComponentFiles(componentId,aCompIterator->iComponentFiles);
   201 			AddComponentLocalizables(componentId,aCompIterator->iComponentLocalizables);
   162 		AddComponentDependencies(componentId, aCompIterator->iComponentDependency, aPreProvisionDetailList.iSoftwareTypeName);
   202 			AddComponentProperties(componentId,aCompIterator->iComponentProperties);
   163 
   203 			AddComponentFiles(componentId,aCompIterator->iComponentFiles);
       
   204 			AddComponentDependencies(componentId, aCompIterator->iComponentDependency, aPreProvisionDetailList.iSoftwareTypeName);
       
   205 			}
       
   206 		AddApplicationRegistrationInfo(componentId,aCompIterator->iApplicationRegistrationInfo);
   164 		std::string commitTransaction("COMMIT;");
   207 		std::string commitTransaction("COMMIT;");
   165 		ExecuteStatement(commitTransaction);
   208 		ExecuteStatement(commitTransaction);
   166 
   209 
   167 		}
   210 		}
   168 	}
   211 	LOGEXIT("CDbLayer::AddPreProvisionDetails()");
   169 
   212 	}
   170 void CDbLayer::AddComponentDetails(const XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const std::wstring& aSoftwareTypeName)
   213 
   171 	{
   214 bool CDbLayer::AddComponentDetails(const XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const std::wstring& aSoftwareTypeName)
       
   215 	{
       
   216 	LOGENTER("CDbLayer::AddComponentDetails()");
   172 	std::string insertComponents;
   217 	std::string insertComponents;
   173 	XmlDetails::TScrPreProvisionDetail::TComponentDetails 
   218 	XmlDetails::TScrPreProvisionDetail::TComponentDetails 
   174 		componentDetail = aComponent.iComponentDetails;
   219 		componentDetail = aComponent.iComponentDetails;
   175 
   220 
       
   221 	if (aComponent.iComponentDetails.iIsRomApplication)
       
   222 		{
       
   223 		LOGINFO("Is rom app");
       
   224 		return true;
       
   225 		}
       
   226 	LOGINFO("Not rom app");
   176 	unsigned int swTypeId = Util::Crc32(aSoftwareTypeName.c_str(),aSoftwareTypeName.length()*2);
   227 	unsigned int swTypeId = Util::Crc32(aSoftwareTypeName.c_str(),aSoftwareTypeName.length()*2);
   177 	std::wstring strGlobalId = componentDetail.iGlobalId;
   228 	std::wstring strGlobalId = componentDetail.iGlobalId;
   178 	
   229 	
   179 	if(!strGlobalId.empty())
   230 	if(!strGlobalId.empty())
   180 		{
   231 		{
   223 		stmtComponents->BindStr(10, localTime);
   274 		stmtComponents->BindStr(10, localTime);
   224 		}
   275 		}
   225 	
   276 	
   226 	stmtComponents->ExecuteStatement();
   277 	stmtComponents->ExecuteStatement();
   227 	stmtComponents->Reset();
   278 	stmtComponents->Reset();
   228 
   279 	LOGEXIT("CDbLayer::AddComponentDetails()");
       
   280 	return false;
   229 	}
   281 	}
   230 
   282 
   231 int CDbLayer::GetInstalledDrives(const std::vector<XmlDetails::TScrPreProvisionDetail::TComponentFile>& aComponentFiles )
   283 int CDbLayer::GetInstalledDrives(const std::vector<XmlDetails::TScrPreProvisionDetail::TComponentFile>& aComponentFiles )
   232 	{
   284 	{
   233 	int installedDrives = 0;
   285 	int installedDrives = 0;
   275 	return wstr;
   327 	return wstr;
   276 	}
   328 	}
   277 
   329 
   278 void CDbLayer::AddComponentLocalizables( int aComponentId, const std::vector<XmlDetails::TScrPreProvisionDetail::TComponentLocalizable>& aComponentLocalizable)
   330 void CDbLayer::AddComponentLocalizables( int aComponentId, const std::vector<XmlDetails::TScrPreProvisionDetail::TComponentLocalizable>& aComponentLocalizable)
   279 	{
   331 	{
       
   332 	LOGENTER("CDbLayer::AddComponentLocalizables()");
   280 	std::string insertComponentLocalizable("INSERT INTO ComponentLocalizables(ComponentId,Locale,Name,Vendor) VALUES(?,?,?,?);");
   333 	std::string insertComponentLocalizable("INSERT INTO ComponentLocalizables(ComponentId,Locale,Name,Vendor) VALUES(?,?,?,?);");
   281 	std::auto_ptr<CStatement> stmtComponentLocalizable(iScrDbHandler->PrepareStatement(insertComponentLocalizable));
   334 	std::auto_ptr<CStatement> stmtComponentLocalizable(iScrDbHandler->PrepareStatement(insertComponentLocalizable));
   282 
   335 
   283 	for(CompLocIterator compLocIter = aComponentLocalizable.begin(); compLocIter != aComponentLocalizable.end() ; ++compLocIter )
   336 	for(CompLocIterator compLocIter = aComponentLocalizable.begin(); compLocIter != aComponentLocalizable.end() ; ++compLocIter )
   284 		{
   337 		{
   287 		stmtComponentLocalizable->BindStr(3, compLocIter->iName);
   340 		stmtComponentLocalizable->BindStr(3, compLocIter->iName);
   288 		stmtComponentLocalizable->BindStr(4, compLocIter->iVendor);
   341 		stmtComponentLocalizable->BindStr(4, compLocIter->iVendor);
   289 		stmtComponentLocalizable->ExecuteStatement();
   342 		stmtComponentLocalizable->ExecuteStatement();
   290 		stmtComponentLocalizable->Reset();
   343 		stmtComponentLocalizable->Reset();
   291 		}
   344 		}
       
   345 	LOGEXIT("CDbLayer::AddComponentLocalizables()");
   292 	}
   346 	}
   293 
   347 
   294 void CDbLayer::AddComponentProperties( 
   348 void CDbLayer::AddComponentProperties( 
   295 	int aComponentId, 
   349 	int aComponentId, 
   296 	const std::vector<XmlDetails::TScrPreProvisionDetail::TComponentProperty>& aComponentProperty)
   350 	const std::vector<XmlDetails::TScrPreProvisionDetail::TComponentProperty>& aComponentProperty)
   297 	{
   351 	{
   298 	
   352 	LOGENTER("CDbLayer::AddComponentProperties()");
   299 	std::string insertComponentProperties;
   353 	std::string insertComponentProperties;
   300 	
   354 	
   301 	for(CompPropIterator compPropIter = aComponentProperty.begin(); compPropIter != aComponentProperty.end() ; ++compPropIter )
   355 	for(CompPropIterator compPropIter = aComponentProperty.begin(); compPropIter != aComponentProperty.end() ; ++compPropIter )
   302 		{
   356 		{
   303 		if(compPropIter->iIsIntValue == 1)
   357 		if(compPropIter->iIsIntValue == 1)
   336 		stmtComponentProperty->BindInt(5, compPropIter->iIsStr8Bit);
   390 		stmtComponentProperty->BindInt(5, compPropIter->iIsStr8Bit);
   337 	
   391 	
   338 		stmtComponentProperty->ExecuteStatement();
   392 		stmtComponentProperty->ExecuteStatement();
   339 		stmtComponentProperty->Reset();
   393 		stmtComponentProperty->Reset();
   340 		}
   394 		}
   341 	
   395 	LOGEXIT("CDbLayer::AddComponentProperties()");
   342 	}
   396 	}
   343 
   397 
   344 void CDbLayer::AddComponentFiles(int aComponentId, const std::vector<XmlDetails::TScrPreProvisionDetail::TComponentFile>& aComponentFiles)
   398 void CDbLayer::AddComponentFiles(int aComponentId, const std::vector<XmlDetails::TScrPreProvisionDetail::TComponentFile>& aComponentFiles)
   345 	{
   399 	{
       
   400 	LOGENTER("CDbLayer::AddComponentFiles()");
   346 	for(CompFileIter compFile = aComponentFiles.begin() ; compFile != aComponentFiles.end() ; ++compFile)
   401 	for(CompFileIter compFile = aComponentFiles.begin() ; compFile != aComponentFiles.end() ; ++compFile)
   347 		{
   402 		{
   348 		AddLocation(aComponentId,compFile->iLocation);
   403 		AddLocation(aComponentId,compFile->iLocation);
   349 		int cmpFileId = iScrDbHandler->LastInsertedId();
   404 		int cmpFileId = iScrDbHandler->LastInsertedId();
   350 		AddFileProperties(cmpFileId,compFile->iFileProperties);
   405 		AddFileProperties(cmpFileId,compFile->iFileProperties);
   351 		
   406 		}
   352 		}
   407 	LOGEXIT("CDbLayer::AddComponentFiles()");
   353 	}
   408 	}
   354 
   409 
   355 
   410 
   356 void CDbLayer::AddComponentDependencies	(	int aComponentId, 
   411 void CDbLayer::AddComponentDependencies	(	int aComponentId, 
   357 											const XmlDetails::TScrPreProvisionDetail::TComponentDependency& aComponentDependency,
   412 											const XmlDetails::TScrPreProvisionDetail::TComponentDependency& aComponentDependency,
   358 											const std::wstring& aSoftwareTypeName
   413 											const std::wstring& aSoftwareTypeName
   359 										)
   414 										)
   360 	{
   415 	{
       
   416 	LOGENTER("CDbLayer::AddComponentDependencies()");
   361 	std::wstring dependentId = aComponentDependency.iDependentId;
   417 	std::wstring dependentId = aComponentDependency.iDependentId;
   362 
   418 
   363 	if(dependentId.empty())
   419 	if(dependentId.empty())
   364 		return;
   420 		return;
   365 	
   421 	
   391 		
   447 		
   392 		stmtComponentDeps->ExecuteStatement();
   448 		stmtComponentDeps->ExecuteStatement();
   393 		stmtComponentDeps->Reset();
   449 		stmtComponentDeps->Reset();
   394 	
   450 	
   395 		}	
   451 		}	
       
   452 	LOGEXIT("CDbLayer::AddComponentDependencies()");
   396 	}
   453 	}
   397 
   454 
   398 
   455 
   399 void CDbLayer::AddLocation(int aComponentId,  const std::wstring& aLocation)
   456 void CDbLayer::AddLocation(int aComponentId,  const std::wstring& aLocation)
   400 	{
   457 	{
   456 		stmtFileProperty->ExecuteStatement();
   513 		stmtFileProperty->ExecuteStatement();
   457 		stmtFileProperty->Reset();
   514 		stmtFileProperty->Reset();
   458 		}
   515 		}
   459 	}
   516 	}
   460 
   517 
       
   518 
       
   519 void CDbLayer::AddApplicationRegistrationInfo( int aComponentId, const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo>& aApplicationRegistrationInfo)
       
   520 	{
       
   521 	LOGENTER("CDbLayer::AddApplicationRegistrationInfo()");
       
   522 	int appflag = 0;
       
   523 	int appUid = 0;
       
   524 	int error = 0;
       
   525 
       
   526 	for(CompApplicationRegistrationInfoIterator compApplicationRegistrationInfoIter = aApplicationRegistrationInfo.begin(); compApplicationRegistrationInfoIter != aApplicationRegistrationInfo.end() ; ++compApplicationRegistrationInfoIter )
       
   527 	{
       
   528 		try {
       
   529 			appflag = 0;
       
   530 			appUid = AddAppAttribute(aComponentId, compApplicationRegistrationInfoIter->iApplicationAttribute);
       
   531 		}
       
   532 		catch(CException& aException)
       
   533 		{
       
   534 			LOGERROR(aException.GetMessageA());
       
   535 			LOGERROR("one of AddAppAttribute is already present in database");
       
   536 			appflag = 1;
       
   537 			error = 1;
       
   538 		}
       
   539 
       
   540 		if(appflag)
       
   541 			continue;
       
   542 				
       
   543 		if (appUid != 0)
       
   544 			{
       
   545 			AddFileOwnershipInfo(appUid, compApplicationRegistrationInfoIter->iFileOwnershipInfo);
       
   546 			AddServiceInfo(appUid, compApplicationRegistrationInfoIter->iApplicationServiceInfo);
       
   547 			AddAppLocalizableInfo(appUid, compApplicationRegistrationInfoIter->iApplicationLocalizableInfo);
       
   548 			AddProperty(appUid, compApplicationRegistrationInfoIter->iApplicationProperty);
       
   549 			}
       
   550 		else
       
   551 			{
       
   552 			std::string errMsg = "AppUid is null.";
       
   553 			LOGERROR(errMsg);
       
   554 			throw CException(errMsg,ExceptionCodes::ESqlArgumentError);
       
   555 			}
       
   556 	}
       
   557 
       
   558 	if(error)
       
   559 	{
       
   560 		std::string errMsg = "Duplicate entry present in database.";
       
   561 		LOGERROR(errMsg);
       
   562 		throw CException(errMsg,ExceptionCodes::EFileExists);
       
   563 	}
       
   564 
       
   565 	LOGEXIT("CDbLayer::AddApplicationRegistrationInfo()");
       
   566 	}
       
   567 
       
   568 int CDbLayer::AddAppAttribute( int aComponentId, const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppAttribute>& aAppAttribute)
       
   569 	{
       
   570 	LOGENTER("CDbLayer::AddAppAttribute()");
       
   571 	std::string insertAppAttributes;
       
   572 	
       
   573 	insertAppAttributes = "INSERT INTO AppRegistrationInfo(AppUid,ComponentId,AppFile,TypeId,Attributes,Hidden,Embeddable,Newfile,Launch,GroupName,DefaultScreenNumber) VALUES(?,?,?,?,?,?,?,?,?,?,?);";
       
   574 	std::auto_ptr<CStatement> stmtAppAttribute(iScrDbHandler->PrepareStatement(insertAppAttributes));
       
   575 
       
   576 	stmtAppAttribute->BindInt64(2, aComponentId);
       
   577 	int appUid = 0;
       
   578 	std::string appfile;
       
   579 	for(ApplicationAttributeIterator applicationAttributeIter = aAppAttribute.begin(); applicationAttributeIter != aAppAttribute.end() ; ++applicationAttributeIter )
       
   580 		{
       
   581 		if (applicationAttributeIter->iName == L"AppUid")
       
   582 			{
       
   583 			LOGINFO("CDbLayer::AddAppAttribute()- appuid");
       
   584 			TInt64 intValue = Util::WideCharToInt64(applicationAttributeIter->iValue.c_str());
       
   585 			stmtAppAttribute->BindInt64(1, intValue);
       
   586 			appUid = intValue;
       
   587 			}
       
   588 		else if (applicationAttributeIter->iName == L"AppFile")
       
   589 			{
       
   590 			stmtAppAttribute->BindStr(3, applicationAttributeIter->iValue);
       
   591 			if (applicationAttributeIter->iValue.length() == 0)
       
   592 				{
       
   593 				std::string errMsg = "Invalid app file.";
       
   594 				LOGERROR(errMsg);
       
   595 				throw CException(errMsg,ExceptionCodes::ESqlArgumentError);
       
   596 				}
       
   597 			
       
   598 			}
       
   599 		else if (applicationAttributeIter->iName == L"TypeId")
       
   600 			{
       
   601 			TInt64 intValue = Util::WideCharToInt64(applicationAttributeIter->iValue.c_str());
       
   602 			stmtAppAttribute->BindInt64(4, intValue);
       
   603 			}
       
   604 		else if (applicationAttributeIter->iName == L"Attributes")
       
   605 			{
       
   606 			TInt64 intValue = Util::WideCharToInt64(applicationAttributeIter->iValue.c_str());
       
   607 			stmtAppAttribute->BindInt64(5, intValue);
       
   608 			}
       
   609 		else if (applicationAttributeIter->iName == L"Hidden")
       
   610 			{
       
   611 			TInt64 intValue = Util::WideCharToInt64(applicationAttributeIter->iValue.c_str());
       
   612 			stmtAppAttribute->BindInt64(6, intValue);
       
   613 			}
       
   614 		else if (applicationAttributeIter->iName == L"Embeddable")
       
   615 			{
       
   616 			TInt64 intValue = Util::WideCharToInt64(applicationAttributeIter->iValue.c_str());
       
   617 			stmtAppAttribute->BindInt64(7, intValue);
       
   618 			}
       
   619 		else if (applicationAttributeIter->iName == L"Newfile")
       
   620 			{
       
   621 			TInt64 intValue = Util::WideCharToInt64(applicationAttributeIter->iValue.c_str());
       
   622 			stmtAppAttribute->BindInt64(8, intValue);
       
   623 			}
       
   624 		else if (applicationAttributeIter->iName == L"Launch")
       
   625 			{
       
   626 			TInt64 intValue = Util::WideCharToInt64(applicationAttributeIter->iValue.c_str());
       
   627 			stmtAppAttribute->BindInt64(9, intValue);
       
   628 			}
       
   629 		else if (applicationAttributeIter->iName == L"GroupName")
       
   630 			{
       
   631 			stmtAppAttribute->BindStr(10, applicationAttributeIter->iValue);
       
   632 			}
       
   633 		else if (applicationAttributeIter->iName == L"DefaultScreenNumber")
       
   634 			{
       
   635 			TInt64 intValue = Util::WideCharToInt64(applicationAttributeIter->iValue.c_str());
       
   636 			stmtAppAttribute->BindInt64(11, intValue);
       
   637 			}
       
   638 		else
       
   639 			{
       
   640 			std::string errMsg = "Invalid application attribute.";
       
   641 			LOGERROR(errMsg);
       
   642 			throw CException(errMsg,ExceptionCodes::ESqlArgumentError);
       
   643 			}
       
   644 		}
       
   645 
       
   646 		try
       
   647 		{
       
   648 			stmtAppAttribute->ExecuteStatement();
       
   649 			stmtAppAttribute->Reset();
       
   650 		}
       
   651 		catch(CException& aException)
       
   652 		{
       
   653 			LOGERROR(aException.GetMessageA());
       
   654 			LOGERROR("AppUid Already Present in Database");
       
   655 		}
       
   656 
       
   657 	LOGEXIT("CDbLayer::AddAppAttribute()");
       
   658 	return appUid;
       
   659 	}
       
   660 
       
   661 void CDbLayer::AddFileOwnershipInfo( int aAppUid, const std::vector<std::wstring>& aFileOwnershipInfo)
       
   662 	{
       
   663 	LOGENTER("CDbLayer::AddFileOwnershipInfo()");
       
   664 	std::string insertFileOwnershipInfo;
       
   665 	
       
   666 	for(ConstWstringIterator cWstringIter = aFileOwnershipInfo.begin(); cWstringIter != aFileOwnershipInfo.end() ; ++cWstringIter )
       
   667 		{  
       
   668 		insertFileOwnershipInfo = "INSERT INTO FileOwnershipInfo(AppUid,FileName) VALUES(?,?);";
       
   669 		std::auto_ptr<CStatement> stmtFileOwnershipInfo(iScrDbHandler->PrepareStatement(insertFileOwnershipInfo));
       
   670 		
       
   671 		stmtFileOwnershipInfo->BindInt64(1, aAppUid);
       
   672 		stmtFileOwnershipInfo->BindStr(2, *cWstringIter);
       
   673 			
       
   674 		stmtFileOwnershipInfo->ExecuteStatement();
       
   675 		stmtFileOwnershipInfo->Reset();
       
   676 		}
       
   677 	LOGEXIT("CDbLayer::AddFileOwnershipInfo()");
       
   678 	}
       
   679 
       
   680 void CDbLayer::AddServiceInfo( int aAppUid, const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppServiceInfo>& aApplicationServiceInfo)
       
   681 	{
       
   682 	LOGENTER("CDbLayer::AddServiceInfo()");
       
   683 	std::string insertServiceInfo;
       
   684 	
       
   685 	for(ApplicationServiceInfoIterator serviceInfoIter = aApplicationServiceInfo.begin(); serviceInfoIter != aApplicationServiceInfo.end() ; ++serviceInfoIter )
       
   686 		{  
       
   687 		insertServiceInfo = "INSERT INTO ServiceInfo(AppUid,Uid) VALUES(?,?);";
       
   688 		std::auto_ptr<CStatement> stmtServiceInfo(iScrDbHandler->PrepareStatement(insertServiceInfo));
       
   689 		
       
   690 		stmtServiceInfo->BindInt64(1, aAppUid);
       
   691 		stmtServiceInfo->BindInt64(2, serviceInfoIter->iUid);
       
   692 		stmtServiceInfo->ExecuteStatement();
       
   693 		stmtServiceInfo->Reset();
       
   694 		
       
   695 		int serviceId = iScrDbHandler->LastInsertedId();
       
   696 		std::string insertDataType;
       
   697 		
       
   698 		const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TDataType>& datatype = serviceInfoIter->iDataType;
       
   699 		for(ApplicationDataTypeIterator dataTypeIter = datatype.begin(); dataTypeIter != datatype.end() ; ++dataTypeIter )
       
   700 			{  
       
   701 			insertDataType = "INSERT INTO DataType(ServiceId,Priority,Type) VALUES(?,?,?);";
       
   702 			std::auto_ptr<CStatement> stmtDataType(iScrDbHandler->PrepareStatement(insertDataType));
       
   703 			
       
   704 			stmtDataType->BindInt64(1, serviceId);
       
   705 			stmtDataType->BindInt64(2, dataTypeIter->iPriority);
       
   706 			stmtDataType->BindStr(3, dataTypeIter->iType);
       
   707 				
       
   708 			stmtDataType->ExecuteStatement();
       
   709 			stmtDataType->Reset();
       
   710 			}
       
   711 		}
       
   712 	LOGEXIT("CDbLayer::AddServiceInfo()");
       
   713 	}
       
   714 
       
   715 void CDbLayer::AddAppLocalizableInfo( int aAppUid, const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo>& aApplicationLocalizableInfo)
       
   716 {
       
   717 	LOGENTER("CDbLayer::AddAppLocalizableInfo()");
       
   718 	for(ApplicationLocalizableInfoIterator localizableInfoIter = aApplicationLocalizableInfo.begin(); localizableInfoIter != aApplicationLocalizableInfo.end() ; ++localizableInfoIter )
       
   719 	{
       
   720 		AddLocalizableAttribute(aAppUid, localizableInfoIter->iLocalizableAttribute);
       
   721 		int localAppInfoId = iScrDbHandler->LastInsertedId();
       
   722 		AddViewData(localAppInfoId, localizableInfoIter->iViewData);
       
   723 	}
       
   724 	LOGEXIT("CDbLayer::AddAppLocalizableInfo()");
       
   725 }
       
   726 
       
   727 void CDbLayer::AddLocalizableAttribute( int aAppUid, const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TLocalizableAttribute>& aApplicationLocalizableAttribute)
       
   728 {
       
   729 	LOGENTER("CDbLayer::AddLocalizableAttribute()");
       
   730 	std::string insertAppLocalizableInfo;
       
   731 		
       
   732 	insertAppLocalizableInfo = "INSERT INTO LocalizableAppInfo(AppUid,ShortCaption,GroupName,Locale,CaptionAndIconId) VALUES(?,?,?,?,?);";
       
   733 	std::auto_ptr<CStatement> stmtAppLocalizableInfo(iScrDbHandler->PrepareStatement(insertAppLocalizableInfo));
       
   734 
       
   735 	std::string insertCaptionAndIconInfo;
       
   736 		
       
   737 	insertCaptionAndIconInfo = "INSERT INTO CaptionAndIconInfo(Caption,NumberOfIcons,IconFile) VALUES(?,?,?);";
       
   738 	std::auto_ptr<CStatement> stmtCaptionAndIconInfo(iScrDbHandler->PrepareStatement(insertCaptionAndIconInfo));
       
   739 
       
   740 	bool captionAndIconInfoPresent = 0;
       
   741 	//for every TLocalizableAttribute
       
   742 	stmtAppLocalizableInfo->BindInt64(1, aAppUid);
       
   743 	for(LocalizableAttributeIterator localizableAttributeIter = aApplicationLocalizableAttribute.begin(); localizableAttributeIter != aApplicationLocalizableAttribute.end() ; ++localizableAttributeIter )
       
   744 	{
       
   745 		if (localizableAttributeIter->iName == L"ShortCaption")
       
   746 		{
       
   747 			stmtAppLocalizableInfo->BindStr(2, localizableAttributeIter->iValue);
       
   748 		}
       
   749 		else if(localizableAttributeIter->iName == L"GroupName")
       
   750 		{
       
   751 			stmtAppLocalizableInfo->BindStr(3, localizableAttributeIter->iValue);
       
   752 		}
       
   753 		else if(localizableAttributeIter->iName == L"Locale")
       
   754 		{
       
   755 			TInt64 intValue = Util::WideCharToInt64(localizableAttributeIter->iValue.c_str());
       
   756 			stmtAppLocalizableInfo->BindInt64(4, intValue);
       
   757 		}
       
   758 		else if(localizableAttributeIter->iName == L"Caption")
       
   759 		{
       
   760 			stmtCaptionAndIconInfo->BindStr(1, localizableAttributeIter->iValue);
       
   761 			captionAndIconInfoPresent = 1;
       
   762 		}
       
   763 		else if(localizableAttributeIter->iName == L"NumberOfIcons")
       
   764 		{
       
   765 			TInt64 intValue = Util::WideCharToInt64(localizableAttributeIter->iValue.c_str());
       
   766 			stmtCaptionAndIconInfo->BindInt64(2, intValue);
       
   767 			captionAndIconInfoPresent = 1;
       
   768 		}
       
   769 		else if(localizableAttributeIter->iName == L"IconFile")
       
   770 		{
       
   771 			stmtCaptionAndIconInfo->BindStr(3, localizableAttributeIter->iValue);
       
   772 			captionAndIconInfoPresent = 1;
       
   773 		}
       
   774 		else
       
   775 		{
       
   776 			std::string errMsg = "Invalid localizable attribute.";
       
   777 			LOGERROR(errMsg);
       
   778 			throw CException(errMsg,ExceptionCodes::ESqlArgumentError);
       
   779 		}
       
   780 	}
       
   781 	if (captionAndIconInfoPresent)
       
   782 	{
       
   783 		stmtCaptionAndIconInfo->ExecuteStatement();
       
   784 		stmtCaptionAndIconInfo->Reset();
       
   785 		int captionAndIconIdForLocalizableInfo = iScrDbHandler->LastInsertedId();
       
   786 		stmtAppLocalizableInfo->BindInt64(5, captionAndIconIdForLocalizableInfo);
       
   787 	}
       
   788 	stmtAppLocalizableInfo->ExecuteStatement();
       
   789 	stmtAppLocalizableInfo->Reset();
       
   790 	LOGEXIT("CDbLayer::AddLocalizableAttribute()");
       
   791 }
       
   792 
       
   793 
       
   794 void CDbLayer::AddViewData( int alocalAppInfoId, const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TViewData>& aViewData)
       
   795 {
       
   796 	LOGENTER("CDbLayer::AddViewData()");
       
   797 
       
   798 	for(ViewDataIterator viewDataIter = aViewData.begin(); viewDataIter != aViewData.end() ; ++viewDataIter )
       
   799 	{
       
   800 		AddViewDataAttributes(alocalAppInfoId, viewDataIter->iViewDataAttributes);
       
   801 	}
       
   802 
       
   803 	LOGEXIT("CDbLayer::AddViewData()");
       
   804 }
       
   805 
       
   806 
       
   807 void CDbLayer::AddViewDataAttributes( int alocalAppInfoId, const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TViewData::TViewDataAttributes>& aViewDataAttribute)
       
   808 	{
       
   809 	LOGENTER("CDbLayer::AddViewData()");
       
   810 	std::string insertViewData;
       
   811 
       
   812 	insertViewData = "INSERT INTO ViewData(LocalAppInfoId,Uid,ScreenMode,CaptionAndIconId) VALUES(?,?,?,?);";
       
   813 	std::auto_ptr<CStatement> stmtViewData(iScrDbHandler->PrepareStatement(insertViewData));
       
   814 
       
   815 	std::string insertCaptionAndIconInfo;
       
   816 		
       
   817 	insertCaptionAndIconInfo = "INSERT INTO CaptionAndIconInfo(Caption,NumberOfIcons,IconFile) VALUES(?,?,?);";
       
   818 	std::auto_ptr<CStatement> stmtCaptionAndIconInfo(iScrDbHandler->PrepareStatement(insertCaptionAndIconInfo));
       
   819 
       
   820 	bool captionAndIconInfoPresent = 0;
       
   821 	//for every TViewData
       
   822 	stmtViewData->BindInt64(1, alocalAppInfoId);
       
   823 
       
   824 	for(ViewDataAttributeIterator viewDataIter = aViewDataAttribute.begin(); viewDataIter != aViewDataAttribute.end() ; ++viewDataIter )
       
   825 		{
       
   826 		if (viewDataIter->iName == L"Uid")
       
   827 			{
       
   828 			TInt64 intValue = Util::WideCharToInt64(viewDataIter->iValue.c_str());
       
   829 			stmtViewData->BindInt64(2, intValue);
       
   830 			}
       
   831 		else if(viewDataIter->iName == L"ScreenMode")
       
   832 			{
       
   833 			TInt64 intValue = Util::WideCharToInt64(viewDataIter->iValue.c_str());
       
   834 			stmtViewData->BindInt64(3, intValue);
       
   835 			}
       
   836 		else if(viewDataIter->iName == L"Caption")
       
   837 			{
       
   838 			stmtCaptionAndIconInfo->BindStr(1, viewDataIter->iValue);
       
   839 			captionAndIconInfoPresent = 1;
       
   840 			}
       
   841 		else if(viewDataIter->iName == L"NumberOfIcons")
       
   842 			{
       
   843 			TInt64 intValue = Util::WideCharToInt64(viewDataIter->iValue.c_str());
       
   844 			stmtCaptionAndIconInfo->BindInt64(2, intValue);
       
   845 			captionAndIconInfoPresent = 1;
       
   846 			}
       
   847 		else if(viewDataIter->iName == L"IconFile")
       
   848 			{
       
   849 			stmtCaptionAndIconInfo->BindStr(3, viewDataIter->iValue);
       
   850 			captionAndIconInfoPresent = 1;
       
   851 			}
       
   852 		else
       
   853 			{
       
   854 			std::string errMsg = "Invalid view data attribute.";
       
   855 			LOGERROR(errMsg);
       
   856 			throw CException(errMsg,ExceptionCodes::ESqlArgumentError);
       
   857 			}
       
   858 		}
       
   859 	if (captionAndIconInfoPresent)
       
   860 		{
       
   861 		stmtCaptionAndIconInfo->ExecuteStatement();
       
   862 		stmtCaptionAndIconInfo->Reset();
       
   863 		int captionAndIconIdForViewData = iScrDbHandler->LastInsertedId();
       
   864 		stmtViewData->BindInt64(4, captionAndIconIdForViewData);
       
   865 		}
       
   866 	stmtViewData->ExecuteStatement();
       
   867 	stmtViewData->Reset();
       
   868 	LOGEXIT("CDbLayer::AddViewData()");
       
   869 	}
       
   870 
       
   871 void CDbLayer::AddProperty( int aAppUid, const std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppProperty>& aApplicationProperty)
       
   872 	{
       
   873 	LOGENTER("CDbLayer::AddProperty()");
       
   874 	std::string insertApplicationProperty;
       
   875 
       
   876 	for(ApplicationPropertyIterator appPropertyIter = aApplicationProperty.begin(); appPropertyIter != aApplicationProperty.end() ; ++appPropertyIter )
       
   877 		{  
       
   878 
       
   879 		insertApplicationProperty = "INSERT INTO AppProperties(AppUid,Locale,Name,ServiceUid,IntValue,StrValue,IsStr8Bit) VALUES(?,?,?,?,?,?,?);";
       
   880 		std::auto_ptr<CStatement> stmtAppProperty(iScrDbHandler->PrepareStatement(insertApplicationProperty));
       
   881 		
       
   882 		stmtAppProperty->BindInt64(1, aAppUid);
       
   883 		stmtAppProperty->BindInt(2, appPropertyIter->iLocale);
       
   884 		stmtAppProperty->BindStr(3, appPropertyIter->iName);
       
   885 		stmtAppProperty->BindInt(4, appPropertyIter->iServiceUid);
       
   886 		stmtAppProperty->BindInt(5, appPropertyIter->iIntValue);
       
   887 
       
   888 		if(appPropertyIter->iIsStr8Bit)
       
   889 			{
       
   890 			std::string str = Util::wstring2string(appPropertyIter->iStrValue);
       
   891 			std::string decodedString = Util::Base64Decode(str);
       
   892 			stmtAppProperty->BindBinary(6, str);
       
   893 			}
       
   894 		else
       
   895 			{
       
   896 			stmtAppProperty->BindStr(6, appPropertyIter->iStrValue);
       
   897 			}
       
   898 		
       
   899 		stmtAppProperty->BindInt(7, appPropertyIter->iIsStr8Bit);
       
   900 
       
   901 		stmtAppProperty->ExecuteStatement();
       
   902 		stmtAppProperty->Reset();
       
   903 		}
       
   904 	LOGEXIT("CDbLayer::AddProperty()");
       
   905 	}
       
   906 
   461 void CDbLayer::ExecuteStatement(const std::string& aStmtStr)
   907 void CDbLayer::ExecuteStatement(const std::string& aStmtStr)
   462 	{
   908 	{
   463 	std::auto_ptr<CStatement> stmt(iScrDbHandler->PrepareStatement(aStmtStr));
   909 	std::auto_ptr<CStatement> stmt(iScrDbHandler->PrepareStatement(aStmtStr));
   464 	stmt->ExecuteStatement();
   910 	stmt->ExecuteStatement();
   465 	}
   911 	}