52
|
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: DS contacts datastore.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef __NSMLCONTACTSDATASTORE_H__
|
|
20 |
#define __NSMLCONTACTSDATASTORE_H__
|
|
21 |
|
|
22 |
// INCLUDE FILES
|
|
23 |
#include <SmlDataProvider.h>
|
|
24 |
#include <SmlDataFormat.h>
|
|
25 |
#include <f32file.h>
|
|
26 |
|
|
27 |
//vpbk headers
|
|
28 |
#include <CVPbkContactManager.h>
|
|
29 |
#include <MVPbkContactStore.h>
|
|
30 |
#include <MVPbkContactStoreObserver.h>
|
|
31 |
#include <MVPbkBatchOperationObserver.h>
|
|
32 |
#include <MVPbkContactViewObserver.h>
|
|
33 |
#include <CVPbkSortOrder.h>
|
|
34 |
#include <CVPbkContactIdConverter.h>
|
|
35 |
#include <CVPbkContactLinkArray.h>
|
|
36 |
#include <MVPbkContactViewBase.h>
|
|
37 |
#include <MVPbkSingleContactOperationObserver.h>
|
|
38 |
#include <CVPbkVCardEng.h>
|
|
39 |
#include <MVPbkContactCopyObserver.h>
|
|
40 |
#include <MVPbkBatchOperationObserver.h>
|
|
41 |
#include <MVPbkContactViewObserver.h>
|
|
42 |
#include <MVPbkContactOperationBase.h>
|
|
43 |
#include <CVPbkSortOrder.h>
|
|
44 |
#include <s32mem.h>
|
|
45 |
|
|
46 |
// MACROS
|
|
47 |
#define KNSmlvCard21Version TVersion(2,1,0);
|
|
48 |
#define KNSmlvCard30Version TVersion(3,0,0);
|
|
49 |
|
|
50 |
// CONSTANTS
|
|
51 |
_LIT( KNSmlContactStoreNameForDefaultDB, "C:Contacts.cdb" );
|
|
52 |
_LIT( KNSmlDriveC, "C" );
|
|
53 |
_LIT8( KNSmlvCard30Name, "text/vcard" );
|
|
54 |
_LIT8( KNSmlvCard30Ver, "3.0" );
|
|
55 |
_LIT8( KNSmlvCard21Name, "text/x-vcard" );
|
|
56 |
_LIT8( KNSmlvCard21Ver, "2.1" );
|
|
57 |
|
|
58 |
_LIT8( KVersitTokenHOME, "HOME" );
|
|
59 |
_LIT8( KVersitTokenWORK, "WORK" );
|
|
60 |
_LIT8( KVersitTokenCELL, "CELL" );
|
|
61 |
_LIT8( KVersitTokenPAGER,"PAGER" );
|
|
62 |
_LIT8( KVersitTokenFAX, "FAX" );
|
|
63 |
_LIT8( KVersitTokenVOICE,"VOICE" );
|
|
64 |
_LIT8( KVersitTokenVIDEO,"VIDEO" );
|
|
65 |
|
|
66 |
//CONSTANTS INTRODUCED FOR HAVING BACKWARD COMPATIBLE PHONE DB SENT TO SERVER
|
|
67 |
//THE CHANGE WAS NEEDED AFTER ADAPTING TO VIRTUAL PHONEBOOK
|
|
68 |
_LIT( KLegacySymbianDatabase,"C:Contacts.cdb");
|
|
69 |
const TInt KOldSymbianDBLength = 20;
|
|
70 |
|
|
71 |
_LIT( KVPbhkSymbianDBPrefix,"cntdb://");
|
|
72 |
const TInt KVPbhkPrefixLength = 10;
|
|
73 |
|
|
74 |
//End NEW CONSTANTS
|
|
75 |
const TInt KNSmlContactsGranularity = 8;
|
|
76 |
const TInt KNSmlCompactAfterChanges = 16;
|
|
77 |
const TInt KNSmlDataStoreMaxSize = 102400; // 100 k
|
|
78 |
const TInt KNSmlDefaultStoreNameMaxSize = 256;
|
|
79 |
const TInt KNSmlItemDataExpandSize = 1024;
|
|
80 |
const TInt KNSmlNoError = 1;
|
|
81 |
|
|
82 |
_LIT(KNSmlContactsStoreFormatRsc_1_1_2,"NSmlContactsDataStoreFormat_1_1_2.rsc");
|
|
83 |
_LIT(KNSmlContactsStoreFormatRsc_1_2,"NSmlContactsDataStoreFormat_1_2.rsc");
|
|
84 |
|
|
85 |
// FORWARD DECLARATIONS
|
|
86 |
class MContactsModsFetcher;
|
|
87 |
class CNSmlDataModBase;
|
|
88 |
class CNSmlChangeFinder;
|
|
89 |
class CNSmlDataItemUidSet;
|
|
90 |
|
|
91 |
// CLASS DECLARATION
|
|
92 |
|
|
93 |
// ------------------------------------------------------------------------------------------------
|
|
94 |
// CNSmlContactsDataStore
|
|
95 |
//
|
|
96 |
// @lib nsmlcontactsdataprovider.lib
|
|
97 |
// ------------------------------------------------------------------------------------------------
|
|
98 |
class CNSmlContactsDataStore : public CSmlDataStore,
|
|
99 |
public MVPbkContactStoreObserver,
|
|
100 |
public MVPbkSingleContactOperationObserver,
|
|
101 |
public MVPbkContactCopyObserver,
|
|
102 |
public MVPbkBatchOperationObserver,
|
|
103 |
public MVPbkContactViewObserver,
|
|
104 |
public MVPbkContactOperationBase
|
|
105 |
{
|
|
106 |
public:
|
|
107 |
/**
|
|
108 |
* Two-phased constructor.
|
|
109 |
*/
|
|
110 |
IMPORT_C static CNSmlContactsDataStore* NewL();
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Destructor.
|
|
114 |
*/
|
|
115 |
IMPORT_C virtual ~CNSmlContactsDataStore();
|
|
116 |
|
|
117 |
/**
|
|
118 |
* Default store name of client.
|
|
119 |
* @return Default store name.
|
|
120 |
*/
|
|
121 |
IMPORT_C const TDesC& DefaultStoreNameL() const;
|
|
122 |
|
|
123 |
/**
|
|
124 |
* Gets a list of all contacts databases on client.
|
|
125 |
* @return List of databases.
|
|
126 |
*/
|
|
127 |
IMPORT_C CDesCArray* DoListStoresLC();
|
|
128 |
|
|
129 |
|
|
130 |
protected:
|
|
131 |
/**
|
|
132 |
* From MVPbkContactStoreListObserver
|
|
133 |
* Called when a contact store is ready to use.
|
|
134 |
*/
|
|
135 |
IMPORT_C void StoreReady( MVPbkContactStore& aContactStore );
|
|
136 |
|
|
137 |
/**
|
|
138 |
* From MVPbkContactStoreListObserver
|
|
139 |
* Called when a contact store becomes unavailable.
|
|
140 |
*/
|
|
141 |
IMPORT_C void StoreUnavailable(MVPbkContactStore& aContactStore,TInt aReason );
|
|
142 |
|
|
143 |
/**
|
|
144 |
* From MVPbkContactStoreListObserver
|
|
145 |
* Called when changes occur in the contact store.
|
|
146 |
*/
|
|
147 |
IMPORT_C void HandleStoreEventL(MVPbkContactStore& aContactStore,TVPbkContactStoreEvent aStoreEvent );
|
|
148 |
|
|
149 |
/**
|
|
150 |
* From MVPbkSingleContactOperationObserver
|
|
151 |
* Called when the operation is completed.
|
|
152 |
*/
|
|
153 |
IMPORT_C void VPbkSingleContactOperationComplete(
|
|
154 |
MVPbkContactOperationBase& aOperation,
|
|
155 |
MVPbkStoreContact* aContact );
|
|
156 |
|
|
157 |
/**
|
|
158 |
* From MVPbkSingleContactOperationObserver
|
|
159 |
* Called if the operation fails.
|
|
160 |
*/
|
|
161 |
IMPORT_C void VPbkSingleContactOperationFailed(MVPbkContactOperationBase& aOperation, TInt aError );
|
|
162 |
|
|
163 |
/**
|
|
164 |
* From MVPbkContactCopyObserver
|
|
165 |
* Called when the contact has been successfully commited or
|
|
166 |
* copied. Caller takes the ownership of results.
|
|
167 |
*/
|
|
168 |
IMPORT_C void ContactsSaved( MVPbkContactOperationBase& aOperation,
|
|
169 |
MVPbkContactLinkArray* aResults ) ;
|
|
170 |
|
|
171 |
/**
|
|
172 |
* From MVPbkContactCopyObserver
|
|
173 |
*Called when there was en error while saving contact(s).
|
|
174 |
*/
|
|
175 |
IMPORT_C void ContactsSavingFailed(
|
|
176 |
MVPbkContactOperationBase& aOperation,
|
|
177 |
TInt aError );
|
|
178 |
// From MVPbkBatchOperationObserver
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Called when one step of the operation is complete.
|
|
182 |
* @param aOperation Operation whose step has completed
|
|
183 |
* @param aStepSize Size of the performed step
|
|
184 |
*/
|
|
185 |
IMPORT_C void StepComplete( MVPbkContactOperationBase& aOperation,
|
|
186 |
TInt aStepSize );
|
|
187 |
|
|
188 |
/**
|
|
189 |
* Called when one step of the operation fails
|
|
190 |
* @param aOperation Operation whose step has failed
|
|
191 |
* @param aStepSize Size of the performed step
|
|
192 |
* @param aError Error that occured
|
|
193 |
* @return ETrue if the batch operation should continue,
|
|
194 |
* EFalse otherwise
|
|
195 |
*/
|
|
196 |
IMPORT_C TBool StepFailed(
|
|
197 |
MVPbkContactOperationBase& aOperation,
|
|
198 |
TInt aStepSize,
|
|
199 |
TInt aError );
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Called when operation is completed
|
|
203 |
* @param aOperation the completed operation
|
|
204 |
*/
|
|
205 |
IMPORT_C void OperationComplete( MVPbkContactOperationBase& aOperation );
|
|
206 |
|
|
207 |
/**
|
|
208 |
* From MVPbkContactViewObserver
|
|
209 |
* Called when a view is ready for use.
|
|
210 |
*/
|
|
211 |
|
|
212 |
IMPORT_C void ContactViewReady(
|
|
213 |
MVPbkContactViewBase& aView ) ;
|
|
214 |
/**
|
|
215 |
* From MVPbkContactViewObserver
|
|
216 |
* Called when a view is unavailable for a while.
|
|
217 |
*/
|
|
218 |
IMPORT_C void ContactViewUnavailable(
|
|
219 |
MVPbkContactViewBase& aView ) ;
|
|
220 |
/**
|
|
221 |
* From MVPbkContactViewObserver
|
|
222 |
* Called when a contact has been added to the view.
|
|
223 |
*/
|
|
224 |
IMPORT_C void ContactAddedToView(
|
|
225 |
MVPbkContactViewBase& aView,
|
|
226 |
TInt aIndex,
|
|
227 |
const MVPbkContactLink& aContactLink );
|
|
228 |
/**
|
|
229 |
* From MVPbkContactViewObserver
|
|
230 |
* Called when a contact has been removed from a view.
|
|
231 |
*/
|
|
232 |
IMPORT_C void ContactRemovedFromView(
|
|
233 |
MVPbkContactViewBase& aView,
|
|
234 |
TInt aIndex,
|
|
235 |
const MVPbkContactLink& aContactLink ) ;
|
|
236 |
/**
|
|
237 |
* From MVPbkContactViewObserver
|
|
238 |
* Called when an error occurs in the view.
|
|
239 |
*/
|
|
240 |
IMPORT_C void ContactViewError(
|
|
241 |
MVPbkContactViewBase& aView,
|
|
242 |
TInt aError,
|
|
243 |
TBool aErrorNotified ) ;
|
|
244 |
|
|
245 |
protected:
|
|
246 |
/**
|
|
247 |
* 2nd phase constructor.
|
|
248 |
*/
|
|
249 |
IMPORT_C void ConstructL();
|
|
250 |
|
|
251 |
/*
|
|
252 |
* 2nd phase constructor.
|
|
253 |
* @param aStorename Name of the contact database instance.
|
|
254 |
* @param aLegaceStore Legacy name of the contact database instance.
|
|
255 |
* This store name is used in the communication with server.
|
|
256 |
*/
|
|
257 |
IMPORT_C void ConstructL( const TDesC& aStoreName, const TDesC& aLegacyStore );
|
|
258 |
/**
|
|
259 |
* DoOpenL() opens the data store specified by aStoreName asynchronously.
|
|
260 |
* @param aStoreName The name of the data store to open.
|
|
261 |
* @param aContext Identifies the specific synchronisation relationship to use for the synchronisation.
|
|
262 |
* @param aStatus On completion of the open, contains the result code.
|
|
263 |
*/
|
|
264 |
IMPORT_C void DoOpenL(const TDesC& aStoreName, MSmlSyncRelationship& aContext, TRequestStatus& aStatus);
|
|
265 |
|
|
266 |
/**
|
|
267 |
* DoCancelRequest() cancels the current asynchronous request, including open. Only one asynchronous request may be outstanding at any one time.
|
|
268 |
*/
|
|
269 |
IMPORT_C void DoCancelRequest();
|
|
270 |
|
|
271 |
/**
|
|
272 |
* DoStoreName() returns the name of the open data store.
|
|
273 |
* @return The name of the currently opened data store.
|
|
274 |
*/
|
|
275 |
IMPORT_C const TDesC& DoStoreName() const;
|
|
276 |
|
|
277 |
/**
|
|
278 |
* DoBeginTransactionL() starts the transaction mode. During this mode calls to CreateItemL, ReplaceItemL,
|
|
279 |
* WriteItemL, CommitItemL, MoveItemL, DeleteItemL and SoftDeleteItemL will be part of this transaction.
|
|
280 |
* Their RequestStatus must be completed, even if the change is not yet really executed in the Data Store.
|
|
281 |
* If a RequestStatus is completed with an error code, the transaction has failed and a rollback must be
|
|
282 |
* done. In this case RevertTransaction will be called.
|
|
283 |
*/
|
|
284 |
IMPORT_C void DoBeginTransactionL();
|
|
285 |
|
|
286 |
/**
|
|
287 |
* DoCommitTransactionL() will be called at the end of a successful transaction. At this point in time the
|
|
288 |
* operations within the transaction are applied to the Data Store in an atomic way. If all operations
|
|
289 |
* succeed, the RequestStatus must be completed with KErrNone. If an operation fails, a rollback must be
|
|
290 |
* done and the RequestStatus must be completed with an appropriate error code.
|
|
291 |
*/
|
|
292 |
IMPORT_C void DoCommitTransactionL(TRequestStatus& aStatus);
|
|
293 |
|
|
294 |
/**
|
|
295 |
* DoRevertTransaction() will be called to abort an ongoing transaction. None of the operations already
|
|
296 |
* submitted may be applied to the Data Store. The RequestStatus must be completed with KErrNone as a revert
|
|
297 |
* cannot fail.
|
|
298 |
*/
|
|
299 |
IMPORT_C void DoRevertTransaction(TRequestStatus& aStatus);
|
|
300 |
|
|
301 |
/**
|
|
302 |
* DoBeginBatchL() starts the batch mode. During this mode calls to CreateItemL, ReplaceItemL,
|
|
303 |
* WriteItemL, CommitItemL, MoveItemL, DeleteItemL and SoftDeleteItemL will be part of this batch.
|
|
304 |
* Their RequestStatus must be completed with KErrNone, which only signals acceptance of the operation
|
|
305 |
* for batch processing.
|
|
306 |
*/
|
|
307 |
IMPORT_C void DoBeginBatchL();
|
|
308 |
|
|
309 |
/**
|
|
310 |
* DoCommitBatchL() will be called at the end of the batch mode. This tells the Data Store to
|
|
311 |
* process the batched operations (in the order they were submitted), and to append the error code
|
|
312 |
* for each operation to aResultArray.
|
|
313 |
* The error codes in aResultArray are only valid if the RequestStatus is completed with KErrNone.
|
|
314 |
* If the RequestStatus is completed with an error code none of the operations in the batch mode
|
|
315 |
* were applied to the Data Store.
|
|
316 |
*/
|
|
317 |
IMPORT_C void DoCommitBatchL(RArray<TInt>& aResultArray, TRequestStatus& aStatus);
|
|
318 |
|
|
319 |
/**
|
|
320 |
* DoCancelBatch() will be called to abort an ongoing batch mode. None of the operations already
|
|
321 |
* submitted may be applied to the Data Store.
|
|
322 |
*/
|
|
323 |
IMPORT_C void DoCancelBatch();
|
|
324 |
|
|
325 |
/**
|
|
326 |
* DoSetRemoteStoreFormatL() sets the SyncML server Data Format - this may optionally be used by the Data
|
|
327 |
* Provider to filter out properties that the server does not support, and should be used to avoid deleting
|
|
328 |
* these properties in case the server sends a changed item to the Data Provider
|
|
329 |
*/
|
|
330 |
IMPORT_C void DoSetRemoteStoreFormatL(const CSmlDataStoreFormat& aServerDataStoreFormat);
|
|
331 |
|
|
332 |
/**
|
|
333 |
* DoSetRemoteMaxObjectSize() sets the SyncML server maximum object size - this may optionally be used by the
|
|
334 |
* Data Provider to not send items to the server exceeding its maximum size. 0 means there is no limit.
|
|
335 |
*/
|
|
336 |
IMPORT_C void DoSetRemoteMaxObjectSize(TInt aServerMaxObjectSize);
|
|
337 |
|
|
338 |
/**
|
|
339 |
* DoMaxObjectSize() gets the Data Store maximum object size which is reported to the SyncML server. 0 means
|
|
340 |
* there is no limit.
|
|
341 |
* @return The maximum object size.
|
|
342 |
*/
|
|
343 |
IMPORT_C TInt DoMaxObjectSize() const;
|
|
344 |
|
|
345 |
/**
|
|
346 |
* DoOpenItemL() opens the data item specified by aUid asynchronously for reading.
|
|
347 |
* @param aUid Item UID which going to be read.
|
|
348 |
* @param aFieldChange Accept field changes.
|
|
349 |
* @param aParent Parent of the item.
|
|
350 |
* @param aSize Size of the item data.
|
|
351 |
* @param aMimeType MIME type of the item.
|
|
352 |
* @param aMimeVer MIME version used on item.
|
|
353 |
* @param aStatus On completion of the opening of item, contains the result code.
|
|
354 |
*/
|
|
355 |
IMPORT_C void DoOpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize, TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, TRequestStatus& aStatus);
|
|
356 |
|
|
357 |
/**
|
|
358 |
* DoCreateItemL() sets the item properties and reference to aUid which will be created.
|
|
359 |
* @param aUid Reference to item UID which going to be created.
|
|
360 |
* @param aSize Size of the item to be created.
|
|
361 |
* @param aParent Parent of the item.
|
|
362 |
* @param aMimeType MIME type of the item.
|
|
363 |
* @param aMimeVer MIME version used on item.
|
|
364 |
* @param aStatus On completion of the creating an item, contains the result code.
|
|
365 |
*/
|
|
366 |
IMPORT_C void DoCreateItemL(TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& aMimeVer, TRequestStatus& aStatus);
|
|
367 |
|
|
368 |
/**
|
|
369 |
* DoReplaceItemL() opens the data item specified by aUid asynchronously to be updated.
|
|
370 |
* @param aUid Item UID which going to be updated.
|
|
371 |
* @param aSize Size of the item data.
|
|
372 |
* @param aParent Parent of the item.
|
|
373 |
* @param aFieldChange Accept field changes.
|
|
374 |
* @param aStatus On completion of the updating of item, contains the result code.
|
|
375 |
*/
|
|
376 |
IMPORT_C void DoReplaceItemL(TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, TBool aFieldChange, TRequestStatus& aStatus);
|
|
377 |
|
|
378 |
/**
|
|
379 |
* DoReadItemL() reads data(or size of aBuffer) of an item opened in DoOpenItemL() to given aBuffer.
|
|
380 |
* @param aBuffer Buffer to item data.
|
|
381 |
*/
|
|
382 |
IMPORT_C void DoReadItemL(TDes8& aBuffer);
|
|
383 |
|
|
384 |
/**
|
|
385 |
* DoWriteItemL() writes aData of an item opened in DoCreateItemL() or DoReplaceItemL() to be saved on database.
|
|
386 |
* @param aData Item data (or part of data).
|
|
387 |
*/
|
|
388 |
IMPORT_C void DoWriteItemL(const TDesC8& aData);
|
|
389 |
|
|
390 |
/**
|
|
391 |
* DoCommitItemL() completes an item operation started in DoCreateItemL() or DoReplaceItemL().
|
|
392 |
* @param aStatus On completion of the operation, contains the result code.
|
|
393 |
*/
|
|
394 |
IMPORT_C void DoCommitItemL(TRequestStatus& aStatus);
|
|
395 |
|
|
396 |
/**
|
|
397 |
* DoCloseItem() completes an item operation started in DoOpenItemL().
|
|
398 |
*/
|
|
399 |
IMPORT_C void DoCloseItem();
|
|
400 |
|
|
401 |
/**
|
|
402 |
* DoMoveItemL() moves item specified by aUid asynchronously.
|
|
403 |
* @param aUid Item UID which going to be moved.
|
|
404 |
* @param aNewParent A new parent of the item.
|
|
405 |
* @param aStatus On completion of the moving an item, contains the result code.
|
|
406 |
*/
|
|
407 |
IMPORT_C void DoMoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus);
|
|
408 |
|
|
409 |
/**
|
|
410 |
* DoDeleteItemL() deletes item specified by aUid asynchronously.
|
|
411 |
* @param aUid Item UID which going to be deleted.
|
|
412 |
* @param aStatus On completion of the deleting an item, contains the result code.
|
|
413 |
*/
|
|
414 |
IMPORT_C void DoDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus);
|
|
415 |
|
|
416 |
/**
|
|
417 |
* DoSoftDeleteItemL() soft deletes item specified by aUid asynchronously.
|
|
418 |
* @param aUid Item UID which going to be softdeleted.
|
|
419 |
* @param aStatus On completion of the softdeleting an item, contains the result code.
|
|
420 |
*/
|
|
421 |
IMPORT_C void DoSoftDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus);
|
|
422 |
|
|
423 |
/**
|
|
424 |
* DoDeleteAllItemsL() deletes all items from opened database asynchronously.
|
|
425 |
* @param aStatus On completion of delete, contains the result code.
|
|
426 |
*/
|
|
427 |
IMPORT_C void DoDeleteAllItemsL(TRequestStatus& aStatus);
|
|
428 |
|
|
429 |
/**
|
|
430 |
* DoHasSyncHistory() checks if previous sync with opened server and context.
|
|
431 |
* @return ETrue if there is synchonization history.
|
|
432 |
*/
|
|
433 |
IMPORT_C TBool DoHasSyncHistory() const;
|
|
434 |
|
|
435 |
/**
|
|
436 |
* DoAddedItems() gets all added items on client since previous synchronization.
|
|
437 |
* @return Added items.
|
|
438 |
*/
|
|
439 |
IMPORT_C const MSmlDataItemUidSet& DoAddedItems() const;
|
|
440 |
|
|
441 |
/**
|
|
442 |
* DoDeletedItems() gets all deleted items on client since previous synchronization.
|
|
443 |
* @return Deleted items.
|
|
444 |
*/
|
|
445 |
IMPORT_C const MSmlDataItemUidSet& DoDeletedItems() const;
|
|
446 |
|
|
447 |
/**
|
|
448 |
* DoSoftDeletedItems() gets all softdeleted items on client since previous synchronization.
|
|
449 |
* @return Soft deleted items.
|
|
450 |
*/
|
|
451 |
IMPORT_C const MSmlDataItemUidSet& DoSoftDeletedItems() const;
|
|
452 |
|
|
453 |
/**
|
|
454 |
* DoModifiedItems() gets all modified items on client since previous synchronization.
|
|
455 |
* @return Modified items.
|
|
456 |
*/
|
|
457 |
IMPORT_C const MSmlDataItemUidSet& DoModifiedItems() const;
|
|
458 |
|
|
459 |
/**
|
|
460 |
* DoMovedItems() gets all moved items on client since previous synchronization.
|
|
461 |
* @return Moved items.
|
|
462 |
*/
|
|
463 |
IMPORT_C const MSmlDataItemUidSet& DoMovedItems() const;
|
|
464 |
|
|
465 |
/**
|
|
466 |
* DoResetChangeInfoL() resets client synchronization data => next time will be slow sync.
|
|
467 |
* @param aStatus On completion of reset, contains the result code.
|
|
468 |
*/
|
|
469 |
IMPORT_C void DoResetChangeInfoL(TRequestStatus& aStatus);
|
|
470 |
|
|
471 |
/**
|
|
472 |
* DoCommitChangeInfoL() commits client synchronization changes for given aItems list.
|
|
473 |
* @param aStatus On completion of given items, contains the result code.
|
|
474 |
* @param aItems Item ids to be commited.
|
|
475 |
*/
|
|
476 |
IMPORT_C void DoCommitChangeInfoL(TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems);
|
|
477 |
|
|
478 |
/**
|
|
479 |
* DoCommitChangeInfoL() commits all client synchronization changes.
|
|
480 |
* @param aStatus On completion of all items, contains the result code.
|
|
481 |
*/
|
|
482 |
IMPORT_C void DoCommitChangeInfoL(TRequestStatus& aStatus);
|
|
483 |
|
|
484 |
/**
|
|
485 |
* Default constructor.
|
|
486 |
*/
|
|
487 |
IMPORT_C CNSmlContactsDataStore();
|
|
488 |
|
|
489 |
/**
|
|
490 |
* SetOwnStoreFormatL() Sets dataproviders own storeformat.
|
|
491 |
*/
|
|
492 |
IMPORT_C void SetOwnStoreFormatL();
|
|
493 |
|
|
494 |
/**
|
|
495 |
* LdoFetchItemL() Fetches item data from database.
|
|
496 |
* @param aUid Items uid for fetching.
|
|
497 |
* @param aItem Items data after fetch.
|
|
498 |
*
|
|
499 |
*/
|
|
500 |
IMPORT_C virtual void LdoFetchItemL( TSmlDbItemUid& aUid, CBufBase& aItem );
|
|
501 |
|
|
502 |
/*
|
|
503 |
* LdoAddItemL() Adds item data to database.
|
|
504 |
* @param aItem Item data to be added.
|
|
505 |
* @param aSize Item data size.
|
|
506 |
*/
|
|
507 |
IMPORT_C virtual void LdoAddItemL( const TDesC8& aItem,
|
|
508 |
TInt aSize);
|
|
509 |
/*
|
|
510 |
* LdoAddItemL() Adds several items to database.
|
|
511 |
* @param aItem Items data to be added.
|
|
512 |
* @param aSize Items data size.
|
|
513 |
*/
|
|
514 |
IMPORT_C virtual void LdoAddItemsL( CBufBase*& aItems,TInt aSize);
|
|
515 |
|
|
516 |
/**
|
|
517 |
* LdoUpdateItemL() Updates item data to database.
|
|
518 |
*
|
|
519 |
*/
|
|
520 |
IMPORT_C virtual void LdoUpdateItemL();
|
|
521 |
|
|
522 |
/**
|
|
523 |
* DriveBelowCriticalLevelL() Checks if there is enough space on client to store added item data.
|
|
524 |
* @param aSize Item size to be added.
|
|
525 |
* @return ETrue if there isn't enough drive space.
|
|
526 |
*/
|
|
527 |
IMPORT_C TBool DriveBelowCriticalLevelL( TInt aSize );
|
|
528 |
|
|
529 |
|
|
530 |
/**
|
|
531 |
* StripPropertyL() Removes aProperty from aItem data.
|
|
532 |
* @param aItem Item data to be stripped.
|
|
533 |
* @param aProperty Property to be removed from aItem.
|
|
534 |
*/
|
|
535 |
IMPORT_C void StripPropertyL( HBufC8*& aItem, const TDesC8& aProperty ) const;
|
|
536 |
|
|
537 |
/**
|
|
538 |
* StripPropertyL() Remove aPropertys from aItem data.
|
|
539 |
* @param aItem Item(s) data to be stripped.
|
|
540 |
* @param aProperty Property to be removed from aItem.
|
|
541 |
*/
|
|
542 |
IMPORT_C void StripPropertyL( CBufBase*& aItem, const TDesC8& aProperty ) const;
|
|
543 |
|
|
544 |
/**
|
|
545 |
* ExecuteBufferL() Executes all buffered items from buffer.
|
|
546 |
* @param aResultArray Array to return statuscodes for each command.
|
|
547 |
*/
|
|
548 |
IMPORT_C virtual void ExecuteBufferL();
|
|
549 |
|
|
550 |
/**
|
|
551 |
* ExecuteAddL() Executes all the add commands in buffer.
|
|
552 |
*/
|
|
553 |
IMPORT_C virtual TInt ExecuteAddL();
|
|
554 |
|
|
555 |
/**
|
|
556 |
* ExecuteDeleteL() Executes all the delete commands in buffer.
|
|
557 |
*/
|
|
558 |
IMPORT_C virtual void ExecuteDeleteL();
|
|
559 |
|
|
560 |
/**
|
|
561 |
* ExecuteBufferL() Executes all the update commands in buffer.
|
|
562 |
*/
|
|
563 |
IMPORT_C virtual void ExecuteUpdateL();
|
|
564 |
|
|
565 |
/**
|
|
566 |
* ExecuteMoveL() Executes all the move commands in buffer.
|
|
567 |
*/
|
|
568 |
IMPORT_C virtual void ExecuteMoveL();
|
|
569 |
|
|
570 |
/**
|
|
571 |
* AddBufferListL()Adds a new item to buffer.
|
|
572 |
* @param aUid New item's uid.
|
|
573 |
* @param aSize New item's size.
|
|
574 |
* @param aStatus New item's status.
|
|
575 |
* @return Pointer to the buffer.
|
|
576 |
*/
|
|
577 |
IMPORT_C CBufBase* AddBufferListL(TSmlDbItemUid& aUid, TInt aSize, TInt aStatus);
|
|
578 |
|
|
579 |
/**
|
|
580 |
* Checks if aItem is confidential or not.
|
|
581 |
* @param aItem Item that is checked.
|
|
582 |
* @return TBool ETrue if item is confidential.
|
|
583 |
* Otherwise EFalse is returned.
|
|
584 |
*/
|
|
585 |
IMPORT_C TBool IsConfidentialL( MVPbkStoreContact& aItem );
|
|
586 |
|
|
587 |
/**
|
|
588 |
* Leaving function called when fetch/retrieve
|
|
589 |
* operation is complete
|
|
590 |
* @param aContact contact fetched/retrieved
|
|
591 |
*
|
|
592 |
*/
|
|
593 |
IMPORT_C void SingleContactOperationCompleteL(MVPbkStoreContact* aContact);
|
|
594 |
|
|
595 |
/**
|
|
596 |
* Create a contact view of the store which is opened
|
|
597 |
*/
|
|
598 |
IMPORT_C void CreateViewL();
|
|
599 |
|
|
600 |
/**
|
|
601 |
* Delete all the contacts
|
|
602 |
*/
|
|
603 |
IMPORT_C virtual void DoDeleteAllContactsL();
|
|
604 |
/**
|
|
605 |
* Leaving function called when the operation is complete
|
|
606 |
*/
|
|
607 |
IMPORT_C void OperationCompleteL();
|
|
608 |
/**
|
|
609 |
* Reset the contacts data buffer
|
|
610 |
*/
|
|
611 |
IMPORT_C void ResetBuffer();
|
|
612 |
|
|
613 |
protected: // New
|
|
614 |
|
|
615 |
/**
|
|
616 |
* Returns the file name for the store format resources.
|
|
617 |
* @return Store format resource file name.
|
|
618 |
*/
|
|
619 |
IMPORT_C virtual const TDesC& GetStoreFormatResourceFileL();
|
|
620 |
|
|
621 |
/**
|
|
622 |
* Creates the ModsFetcher object for the DataStore.
|
|
623 |
* @return ContactsModsFetcher object.
|
|
624 |
*/
|
|
625 |
IMPORT_C virtual MContactsModsFetcher* CreateModsFetcherL();
|
|
626 |
|
|
627 |
/**
|
|
628 |
* Get datamod instance
|
|
629 |
* @return reference to datamod instance.
|
|
630 |
*/
|
|
631 |
IMPORT_C virtual CNSmlDataModBase& GetDataMod();
|
|
632 |
|
|
633 |
protected: // data
|
|
634 |
|
|
635 |
// MODULE DATA STRUCTURES
|
|
636 |
enum TNSmlDataStoreStatus // DataStore status
|
|
637 |
{
|
|
638 |
ENSmlClosed = 1,
|
|
639 |
ENSmlOpenAndWaiting,
|
|
640 |
ENSmlItemOverflow,
|
|
641 |
ENSmlItemOpen,
|
|
642 |
ENSmlItemCreating,
|
|
643 |
ENSmlItemUpdating
|
|
644 |
};
|
|
645 |
|
|
646 |
enum TNSmlCntCommand // Modification type
|
|
647 |
{
|
|
648 |
ENSmlCntItemAdd = 1,
|
|
649 |
ENSmlCntItemDelete,
|
|
650 |
ENSmlCntItemSoftDelete,
|
|
651 |
ENSmlCntItemRead,
|
|
652 |
ENSmlCntItemMove,
|
|
653 |
ENSmlCntItemReplace,
|
|
654 |
ENSmlCntItemFieldLevelReplace
|
|
655 |
};
|
|
656 |
|
|
657 |
enum TNSmlLastOp
|
|
658 |
{
|
|
659 |
ENSmlRetrieveOp = 1,
|
|
660 |
ENSmlAddOp,
|
|
661 |
ENSmlDeleteOp,
|
|
662 |
ENSMLFetchOp,
|
|
663 |
ENSMLDeleteAllOp,
|
|
664 |
ENSMLUpdateExportOp,
|
|
665 |
ENSMLUpdateImportOp,
|
|
666 |
ENSmlNone
|
|
667 |
};
|
|
668 |
|
|
669 |
|
|
670 |
// ------------------------------------------------------------------------------------------------
|
|
671 |
// Buffering Stuff for BatchMode operations
|
|
672 |
// ------------------------------------------------------------------------------------------------
|
|
673 |
class CNSmlContactsBufferItem : public CBase
|
|
674 |
{
|
|
675 |
public:
|
|
676 |
/**
|
|
677 |
* Destructor.
|
|
678 |
*/
|
|
679 |
~CNSmlContactsBufferItem();
|
|
680 |
|
|
681 |
public: // data
|
|
682 |
TSmlDbItemUid *iPUid; // New item ID
|
|
683 |
TSmlDbItemUid iUid; // Item ID
|
|
684 |
CBufBase *iItemData; // Item data
|
|
685 |
HBufC8 *iMimeType; // Mimetype
|
|
686 |
HBufC8 *iMimeVersion; // Mime version
|
|
687 |
TNSmlCntCommand iModType; // Commands type
|
|
688 |
TInt iStatus; // Command status
|
|
689 |
TInt iSize; // Item size
|
|
690 |
};
|
|
691 |
|
|
692 |
protected:
|
|
693 |
CNSmlChangeFinder* iChangeFinder;
|
|
694 |
TRequestStatus* iCallerStatus;
|
|
695 |
TBool iSnapshotRegistered;
|
|
696 |
TBool iBatchMode;
|
|
697 |
TBool iOpened;
|
|
698 |
TInt64 iOpenedStoreId;
|
|
699 |
TInt iServerMaxObjectSize;
|
|
700 |
TSmlDbItemUid iUid;
|
|
701 |
TInt iItemPos;
|
|
702 |
TNSmlCntCommand iModType;
|
|
703 |
CBufBase* iItemData;
|
|
704 |
CBufBase* iItemDataAddBatch;
|
|
705 |
CBufFlat* iMergeItem;
|
|
706 |
RPointerArray<CNSmlContactsBufferItem> iContactsBufferItemList;
|
|
707 |
TKeyArrayFix iKey;
|
|
708 |
TBool iSyncHistory;
|
|
709 |
CSmlDataStoreFormat* iStoreFormat;
|
|
710 |
TNSmlDataStoreStatus iState;
|
|
711 |
|
|
712 |
CVPbkContactManager* iContactManager;
|
|
713 |
MVPbkContactStore* iStore;
|
|
714 |
CVPbkContactIdConverter* iIdConverter;
|
|
715 |
MVPbkContactViewBase* iContactViewBase;
|
|
716 |
|
|
717 |
TInt *iSize;
|
|
718 |
RBufWriteStream iWriteStream;
|
|
719 |
RDesReadStream iReadStream;
|
|
720 |
HBufC8* iBuf;
|
|
721 |
TInt iRetCommand;
|
|
722 |
TInt iIndex;
|
|
723 |
TInt iRetrieveCount;
|
|
724 |
RArray<TInt> *iResultArray;
|
|
725 |
TNSmlLastOp iLastOperation;
|
|
726 |
|
|
727 |
TInt iStateItem;
|
|
728 |
|
|
729 |
TBool iFieldLevelReplace;
|
|
730 |
|
|
731 |
private:
|
|
732 |
TBool iTransactionMode;
|
|
733 |
TInt iModificationCount;
|
|
734 |
TPtrC8 iMimeTypeItem;
|
|
735 |
TPtrC8 iMimeVersionItem;
|
|
736 |
TPtrC8 iUsedMimeType;
|
|
737 |
TPtrC8 iUsedMimeVersion;
|
|
738 |
RStringF iServerMimeType;
|
|
739 |
RStringF iServerMimeVersion;
|
|
740 |
HBufC* iDefaultStoreName;
|
|
741 |
|
|
742 |
//The symbian Db name that is used for communication with servers
|
|
743 |
//Changes done to mantain backward compatibility of function
|
|
744 |
HBufC* iPacketStoreName;
|
|
745 |
|
|
746 |
CNSmlDataModBase* iDataMod;
|
|
747 |
MContactsModsFetcher* iContactsModsFetcher;
|
|
748 |
|
|
749 |
RFs iRfs;
|
|
750 |
TInt iDrive;
|
|
751 |
TInt iItemSize;
|
|
752 |
|
|
753 |
HBufC* iStoreName;
|
|
754 |
|
|
755 |
RStringPool iStringPool;
|
|
756 |
|
|
757 |
CNSmlDataItemUidSet* iNewUids;
|
|
758 |
CNSmlDataItemUidSet* iDeletedUids;
|
|
759 |
CNSmlDataItemUidSet* iSoftDeletedUids;
|
|
760 |
CNSmlDataItemUidSet* iReplacedUids;
|
|
761 |
CNSmlDataItemUidSet* iMovedUids;
|
|
762 |
|
|
763 |
RArray<TInt> iAddResultArray;
|
|
764 |
|
|
765 |
CVPbkVCardEng* iVCardEngine ;
|
|
766 |
MVPbkContactLink* iContactLink;
|
|
767 |
CVPbkContactLinkArray* iContactLnks;
|
|
768 |
MVPbkContactOperationBase* iDeleteAllOperation;
|
|
769 |
};
|
|
770 |
|
|
771 |
|
|
772 |
#endif // __NSMLCONTACTSDATASTORE_H__
|
|
773 |
|
|
774 |
// End of File
|