|
1 /* |
|
2 * Copyright (c) 2009 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: DS Dummy datastore |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CNSMLDUMMYDATASTORE_H |
|
19 #define CNSMLDUMMYDATASTORE_H |
|
20 |
|
21 // EXTERNAL INCLUDES |
|
22 #include <nsmlcontactsdatastore.h> |
|
23 |
|
24 // Device Info resource filenames |
|
25 _LIT( KNSmlDummyContactsStoreFormatRsc_1_1_2, "NSmlDummyDataStoreFormat_1_1_2.rsc" ); |
|
26 _LIT( KNSmlDummyContactsStoreFormatRsc_1_2, "NSmlDummyDataStoreFormat_1_2.rsc" ); |
|
27 |
|
28 // CLASS DEFINITION |
|
29 /** |
|
30 * Datastore class for Dummy adapters |
|
31 * @lib nsmldummydataprovider.lib |
|
32 * @since 3.23 |
|
33 */ |
|
34 class CNSmlDummyDataStore : public CNSmlContactsDataStore |
|
35 { |
|
36 private: // Friend class definitions (for unit test purposes) |
|
37 friend class CNSmlDummyDataStore_Test; |
|
38 friend class CNSmlDummyDataStoreWaiter; |
|
39 |
|
40 public: // Constructors and destructor |
|
41 |
|
42 static CNSmlDummyDataStore* NewL(); |
|
43 static CNSmlDummyDataStore* NewLC(); |
|
44 ~CNSmlDummyDataStore(); |
|
45 |
|
46 protected: // Constructors |
|
47 |
|
48 CNSmlDummyDataStore(); |
|
49 void ConstructL(); |
|
50 |
|
51 protected: // From CNSmlContactsDataStore |
|
52 |
|
53 /** |
|
54 * Opens datastore for read/write access. Store to open is specified |
|
55 * by datastore name aStoreName and syncronisation relationship |
|
56 * aContext. Command status is returned in aStatus. Internal state |
|
57 * of this class instance is set to ENSmlOpenAndWaiting and was |
|
58 * expected to be ENSmlClosed before calling this method, otherwise |
|
59 * KErrInUse error is returned. |
|
60 */ |
|
61 void DoOpenL( const TDesC& aStoreName, MSmlSyncRelationship& aContext, |
|
62 TRequestStatus& aStatus); |
|
63 |
|
64 /** |
|
65 * Cancels the current asynchronous request (including OpenL()-method.) |
|
66 */ |
|
67 void DoCancelRequest(); |
|
68 |
|
69 /** |
|
70 * Returns the name of the currently opened datastore. |
|
71 */ |
|
72 const TDesC& DoStoreName() const; |
|
73 |
|
74 /** |
|
75 * Not supported currently (Starts the transaction.) |
|
76 */ |
|
77 void DoBeginTransactionL(); |
|
78 |
|
79 /** |
|
80 * Not supported currently |
|
81 * |
|
82 * (After executing operations for data items and no errors has |
|
83 * occurred CommitTransactionL() is called. aStatus is a return |
|
84 * status for CommitTransactionL()method.) |
|
85 */ |
|
86 void DoCommitTransactionL( TRequestStatus& aStatus ); |
|
87 |
|
88 /** |
|
89 * Not supported currently |
|
90 * |
|
91 * (If an execution of an operation for a dataitem fails during |
|
92 * transaction then RevertTransactionL() is called. aStatus is |
|
93 * a return status for RevertTransactionL()method. ) |
|
94 */ |
|
95 void DoRevertTransaction( TRequestStatus& aStatus ); |
|
96 |
|
97 /** |
|
98 * Starts the batch. During this mode calls to CreateItemL(), |
|
99 * ReplaceItemL(), WriteItemL(), CommitItemL(), MoveItemL(), |
|
100 * DeleteItemL() and SoftDeleteItemL() will be buffered until |
|
101 * DoCommitBatchL(). |
|
102 */ |
|
103 void DoBeginBatchL(); |
|
104 |
|
105 /** |
|
106 * Executes all batched commands. Results for items are returned |
|
107 * in array structure aResultArray and status for CommitBatchL |
|
108 * is returned in aStatus. |
|
109 */ |
|
110 void DoCommitBatchL( RArray< TInt >& aResultArray, |
|
111 TRequestStatus& aStatus ); |
|
112 |
|
113 /** |
|
114 * Cancels the ongoing batch command buffering and frees all |
|
115 * buffered commands. |
|
116 */ |
|
117 void DoCancelBatch(); |
|
118 |
|
119 /** |
|
120 * Sets the datastore format according aServerDataStoreFormat |
|
121 * structure. This is used in stripping and merging. |
|
122 */ |
|
123 void DoSetRemoteStoreFormatL( |
|
124 const CSmlDataStoreFormat& aServerDataStoreFormat ); |
|
125 |
|
126 /** |
|
127 * Sets the SyncML Remote Server maximum object size. This size |
|
128 * is used to check that only smaller items than maximum object |
|
129 * size are sent to SyncML Remote Server. |
|
130 */ |
|
131 void DoSetRemoteMaxObjectSize( TInt aServerMaxObjectSize ); |
|
132 |
|
133 /** |
|
134 * Returns the maximum object size of data provider. Size is read |
|
135 * from resources if they are already opened otherwise default |
|
136 * value KNSmlDataStoreMaxSize is returned. |
|
137 */ |
|
138 TInt DoMaxObjectSize() const; |
|
139 |
|
140 /** |
|
141 * Indicates that SyncML Remote Server is going to read item with |
|
142 * ReadItemL() method. Input value aUid indicates item id to open, |
|
143 * references returned aFieldChange, aSize, aParent, aMimeType, |
|
144 * aMimeVer and aStatus indicates if fieldchange is possible, |
|
145 * parent uid, item’s mimetype, item’s mimeversion and status of |
|
146 * this commands execution respectively. aFieldChange is not currently |
|
147 * supported. Internal state of this class instance is set to |
|
148 * ENSmlItemOpen and was expected to be ENSmlOpenAndWaiting before |
|
149 * calling this method, otherwise KErrNotReady error is returned. |
|
150 */ |
|
151 void DoOpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange, |
|
152 TInt& aSize, TSmlDbItemUid& aParent, TDes8& aMimeType, |
|
153 TDes8& aMimeVer, TRequestStatus& aStatus ); |
|
154 |
|
155 /** |
|
156 * Indicates that SyncML Remote Server is going to create item with |
|
157 * WriteItemL() method. Input values aSize, aParent, aMimeType and |
|
158 * aMimeVer indicates item size that is to be created, parent’s uid, |
|
159 * item’s mimetype and item’s mimeversion respectively. Status of |
|
160 * this commands execution is returned in reference aStatus and |
|
161 * item’s uid that is created is returned in aUid. Internal state |
|
162 * of this class instance is set to ENSmlItemCreating and was expected |
|
163 * to be ENSmlOpenAndWaiting before calling this method, otherwise |
|
164 * KErrNotReady error is returned. |
|
165 */ |
|
166 void DoCreateItemL( TSmlDbItemUid& aUid, TInt aSize, |
|
167 TSmlDbItemUid aParent, const TDesC8& aMimeType, |
|
168 const TDesC8& aMimeVer, TRequestStatus& aStatus ); |
|
169 |
|
170 /** |
|
171 * Indicates that SyncPartner is going to replace item’s data with |
|
172 * WriteItemL() method. Input values aUid, aSize, aParent and |
|
173 * aFieldChange indicates item’s id, size, parent’s uid that is to |
|
174 * be replaced and if replace is field change respectively. Status |
|
175 * of this commands execution is returned in reference aStatus. |
|
176 * Internal state of this class instance is set to ENSmlItemUpdating |
|
177 * and was expected to be ENSmlOpenAndWaiting before calling this |
|
178 * method, otherwise KErrNotReady error is returned. |
|
179 */ |
|
180 void DoReplaceItemL( TSmlDbItemUid aUid, TInt aSize, |
|
181 TSmlDbItemUid aParent, TBool aFieldChange, |
|
182 TRequestStatus& aStatus ); |
|
183 |
|
184 /** |
|
185 * Reads data from item at Data Store. Item must be opened with |
|
186 * DoOpenItemL() method before calling this method. Internal state |
|
187 * of this class instance is expected to be ENSmlItemOpen before |
|
188 * calling this method, otherwise KErrNotReady error is returned. |
|
189 * This method leaves with KErrEof when item is completely read. |
|
190 */ |
|
191 void DoReadItemL( TDes8& aBuffer ); |
|
192 |
|
193 /** |
|
194 * DoCreateItemL() or DoReplaceItemL() method must be called before |
|
195 * this method can be called. This method is called until all data |
|
196 * to current item is written. Internal state of this class instance |
|
197 * is expected to be ENSmlItemCreating or ENSmlItemUpdating before |
|
198 * calling this method, otherwise KErrNotReady error is returned. |
|
199 */ |
|
200 void DoWriteItemL( const TDesC8& aData ); |
|
201 |
|
202 /** |
|
203 * Commits item changes to Contacts database. This method updates |
|
204 * Contacts database through contacts model method ImportContactsL |
|
205 * to update or to create item respectively. Internal state of this |
|
206 * class instance is expected to be ENSmlItemCreating or |
|
207 * ENSmlItemUpdating before calling this method, otherwise |
|
208 * KErrNotReady error is returned.On BatchMode KErrNone returned |
|
209 * and final command status(es) for each buffered command is returned |
|
210 * when DoCommitBatchL() is called. |
|
211 */ |
|
212 void DoCommitItemL( TRequestStatus& aStatus ); |
|
213 |
|
214 /** |
|
215 * Closes operations for opened item. Called after DoReadItemL(). |
|
216 */ |
|
217 void DoCloseItem(); |
|
218 |
|
219 /** |
|
220 * Not supported for Contacts data provider. |
|
221 */ |
|
222 void DoMoveItemL( TSmlDbItemUid aUid, |
|
223 TSmlDbItemUid aNewParent, TRequestStatus& aStatus ); |
|
224 |
|
225 /** |
|
226 * Deletes item with given aUid. |
|
227 */ |
|
228 void DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus ); |
|
229 |
|
230 /** |
|
231 * Soft delete is not supported. |
|
232 */ |
|
233 void DoSoftDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus ); |
|
234 |
|
235 /** |
|
236 * Deletes all items except OwnCardId. ChangeFinder data is resetted. |
|
237 */ |
|
238 void DoDeleteAllItemsL( TRequestStatus& aStatus ); |
|
239 |
|
240 /** |
|
241 * Returns True if synchronisation history is available for server, |
|
242 * otherwise False. Checks also that database id is not changed |
|
243 * for some reason. |
|
244 */ |
|
245 TBool DoHasSyncHistory() const; |
|
246 |
|
247 /** |
|
248 * Returns UIDs of items that are added to client after previous |
|
249 * synchronization. ChangeFinder-method FindNewItemsL() called |
|
250 * to get list. |
|
251 */ |
|
252 const MSmlDataItemUidSet& DoAddedItems() const; |
|
253 |
|
254 /** |
|
255 * Returns UIDs of items that are deleted from client after previous |
|
256 * synchronization. ChangeFinder-method FindDeletedItemsL() called |
|
257 * to get list. |
|
258 */ |
|
259 const MSmlDataItemUidSet& DoDeletedItems() const; |
|
260 |
|
261 /** |
|
262 * Returns UIDs of items that are softdeleted from client after |
|
263 * previous synchronization. ChangeFinder-method |
|
264 * FindSoftDeletedItemsL() called to get list. |
|
265 */ |
|
266 const MSmlDataItemUidSet& DoSoftDeletedItems() const; |
|
267 |
|
268 /** |
|
269 * Returns UIDs of items that are updated in client after previous |
|
270 * synchronization. ChangeFinder-method FindChangedItemsL() called |
|
271 * to get list. |
|
272 */ |
|
273 const MSmlDataItemUidSet& DoModifiedItems() const; |
|
274 |
|
275 /** |
|
276 * Not actually supported for Contacts. |
|
277 * Returns UIDs of items that are moved in client after previous |
|
278 * synchronization. ChangeFinder-method FindMovedItemsL() called |
|
279 * to get list. |
|
280 */ |
|
281 const MSmlDataItemUidSet& DoMovedItems() const; |
|
282 |
|
283 /** |
|
284 * Resets the current synchronisation history by ChangeFinder |
|
285 * ResetL()-method. ResetChangeInfoL()status is returned in aStatus. |
|
286 */ |
|
287 void DoResetChangeInfoL( TRequestStatus& aStatus ); |
|
288 |
|
289 /** |
|
290 * Commits change info changes with ChangeFinder |
|
291 * CommitChangesL()-method and returns status for uid set aItems. |
|
292 * CommitChangeInfoL()status is returned in aStatus. This method |
|
293 * is called for all commands succefully executed in HostServer. |
|
294 */ |
|
295 void DoCommitChangeInfoL( TRequestStatus& aStatus, |
|
296 const MSmlDataItemUidSet& aItems ); |
|
297 |
|
298 /** |
|
299 * Commits change info changes with ChangeFinder |
|
300 * CommitChangesL()-method and returns status in aStatus. |
|
301 */ |
|
302 void DoCommitChangeInfoL( TRequestStatus& aStatus ); |
|
303 |
|
304 const TDesC& GetStoreFormatResourceFileL() const; |
|
305 TInt DoExecuteBufferL( RArray< TInt >& aResultArray ); |
|
306 CNSmlDataModBase& GetDataMod(); |
|
307 TInt ExportContactsL( const TUid& aUid, CBufBase& aContactBufBase ); |
|
308 CArrayFixFlat<TUid>* ImportContactsL( const TDesC8& aContactBufBase ); |
|
309 }; |
|
310 |
|
311 #endif // CNSMLDUMMYDATASTORE_H |
|
312 |
|
313 // End of file |