os/persistentdata/persistentstorage/centralrepository/pccenrep/src/pccenrepimpl.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "heaprepos.h"
sl@0
    17
#include "datatype.h"
sl@0
    18
#include "operations.h"
sl@0
    19
sl@0
    20
/**
sl@0
    21
PC side repository impl class
sl@0
    22
@internalTechnology
sl@0
    23
*/
sl@0
    24
NONSHARABLE_CLASS(CPcRepImpl): public CBase, public MOperationLogic
sl@0
    25
{
sl@0
    26
friend class CRepository;
sl@0
    27
public:
sl@0
    28
	static CPcRepImpl* NewL(TUid aRepositoryUid,const TDesC& aInFileName, const TDesC& aOutFileName,TBool aAutoLoading);
sl@0
    29
	~CPcRepImpl();
sl@0
    30
	void MoveL(TUint32 aSourcePartialKey, TUint32 aTargetPartialKey,TUint32 aMask, TUint32& aErrorKey);
sl@0
    31
	void DeleteRangeL(TUint32 aPartialKey, TUint32 aMask,TUint32& aErrorKey);
sl@0
    32
	void GetSingleMetaArrayL(RSingleMetaArray& aMetaArray);
sl@0
    33
	TInt Flush();
sl@0
    34
	static void FailTransactionCleanupOperation(TAny* /**aRepository*/);		
sl@0
    35
sl@0
    36
	//----------------virtuals from MOperationLogic------------------------------------
sl@0
    37
	void GetSingleMeta(TUint aKey,TUint32& aMeta)
sl@0
    38
		{
sl@0
    39
		TInt ret=iSingleMetaArray.Find(aKey,aMeta);
sl@0
    40
		if (ret==KErrNotFound)
sl@0
    41
			{
sl@0
    42
			//search for range/then default meta
sl@0
    43
			TSettingsDefaultMeta *defaultMeta = iRepository->RangeMetaArray().Find(aKey);
sl@0
    44
			if (defaultMeta)
sl@0
    45
				{
sl@0
    46
				aMeta=defaultMeta->GetDefaultMetadata();
sl@0
    47
				}
sl@0
    48
			else
sl@0
    49
				{
sl@0
    50
				aMeta=iRepository->DefaultMeta();
sl@0
    51
				}			
sl@0
    52
			}
sl@0
    53
		}
sl@0
    54
sl@0
    55
	TSettingsAccessPolicy* GetFallbackAccessPolicy(TUint32 aId)const
sl@0
    56
		{
sl@0
    57
		return iRepository->GetFallbackAccessPolicy(aId);
sl@0
    58
		}
sl@0
    59
	TServerSetting* GetSetting(TUint aKey)
sl@0
    60
		{
sl@0
    61
		return iRepository->SettingsArray().Find(aKey);
sl@0
    62
		}
sl@0
    63
	TInt FindSettings(TUint32 aSourcePartialKey,TUint32 aMask,RSettingPointerArray& aOutputArray) const
sl@0
    64
		{
sl@0
    65
		return iRepository->SettingsArray().Find(aSourcePartialKey,aMask,aOutputArray);
sl@0
    66
		}
sl@0
    67
sl@0
    68
	RSettingsArray& GetWritableSettingList()
sl@0
    69
		{
sl@0
    70
		return iRepository->SettingsArray();
sl@0
    71
		}
sl@0
    72
		
sl@0
    73
	//------------------------end of virtuals------------------------------------------
sl@0
    74
		
sl@0
    75
	template <class T>	
sl@0
    76
	void FindSettingsComparisonL(TUint32 aSourcePartialKey,TUint32 aMask,const T& aValue,TComparison aComparison,RArray<TUint32>& aFoundIds) const
sl@0
    77
		{
sl@0
    78
		RSettingPointerArray sourceArray;
sl@0
    79
		CleanupClosePushL(sourceArray);
sl@0
    80
		User::LeaveIfError(FindSettings(aSourcePartialKey,aMask,sourceArray));
sl@0
    81
		
sl@0
    82
		FindCompareL(sourceArray,aValue,aComparison,aFoundIds);
sl@0
    83
		CleanupStack::PopAndDestroy();
sl@0
    84
		}
sl@0
    85
sl@0
    86
private:
sl@0
    87
	void ConstructL(TUid aRepositoryUid,const TDesC& aInFileName,const TDesC& aOutFileName,TBool aAutoLoading);
sl@0
    88
	void IsOriginalL(TUid aUid, const TDesC& aOutFile, TBool aAutoLoading, TFileName& aOgnFileName, TBool& aIsOriginal);
sl@0
    89
	void RemoveAnyMarkDeleted()
sl@0
    90
		{
sl@0
    91
		for (TInt i=0;i<iRepository->SettingsArray().Count();i++)
sl@0
    92
			{
sl@0
    93
			TServerSetting ts=iRepository->SettingsArray()[i];
sl@0
    94
			if (ts.IsDeleted())
sl@0
    95
				{
sl@0
    96
				iRepository->SettingsArray().DeleteElement(i);
sl@0
    97
				i--;			
sl@0
    98
				}
sl@0
    99
			}		
sl@0
   100
		}
sl@0
   101
sl@0
   102
private:	
sl@0
   103
	CHeapRepository* iRepository;
sl@0
   104
	HBufC* iOutFileName;
sl@0
   105
	RFs iFs;
sl@0
   106
	RSingleMetaArray iSingleMetaArray;
sl@0
   107
	TBool iInitialised;	
sl@0
   108
};