sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: 
sl@0: #include "RegistryDataStateAccessor.h"
sl@0: #include "TestUtilities.h"	// For __FILE__LINE__
sl@0: 
sl@0: // ______________________________________________________________________________
sl@0: //
sl@0: TInt TRegistryData_StateAccessor::InvariantTest(TAny* aTestObject)
sl@0: 	{
sl@0: 	CRegistryData* regData = REINTERPRET_CAST(CRegistryData*, aTestObject);
sl@0: 	if(regData->iRegistrations == NULL)
sl@0: 		return KTestBedFailedInvariant;
sl@0: 	return KErrNone;
sl@0: 	}
sl@0: 
sl@0: TInt TRegistryData_StateAccessor::Internalize(TAny* /* aTestObject */)
sl@0: 	{
sl@0: 	// Not required
sl@0: 	return KErrNone;
sl@0: 	}
sl@0: 
sl@0: TInt TRegistryData_StateAccessor::Externalize(TAny* /* aTestObject */)
sl@0: 	{
sl@0: 	// Not required
sl@0: 	return KErrNone;
sl@0: 	}
sl@0: 
sl@0: inline void TRegistryData_StateAccessor::BuildIndexesL(CRegistryData& aRegData)
sl@0: 	{
sl@0: 	aRegData.BuildIndexesL();
sl@0: 	}
sl@0: 
sl@0: inline TInt TRegistryData_StateAccessor::IndexedFind(CRegistryData& aRegData, const TUid& aImplementationUid)
sl@0: 	{
sl@0: 	return aRegData.IndexedFind(aImplementationUid);
sl@0: 	}
sl@0: 
sl@0: inline TBool TRegistryData_StateAccessor::MatchOnUid()
sl@0: 	{
sl@0: 	return CRegistryData::MatchOnUid(iIndexItem, iKey);
sl@0: 	}
sl@0: 
sl@0: inline void TRegistryData_StateAccessor::RestoreL(CRegistryData& aRegData, RFileReadStream& aStore)
sl@0: 	{
sl@0: 	aRegData.RestoreL(aStore);
sl@0: 	}
sl@0: 
sl@0: inline void TRegistryData_StateAccessor::StoreL(CRegistryData& aRegData, RFileWriteStream& aStore)
sl@0: 	{
sl@0: 	aRegData.StoreL(aStore);
sl@0: 	}
sl@0: 
sl@0: TBool TRegistryData_StateAccessor::IsRegisteredDrive(CRegistryData& aRegData, 
sl@0: 													 TDriveUnit aDriveUnit)
sl@0: 	{
sl@0: 	TInt driveIndex = KErrNotFound;
sl@0: 	const TInt driveCount = aRegData.iRegistrations->Count();
sl@0: 	for(TInt index = 0; (index<driveCount) && (driveIndex==KErrNotFound); ++index)
sl@0: 		{
sl@0: 		if((*(aRegData.iRegistrations))[index]->iDrive == aDriveUnit)
sl@0: 			driveIndex = index;
sl@0: 		}
sl@0: 
sl@0: 	// Return ETrue if the drive has been found
sl@0: 	return driveIndex != KErrNotFound;
sl@0: 	}
sl@0: