// -----------------------------------------------------------------------
// CPreviouslyInstalledAppsCache::UpdateAllL
// -----------------------------------------------------------------------
//  
void CPreviouslyInstalledAppsCache::UpdateAllL()
	{
    FLOG( _L("Daemon: CPreviouslyInstalledAppsCache::UpdateAllL ") );
    
	RThread ourThread; // nb. Default constructor gives handle to current thread.
	
	if( !ourThread.HasCapability(ECapabilityReadUserData, 0) )
		{
		// Have not got ReadUserData - if we try and enumerate package
		// UIDs the registry server will panic us!
		User::Leave(KErrAccessDenied);
		}
	ourThread.Close();

	// Let's use SisRegistry in this case since in SCR there is no
	// simple way to retriev sisx pacakge UIDs in one call.
    RSisRegistrySession registrySession;
    User::LeaveIfError( registrySession.Connect() );
    CleanupClosePushL( registrySession );
    
    RPointerArray<CSisRegistryPackage> packages;
    registrySession.InstalledPackagesL( packages );
    CleanupResetAndDestroy< 
           RPointerArray<CSisRegistryPackage> >::PushL( packages );
    
    for ( TInt i = 0; i < packages.Count(); ++i )
        {
        (void)iPrevPkgUids.InsertInSignedKeyOrder( packages[i]->Uid() );
        
        FLOG_1( _L("Daemon: UpdateAllL: Add UID = 0x%x"), 
                packages[i]->Uid().iUid );
        }
    
    CleanupStack::PopAndDestroy( &packages );
    CleanupStack::PopAndDestroy( &registrySession );
	}