|
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: Interface for CA database implementations |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CASTORAGEPROXY_H |
|
19 #define CASTORAGEPROXY_H |
|
20 |
|
21 #include "cadef.h" |
|
22 #include "castorage_global.h" |
|
23 #include "caoperationparams.h" |
|
24 |
|
25 |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CCaStorage; |
|
29 class CCaInnerQuery; |
|
30 class CCaInnerEntry; |
|
31 class CCaLocalizationEntry; |
|
32 class MCaSessionNorifier; |
|
33 |
|
34 CA_STORAGE_TEST_CLASS( TestCaClient ) |
|
35 |
|
36 /** |
|
37 * Interface for CA database implementations. |
|
38 * |
|
39 */ |
|
40 class CCaStorageProxy: public CBase |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 */ |
|
47 static CCaStorageProxy* NewL(); |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 static CCaStorageProxy* NewLC(); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 ~CCaStorageProxy(); |
|
58 |
|
59 /** |
|
60 * Localizes one entry attribute |
|
61 * |
|
62 * @param aLocalization information about one localization row. |
|
63 */ |
|
64 IMPORT_C void LocalizeEntryL( CCaLocalizationEntry& aLocalization ); |
|
65 |
|
66 /** |
|
67 * Add localization row to the storage |
|
68 * |
|
69 * @param aLocalization entry containing localization row to be added |
|
70 */ |
|
71 IMPORT_C void AddLocalizationL(const CCaLocalizationEntry& aLocalization); |
|
72 |
|
73 /** |
|
74 * Fetches localization data from database |
|
75 * |
|
76 * @param aResultContainer Target for results. |
|
77 */ |
|
78 IMPORT_C void GetLocalizationsL( |
|
79 RPointerArray<CCaLocalizationEntry>& aResultContainer ); |
|
80 |
|
81 /** |
|
82 * Fetches data from storage. |
|
83 * @param aQuery Query filter for entries to be fetched. |
|
84 * @param aResult Result entry container. |
|
85 */ |
|
86 IMPORT_C void GetEntriesL( const CCaInnerQuery* aQuery, |
|
87 RPointerArray<CCaInnerEntry>& aResultContainer ); |
|
88 |
|
89 /** |
|
90 * Fetches entry ids from storage. |
|
91 * @param aQuery Query filter for entries' ids to be fetched. |
|
92 * @param aResultIdArray Result entry id array. |
|
93 */ |
|
94 IMPORT_C void GetEntriesIdsL( const CCaInnerQuery* aQuery, |
|
95 RArray<TInt>& aResultIdArray ); |
|
96 |
|
97 /** |
|
98 * Adds or Updates data to storage. |
|
99 * In case when data is added the input aEntry serves. |
|
100 * also as an output entry. |
|
101 * @param aEntry Entry data. |
|
102 * @param aUpdate is entry updated by a client. |
|
103 * @param aItemAppearanceChange a type of change of the item. |
|
104 */ |
|
105 IMPORT_C void AddL( CCaInnerEntry* aEntry, |
|
106 TBool aUpdate = EFalse, |
|
107 TItemAppearance aItemAppearanceChange = EItemAppearanceNotChanged ); |
|
108 |
|
109 /** |
|
110 * Removes entries from storage. |
|
111 * @param aEntryIds Ids of entries to be removed. |
|
112 */ |
|
113 IMPORT_C void RemoveL( const RArray<TInt>& aEntryIds ); |
|
114 |
|
115 /** |
|
116 * Organizes entries in storage. |
|
117 * @param aEntryIds Entry ids to be organized |
|
118 * (insert, remove, append, prepend are possible). |
|
119 * @param aParams Organize parameters. |
|
120 */ |
|
121 IMPORT_C void OrganizeL( const RArray<TInt>& aEntryIds, |
|
122 TCaOperationParams aParams ); |
|
123 |
|
124 /** |
|
125 * Executes touch specific actions on storage. |
|
126 * Should be called when e.g. entry is clicked. |
|
127 * @param aEntry entry to be touched |
|
128 */ |
|
129 IMPORT_C void TouchL( CCaInnerEntry* aEntry ); |
|
130 |
|
131 /** |
|
132 * Get database property on storage. |
|
133 * |
|
134 * @param aProperty The property to get. |
|
135 * @param aPropertyValue The value of property. |
|
136 */ |
|
137 IMPORT_C void DbPropertyL( const TDesC& aProperty, TDes& aPropertyValue ); |
|
138 |
|
139 /** |
|
140 * Set property action on storage. |
|
141 * |
|
142 * @param aProperty The property to set. |
|
143 * @param aPropertyValue The value of property. |
|
144 */ |
|
145 IMPORT_C void SetDBPropertyL( const TDesC& aProperty, |
|
146 const TDesC& aPropertyValue ); |
|
147 |
|
148 /** |
|
149 * Organizes data within a group in custom order in storage. |
|
150 * |
|
151 * @param aEntryIds Ids of entries in custom order. |
|
152 * @param aGroupId Group to sort. |
|
153 */ |
|
154 IMPORT_C void CustomSortL( const RArray<TInt>& aEntryIds, |
|
155 const TInt aGroupId ); |
|
156 |
|
157 |
|
158 /** |
|
159 * Saves a copy of database to private. |
|
160 */ |
|
161 IMPORT_C void SaveDatabaseL(); |
|
162 |
|
163 /** |
|
164 * Marks db to be restored from backup by next restart |
|
165 */ |
|
166 IMPORT_C void RestoreDatabaseL(); |
|
167 |
|
168 |
|
169 /** |
|
170 * Loads data base from rom. |
|
171 */ |
|
172 IMPORT_C void LoadDataBaseFromRomL(); |
|
173 |
|
174 /** |
|
175 * Add a session. Ownership not taken, this object only keeps a list of |
|
176 * sessions that are dependent on its engine. |
|
177 * @param aSession Session. |
|
178 */ |
|
179 void AddSessionL( MCaSessionNorifier* aHandlerNotifier ); |
|
180 |
|
181 /** |
|
182 * Remove a session. Safe to call if not added. |
|
183 * When no more sessions remain dependent on this object, timed |
|
184 * self-deletion is scheduled. |
|
185 */ |
|
186 void RemoveSession( MCaSessionNorifier* aHandlerNotifier ); |
|
187 |
|
188 private: |
|
189 |
|
190 /** |
|
191 * Perform the second phase construction of a CCpStorageEngine object. |
|
192 */ |
|
193 void ConstructL(); |
|
194 |
|
195 /** |
|
196 * C++ default constructor. |
|
197 */ |
|
198 CCaStorageProxy(); |
|
199 |
|
200 CCaLocalizationEntry* LocalizeTextL( CCaInnerEntry* aEntry ); |
|
201 |
|
202 CCaLocalizationEntry* LocalizeDescriptionL( CCaInnerEntry* aEntry ); |
|
203 |
|
204 TBool InitializeTranslatorL( TDesC& aQmFilename ); |
|
205 |
|
206 private: |
|
207 //Data |
|
208 |
|
209 /** |
|
210 * Data storage. Own. |
|
211 */ |
|
212 CCaStorage* iStorage; |
|
213 |
|
214 /** |
|
215 * Sessions using this engine. Own. |
|
216 */ |
|
217 RPointerArray<MCaSessionNorifier> iHandlerNotifier; |
|
218 |
|
219 CA_STORAGE_TEST_FRIEND_CLASS( TestCaClient ) |
|
220 |
|
221 }; |
|
222 |
|
223 #endif //CASTORAGEPROXY_H |