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