|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Container store containers table. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CONTAINER_STORE_CONTAINERS_TABLE_H__ |
|
21 #define __CONTAINER_STORE_CONTAINERS_TABLE_H__ |
|
22 |
|
23 // ======== |
|
24 // INCLUDES |
|
25 // ======== |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <d32dbms.h> // database |
|
29 //<cmail> |
|
30 #include "DebugLogMacros.h" |
|
31 //</cmail> |
|
32 |
|
33 #include "ContainerStoreTable.h" |
|
34 #include "ContainerStore.h" |
|
35 #include "ContainerStoreDefs.h" |
|
36 |
|
37 // ======= |
|
38 // CLASSES |
|
39 // ======= |
|
40 |
|
41 // ===================================== |
|
42 // CLASS: CContainerStoreContainersTable |
|
43 // ===================================== |
|
44 class CContainerStoreContainersTable : public CContainerStoreTable |
|
45 { |
|
46 public: |
|
47 |
|
48 // ============== |
|
49 // PUBLIC METHODS |
|
50 // ============== |
|
51 |
|
52 static CContainerStoreContainersTable* CreateL( CContainerStoreUtils& aUtils, |
|
53 MCustomBehaviorProvider& aCustomBehaviorProvider, |
|
54 TUint aCountsLength, |
|
55 CContainerStoreEncryption& aEncryption ); |
|
56 |
|
57 static CContainerStoreContainersTable* OpenL( CContainerStoreUtils& aUtils, |
|
58 MCustomBehaviorProvider& aCustomBehaviorProvider, |
|
59 TUint aCountsLength, |
|
60 CContainerStoreEncryption& aEncryption ); |
|
61 |
|
62 virtual ~CContainerStoreContainersTable(); |
|
63 |
|
64 // Leaves with KErrNotFound if not found or if it is in the hierarchy of a container that is |
|
65 // to be deleted. |
|
66 void SeekL( TContainerId aId, |
|
67 RArray<TContainerId>& aHierarchy ); |
|
68 |
|
69 // Leaves with KErrNotFound if not found |
|
70 void SeekL( TContainerId aId ); |
|
71 |
|
72 // Leaves with KErrNotFound if not found |
|
73 void SeekL( TContainerId aId, |
|
74 TContainerId& aParentId ); |
|
75 |
|
76 // Leaves with KErrNotFound if not found |
|
77 TContainerId GotoL( TDbBookmark aBookmark ); |
|
78 |
|
79 // Leaves with KErrNotFound if not found or if it is in the hierarchy of a container that is |
|
80 // to be deleted. (This is different from SeekL in that GetL is not on the record. Use this |
|
81 // version if the container whose hierarchy is being queried is not used immediately after the |
|
82 // call). |
|
83 void HierarchyL( TContainerId aId, |
|
84 RArray<TContainerId>& aHierarchy ); |
|
85 |
|
86 TContainerId FindL( const TDesC& aSqlQuery ); |
|
87 |
|
88 TDbBookmark Bookmark(); |
|
89 |
|
90 TContainerId ParentId(); |
|
91 |
|
92 void ListChildrenL( RArray<TContainerId>& aChildren, |
|
93 TContainerId aId, |
|
94 TContainerId aType = KContainerTypeAny, |
|
95 TBool aRecursive = EFalse ); |
|
96 |
|
97 void ChildrenCountsL( TDes8& aCounts, TBool aRecursive = EFalse ); |
|
98 |
|
99 void PropertiesL( RBuf8& aProperties ); |
|
100 |
|
101 TUint PropertiesSizeL( TContainerId aId ); |
|
102 |
|
103 void QuickPropertiesL( RBuf8& aQuickProperties ); |
|
104 |
|
105 void CreateContainerL( TContainerId aId, |
|
106 TContainerId aParentId, |
|
107 const TDesC8& aProperties, |
|
108 RBuf8& aQuickProperties ); |
|
109 |
|
110 // nonrecursive |
|
111 void DeleteL(); |
|
112 |
|
113 /** |
|
114 * Only to be used when failed to delete a part because client has |
|
115 * the content file open, this method markes the part to be skipped in the current deletion |
|
116 * round, but the next round will change this to MarkForDeleteL(), so that it will get deleted. |
|
117 * |
|
118 * This method does NOT update any message counts because those have already |
|
119 * been handled. |
|
120 */ |
|
121 void MarkAsDeleteRetryL(); |
|
122 |
|
123 /** |
|
124 * Only to be used when about to retry deleting a container. |
|
125 * This method markes the part as to be deleted so that it can be deleted in the |
|
126 * current round of deletion. |
|
127 * |
|
128 * This method does NOT update any message counts because those have already |
|
129 * been handled. |
|
130 */ |
|
131 void MarkForDeleteL(); |
|
132 |
|
133 void MoveL( TContainerId aNewParentId, TDes8& aTotalCountsDelta ); |
|
134 |
|
135 // nonrecursive, copies current row to the parent ID, using the given id |
|
136 void CopyL( TContainerId aNewId, TContainerId aParentId, RBuf8& aQuickProperties ); |
|
137 |
|
138 void UpdatePropertiesL( const TDesC8& aProperties, |
|
139 RBuf8& aQuickProperties, |
|
140 TDes8& aTotalCountsDelta, |
|
141 TContainerId& aRealParentId ); |
|
142 |
|
143 void UpdatePropertyL( const TDesC8& aName, |
|
144 TUint8 aType, |
|
145 const TDesC8& aValue, |
|
146 RBuf8& aQuickProperties, |
|
147 TDes8& aTotalCountsDelta, |
|
148 TContainerId& aRealParentId ); |
|
149 |
|
150 TBool EncryptFirstL( TDbBookmark& aNextRow ); |
|
151 |
|
152 TBool EncryptNextL ( TDbBookmark& aNextRow, TContainerId& aEncryptedContainerId ); |
|
153 |
|
154 TBool DecryptFirstL( TDbBookmark& aNextRow ); |
|
155 |
|
156 TBool DecryptNextL ( TDbBookmark& aNextRow, TContainerId& aDecryptedContainerId ); |
|
157 |
|
158 TBool IsEncrypted(); |
|
159 |
|
160 private: |
|
161 |
|
162 // =============== |
|
163 // PRIVATE METHODS |
|
164 // =============== |
|
165 |
|
166 CContainerStoreContainersTable( CContainerStoreUtils& aUtils, |
|
167 MCustomBehaviorProvider& aCustomBehaviorProvider, |
|
168 TUint aCountsLength, |
|
169 CContainerStoreEncryption& aEncryption ); |
|
170 |
|
171 void CreateTableL(); |
|
172 void OpenTableL(); |
|
173 |
|
174 void UpdateQuickPropertiesAndCountsL( TContainerId aType, |
|
175 const TDesC8& aProperties, |
|
176 RBuf8& aQuickProperties, |
|
177 TDes8& aCounts ); |
|
178 |
|
179 void IncrementParentCountsL( const TDesC8& aCountsDelta ); |
|
180 void DecrementParentCountsL( const TDesC8& aCountsDelta ); |
|
181 |
|
182 void ReadPropertiesColumnL( RBuf8& aUnencryptedBuffer ); |
|
183 void WritePropertiesColumnL( const TDesC8& aUnencryptedBuffer ); |
|
184 |
|
185 void ReadAndDescrptPropertiesColumnL( RBuf8& aProperties ); |
|
186 void EncryptAndWritePropertiesColumnL( const TDesC8& aProperties ); |
|
187 |
|
188 void ReadUnencryptedPropertiesColumnL( RBuf8& aProperties ); |
|
189 void WriteUnencryptedPropertiesColumnL( const TDesC8& aProperties ); |
|
190 |
|
191 void SetEncryptedL( TBool aIsEncrypted ); |
|
192 |
|
193 // ================== |
|
194 // PRIVATE ATTRIBUTES |
|
195 // ================== |
|
196 |
|
197 MCustomBehaviorProvider& iCustomBehaviorProvider; |
|
198 const TUint iCountsLength; |
|
199 CContainerStoreEncryption& iEncryption; |
|
200 |
|
201 TInt iIdColNum; |
|
202 TInt iParentIdColNum; |
|
203 TInt iChildrenCountColNum; |
|
204 TInt iPropertiesColNum; |
|
205 TInt iQuickPropertiesColNum; |
|
206 TInt iCountsColNum; |
|
207 TInt iChildrenCountsColNum; |
|
208 TInt iIsRowEncryptedColNum; |
|
209 |
|
210 __LOG_DECLARATION |
|
211 |
|
212 }; // end class CContainerStoreContainersTable |
|
213 |
|
214 #endif |