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