installationservices/swi/source/sisregistry/server_legacy/sisregistrycache.cpp
branchRCL_3
changeset 17 741e5bba2bd1
parent 0 ba25891c3a9e
child 21 5bddc28da627
equal deleted inserted replaced
15:98a43fae6e2b 17:741e5bba2bd1
     1 /*
     1 /*
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2004-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".
   181 		}
   181 		}
   182 	}
   182 	}
   183 
   183 
   184 void CSisRegistryCache::PackageListL(RPointerArray<CSisRegistryPackage>& aPackages) const
   184 void CSisRegistryCache::PackageListL(RPointerArray<CSisRegistryPackage>& aPackages) const
   185 	{
   185 	{
       
   186 	CleanupResetAndDestroyPushL(aPackages);
   186 	aPackages.ResetAndDestroy();
   187 	aPackages.ResetAndDestroy();
       
   188 	
   187 	for (TInt i = 0; i < iTokens.Count(); i++)
   189 	for (TInt i = 0; i < iTokens.Count(); i++)
   188 		{
   190 		{
   189 		CSisRegistryPackage *package = CSisRegistryPackage::NewLC(*iTokens[i]);
   191 		CSisRegistryPackage *package = CSisRegistryPackage::NewLC(*iTokens[i]);
   190 		aPackages.AppendL(package);
   192 		aPackages.AppendL(package);
   191 		CleanupStack::Pop(package);
   193 		CleanupStack::Pop(package);
   192 		}
   194 		}
       
   195 	CleanupStack::Pop(&aPackages);
   193 	}
   196 	}
   194 	
   197 	
   195 RFs& CSisRegistryCache::RFsHandle()
   198 RFs& CSisRegistryCache::RFsHandle()
   196 	{ 
   199 	{ 
   197 	return iFs;
   200 	return iFs;
   713 	return *iTokens[0];	
   716 	return *iTokens[0];	
   714 	}
   717 	}
   715 
   718 
   716 void CSisRegistryCache::SidToPackageL(const TUid aSid, RArray<CSisRegistryPackage>& aListMatchingPackages) const
   719 void CSisRegistryCache::SidToPackageL(const TUid aSid, RArray<CSisRegistryPackage>& aListMatchingPackages) const
   717 	{
   720 	{
   718 		for (TInt i = 0; i < iTokens.Count(); i++)
   721 	CleanupClosePushL(aListMatchingPackages);
   719 		{
   722 	for (TInt i = 0; i < iTokens.Count(); i++)
   720 		if (iTokens[i]->SidPresent(aSid))
   723 	{
   721 			{
   724 	if (iTokens[i]->SidPresent(aSid))
   722 			aListMatchingPackages.AppendL(*iTokens[i]); 
   725 		{
   723 			}
   726 		aListMatchingPackages.AppendL(*iTokens[i]); 
   724 		}
   727 		}
       
   728 	}
   725 	
   729 	
   726 	DEBUG_PRINTF2(_L("SidToPackageL ListMatchingPackages->Count = %d"), aListMatchingPackages.Count());
   730 	DEBUG_PRINTF2(_L("SidToPackageL ListMatchingPackages->Count = %d"), aListMatchingPackages.Count());
   727 	if(aListMatchingPackages.Count() == 0  )
   731 	if(aListMatchingPackages.Count() == 0  )
   728 		{
   732 		{
   729 		User::Leave(KErrNotFound);
   733 		User::Leave(KErrNotFound);
   730 		}
   734 		}
       
   735 	
       
   736 	CleanupStack::Pop(&aListMatchingPackages);
   731 	}
   737 	}
   732 	
   738 	
   733 TBool CSisRegistryCache::ModifiableL(const TDesC& aFileName)
   739 TBool CSisRegistryCache::ModifiableL(const TDesC& aFileName)
   734 	{
   740 	{
   735 	for (TInt i = 0; i < iTokens.Count(); i++)
   741 	for (TInt i = 0; i < iTokens.Count(); i++)
   833 	return dummyHashContainer;
   839 	return dummyHashContainer;
   834 	}
   840 	}
   835 
   841 
   836 void CSisRegistryCache::PackageAugmentationsL(const TUid aUid, RPointerArray<CSisRegistryPackage>& aPackages) const
   842 void CSisRegistryCache::PackageAugmentationsL(const TUid aUid, RPointerArray<CSisRegistryPackage>& aPackages) const
   837 	{
   843 	{
       
   844 	CleanupResetAndDestroyPushL(aPackages);
   838 	for (TInt i = 0; i < iTokens.Count(); i++)
   845 	for (TInt i = 0; i < iTokens.Count(); i++)
   839 		{
   846 		{
   840 		if ((iTokens[i]->Uid() == aUid) && (iTokens[i]->Index() != CSisRegistryPackage::PrimaryIndex))
   847 		if ((iTokens[i]->Uid() == aUid) && (iTokens[i]->Index() != CSisRegistryPackage::PrimaryIndex))
   841 			{
   848 			{
   842 			CSisRegistryPackage* tmp = CSisRegistryPackage::NewLC(*iTokens[i]);
   849 			CSisRegistryPackage* tmp = CSisRegistryPackage::NewLC(*iTokens[i]);
   843 			aPackages.AppendL(tmp);
   850 			aPackages.AppendL(tmp);
   844 			CleanupStack::Pop(tmp);
   851 			CleanupStack::Pop(tmp);
   845 			}
   852 			}
   846 		}
   853 		}
       
   854 	CleanupStack::Pop(&aPackages);
   847 	}
   855 	}
   848 	
   856 	
   849 TInt CSisRegistryCache::PackageAugmentationsNumber(const TUid aUid) const
   857 TInt CSisRegistryCache::PackageAugmentationsNumber(const TUid aUid) const
   850 	{
   858 	{
   851 	TInt num = 0;
   859 	TInt num = 0;
  1004 void CSisRegistryCache::DependentsPackagesL(
  1012 void CSisRegistryCache::DependentsPackagesL(
  1005 							   const CSisRegistryObject& aObject,
  1013 							   const CSisRegistryObject& aObject,
  1006 							   RPointerArray<CSisRegistryPackage>& aDependents
  1014 							   RPointerArray<CSisRegistryPackage>& aDependents
  1007 							   )
  1015 							   )
  1008 	{
  1016 	{
       
  1017 	CleanupResetAndDestroyPushL(aDependents);
  1009 	aDependents.ResetAndDestroy();
  1018 	aDependents.ResetAndDestroy();
  1010 	// if it is an augmentation - nothing depends on it
  1019 	// if it is an augmentation - nothing depends on it
  1011 	if (aObject.InstallType() == Sis::EInstAugmentation || 
  1020 	if (aObject.InstallType() == Sis::EInstAugmentation || 
  1012 		aObject.InstallType() == Sis::EInstPreInstalledPatch)
  1021 		aObject.InstallType() == Sis::EInstPreInstalledPatch)
  1013 		{
  1022 		{
       
  1023 		CleanupStack::Pop(&aDependents);
  1014 		return;
  1024 		return;
  1015 		}	
  1025 		}	
  1016 		
  1026 		
  1017 	TUid matchingUid = aObject.Uid();
  1027 	TUid matchingUid = aObject.Uid();
  1018 	
  1028 	
  1060 				}
  1070 				}
  1061 			// delete entry & stream 
  1071 			// delete entry & stream 
  1062 			CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
  1072 			CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
  1063 			}
  1073 			}
  1064 		}
  1074 		}
       
  1075 	CleanupStack::Pop(&aDependents);
  1065 	}
  1076 	}
  1066 
  1077 
  1067 void CSisRegistryCache::EmbeddingPackagesL(const CSisRegistryObject& aObject,
  1078 void CSisRegistryCache::EmbeddingPackagesL(const CSisRegistryObject& aObject,
  1068 									   RPointerArray<CSisRegistryPackage>& aEmbeddingPackages)
  1079 									   RPointerArray<CSisRegistryPackage>& aEmbeddingPackages)
  1069 	{
  1080 	{
       
  1081 	CleanupResetAndDestroyPushL(aEmbeddingPackages);
  1070 	aEmbeddingPackages.ResetAndDestroy();
  1082 	aEmbeddingPackages.ResetAndDestroy();
  1071 	
  1083 	
  1072 	TUid matchingUid = aObject.Uid();
  1084 	TUid matchingUid = aObject.Uid();
  1073 	
  1085 	
  1074 	// for all entries in the list
  1086 	// for all entries in the list
  1089 			aEmbeddingPackages.AppendL(tmpPackage);
  1101 			aEmbeddingPackages.AppendL(tmpPackage);
  1090 			CleanupStack::Pop(tmpPackage);	
  1102 			CleanupStack::Pop(tmpPackage);	
  1091 			}
  1103 			}
  1092 		// delete entry & stream 
  1104 		// delete entry & stream 
  1093 		CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
  1105 		CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
  1094 		}	
  1106 		}
       
  1107 	CleanupStack::Pop(&aEmbeddingPackages);
  1095 	}
  1108 	}
  1096 	
  1109 	
  1097 void CSisRegistryCache::GenerateChainListL(const CSisRegistryObject& aObject, 
  1110 void CSisRegistryCache::GenerateChainListL(const CSisRegistryObject& aObject, 
  1098 											 RPointerArray<HBufC8>& aChainList)	
  1111 											 RPointerArray<HBufC8>& aChainList)	
  1099 	{
  1112 	{
       
  1113 	CleanupResetAndDestroyPushL(aChainList);
  1100 	aChainList.ResetAndDestroy();
  1114 	aChainList.ResetAndDestroy();
  1101 	// read the controller for every member of the list	
  1115 	// read the controller for every member of the list	
  1102 	for (TInt i = 0; i < aObject.ControllerInfo().Count(); i++)
  1116 	for (TInt i = 0; i < aObject.ControllerInfo().Count(); i++)
  1103 		{
  1117 		{
  1104 		// open every controller to extract the information
  1118 		// open every controller to extract the information
  1116 			CleanupStack::Pop(tmp);
  1130 			CleanupStack::Pop(tmp);
  1117 			}
  1131 			}
  1118 		// release the data	
  1132 		// release the data	
  1119 		CleanupStack::PopAndDestroy(3, name); // fileProvider, controller
  1133 		CleanupStack::PopAndDestroy(3, name); // fileProvider, controller
  1120 		}	
  1134 		}	
       
  1135 	CleanupStack::Pop(&aChainList);
  1121 	}
  1136 	}
  1122 
  1137 
  1123 HBufC8* CSisRegistryCache::LoadControllerLC(const CSisRegistryObject& aObject, TUint aIndex)
  1138 HBufC8* CSisRegistryCache::LoadControllerLC(const CSisRegistryObject& aObject, TUint aIndex)
  1124 	{
  1139 	{
  1125 	// construct the name using the package and offset
  1140 	// construct the name using the package and offset
  1145 	}
  1160 	}
  1146 
  1161 
  1147 void CSisRegistryCache::GenerateControllersArrayL(const CSisRegistryObject& aObject, 
  1162 void CSisRegistryCache::GenerateControllersArrayL(const CSisRegistryObject& aObject, 
  1148 												RPointerArray<HBufC8>& aControllers)
  1163 												RPointerArray<HBufC8>& aControllers)
  1149 	{
  1164 	{
       
  1165 	CleanupResetAndDestroyPushL(aControllers);
  1150 	aControllers.ResetAndDestroy();
  1166 	aControllers.ResetAndDestroy();
  1151 	
  1167 	
  1152 	// read the controller for every member of the list	
  1168 	// read the controller for every member of the list	
  1153 	TInt count = aObject.ControllerInfo().Count();
  1169 	TInt count = aObject.ControllerInfo().Count();
  1154 	for (TInt i = 0; i < count; ++i)
  1170 	for (TInt i = 0; i < count; ++i)
  1156 		HBufC8* buffer = LoadControllerLC(aObject, i);
  1172 		HBufC8* buffer = LoadControllerLC(aObject, i);
  1157 		// add it to the list 
  1173 		// add it to the list 
  1158 		aControllers.AppendL(buffer);
  1174 		aControllers.AppendL(buffer);
  1159 		CleanupStack::Pop(buffer);
  1175 		CleanupStack::Pop(buffer);
  1160 		}
  1176 		}
       
  1177 	CleanupStack::Pop(&aControllers);
  1161 	}	
  1178 	}	
  1162 		
  1179 		
  1163 void CSisRegistryCache::AddControllerL(const CSisRegistryObject& aObject, 
  1180 void CSisRegistryCache::AddControllerL(const CSisRegistryObject& aObject, 
  1164 									CIntegrityServices& aIntegrityService,
  1181 									CIntegrityServices& aIntegrityService,
  1165 									const TDesC8& aBuffer, const TInt aDrive)		
  1182 									const TDesC8& aBuffer, const TInt aDrive)		
  1390 	
  1407 	
  1391 // creates a compacted array using a token
  1408 // creates a compacted array using a token
  1392 void CSisRegistryCache::ControllerDriveListL(const CSisRegistryObject& aObject,
  1409 void CSisRegistryCache::ControllerDriveListL(const CSisRegistryObject& aObject,
  1393 										 RArray<TInt>& aDriveList)
  1410 										 RArray<TInt>& aDriveList)
  1394 	{
  1411 	{
       
  1412 	CleanupClosePushL(aDriveList);
  1395 	aDriveList.Reset();
  1413 	aDriveList.Reset();
  1396 	// a copy of the controller is always kept on drive C
  1414 	// a copy of the controller is always kept on drive C
  1397 	aDriveList.Append(iSystemDrive);
  1415 	aDriveList.Append(iSystemDrive);
  1398 	
  1416 	
  1399 	// only controllers will be written to removable media and 
  1417 	// only controllers will be written to removable media and 
  1400 	// we have now to check for those 
  1418 	// we have now to check for those 
  1401 	TUint installationDrives  = aObject.Drives();
  1419 	TUint installationDrives  = aObject.Drives();
  1402 	TUint fixedDrives = FixedDrives();
  1420 	TUint fixedDrives = FixedDrives();
  1403 	TUint remainingDrives = installationDrives & ~fixedDrives;
  1421 	TUint remainingDrives = installationDrives & ~fixedDrives;
  1404 
  1422 
  1405 		if (remainingDrives)
  1423 	if (remainingDrives)
  1406 			{
  1424 		{
  1407 			TInt index = 0;
  1425 		TInt index = 0;
  1408 			// reuse the path but change drive letter
  1426 		// reuse the path but change drive letter
  1409 			while (remainingDrives)
  1427 		while (remainingDrives)
       
  1428 			{
       
  1429 			// compare a single drive digit
       
  1430 			if (remainingDrives & 0x00000001)
  1410 				{
  1431 				{
  1411 				// compare a single drive digit
  1432 				User::LeaveIfError(aDriveList.Append(index)); 
  1412 				if (remainingDrives & 0x00000001)
       
  1413 					{
       
  1414 					User::LeaveIfError(aDriveList.Append(index)); 
       
  1415 					}
       
  1416 				remainingDrives>>=1;
       
  1417 				index++;
       
  1418 				}
  1433 				}
  1419 			}
  1434 			remainingDrives>>=1;
       
  1435 			index++;
       
  1436 			}
       
  1437 		}
       
  1438 	CleanupStack::Pop(&aDriveList);	
  1420 	}
  1439 	}
  1421 
  1440 
  1422 	
  1441 	
  1423 void CSisRegistryCache::InitDrivesL()
  1442 void CSisRegistryCache::InitDrivesL()
  1424 	{
  1443 	{
  2044 void CSisRegistryCache::RemovablePackageListL(RPointerArray<CSisRegistryPackage>& aPackages)
  2063 void CSisRegistryCache::RemovablePackageListL(RPointerArray<CSisRegistryPackage>& aPackages)
  2045 	{
  2064 	{
  2046 	CSisRegistryObject* obj = 0;
  2065 	CSisRegistryObject* obj = 0;
  2047 	TUint id = 0;
  2066 	TUint id = 0;
  2048 	
  2067 	
       
  2068 	CleanupResetAndDestroyPushL(aPackages);
       
  2069 
  2049 	aPackages.ResetAndDestroy();
  2070 	aPackages.ResetAndDestroy();
  2050 	for (TInt i = 0; i < iTokens.Count(); i++)
  2071 	for (TInt i = 0; i < iTokens.Count(); i++)
  2051 		{
  2072 		{
  2052 		// load the object.
  2073 		// load the object.
  2053 		OpenReadHandleL(PackageL(iTokens[i]->Uid() ,iTokens[i]->Index()), id); 
  2074 		OpenReadHandleL(PackageL(iTokens[i]->Uid() ,iTokens[i]->Index()), id); 
  2060 			CleanupStack::Pop(package);			
  2081 			CleanupStack::Pop(package);			
  2061 			}
  2082 			}
  2062 
  2083 
  2063 		CloseReadHandleL(id);
  2084 		CloseReadHandleL(id);
  2064 		}	
  2085 		}	
       
  2086 	CleanupStack::Pop(&aPackages);
  2065 	}
  2087 	}
  2066 	
  2088 	
  2067 void CSisRegistryCache::RecoverL()
  2089 void CSisRegistryCache::RecoverL()
  2068 	{
  2090 	{
  2069 	// Check to see if SWI is in use (install/uninstall/restore)
  2091 	// Check to see if SWI is in use (install/uninstall/restore)