625 // transaction ID - ipc(3) |
624 // transaction ID - ipc(3) |
626 TInt64 transactionID; |
625 TInt64 transactionID; |
627 TPckg<TInt64> pkgTransactionID(transactionID); |
626 TPckg<TInt64> pkgTransactionID(transactionID); |
628 aMessage.ReadL(EIpcArgument3, pkgTransactionID); |
627 aMessage.ReadL(EIpcArgument3, pkgTransactionID); |
629 |
628 |
630 // create a integrity service object |
629 DeleteEntryL(*object, transactionID); |
631 CIntegrityServices* integrityService = CIntegrityServices::NewLC(transactionID, KIntegrityServicesPath); |
630 |
632 Server().Cache().RemoveRegistryEntryL(*object, *integrityService); |
631 CleanupStack::PopAndDestroy(object); |
633 |
|
634 //If removal is for ROM upgrade type, |
|
635 //After removing the existing registry entry set, |
|
636 //re generate the Registry Entry Cache. |
|
637 //If any of the ROM based stub doesn't have it's registry set |
|
638 //in appropriate path, it will create them (.reg & . ctl) |
|
639 //from the ROM based stub sis file. |
|
640 if ((object->InstallType() == Sis::EInstInstallation || |
|
641 object->InstallType() == Sis::EInstPartialUpgrade) && |
|
642 SisRegistryUtil::RomBasedPackageL(object->Uid())) |
|
643 { |
|
644 Server().Cache().RegenerateCacheL(); |
|
645 } |
|
646 |
|
647 HBufC* logName = SisRegistryUtil::BuildLogFileNameLC(); |
|
648 |
|
649 TDriveUnit sysDrive(RFs::GetSystemDrive()); |
|
650 TBuf<128> logDir = sysDrive.Name(); |
|
651 logDir.Append(KLogDir); |
|
652 |
|
653 if( SisRegistryUtil::FileExistsL(iFs,*logName)) |
|
654 { |
|
655 TInt sizeOfFile = 0; |
|
656 RFile file; |
|
657 User::LeaveIfError(file.Open(iFs,logDir,EFileRead)); |
|
658 CleanupClosePushL(file); |
|
659 User::LeaveIfError(file.Size(sizeOfFile)); |
|
660 RBuf8 text; |
|
661 text.CreateL(sizeOfFile); |
|
662 text.CleanupClosePushL(); |
|
663 file.Read(text,sizeOfFile); |
|
664 file.Close(); |
|
665 integrityService->RemoveL(*logName); |
|
666 User::LeaveIfError(file.Create(iFs,logDir,EFileWrite| EFileShareExclusive |EFileStream)); |
|
667 User::LeaveIfError(file.Write(text,sizeOfFile)); |
|
668 CleanupStack::PopAndDestroy(2,&file); |
|
669 } |
|
670 integrityService->AddL(*logName); |
|
671 Server().Cache().AddLogEntryL(*object,ESwiLogUnInstall); |
|
672 |
|
673 CleanupStack::PopAndDestroy(3, object);// object, integrityService , logName |
|
674 |
|
675 aMessage.Complete(KErrNone); |
632 aMessage.Complete(KErrNone); |
676 } |
633 } |
677 |
634 |
|
635 void CSisRegistrySession::DeleteEntryL(const CSisRegistryObject& aObject, TInt64 aTransactionId, TBool aRegenerateCache/*=ETrue*/) |
|
636 { |
|
637 // Create a integrity service object |
|
638 CIntegrityServices* integrityService = CIntegrityServices::NewLC(aTransactionId, KIntegrityServicesPath); |
|
639 Server().Cache().RemoveRegistryEntryL(aObject, *integrityService); |
|
640 |
|
641 //If removal is for ROM upgrade type, |
|
642 //After removing the existing registry entry set, |
|
643 //re generate the Registry Entry Cache. |
|
644 //If any of the ROM based stub doesn't have it's registry set |
|
645 //in appropriate path, it will create them (.reg & . ctl) |
|
646 //from the ROM based stub sis file. |
|
647 if ((aObject.InstallType() == Sis::EInstInstallation || |
|
648 aObject.InstallType() == Sis::EInstPartialUpgrade) && |
|
649 SisRegistryUtil::RomBasedPackageL(aObject.Uid()) && |
|
650 aRegenerateCache) |
|
651 { |
|
652 Server().Cache().RegenerateCacheL(); |
|
653 } |
|
654 |
|
655 HBufC* logName = SisRegistryUtil::BuildLogFileNameLC(); |
|
656 |
|
657 TDriveUnit sysDrive(RFs::GetSystemDrive()); |
|
658 TBuf<128> logDir = sysDrive.Name(); |
|
659 logDir.Append(KLogDir); |
|
660 |
|
661 if( SisRegistryUtil::FileExistsL(iFs,*logName)) |
|
662 { |
|
663 TInt sizeOfFile = 0; |
|
664 RFile file; |
|
665 User::LeaveIfError(file.Open(iFs,logDir,EFileRead)); |
|
666 CleanupClosePushL(file); |
|
667 User::LeaveIfError(file.Size(sizeOfFile)); |
|
668 RBuf8 text; |
|
669 text.CreateL(sizeOfFile); |
|
670 text.CleanupClosePushL(); |
|
671 file.Read(text,sizeOfFile); |
|
672 file.Close(); |
|
673 integrityService->RemoveL(*logName); |
|
674 User::LeaveIfError(file.Create(iFs,logDir,EFileWrite| EFileShareExclusive |EFileStream)); |
|
675 User::LeaveIfError(file.Write(text,sizeOfFile)); |
|
676 CleanupStack::PopAndDestroy(2,&file); |
|
677 } |
|
678 integrityService->AddL(*logName); |
|
679 Server().Cache().AddLogEntryL(aObject,ESwiLogUnInstall); |
|
680 |
|
681 CleanupStack::PopAndDestroy(2, integrityService);// logName,integrityService |
|
682 } |
678 void CSisRegistrySession::OpenRegistryUidEntryL(const RMessage2& aMessage) |
683 void CSisRegistrySession::OpenRegistryUidEntryL(const RMessage2& aMessage) |
679 { |
684 { |
680 // expects a UID as an arg 0 |
685 // expects a UID as an arg 0 |
681 TUid uid; |
686 TUid uid; |
682 TPckg<TUid> packageUid(uid); |
687 TPckg<TUid> packageUid(uid); |
1691 CleanupStack::PopAndDestroy(2, &fileStream); // fileStream, object |
1696 CleanupStack::PopAndDestroy(2, &fileStream); // fileStream, object |
1692 } |
1697 } |
1693 |
1698 |
1694 void CSisRegistrySession::AddDriveL(const RMessage2& aMessage) |
1699 void CSisRegistrySession::AddDriveL(const RMessage2& aMessage) |
1695 { |
1700 { |
1696 TInt drive; |
1701 TInt addedDrive; |
1697 TPckg<TInt> pkgDrive(drive); |
1702 TPckg<TInt> pkgDrive(addedDrive); |
1698 aMessage.ReadL(EIpcArgument0, pkgDrive); |
1703 aMessage.ReadL(EIpcArgument0, pkgDrive); |
1699 |
1704 |
1700 DEBUG_PRINTF2(_L8("Sis Registry Server - Removable drive %d added."), drive); |
1705 DEBUG_PRINTF2(_L8("Sis Registry Server - Removable drive %d added."), addedDrive); |
1701 |
1706 |
|
1707 // Get the drive character. |
|
1708 TChar drive; |
|
1709 User::LeaveIfError(iFs.DriveToChar(addedDrive, drive)); |
|
1710 TUint driveChar(drive); |
|
1711 |
|
1712 // Retrieve drive info. |
|
1713 TDriveInfo driveInfo; |
|
1714 User::LeaveIfError(iFs.Drive(driveInfo, addedDrive)); |
|
1715 |
|
1716 #ifndef __WINSCW__ |
|
1717 if(driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) |
|
1718 { |
|
1719 #endif |
|
1720 /* |
|
1721 In case a logically removable drive is added, |
|
1722 Look for the presence of the first boot marker file corresponding to it in the sisregistry private |
|
1723 folder in C drive. If absent, assume first boot and create the marker file. |
|
1724 Also added a marker file in the <drive>\sys\install directory which would be used to detect a format. |
|
1725 |
|
1726 Subsequent boots would look for the drive format marker to check if a format has occured and delete |
|
1727 the registry entries. |
|
1728 */ |
|
1729 |
|
1730 // Create first boot marker path. |
|
1731 _LIT(KFirstBootMarkerFilePath, "%c:%SfirstBootMarkerFileFor%c"); |
|
1732 |
|
1733 RBuf privatePath; |
|
1734 privatePath.CreateL(KMaxPath); |
|
1735 CleanupClosePushL(privatePath); |
|
1736 |
|
1737 User::LeaveIfError(iFs.PrivatePath(privatePath)); |
|
1738 |
|
1739 RBuf firstBootMarkerFilePath; |
|
1740 firstBootMarkerFilePath.CreateL(KMaxPath); |
|
1741 CleanupClosePushL(firstBootMarkerFilePath); |
|
1742 |
|
1743 TChar systemDrive = RFs::GetSystemDriveChar(); |
|
1744 firstBootMarkerFilePath.Format(KFirstBootMarkerFilePath, static_cast<TUint>(systemDrive), &privatePath, driveChar); |
|
1745 |
|
1746 // Create drive format marker path. |
|
1747 _LIT(KFormatMarkerPath, "%c:\\sys\\install\\formatMarkerFile"); |
|
1748 |
|
1749 RBuf formatMarkerPath; |
|
1750 formatMarkerPath.CreateL(KMaxPath); |
|
1751 CleanupClosePushL(formatMarkerPath); |
|
1752 formatMarkerPath.Format(KFormatMarkerPath, driveChar); |
|
1753 |
|
1754 // The drive marker files are marked hidden and read-only. |
|
1755 TUint fileAttributes = KEntryAttReadOnly | KEntryAttHidden; |
|
1756 |
|
1757 if(!SisRegistryUtil::FileExistsL(iFs, firstBootMarkerFilePath)) |
|
1758 { |
|
1759 // First boot detected. Add the first boot marker file as well as the format marker on the drive. |
|
1760 SisRegistryUtil::CreateFileWithAttributesL(iFs, firstBootMarkerFilePath); |
|
1761 SisRegistryUtil::CreateFileWithAttributesL(iFs, formatMarkerPath, fileAttributes); |
|
1762 } |
|
1763 else |
|
1764 { |
|
1765 // Subsequent boot. Check for the presence of a marker file <drive>\sys\install directory. |
|
1766 // If absent, assume format. |
|
1767 if(!SisRegistryUtil::FileExistsL(iFs, formatMarkerPath)) |
|
1768 { |
|
1769 DriveFormatDetectedL(TDriveUnit(addedDrive)); |
|
1770 //Add missing format marker file |
|
1771 SisRegistryUtil::CreateFileWithAttributesL(iFs, formatMarkerPath, fileAttributes); |
|
1772 } |
|
1773 } |
|
1774 |
|
1775 CleanupStack::PopAndDestroy(3, &privatePath); |
|
1776 #ifndef __WINSCW__ |
|
1777 } |
|
1778 #endif |
|
1779 |
1702 // update the drives state |
1780 // update the drives state |
1703 Server().Cache().AddDriveAndRefreshL(drive); |
1781 Server().Cache().AddDriveAndRefreshL(addedDrive); |
1704 aMessage.Complete(KErrNone); |
1782 aMessage.Complete(KErrNone); |
1705 } |
1783 } |
1706 |
1784 |
1707 void CSisRegistrySession::RemoveDriveL(const RMessage2& aMessage) |
1785 void CSisRegistrySession::RemoveDriveL(const RMessage2& aMessage) |
1708 { |
1786 { |
2253 |
2332 |
2254 SendDataPointerArrayL(aMessage, files, EIpcArgument0); |
2333 SendDataPointerArrayL(aMessage, files, EIpcArgument0); |
2255 |
2334 |
2256 CleanupStack::PopAndDestroy(&files); |
2335 CleanupStack::PopAndDestroy(&files); |
2257 } |
2336 } |
|
2337 |
|
2338 void CSisRegistrySession::DriveFormatDetectedL(TDriveUnit aDrive) |
|
2339 { |
|
2340 DEBUG_PRINTF2(_L("Sis Registry Server - Drive format detected for drive %d"), static_cast<TInt>(aDrive)); |
|
2341 |
|
2342 //Get the list of tokens. |
|
2343 const RPointerArray <CSisRegistryToken>& tokensArray = Server().Cache().TokenList(); |
|
2344 |
|
2345 TTime currentTime; |
|
2346 currentTime.UniversalTime(); |
|
2347 TInt64 transactionId = currentTime.Int64(); |
|
2348 |
|
2349 TBool regenerateCache = EFalse; |
|
2350 |
|
2351 TInt i(0); |
|
2352 |
|
2353 while(i < tokensArray.Count()) |
|
2354 { |
|
2355 TUint installedDrives = tokensArray[i]->Drives(); |
|
2356 |
|
2357 // Look for the formatted drive in the list of installed drives. |
|
2358 if(installedDrives & (1 << aDrive)) |
|
2359 { |
|
2360 CSisRegistryObject* object = Server().Cache().ObjectL(*tokensArray[i]); |
|
2361 CleanupStack::PushL(object); |
|
2362 |
|
2363 if (!regenerateCache && |
|
2364 (object->InstallType() == Sis::EInstInstallation || object->InstallType() == Sis::EInstPartialUpgrade) && |
|
2365 SisRegistryUtil::RomBasedPackageL(object->Uid())) |
|
2366 { |
|
2367 regenerateCache = ETrue; |
|
2368 } |
|
2369 |
|
2370 // Retrieve all the associated files. |
|
2371 const RPointerArray<CSisRegistryFileDescription>& fileDescriptions = object->FileDescriptions(); |
|
2372 |
|
2373 _LIT(KHashPathFormat, "%c:\\sys\\hash\\%S"); |
|
2374 |
|
2375 for(TInt j=0; j<fileDescriptions.Count(); ++j) |
|
2376 { |
|
2377 const TDesC& targetPath = fileDescriptions[j]->Target(); |
|
2378 DEBUG_PRINTF2(_L("File - %S "), &targetPath); |
|
2379 |
|
2380 // Get the drive on which the file is present. |
|
2381 TInt drive; |
|
2382 User::LeaveIfError(RFs::CharToDrive(targetPath[0], drive)); |
|
2383 |
|
2384 // If the file is a binary ( present in \sys\bin), delete the corresponding hash present in |
|
2385 // C:\sys\hash |
|
2386 |
|
2387 if(KErrNotFound != targetPath.FindF(KBinPath)) |
|
2388 { |
|
2389 // Retrieve the filename from the target path. |
|
2390 TParsePtrC parser(targetPath); |
|
2391 HBufC* fileName = parser.NameAndExt().AllocLC(); |
|
2392 |
|
2393 TChar systemDrive = RFs::GetSystemDriveChar(); |
|
2394 |
|
2395 // Create the hash file path. |
|
2396 RBuf hashFilePath; |
|
2397 hashFilePath.CreateL(KMaxPath); |
|
2398 CleanupClosePushL(hashFilePath); |
|
2399 hashFilePath.Format(KHashPathFormat, static_cast<TUint>(systemDrive), fileName); |
|
2400 |
|
2401 // Delete hash file. |
|
2402 SisRegistryUtil::DeleteFile(iFs, hashFilePath); //Ignore return code. |
|
2403 |
|
2404 CleanupStack::PopAndDestroy(2, fileName); |
|
2405 |
|
2406 } |
|
2407 |
|
2408 if(aDrive == TDriveUnit(drive)) |
|
2409 { |
|
2410 // File should not exist on disk as the drive is assumed to have been formatted. |
|
2411 continue; |
|
2412 } |
|
2413 SisRegistryUtil::DeleteFile(iFs, targetPath); //Ignore return code. |
|
2414 } |
|
2415 |
|
2416 // Delete registry entry. |
|
2417 DeleteEntryL(*object, transactionId, EFalse); |
|
2418 CleanupStack::PopAndDestroy(object); |
|
2419 } |
|
2420 else |
|
2421 { |
|
2422 // Increment only in case an entry is not found. |
|
2423 i++; |
|
2424 } |
|
2425 } |
|
2426 |
|
2427 if(regenerateCache) |
|
2428 { |
|
2429 Server().Cache().RegenerateCacheL(); |
|
2430 } |
|
2431 |
|
2432 // Commit the changes. |
|
2433 CIntegrityServices* intServ = CIntegrityServices::NewLC(transactionId, KIntegrityServicesPath); |
|
2434 intServ->CommitL(); |
|
2435 CleanupStack::PopAndDestroy(intServ); |
|
2436 } |