85
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Database implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef C_CASTORAGE_ENGINE_H
|
|
19 |
#define C_CASTORAGE_ENGINE_H
|
|
20 |
|
88
|
21 |
#include <bautils.h>
|
85
|
22 |
#include <e32cons.h>
|
|
23 |
#include <sqldb.h>
|
|
24 |
#include "castorage.h"
|
|
25 |
#include "castorage_global.h"
|
|
26 |
CA_STORAGE_TEST_CLASS(CCAStorageTest)
|
|
27 |
|
|
28 |
// FORWARD DECLARATIONS
|
|
29 |
class CaSqlQueryCreator;
|
|
30 |
class RCaEntryAttrArray;
|
|
31 |
class CCaSqlQuery;
|
|
32 |
class TCaOperationParams;
|
|
33 |
class RFs;
|
|
34 |
class CCaLocalizationEntry;
|
|
35 |
|
|
36 |
// CLASS DECLARATION
|
|
37 |
/**
|
|
38 |
* SQLite based databse for Content Publisher
|
|
39 |
*
|
|
40 |
* @lib castorage.dll
|
|
41 |
* @since S60 v5.0
|
|
42 |
*/
|
|
43 |
NONSHARABLE_CLASS( CCaSqLiteStorage ): public CCaStorage
|
|
44 |
{
|
|
45 |
CA_STORAGE_TEST_FRIEND_CLASS(CCAStorageTest)
|
|
46 |
|
|
47 |
public:
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Two-phased constructor.
|
|
51 |
*/
|
|
52 |
static CCaSqLiteStorage* NewL();
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Two-phased constructor.
|
|
56 |
*/
|
|
57 |
static CCaSqLiteStorage* NewLC();
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Destructor.
|
|
61 |
*/
|
|
62 |
~CCaSqLiteStorage();
|
|
63 |
|
|
64 |
//from CCpStorage
|
86
|
65 |
/**
|
|
66 |
* Loads data base from rom.
|
|
67 |
*/
|
|
68 |
void LoadDataBaseFromRomL();
|
107
|
69 |
|
|
70 |
//from CCpStorage
|
|
71 |
/**
|
|
72 |
* Saves a copy of database to private.
|
|
73 |
*/
|
|
74 |
void SaveDatabaseL();
|
|
75 |
|
|
76 |
//from CCpStorage
|
|
77 |
/**
|
|
78 |
* Restores a copy of database from backup to private.
|
|
79 |
*/
|
|
80 |
void RestoreDatabaseL();
|
85
|
81 |
|
|
82 |
/**
|
|
83 |
* Localizes one entry attribute.
|
|
84 |
*
|
|
85 |
* @param aLocalization Localization information.
|
|
86 |
*/
|
|
87 |
void LocalizeEntryL( CCaLocalizationEntry& aLocalization );
|
|
88 |
|
|
89 |
/**
|
94
|
90 |
* Adds or updates localization row in the localization table
|
|
91 |
*
|
|
92 |
* @param aLocalization localization information about entry.
|
|
93 |
*/
|
|
94 |
void AddLocalizationL( const CCaLocalizationEntry& aLocalization );
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Checks if entry already exists in localization table
|
|
98 |
*
|
|
99 |
* @param aLocalization localization information about entry.
|
|
100 |
*/
|
|
101 |
TBool LocalizationEntryPresentL(const CCaLocalizationEntry& aLocalization);
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Updates localization row in the localization table
|
|
105 |
*
|
|
106 |
* @param aLocalization localization information about entry.
|
|
107 |
* @param aStatement SQL statement
|
|
108 |
*/
|
|
109 |
void ExecuteLocalizationStatementL(const CCaLocalizationEntry& aLocalization,
|
|
110 |
const TDesC& aStatement);
|
|
111 |
|
|
112 |
/**
|
85
|
113 |
* Fetches data from database.
|
|
114 |
*
|
|
115 |
* @param aMap Filtering and sorting criteria
|
|
116 |
*/
|
86
|
117 |
void GetLocalizationsL(
|
|
118 |
RPointerArray<CCaLocalizationEntry>& aResultContainer );
|
85
|
119 |
|
|
120 |
/**
|
|
121 |
* Fetches data from database.
|
|
122 |
*
|
|
123 |
* @param aQuery .
|
|
124 |
* @param aResultContainer Target for results.
|
|
125 |
*/
|
86
|
126 |
void GetEntriesL( const CCaInnerQuery* aQuery,
|
85
|
127 |
RPointerArray<CCaInnerEntry>& aResultContainer );
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Fetches entry ids from database.
|
|
131 |
*
|
|
132 |
* @param aQuery Filtering and sorting criteria.
|
|
133 |
* @param aResultIdArray Target for results.
|
|
134 |
*/
|
|
135 |
void GetEntriesIdsL( const CCaInnerQuery* aQuery,
|
|
136 |
RArray<TInt>& aResultIdArray );
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Fetches parent id from database by entry ids.
|
|
140 |
*
|
|
141 |
* @param aEntryIdArray List of enties ids.
|
|
142 |
* @param aParentIdArray The result list of parents
|
|
143 |
* ids for a specific select.
|
98
|
144 |
* @param aCheckParentsParent falg if set to true then
|
|
145 |
* search also for parent of the parent
|
85
|
146 |
*/
|
|
147 |
void GetParentsIdsL( const RArray<TInt>& aEntryIdArray,
|
98
|
148 |
RArray<TInt>& aParentIdArray,
|
|
149 |
TBool aCheckParentsParent = ETrue );
|
85
|
150 |
|
|
151 |
/**
|
|
152 |
* Adds or Updates data & action to database.
|
|
153 |
* @param aEntry Map Containing data item.
|
|
154 |
* @param aUpdate true means there goes an update
|
|
155 |
* @return id of added entry.
|
|
156 |
*/
|
|
157 |
void AddL( CCaInnerEntry* aEntry, TBool aUpdate = EFalse);
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Remove data item from database.
|
|
161 |
* @param aEntryIds Filtering and sorting criteria.
|
|
162 |
*/
|
|
163 |
void RemoveL( const RArray<TInt>& aEntryIds );
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Organize data.
|
|
167 |
* @param aEntryIds Ids array.
|
|
168 |
* @param aParams TCaOperationParams describe operation type.
|
|
169 |
*/
|
|
170 |
void OrganizeL( const RArray<TInt>& aEntryIds,
|
|
171 |
TCaOperationParams aParams );
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Add ifno launch to db.
|
|
175 |
* @param aEntryId.
|
107
|
176 |
* @param aRemovable.
|
85
|
177 |
*/
|
107
|
178 |
void TouchL( const TInt aEntryId, TBool aRemovable );
|
86
|
179 |
|
85
|
180 |
/**
|
|
181 |
* Get database property from db.
|
|
182 |
*
|
|
183 |
* @param aProperty The property to get.
|
|
184 |
* @param aPropertyValue The value of property.
|
|
185 |
*/
|
|
186 |
void DbPropertyL( const TDesC& aProperty, TDes& aPropertyValue );
|
86
|
187 |
|
85
|
188 |
/**
|
|
189 |
* Set property .
|
|
190 |
*
|
|
191 |
* @param aProperty The property to set.
|
|
192 |
* @param aPropertyValue The value of property.
|
|
193 |
*/
|
86
|
194 |
void SetDBPropertyL( const TDesC& aProperty,
|
|
195 |
const TDesC& aPropertyValue );
|
85
|
196 |
|
|
197 |
/**
|
|
198 |
* Remove from localization table .
|
|
199 |
*
|
|
200 |
* @param aEntryId Entry Id to remove.
|
|
201 |
*/
|
|
202 |
void RemoveFromLocalizationL( const TInt aEntryId );
|
86
|
203 |
|
85
|
204 |
/**
|
|
205 |
* Organizes data within a group in custom order.
|
|
206 |
*
|
|
207 |
* @param aEntryIds Ids of entries in custom order.
|
|
208 |
* @param aGroupId Group to sort.
|
|
209 |
*/
|
|
210 |
void CustomSortL( const RArray<TInt>& aEntryIds, const TInt aGroupId );
|
|
211 |
|
|
212 |
private:
|
|
213 |
|
|
214 |
/**
|
86
|
215 |
* Perform the second phase construction of a CCpStorageEngine
|
85
|
216 |
* object.
|
|
217 |
*/
|
|
218 |
void ConstructL();
|
|
219 |
|
|
220 |
/**
|
|
221 |
* C++ default constructor.
|
|
222 |
*/
|
|
223 |
CCaSqLiteStorage();
|
|
224 |
|
|
225 |
TInt CreatePrivateDirPath( TFileName& aPrivatePath,
|
86
|
226 |
const TDesC& aDrive, const TDesC& aDbName );
|
|
227 |
|
85
|
228 |
void ExecuteStatementL( const TDesC& aStatement );
|
86
|
229 |
|
85
|
230 |
void ExecuteAddL( CCaInnerEntry* aEntry,
|
|
231 |
RPointerArray<CCaSqlQuery>& sqlQuery );
|
86
|
232 |
|
85
|
233 |
void ExecuteRemoveL( const RArray<TInt>& aEntryIds );
|
86
|
234 |
|
85
|
235 |
void ExecuteRemoveFromLocalizationL( const TInt aEntryId );
|
86
|
236 |
|
85
|
237 |
void ExecuteOrganizeL( const RArray<TInt>& aEntryIds,
|
|
238 |
TCaOperationParams aParams );
|
86
|
239 |
|
107
|
240 |
void ExecuteTouchL( const TInt aEntryId, TBool aRemovable );
|
86
|
241 |
|
85
|
242 |
void ExecuteDbPropertyL( const TDesC& aProperty, TDes& aPropertyValue );
|
86
|
243 |
|
|
244 |
void ExecuteSetDbPropertyL( const TDesC& aProperty,
|
|
245 |
const TDesC& aPropertyValue );
|
|
246 |
|
|
247 |
void ExecuteCustomSortL( const RArray<TInt>& aEntryIds,
|
|
248 |
const TInt aGroupId,
|
85
|
249 |
RPointerArray<CCaSqlQuery>& aSqlQuery );
|
86
|
250 |
|
85
|
251 |
void RemoveOldEntriesFromLaunchTableL( TInt aDays );
|
86
|
252 |
|
85
|
253 |
void VerifyOrganizeParamsL( const RArray<TInt>& aEntryIds,
|
|
254 |
TCaOperationParams aParams );
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Sets entries in proper order
|
|
258 |
* @param aEntryIds array with ids which are ordered properly
|
|
259 |
* @param aResultContainer array containing entries to be ordered
|
|
260 |
*/
|
|
261 |
void SetEntriesInProperOrderL( const RArray<TInt>& aEntryIds,
|
|
262 |
RPointerArray<CCaInnerEntry>& aResultContainer );
|
|
263 |
|
|
264 |
private:
|
|
265 |
|
|
266 |
/**
|
|
267 |
* Database.
|
|
268 |
* Own.
|
|
269 |
*/
|
|
270 |
RSqlDatabase iSqlDb;
|
|
271 |
|
86
|
272 |
/**
|
|
273 |
* Path to data base in private path on C-drive.
|
|
274 |
*/
|
|
275 |
TFileName iPrivatePathCDriveDb;
|
|
276 |
|
|
277 |
/**
|
|
278 |
* Path to data base in private path on Z-drive.
|
|
279 |
*/
|
|
280 |
TFileName iPrivatePathZDriveDb;
|
|
281 |
|
|
282 |
/**
|
|
283 |
* Private path on C-drive.
|
|
284 |
*/
|
|
285 |
TFileName iPrivatePathCDrive;
|
107
|
286 |
|
|
287 |
/**
|
|
288 |
* Private path on C-drive for backup db.
|
|
289 |
*/
|
|
290 |
TFileName iPrivatePathCDriveDbBackup;
|
86
|
291 |
|
|
292 |
/**
|
|
293 |
* RFs session.
|
|
294 |
*/
|
|
295 |
RFs iRfs;
|
|
296 |
|
85
|
297 |
};
|
|
298 |
|
|
299 |
#endif //C_CASTORAGE_ENGINE_H
|