installationservices/swi/source/sisregistry/server_legacy/sisregistrycache.cpp
branchRCL_3
changeset 66 8b7f4e561641
parent 65 7333d7932ef7
equal deleted inserted replaced
65:7333d7932ef7 66:8b7f4e561641
    80 	{
    80 	{
    81 	TInt res;
    81 	TInt res;
    82 	// General note: trap the error because this is not a leaving function
    82 	// General note: trap the error because this is not a leaving function
    83 	// and generating an error will not help 
    83 	// and generating an error will not help 
    84 
    84 
    85 	// store the backup file out 
    85 	if (iIntegrityService)
    86  	TRAP(res, StoreBackupL());
    86 	    {
    87  	if (res != KErrNone)
    87 	    // store the backup file out 
    88  		{
    88 	    TRAP(res, StoreBackupL());
    89  	DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to store backup (failure code: %d.)"), res);
    89 	    if (res != KErrNone)
    90  		}
    90 	        {
    91 
    91 	        DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to store backup (failure code: %d.)"), res);
    92 	// integrity service operation committing point 
    92 	        }
    93 	TRAP(res, iIntegrityService->CommitL());
    93 
    94 	if (res != KErrNone)
    94 	    // integrity service operation committing point 
    95  		{
    95 	    TRAP(res, iIntegrityService->CommitL());
    96 	DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to commit integrity services changes (failure code %d.)"), res);
    96 	    if (res != KErrNone)
    97  		}
    97 	        {
    98 
    98 	        DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to commit integrity services changes (failure code %d.)"), res);
       
    99 	        }
       
   100 	    }
       
   101 	
    99 	delete iBackupFile;
   102 	delete iBackupFile;
   100 	
   103 	
   101 	delete iIntegrityService;
   104 	delete iIntegrityService;
   102 	delete iSisRegLangMonitor;
   105 	delete iSisRegLangMonitor;
   103 	CleanUp();
   106 	CleanUp();
   181 		}
   184 		}
   182 	}
   185 	}
   183 
   186 
   184 void CSisRegistryCache::PackageListL(RPointerArray<CSisRegistryPackage>& aPackages) const
   187 void CSisRegistryCache::PackageListL(RPointerArray<CSisRegistryPackage>& aPackages) const
   185 	{
   188 	{
       
   189 	CleanupResetAndDestroyPushL(aPackages);
   186 	aPackages.ResetAndDestroy();
   190 	aPackages.ResetAndDestroy();
       
   191 	
   187 	for (TInt i = 0; i < iTokens.Count(); i++)
   192 	for (TInt i = 0; i < iTokens.Count(); i++)
   188 		{
   193 		{
   189 		CSisRegistryPackage *package = CSisRegistryPackage::NewLC(*iTokens[i]);
   194 		CSisRegistryPackage *package = CSisRegistryPackage::NewLC(*iTokens[i]);
   190 		aPackages.AppendL(package);
   195 		aPackages.AppendL(package);
   191 		CleanupStack::Pop(package);
   196 		CleanupStack::Pop(package);
   192 		}
   197 		}
   193 	}
   198 	CleanupStack::Pop(&aPackages);
       
   199 	}
       
   200 
       
   201 const RPointerArray<CSisRegistryToken>& CSisRegistryCache::TokenList() const
       
   202     {
       
   203     return iTokens;
       
   204     }
   194 	
   205 	
   195 RFs& CSisRegistryCache::RFsHandle()
   206 RFs& CSisRegistryCache::RFsHandle()
   196 	{ 
   207 	{ 
   197 	return iFs;
   208 	return iFs;
   198 	}
   209 	}
   436 			{
   447 			{
   437 			DEBUG_PRINTF(_L8("Sis Registry Server - Registry file does not match entry directory. Corrupt."));
   448 			DEBUG_PRINTF(_L8("Sis Registry Server - Registry file does not match entry directory. Corrupt."));
   438 			User::Leave(KErrCorrupt);	
   449 			User::Leave(KErrCorrupt);	
   439 			}
   450 			}
   440 			
   451 			
   441 		iTokens.Append(token);
   452 		iTokens.AppendL(token);
   442 		CleanupStack::Pop(token);
   453 		CleanupStack::Pop(token);
   443 		CleanupStack::PopAndDestroy(&fileStream);
   454 		CleanupStack::PopAndDestroy(&fileStream);
   444 				
   455 				
   445 		}
   456 		}
   446 
   457 
   512 	UpdatePackagePresentStateL();
   523 	UpdatePackagePresentStateL();
   513 	}
   524 	}
   514 	
   525 	
   515 void CSisRegistryCache::InitStartUpL()
   526 void CSisRegistryCache::InitStartUpL()
   516 	{
   527 	{
   517 	// else reinit lists- initial settings, esp at the first reboot
       
   518 	BuildUidListL();
       
   519 	iUseIntegServices = EFalse; // temporarily "turn off" integrity services. It is not needed to process ROM stubs
       
   520 	BuildRomListL();
       
   521 	iUseIntegServices = ETrue;
       
   522 	
       
   523 	// While building the UIDs and the ROM list, new files could've been generated, so we should commit the changes to the FS.
       
   524 	iIntegrityService->CommitL();
       
   525 			
       
   526 	// only when all is processed one can check the package state		
       
   527 	UpdatePackagePresentStateL();
       
   528 	
       
   529     TRAPD(res, UpdateRecentFWVersionL(););
   528     TRAPD(res, UpdateRecentFWVersionL(););
   530     if (res != KErrNone)
   529     if (res != KErrNone)
   531         {
   530         {
   532         // log that
   531         // log that
   533         DEBUG_PRINTF2(_L8("Updating recent Firmware Version failed with error code = %d."), res);
   532         DEBUG_PRINTF2(_L8("Updating recent Firmware Version failed with error code = %d."), res);
   534         }
   533         }
       
   534 	
       
   535 	// else reinit lists- initial settings, esp at the first reboot
       
   536 	BuildUidListL();
       
   537 	iUseIntegServices = EFalse; // temporarily "turn off" integrity services. It is not needed to process ROM stubs
       
   538 	BuildRomListL();
       
   539 	iUseIntegServices = ETrue;
       
   540 	
       
   541 	// While building the UIDs and the ROM list, new files could've been generated, so we should commit the changes to the FS.
       
   542 	iIntegrityService->CommitL();
       
   543 			
       
   544 	// only when all is processed one can check the package state		
       
   545 	UpdatePackagePresentStateL();
   535 	}
   546 	}
   536 
   547 
   537 void CSisRegistryCache::StoreBackupL()
   548 void CSisRegistryCache::StoreBackupL()
   538 	{
   549 	{
   539 	SisRegistryUtil::EnsureDirExistsL(iFs, *iBackupFile);
   550 	SisRegistryUtil::EnsureDirExistsL(iFs, *iBackupFile);
   713 	return *iTokens[0];	
   724 	return *iTokens[0];	
   714 	}
   725 	}
   715 
   726 
   716 void CSisRegistryCache::SidToPackageL(const TUid aSid, RArray<CSisRegistryPackage>& aListMatchingPackages) const
   727 void CSisRegistryCache::SidToPackageL(const TUid aSid, RArray<CSisRegistryPackage>& aListMatchingPackages) const
   717 	{
   728 	{
   718 		for (TInt i = 0; i < iTokens.Count(); i++)
   729 	CleanupClosePushL(aListMatchingPackages);
   719 		{
   730 	for (TInt i = 0; i < iTokens.Count(); i++)
   720 		if (iTokens[i]->SidPresent(aSid))
   731 	{
   721 			{
   732 	if (iTokens[i]->SidPresent(aSid))
   722 			aListMatchingPackages.AppendL(*iTokens[i]); 
   733 		{
   723 			}
   734 		aListMatchingPackages.AppendL(*iTokens[i]); 
   724 		}
   735 		}
       
   736 	}
   725 	
   737 	
   726 	DEBUG_PRINTF2(_L("SidToPackageL ListMatchingPackages->Count = %d"), aListMatchingPackages.Count());
   738 	DEBUG_PRINTF2(_L("SidToPackageL ListMatchingPackages->Count = %d"), aListMatchingPackages.Count());
   727 	if(aListMatchingPackages.Count() == 0  )
   739 	if(aListMatchingPackages.Count() == 0  )
   728 		{
   740 		{
   729 		User::Leave(KErrNotFound);
   741 		User::Leave(KErrNotFound);
   730 		}
   742 		}
       
   743 	
       
   744 	CleanupStack::Pop(&aListMatchingPackages);
   731 	}
   745 	}
   732 	
   746 	
   733 TBool CSisRegistryCache::ModifiableL(const TDesC& aFileName)
   747 TBool CSisRegistryCache::ModifiableL(const TDesC& aFileName)
   734 	{
   748 	{
   735 	for (TInt i = 0; i < iTokens.Count(); i++)
   749 	for (TInt i = 0; i < iTokens.Count(); i++)
   833 	return dummyHashContainer;
   847 	return dummyHashContainer;
   834 	}
   848 	}
   835 
   849 
   836 void CSisRegistryCache::PackageAugmentationsL(const TUid aUid, RPointerArray<CSisRegistryPackage>& aPackages) const
   850 void CSisRegistryCache::PackageAugmentationsL(const TUid aUid, RPointerArray<CSisRegistryPackage>& aPackages) const
   837 	{
   851 	{
       
   852 	CleanupResetAndDestroyPushL(aPackages);
   838 	for (TInt i = 0; i < iTokens.Count(); i++)
   853 	for (TInt i = 0; i < iTokens.Count(); i++)
   839 		{
   854 		{
   840 		if ((iTokens[i]->Uid() == aUid) && (iTokens[i]->Index() != CSisRegistryPackage::PrimaryIndex))
   855 		if ((iTokens[i]->Uid() == aUid) && (iTokens[i]->Index() != CSisRegistryPackage::PrimaryIndex))
   841 			{
   856 			{
   842 			CSisRegistryPackage* tmp = CSisRegistryPackage::NewLC(*iTokens[i]);
   857 			CSisRegistryPackage* tmp = CSisRegistryPackage::NewLC(*iTokens[i]);
   843 			aPackages.AppendL(tmp);
   858 			aPackages.AppendL(tmp);
   844 			CleanupStack::Pop(tmp);
   859 			CleanupStack::Pop(tmp);
   845 			}
   860 			}
   846 		}
   861 		}
       
   862 	CleanupStack::Pop(&aPackages);
   847 	}
   863 	}
   848 	
   864 	
   849 TInt CSisRegistryCache::PackageAugmentationsNumber(const TUid aUid) const
   865 TInt CSisRegistryCache::PackageAugmentationsNumber(const TUid aUid) const
   850 	{
   866 	{
   851 	TInt num = 0;
   867 	TInt num = 0;
  1004 void CSisRegistryCache::DependentsPackagesL(
  1020 void CSisRegistryCache::DependentsPackagesL(
  1005 							   const CSisRegistryObject& aObject,
  1021 							   const CSisRegistryObject& aObject,
  1006 							   RPointerArray<CSisRegistryPackage>& aDependents
  1022 							   RPointerArray<CSisRegistryPackage>& aDependents
  1007 							   )
  1023 							   )
  1008 	{
  1024 	{
       
  1025 	CleanupResetAndDestroyPushL(aDependents);
  1009 	aDependents.ResetAndDestroy();
  1026 	aDependents.ResetAndDestroy();
  1010 	// if it is an augmentation - nothing depends on it
  1027 	// if it is an augmentation - nothing depends on it
  1011 	if (aObject.InstallType() == Sis::EInstAugmentation || 
  1028 	if (aObject.InstallType() == Sis::EInstAugmentation || 
  1012 		aObject.InstallType() == Sis::EInstPreInstalledPatch)
  1029 		aObject.InstallType() == Sis::EInstPreInstalledPatch)
  1013 		{
  1030 		{
       
  1031 		CleanupStack::Pop(&aDependents);
  1014 		return;
  1032 		return;
  1015 		}	
  1033 		}	
  1016 		
  1034 		
  1017 	TUid matchingUid = aObject.Uid();
  1035 	TUid matchingUid = aObject.Uid();
  1018 	
  1036 	
  1060 				}
  1078 				}
  1061 			// delete entry & stream 
  1079 			// delete entry & stream 
  1062 			CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
  1080 			CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
  1063 			}
  1081 			}
  1064 		}
  1082 		}
       
  1083 	CleanupStack::Pop(&aDependents);
  1065 	}
  1084 	}
  1066 
  1085 
  1067 void CSisRegistryCache::EmbeddingPackagesL(const CSisRegistryObject& aObject,
  1086 void CSisRegistryCache::EmbeddingPackagesL(const CSisRegistryObject& aObject,
  1068 									   RPointerArray<CSisRegistryPackage>& aEmbeddingPackages)
  1087 									   RPointerArray<CSisRegistryPackage>& aEmbeddingPackages)
  1069 	{
  1088 	{
       
  1089 	CleanupResetAndDestroyPushL(aEmbeddingPackages);
  1070 	aEmbeddingPackages.ResetAndDestroy();
  1090 	aEmbeddingPackages.ResetAndDestroy();
  1071 	
  1091 	
  1072 	TUid matchingUid = aObject.Uid();
  1092 	TUid matchingUid = aObject.Uid();
  1073 	
  1093 	
  1074 	// for all entries in the list
  1094 	// for all entries in the list
  1089 			aEmbeddingPackages.AppendL(tmpPackage);
  1109 			aEmbeddingPackages.AppendL(tmpPackage);
  1090 			CleanupStack::Pop(tmpPackage);	
  1110 			CleanupStack::Pop(tmpPackage);	
  1091 			}
  1111 			}
  1092 		// delete entry & stream 
  1112 		// delete entry & stream 
  1093 		CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
  1113 		CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
  1094 		}	
  1114 		}
       
  1115 	CleanupStack::Pop(&aEmbeddingPackages);
  1095 	}
  1116 	}
  1096 	
  1117 	
  1097 void CSisRegistryCache::GenerateChainListL(const CSisRegistryObject& aObject, 
  1118 void CSisRegistryCache::GenerateChainListL(const CSisRegistryObject& aObject, 
  1098 											 RPointerArray<HBufC8>& aChainList)	
  1119 											 RPointerArray<HBufC8>& aChainList)	
  1099 	{
  1120 	{
       
  1121 	CleanupResetAndDestroyPushL(aChainList);
  1100 	aChainList.ResetAndDestroy();
  1122 	aChainList.ResetAndDestroy();
  1101 	// read the controller for every member of the list	
  1123 	// read the controller for every member of the list	
  1102 	for (TInt i = 0; i < aObject.ControllerInfo().Count(); i++)
  1124 	for (TInt i = 0; i < aObject.ControllerInfo().Count(); i++)
  1103 		{
  1125 		{
  1104 		// open every controller to extract the information
  1126 		// open every controller to extract the information
  1116 			CleanupStack::Pop(tmp);
  1138 			CleanupStack::Pop(tmp);
  1117 			}
  1139 			}
  1118 		// release the data	
  1140 		// release the data	
  1119 		CleanupStack::PopAndDestroy(3, name); // fileProvider, controller
  1141 		CleanupStack::PopAndDestroy(3, name); // fileProvider, controller
  1120 		}	
  1142 		}	
       
  1143 	CleanupStack::Pop(&aChainList);
  1121 	}
  1144 	}
  1122 
  1145 
  1123 HBufC8* CSisRegistryCache::LoadControllerLC(const CSisRegistryObject& aObject, TUint aIndex)
  1146 HBufC8* CSisRegistryCache::LoadControllerLC(const CSisRegistryObject& aObject, TUint aIndex)
  1124 	{
  1147 	{
  1125 	// construct the name using the package and offset
  1148 	// construct the name using the package and offset
  1392 	
  1415 	
  1393 // creates a compacted array using a token
  1416 // creates a compacted array using a token
  1394 void CSisRegistryCache::ControllerDriveListL(const CSisRegistryObject& aObject,
  1417 void CSisRegistryCache::ControllerDriveListL(const CSisRegistryObject& aObject,
  1395 										 RArray<TInt>& aDriveList)
  1418 										 RArray<TInt>& aDriveList)
  1396 	{
  1419 	{
       
  1420 	CleanupClosePushL(aDriveList);
  1397 	aDriveList.Reset();
  1421 	aDriveList.Reset();
  1398 	// a copy of the controller is always kept on drive C
  1422 	// a copy of the controller is always kept on drive C
  1399 	aDriveList.Append(iSystemDrive);
  1423 	aDriveList.AppendL(iSystemDrive);
  1400 	
  1424 	
  1401 	// only controllers will be written to removable media and 
  1425 	// only controllers will be written to removable media and 
  1402 	// we have now to check for those 
  1426 	// we have now to check for those 
  1403 	TUint installationDrives  = aObject.Drives();
  1427 	TUint installationDrives  = aObject.Drives();
  1404 	TUint fixedDrives = FixedDrives();
  1428 	TUint fixedDrives = FixedDrives();
  1405 	TUint remainingDrives = installationDrives & ~fixedDrives;
  1429 	TUint remainingDrives = installationDrives & ~fixedDrives;
  1406 
  1430 
  1407 		if (remainingDrives)
  1431 	if (remainingDrives)
  1408 			{
  1432 		{
  1409 			TInt index = 0;
  1433 		TInt index = 0;
  1410 			// reuse the path but change drive letter
  1434 		// reuse the path but change drive letter
  1411 			while (remainingDrives)
  1435 		while (remainingDrives)
       
  1436 			{
       
  1437 			// compare a single drive digit
       
  1438 			if (remainingDrives & 0x00000001)
  1412 				{
  1439 				{
  1413 				// compare a single drive digit
  1440 				User::LeaveIfError(aDriveList.Append(index)); 
  1414 				if (remainingDrives & 0x00000001)
       
  1415 					{
       
  1416 					User::LeaveIfError(aDriveList.Append(index)); 
       
  1417 					}
       
  1418 				remainingDrives>>=1;
       
  1419 				index++;
       
  1420 				}
  1441 				}
  1421 			}
  1442 			remainingDrives>>=1;
       
  1443 			index++;
       
  1444 			}
       
  1445 		}
       
  1446 	CleanupStack::Pop(&aDriveList);	
  1422 	}
  1447 	}
  1423 
  1448 
  1424 	
  1449 	
  1425 void CSisRegistryCache::InitDrivesL()
  1450 void CSisRegistryCache::InitDrivesL()
  1426 	{
  1451 	{
  2046 void CSisRegistryCache::RemovablePackageListL(RPointerArray<CSisRegistryPackage>& aPackages)
  2071 void CSisRegistryCache::RemovablePackageListL(RPointerArray<CSisRegistryPackage>& aPackages)
  2047 	{
  2072 	{
  2048 	CSisRegistryObject* obj = 0;
  2073 	CSisRegistryObject* obj = 0;
  2049 	TUint id = 0;
  2074 	TUint id = 0;
  2050 	
  2075 	
       
  2076 	CleanupResetAndDestroyPushL(aPackages);
       
  2077 
  2051 	aPackages.ResetAndDestroy();
  2078 	aPackages.ResetAndDestroy();
  2052 	for (TInt i = 0; i < iTokens.Count(); i++)
  2079 	for (TInt i = 0; i < iTokens.Count(); i++)
  2053 		{
  2080 		{
  2054 		// load the object.
  2081 		// load the object.
  2055 		OpenReadHandleL(PackageL(iTokens[i]->Uid() ,iTokens[i]->Index()), id); 
  2082 		OpenReadHandleL(PackageL(iTokens[i]->Uid() ,iTokens[i]->Index()), id); 
  2062 			CleanupStack::Pop(package);			
  2089 			CleanupStack::Pop(package);			
  2063 			}
  2090 			}
  2064 
  2091 
  2065 		CloseReadHandleL(id);
  2092 		CloseReadHandleL(id);
  2066 		}	
  2093 		}	
       
  2094 	CleanupStack::Pop(&aPackages);
  2067 	}
  2095 	}
  2068 	
  2096 	
  2069 void CSisRegistryCache::RecoverL()
  2097 void CSisRegistryCache::RecoverL()
  2070 	{
  2098 	{
  2071 	// Check to see if SWI is in use (install/uninstall/restore)
  2099 	// Check to see if SWI is in use (install/uninstall/restore)