os/persistentdata/persistentstorage/centralrepository/pccenrep/src/pccenrepimpl.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/pccenrep/src/pccenrepimpl.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,108 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "heaprepos.h"
    1.20 +#include "datatype.h"
    1.21 +#include "operations.h"
    1.22 +
    1.23 +/**
    1.24 +PC side repository impl class
    1.25 +@internalTechnology
    1.26 +*/
    1.27 +NONSHARABLE_CLASS(CPcRepImpl): public CBase, public MOperationLogic
    1.28 +{
    1.29 +friend class CRepository;
    1.30 +public:
    1.31 +	static CPcRepImpl* NewL(TUid aRepositoryUid,const TDesC& aInFileName, const TDesC& aOutFileName,TBool aAutoLoading);
    1.32 +	~CPcRepImpl();
    1.33 +	void MoveL(TUint32 aSourcePartialKey, TUint32 aTargetPartialKey,TUint32 aMask, TUint32& aErrorKey);
    1.34 +	void DeleteRangeL(TUint32 aPartialKey, TUint32 aMask,TUint32& aErrorKey);
    1.35 +	void GetSingleMetaArrayL(RSingleMetaArray& aMetaArray);
    1.36 +	TInt Flush();
    1.37 +	static void FailTransactionCleanupOperation(TAny* /**aRepository*/);		
    1.38 +
    1.39 +	//----------------virtuals from MOperationLogic------------------------------------
    1.40 +	void GetSingleMeta(TUint aKey,TUint32& aMeta)
    1.41 +		{
    1.42 +		TInt ret=iSingleMetaArray.Find(aKey,aMeta);
    1.43 +		if (ret==KErrNotFound)
    1.44 +			{
    1.45 +			//search for range/then default meta
    1.46 +			TSettingsDefaultMeta *defaultMeta = iRepository->RangeMetaArray().Find(aKey);
    1.47 +			if (defaultMeta)
    1.48 +				{
    1.49 +				aMeta=defaultMeta->GetDefaultMetadata();
    1.50 +				}
    1.51 +			else
    1.52 +				{
    1.53 +				aMeta=iRepository->DefaultMeta();
    1.54 +				}			
    1.55 +			}
    1.56 +		}
    1.57 +
    1.58 +	TSettingsAccessPolicy* GetFallbackAccessPolicy(TUint32 aId)const
    1.59 +		{
    1.60 +		return iRepository->GetFallbackAccessPolicy(aId);
    1.61 +		}
    1.62 +	TServerSetting* GetSetting(TUint aKey)
    1.63 +		{
    1.64 +		return iRepository->SettingsArray().Find(aKey);
    1.65 +		}
    1.66 +	TInt FindSettings(TUint32 aSourcePartialKey,TUint32 aMask,RSettingPointerArray& aOutputArray) const
    1.67 +		{
    1.68 +		return iRepository->SettingsArray().Find(aSourcePartialKey,aMask,aOutputArray);
    1.69 +		}
    1.70 +
    1.71 +	RSettingsArray& GetWritableSettingList()
    1.72 +		{
    1.73 +		return iRepository->SettingsArray();
    1.74 +		}
    1.75 +		
    1.76 +	//------------------------end of virtuals------------------------------------------
    1.77 +		
    1.78 +	template <class T>	
    1.79 +	void FindSettingsComparisonL(TUint32 aSourcePartialKey,TUint32 aMask,const T& aValue,TComparison aComparison,RArray<TUint32>& aFoundIds) const
    1.80 +		{
    1.81 +		RSettingPointerArray sourceArray;
    1.82 +		CleanupClosePushL(sourceArray);
    1.83 +		User::LeaveIfError(FindSettings(aSourcePartialKey,aMask,sourceArray));
    1.84 +		
    1.85 +		FindCompareL(sourceArray,aValue,aComparison,aFoundIds);
    1.86 +		CleanupStack::PopAndDestroy();
    1.87 +		}
    1.88 +
    1.89 +private:
    1.90 +	void ConstructL(TUid aRepositoryUid,const TDesC& aInFileName,const TDesC& aOutFileName,TBool aAutoLoading);
    1.91 +	void IsOriginalL(TUid aUid, const TDesC& aOutFile, TBool aAutoLoading, TFileName& aOgnFileName, TBool& aIsOriginal);
    1.92 +	void RemoveAnyMarkDeleted()
    1.93 +		{
    1.94 +		for (TInt i=0;i<iRepository->SettingsArray().Count();i++)
    1.95 +			{
    1.96 +			TServerSetting ts=iRepository->SettingsArray()[i];
    1.97 +			if (ts.IsDeleted())
    1.98 +				{
    1.99 +				iRepository->SettingsArray().DeleteElement(i);
   1.100 +				i--;			
   1.101 +				}
   1.102 +			}		
   1.103 +		}
   1.104 +
   1.105 +private:	
   1.106 +	CHeapRepository* iRepository;
   1.107 +	HBufC* iOutFileName;
   1.108 +	RFs iFs;
   1.109 +	RSingleMetaArray iSingleMetaArray;
   1.110 +	TBool iInitialised;	
   1.111 +};