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 |
|
19 #ifndef C_CPSTORAGE_ENGINE_H |
|
20 #define C_CPSTORAGE_ENGINE_H |
|
21 |
|
22 #include <e32cons.h> |
|
23 #include <sqldb.h> |
|
24 #include "cpstorage.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 #ifdef CONTENT_PUBLISHER_DEBUG |
|
28 class CCPDebug; |
|
29 #endif |
|
30 class MCPChangeNotifier; |
|
31 class CRepository; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 /** |
|
35 * SQLite based databse for Content Publisher |
|
36 * |
|
37 * @lib cpstorage.dll |
|
38 * @since S60 v5.0 |
|
39 */ |
|
40 NONSHARABLE_CLASS( CCpStorageEngine ): public CCpStorage |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 */ |
|
47 static CCpStorageEngine* NewL(); |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 static CCpStorageEngine* NewLC(); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 ~CCpStorageEngine(); |
|
58 |
|
59 //from CCpStorage |
|
60 |
|
61 /** |
|
62 * Fetches data from database |
|
63 * |
|
64 * @param aMap Filtering and sorting criteria |
|
65 * @param aList Target for results |
|
66 */ |
|
67 void GetListL( const CLiwMap* aMap, CLiwGenericParamList& aList ); |
|
68 |
|
69 /** |
|
70 * Adds or Updates data & action to database |
|
71 * @param Map containing data item |
|
72 * @return id of added entry |
|
73 */ |
|
74 TInt32 AddL( const CLiwMap* aMap ); |
|
75 |
|
76 /** |
|
77 * Remove data item from database |
|
78 * @param Filtering and sorting criteria |
|
79 */ |
|
80 void RemoveL( const CLiwMap* aMap ); |
|
81 |
|
82 /** |
|
83 * Set database observer |
|
84 * @param Callback pointer |
|
85 */ |
|
86 void SetCallback( MCPChangeNotifier* aCallback ); |
|
87 |
|
88 private: |
|
89 |
|
90 /** |
|
91 * Perform the second phase construction of a CCpStorageEngine object. |
|
92 */ |
|
93 void ConstructL(); |
|
94 |
|
95 /** |
|
96 * C++ default constructor. |
|
97 */ |
|
98 CCpStorageEngine(); |
|
99 |
|
100 /** |
|
101 * Creates database tables. |
|
102 */ |
|
103 void CreateTablesL(); |
|
104 |
|
105 /** |
|
106 * Creates new database. |
|
107 * If Db is created for the first time, |
|
108 * set repository db state into KSQLDBStateNormal |
|
109 */ |
|
110 void CreateNewDbL(); |
|
111 |
|
112 /** |
|
113 * Deletes database. |
|
114 * Called when opening Db try return KSqlErrCorrupt error. |
|
115 * Removes KSQLDBStateNormal state and set KSQLDBStateRestored into |
|
116 * repository db state. |
|
117 */ |
|
118 void DeleteCorruptedDbL(); |
|
119 |
|
120 private: |
|
121 |
|
122 /** |
|
123 * Database. |
|
124 * Own. |
|
125 */ |
|
126 RSqlDatabase iSqlDb; |
|
127 |
|
128 /** |
|
129 * Callback pointer. |
|
130 * Not own. |
|
131 */ |
|
132 MCPChangeNotifier* iCallback; |
|
133 |
|
134 /** |
|
135 * Repository keeps information about Db state. |
|
136 * Own. |
|
137 */ |
|
138 CRepository* iRepository; |
|
139 |
|
140 #ifdef CONTENT_PUBLISHER_DEBUG |
|
141 CCPDebug* iDebug; |
|
142 #endif |
|
143 }; |
|
144 |
|
145 #endif //C_CPSTORAGE_ENGINE_H |
|