secureswitools/swisistools/source/dbmanager/dblayer.cpp
changeset 60 245df5276b97
parent 33 8110bf1194d1
child 67 3a625661d1ce
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
    19 #include "dblayer.h"
    19 #include "dblayer.h"
    20 #include "exception.h"
    20 #include "exception.h"
    21 #include "logs.h"
    21 #include "logs.h"
    22 #include "util.h"
    22 #include "util.h"
    23 #include "symbiantypes.h"
    23 #include "symbiantypes.h"
       
    24 #include "../sisxlibrary/utility.h"
    24 
    25 
    25 #include <string>
    26 #include <string>
    26 #include <vector>
    27 #include <vector>
    27 #include <algorithm>
    28 #include <algorithm>
    28 #include <sstream>
    29 #include <sstream>
    52 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TViewData>::const_iterator ViewDataIterator;
    53 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::TAppLocalizableInfo::TViewData::TViewDataAttributes>::const_iterator ViewDataAttributeIterator;
    54 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppProperty>::const_iterator ApplicationPropertyIterator;
    55 typedef std::vector<XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppProperty>::const_iterator ApplicationPropertyIterator;
    55 
    56 
    56 
    57 
       
    58 #ifdef __LINUX__
       
    59 
       
    60 /*
       
    61 * Platform specific feature
       
    62 *
       
    63 * In WINDOWS : sizeof(wchar_t) = 2
       
    64 * In LINUX   : sizeof(wchar_t) = 4
       
    65 */
       
    66 
       
    67 static utf16WString utf32WString2utf16WString(std::wstring aParameter)
       
    68 {
       
    69 	int strLen = aParameter.length();
       
    70 	const wchar_t * source = aParameter.c_str();
       
    71 	unsigned short int* buffer = new unsigned short int[strLen + 1];
       
    72 
       
    73 	// Using a temp variable in place of buffer as ConvertUTF32toUTF16 modifies the source pointer passed.
       
    74 	unsigned short int* temp = buffer;
       
    75 
       
    76 	ConvertUTF32toUTF16(&source, source + strLen, &temp,  temp + strLen, lenientConversion);
       
    77 
       
    78 	// Appending NUL to the converted buffer.
       
    79 	*temp = 0;
       
    80 
       
    81 	utf16WString utf16Ws;
       
    82 	utf16Ws.resize(strLen);
       
    83 
       
    84 	// The built-in basic_string template class copy operation
       
    85 	// truncates when a NUL is encountered when a c_str() is
       
    86 	// used to construct the required string.
       
    87 	// So, if aParameter is any hashable string having the
       
    88 	// syntax : swtypeName + L'\0' + someId then, we will end
       
    89 	// up returning only part of the converted UTF-16 string.
       
    90 	// Hence, we resort to the explicit copy operation with
       
    91 	// two bytes at a time.
       
    92 	while( strLen-- )
       
    93 	{
       
    94 		utf16Ws[ strLen ] = buffer[ strLen ];
       
    95 	}
       
    96 
       
    97 	delete[] buffer;
       
    98 
       
    99 	return utf16Ws;
       
   100 }
       
   101 
       
   102 #else
       
   103 
       
   104 // We need not do anything for WINDOWS, since the windows wstring
       
   105 // will already be in UTF-16 encoding.
       
   106 #define utf32WString2utf16WString(aParameter) (aParameter)
       
   107 
       
   108 #endif
       
   109 
       
   110 
       
   111 
    57 const int KMaxDrives=26;
   112 const int KMaxDrives=26;
    58 
   113 
    59 CDbLayer::CDbLayer(const std::string& aDllPath, const std::string& aSqlDbName)
   114 CDbLayer::CDbLayer(const std::string& aDllPath, const std::string& aSqlDbName)
    60 	{
   115 	{
    61 	iScrDbHandler = new CDbProcessor(aDllPath, aSqlDbName);
   116 	iScrDbHandler = new CDbProcessor(aDllPath, aSqlDbName);
   138 	std::string insertMimeType("INSERT INTO MimeTypes(SoftwareTypeId,MimeType) VALUES(?,?);");
   193 	std::string insertMimeType("INSERT INTO MimeTypes(SoftwareTypeId,MimeType) VALUES(?,?);");
   139 	std::auto_ptr<CStatement> stmtMimeType(iScrDbHandler->PrepareStatement(insertMimeType));
   194 	std::auto_ptr<CStatement> stmtMimeType(iScrDbHandler->PrepareStatement(insertMimeType));
   140 
   195 
   141 	for(ScrEnvIterator aScrEnvIterator = aScrEnvDetails.begin(); aScrEnvIterator != aScrEnvDetails.end(); ++aScrEnvIterator)
   196 	for(ScrEnvIterator aScrEnvIterator = aScrEnvDetails.begin(); aScrEnvIterator != aScrEnvDetails.end(); ++aScrEnvIterator)
   142 		{
   197 		{
   143 		unsigned int swTypeId = Util::Crc32(aScrEnvIterator->iUniqueSoftwareTypeName.c_str(),aScrEnvIterator->iUniqueSoftwareTypeName.length()*2);
   198 		// To maintain the consistency of CRC value across the platforms(WINDOWS and LINUX), we are
       
   199 		// using UTF-16 string in CRC generation.
       
   200 		utf16WString utf16Ws = utf32WString2utf16WString(aScrEnvIterator->iUniqueSoftwareTypeName);
       
   201 		unsigned int swTypeId = Util::Crc32(utf16Ws.c_str(),aScrEnvIterator->iUniqueSoftwareTypeName.length()*2);
       
   202 
   144 		if (!aScrEnvIterator->iLauncherExecutable.empty())
   203 		if (!aScrEnvIterator->iLauncherExecutable.empty())
   145 		{
   204 		{
   146 		stmtSwType->BindInt(1, swTypeId);
   205 		stmtSwType->BindInt(1, swTypeId);
   147 		stmtSwType->BindInt(2, aScrEnvIterator->iSifPluginUid);
   206 		stmtSwType->BindInt(2, aScrEnvIterator->iSifPluginUid);
   148 		stmtSwType->BindStr(3, aScrEnvIterator->iLauncherExecutable);
   207 		stmtSwType->BindStr(3, aScrEnvIterator->iLauncherExecutable);
   215 	{
   274 	{
   216 	LOGENTER("CDbLayer::AddComponentDetails()");
   275 	LOGENTER("CDbLayer::AddComponentDetails()");
   217 	std::string insertComponents;
   276 	std::string insertComponents;
   218 	XmlDetails::TScrPreProvisionDetail::TComponentDetails 
   277 	XmlDetails::TScrPreProvisionDetail::TComponentDetails 
   219 		componentDetail = aComponent.iComponentDetails;
   278 		componentDetail = aComponent.iComponentDetails;
   220 
       
   221 	if (aComponent.iComponentDetails.iIsRomApplication)
   279 	if (aComponent.iComponentDetails.iIsRomApplication)
   222 		{
   280 		{
   223 		LOGINFO("Is rom app");
   281 		LOGINFO("Is rom app");
   224 		return true;
   282 		return true;
   225 		}
   283 		}
   226 	LOGINFO("Not rom app");
   284 	LOGINFO("Not rom app");
   227 	unsigned int swTypeId = Util::Crc32(aSoftwareTypeName.c_str(),aSoftwareTypeName.length()*2);
   285 
       
   286 	// To maintain the consistency of CRC value across the platforms(WINDOWS and LINUX), we are
       
   287 	// using UTF-16 string in CRC generation.
       
   288     utf16WString utf16Ws = utf32WString2utf16WString(aSoftwareTypeName);
       
   289 	unsigned int swTypeId = Util::Crc32(utf16Ws.c_str(),aSoftwareTypeName.length()*2);
       
   290 
       
   291 
   228 	std::wstring strGlobalId = componentDetail.iGlobalId;
   292 	std::wstring strGlobalId = componentDetail.iGlobalId;
   229 	
   293 	
   230 	if(!strGlobalId.empty())
   294 	if(!strGlobalId.empty())
   231 		{
   295 		{
   232 		insertComponents = "INSERT INTO Components(SoftwareTypeId, SoftwareTypeName, Removable, Size, ScomoState, InstalledDrives, OriginVerified, Hidden, GlobalIdHash, GlobalId, Version, InstallTime) VALUES(?,?,?,?,?,?,?,?,?,?,?,?);";
   296 		insertComponents = "INSERT INTO Components(SoftwareTypeId, SoftwareTypeName, Removable, Size, ScomoState, InstalledDrives, OriginVerified, Hidden, GlobalIdHash, GlobalId, Version, InstallTime) VALUES(?,?,?,?,?,?,?,?,?,?,?,?);";
   260 	std::wstring localTime = GetLocalTime();
   324 	std::wstring localTime = GetLocalTime();
   261 	
   325 	
   262 	if(!strGlobalId.empty())
   326 	if(!strGlobalId.empty())
   263 		{
   327 		{
   264 		std::wstring concatGlobalId = aSoftwareTypeName + L'\0' + strGlobalId;
   328 		std::wstring concatGlobalId = aSoftwareTypeName + L'\0' + strGlobalId;
   265 		unsigned int globalIdHash = Util::Crc32(concatGlobalId.c_str(),concatGlobalId.length()*2);
   329 
       
   330 		// To maintain the consistency of CRC value across the platforms(WINDOWS and LINUX), we are
       
   331 		// using UTF-16 string in CRC generation.
       
   332 		utf16WString utf16Ws = utf32WString2utf16WString(concatGlobalId);
       
   333 		unsigned int globalIdHash = Util::Crc32(utf16Ws.c_str(),concatGlobalId.length()*2);
       
   334 
   266 		stmtComponents->BindInt(9, globalIdHash);
   335 		stmtComponents->BindInt(9, globalIdHash);
   267 		stmtComponents->BindStr(10, concatGlobalId);
   336 		stmtComponents->BindStr(10, concatGlobalId);
   268 		stmtComponents->BindStr(11, version);
   337 		stmtComponents->BindStr(11, version);
   269 		stmtComponents->BindStr(12, localTime);
   338 		stmtComponents->BindStr(12, localTime);
   270 		}
   339 		}
   374 			}
   443 			}
   375 		else
   444 		else
   376 			{
   445 			{
   377 			if(compPropIter->iIsStr8Bit)
   446 			if(compPropIter->iIsStr8Bit)
   378 				{
   447 				{
   379 				std::string str = Util::wstring2string(compPropIter->iValue);
   448 				std::string str = wstring2string(compPropIter->iValue);
   380 				std::string decodedString = Util::Base64Decode(str);
   449 				std::string decodedString = Util::Base64Decode(str);
   381 				stmtComponentProperty->BindBinary(4, str);
   450 				stmtComponentProperty->BindBinary(4, decodedString);
   382 				}
   451 				}
   383 			else
   452 			else
   384 				{
   453 				{
   385 				stmtComponentProperty->BindStr(4, compPropIter->iValue);
   454 				stmtComponentProperty->BindStr(4, compPropIter->iValue);
   386 				}
   455 				}
   427 	std::vector<XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail>::const_iterator compDepIter;
   496 	std::vector<XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail>::const_iterator compDepIter;
   428 
   497 
   429 	for(compDepIter = aComponentDependencyDetails.begin() ; compDepIter != aComponentDependencyDetails.end() ; ++compDepIter)
   498 	for(compDepIter = aComponentDependencyDetails.begin() ; compDepIter != aComponentDependencyDetails.end() ; ++compDepIter)
   430 		{
   499 		{
   431 		std::wstring concatGlobalId = dependantGlobalId + compDepIter->iSupplierId;
   500 		std::wstring concatGlobalId = dependantGlobalId + compDepIter->iSupplierId;
   432 				
   501 
   433 		unsigned int globalIdHash = Util::Crc32(concatGlobalId.c_str(),concatGlobalId.length()*2);
   502 		// To maintain the consistency of CRC value across the platforms(WINDOWS and LINUX), we are
   434 		unsigned int dependantIdHash = Util::Crc32(dependantGlobalId.c_str(),dependantGlobalId.length()*2);
   503 		// using UTF-16 string in CRC generation.
   435 		unsigned int supplierIdHash = Util::Crc32(compDepIter->iSupplierId.c_str(),compDepIter->iSupplierId.length()*2);
   504 		utf16WString utf16Ws = utf32WString2utf16WString(concatGlobalId);
   436 		
   505 		unsigned int globalIdHash = Util::Crc32(utf16Ws.c_str(),concatGlobalId.length()*2);
       
   506 
       
   507 		utf16Ws = utf32WString2utf16WString(dependantGlobalId);
       
   508 		unsigned int dependantIdHash = Util::Crc32(utf16Ws.c_str(),dependantGlobalId.length()*2);
       
   509 
       
   510 		utf16Ws = utf32WString2utf16WString(compDepIter->iSupplierId);
       
   511 		unsigned int supplierIdHash = Util::Crc32(utf16Ws.c_str(),compDepIter->iSupplierId.length()*2);
       
   512 
       
   513 
   437 		std::string insertComponentDeps("INSERT INTO ComponentDependencies(GlobalIdHash,DependantGlobalIdHash, SupplierGlobalIdHash, DependantGlobalId,SupplierGlobalId,VersionFrom,VersionTo) VALUES(?,?,?,?,?,?,?);");
   514 		std::string insertComponentDeps("INSERT INTO ComponentDependencies(GlobalIdHash,DependantGlobalIdHash, SupplierGlobalIdHash, DependantGlobalId,SupplierGlobalId,VersionFrom,VersionTo) VALUES(?,?,?,?,?,?,?);");
   438 		std::auto_ptr<CStatement> stmtComponentDeps(iScrDbHandler->PrepareStatement(insertComponentDeps));
   515 		std::auto_ptr<CStatement> stmtComponentDeps(iScrDbHandler->PrepareStatement(insertComponentDeps));
   439 		
   516 		
   440 		stmtComponentDeps->BindInt( 1 ,globalIdHash);
   517 		stmtComponentDeps->BindInt( 1 ,globalIdHash);
   441 		stmtComponentDeps->BindInt( 2 ,dependantIdHash);
   518 		stmtComponentDeps->BindInt( 2 ,dependantIdHash);
   458 	std::string insertComponentFileDetails("INSERT INTO ComponentsFiles(ComponentId,LocationHash,Location) VALUES(?,?,?);");
   535 	std::string insertComponentFileDetails("INSERT INTO ComponentsFiles(ComponentId,LocationHash,Location) VALUES(?,?,?);");
   459 	std::auto_ptr<CStatement> stmtComponentFileDetails(iScrDbHandler->PrepareStatement(insertComponentFileDetails));
   536 	std::auto_ptr<CStatement> stmtComponentFileDetails(iScrDbHandler->PrepareStatement(insertComponentFileDetails));
   460 	
   537 	
   461 	stmtComponentFileDetails->BindInt(1,aComponentId);
   538 	stmtComponentFileDetails->BindInt(1,aComponentId);
   462 	
   539 	
   463 	// size does not return the actual binary size of the object
       
   464 	int length = aLocation.length()*2 ;
   540 	int length = aLocation.length()*2 ;
       
   541 
   465 	// generate hash for location
   542 	// generate hash for location
   466 	std::wstring location = aLocation;
   543 	std::wstring location = aLocation;
   467 	std::transform(	location.begin(), location.end(), location.begin(), tolower);
   544 	std::transform(	location.begin(), location.end(), location.begin(), tolower);
   468 
   545 
   469 	unsigned int hash = Util::Crc32(location.c_str(),length);
   546 	#ifdef __TOOLS2_LINUX__
   470 	
   547 
       
   548 	// To maintain the consistency of the LocationHash value(essentially the CRC of
       
   549 	// Location string) across the WINDOWS and LINUX platforms, we reconstruct the
       
   550 	// location to have WINDOWS specific path.
       
   551 
       
   552     std::wstring::size_type idx = 0;
       
   553      while( (idx = location.find(L"//", idx)) != std::wstring::npos)
       
   554      {
       
   555     	 location.replace( idx, 2, L"\\\\" );
       
   556      }
       
   557 
       
   558      idx = 0;
       
   559 
       
   560      while( (idx = location.find(L"/", idx)) != std::wstring::npos)
       
   561      {
       
   562     	 location.replace( idx, 1, L"\\" );
       
   563      }
       
   564 
       
   565 	#endif
       
   566 
       
   567 
       
   568 	// To maintain the consistency of CRC value across the platforms(WINDOWS and LINUX), we are
       
   569 	// using UTF-16 string in CRC generation.
       
   570 
       
   571 	utf16WString utf16Ws = utf32WString2utf16WString(location);
       
   572 	unsigned int hash = Util::Crc32(utf16Ws.c_str(),length);
       
   573 
   471 	stmtComponentFileDetails->BindInt(2,hash);
   574 	stmtComponentFileDetails->BindInt(2,hash);
   472 	stmtComponentFileDetails->BindStr(3,aLocation);
   575 	stmtComponentFileDetails->BindStr(3,aLocation);
   473 	stmtComponentFileDetails->ExecuteStatement();
   576 	stmtComponentFileDetails->ExecuteStatement();
   474 	stmtComponentFileDetails->Reset();
   577 	stmtComponentFileDetails->Reset();
   475 		
   578 		
   502 			int intValue = Util::WideCharToInteger(filePropIter->iValue.c_str());
   605 			int intValue = Util::WideCharToInteger(filePropIter->iValue.c_str());
   503 			stmtFileProperty->BindInt(3, intValue);
   606 			stmtFileProperty->BindInt(3, intValue);
   504 			}
   607 			}
   505 		else
   608 		else
   506 			{
   609 			{
   507 			std::string str = Util::wstring2string(filePropIter->iValue);
   610 			std::string str = wstring2string(filePropIter->iValue);
   508 			std::string decodedString = Util::Base64Decode(str);
   611 			std::string decodedString = Util::Base64Decode(str);
   509 			stmtFileProperty->BindBinary(3, str);
   612 			stmtFileProperty->BindBinary(3, decodedString);
   510 			stmtFileProperty->BindInt(4, 1);
   613 			stmtFileProperty->BindInt(4, 1);
   511 			}
   614 			}
   512 
   615 
   513 		stmtFileProperty->ExecuteStatement();
   616 		stmtFileProperty->ExecuteStatement();
   514 		stmtFileProperty->Reset();
   617 		stmtFileProperty->Reset();
   572 	
   675 	
   573 	insertAppAttributes = "INSERT INTO AppRegistrationInfo(AppUid,ComponentId,AppFile,TypeId,Attributes,Hidden,Embeddable,Newfile,Launch,GroupName,DefaultScreenNumber) VALUES(?,?,?,?,?,?,?,?,?,?,?);";
   676 	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));
   677 	std::auto_ptr<CStatement> stmtAppAttribute(iScrDbHandler->PrepareStatement(insertAppAttributes));
   575 
   678 
   576 	stmtAppAttribute->BindInt64(2, aComponentId);
   679 	stmtAppAttribute->BindInt64(2, aComponentId);
       
   680 
       
   681 	//Assigning Default Values
       
   682 	TInt64 intVal = 0; 
       
   683 	stmtAppAttribute->BindInt64(5, intVal); //Attributes
       
   684 	stmtAppAttribute->BindInt64(6, intVal); //Hidden
       
   685 	stmtAppAttribute->BindInt64(7, intVal); //Embeddable
       
   686 	stmtAppAttribute->BindInt64(8, intVal); //Newfile
       
   687 	stmtAppAttribute->BindInt64(9, intVal); //Launch
       
   688 	stmtAppAttribute->BindInt64(11, intVal); //DefaultScreenNumber
       
   689 	std::wstring strVal(L"");
       
   690 	stmtAppAttribute->BindStr(10, strVal); //GroupName
       
   691 	
   577 	int appUid = 0;
   692 	int appUid = 0;
   578 	std::string appfile;
   693 	std::string appfile;
   579 	for(ApplicationAttributeIterator applicationAttributeIter = aAppAttribute.begin(); applicationAttributeIter != aAppAttribute.end() ; ++applicationAttributeIter )
   694 	for(ApplicationAttributeIterator applicationAttributeIter = aAppAttribute.begin(); applicationAttributeIter != aAppAttribute.end() ; ++applicationAttributeIter )
   580 		{
   695 		{
   581 		if (applicationAttributeIter->iName == L"AppUid")
   696 		if (applicationAttributeIter->iName == L"AppUid")
   701 			insertDataType = "INSERT INTO DataType(ServiceId,Priority,Type) VALUES(?,?,?);";
   816 			insertDataType = "INSERT INTO DataType(ServiceId,Priority,Type) VALUES(?,?,?);";
   702 			std::auto_ptr<CStatement> stmtDataType(iScrDbHandler->PrepareStatement(insertDataType));
   817 			std::auto_ptr<CStatement> stmtDataType(iScrDbHandler->PrepareStatement(insertDataType));
   703 			
   818 			
   704 			stmtDataType->BindInt64(1, serviceId);
   819 			stmtDataType->BindInt64(1, serviceId);
   705 			stmtDataType->BindInt64(2, dataTypeIter->iPriority);
   820 			stmtDataType->BindInt64(2, dataTypeIter->iPriority);
       
   821 			#ifdef __TOOLS2_LINUX__
       
   822 			stmtDataType->BindStr(3, dataTypeIter->iType, avoidSlashConversion);
       
   823 			#else
   706 			stmtDataType->BindStr(3, dataTypeIter->iType);
   824 			stmtDataType->BindStr(3, dataTypeIter->iType);
       
   825 			#endif
   707 				
   826 				
   708 			stmtDataType->ExecuteStatement();
   827 			stmtDataType->ExecuteStatement();
   709 			stmtDataType->Reset();
   828 			stmtDataType->Reset();
   710 			}
   829 			}
   711 		}
   830 		}
   730 	std::string insertAppLocalizableInfo;
   849 	std::string insertAppLocalizableInfo;
   731 		
   850 		
   732 	insertAppLocalizableInfo = "INSERT INTO LocalizableAppInfo(AppUid,ShortCaption,GroupName,Locale,CaptionAndIconId) VALUES(?,?,?,?,?);";
   851 	insertAppLocalizableInfo = "INSERT INTO LocalizableAppInfo(AppUid,ShortCaption,GroupName,Locale,CaptionAndIconId) VALUES(?,?,?,?,?);";
   733 	std::auto_ptr<CStatement> stmtAppLocalizableInfo(iScrDbHandler->PrepareStatement(insertAppLocalizableInfo));
   852 	std::auto_ptr<CStatement> stmtAppLocalizableInfo(iScrDbHandler->PrepareStatement(insertAppLocalizableInfo));
   734 
   853 
       
   854 	//Assigning default value
       
   855 	TInt64 intVal = 0;
       
   856 	stmtAppLocalizableInfo->BindInt64(4, intVal); //Locale
       
   857 	std::wstring strVal(L"");
       
   858 	stmtAppLocalizableInfo->BindStr(2, strVal); //ShortCaption
       
   859 	stmtAppLocalizableInfo->BindStr(3, strVal); //GroupName
       
   860 
   735 	std::string insertCaptionAndIconInfo;
   861 	std::string insertCaptionAndIconInfo;
   736 		
   862 		
   737 	insertCaptionAndIconInfo = "INSERT INTO CaptionAndIconInfo(Caption,NumberOfIcons,IconFile) VALUES(?,?,?);";
   863 	insertCaptionAndIconInfo = "INSERT INTO CaptionAndIconInfo(Caption,NumberOfIcons,IconFile) VALUES(?,?,?);";
   738 	std::auto_ptr<CStatement> stmtCaptionAndIconInfo(iScrDbHandler->PrepareStatement(insertCaptionAndIconInfo));
   864 	std::auto_ptr<CStatement> stmtCaptionAndIconInfo(iScrDbHandler->PrepareStatement(insertCaptionAndIconInfo));
   739 
   865 
   814 
   940 
   815 	std::string insertCaptionAndIconInfo;
   941 	std::string insertCaptionAndIconInfo;
   816 		
   942 		
   817 	insertCaptionAndIconInfo = "INSERT INTO CaptionAndIconInfo(Caption,NumberOfIcons,IconFile) VALUES(?,?,?);";
   943 	insertCaptionAndIconInfo = "INSERT INTO CaptionAndIconInfo(Caption,NumberOfIcons,IconFile) VALUES(?,?,?);";
   818 	std::auto_ptr<CStatement> stmtCaptionAndIconInfo(iScrDbHandler->PrepareStatement(insertCaptionAndIconInfo));
   944 	std::auto_ptr<CStatement> stmtCaptionAndIconInfo(iScrDbHandler->PrepareStatement(insertCaptionAndIconInfo));
       
   945 
       
   946 	//Assigning Default Value
       
   947 	TInt64 intVal = 0;
       
   948 	stmtViewData->BindInt64(3, intVal); //ScreenMode
       
   949 	stmtCaptionAndIconInfo->BindInt64(2, intVal); //NumberOfIcons
       
   950 	std::wstring strVal(L"");
       
   951 	stmtCaptionAndIconInfo->BindStr(3, strVal); //IconFile
   819 
   952 
   820 	bool captionAndIconInfoPresent = 0;
   953 	bool captionAndIconInfoPresent = 0;
   821 	//for every TViewData
   954 	//for every TViewData
   822 	stmtViewData->BindInt64(1, alocalAppInfoId);
   955 	stmtViewData->BindInt64(1, alocalAppInfoId);
   823 
   956 
   885 		stmtAppProperty->BindInt(4, appPropertyIter->iServiceUid);
  1018 		stmtAppProperty->BindInt(4, appPropertyIter->iServiceUid);
   886 		stmtAppProperty->BindInt(5, appPropertyIter->iIntValue);
  1019 		stmtAppProperty->BindInt(5, appPropertyIter->iIntValue);
   887 
  1020 
   888 		if(appPropertyIter->iIsStr8Bit)
  1021 		if(appPropertyIter->iIsStr8Bit)
   889 			{
  1022 			{
   890 			stmtAppProperty->BindBinary(6, appPropertyIter->iStrValue);
  1023 				std::string str = wstring2string(appPropertyIter->iStrValue);
       
  1024 				std::string decodedString = Util::Base64Decode(str);
       
  1025 				stmtAppProperty->BindBinary(6, decodedString);
   891 			}
  1026 			}
   892 		else
  1027 		else
   893 			{
  1028 			{
   894 			stmtAppProperty->BindStr(6, appPropertyIter->iStrValue);
  1029 			stmtAppProperty->BindStr(6, appPropertyIter->iStrValue);
   895 			}
  1030 			}