omads/omadsextensions/adapters/contacts/src/NSmlContactsDataStore.cpp
branchRCL_3
changeset 14 b922b9936679
parent 8 ad0f53516d84
child 15 3f1ffafb31ec
equal deleted inserted replaced
8:ad0f53516d84 14:b922b9936679
    51 #include <CVPbkContactViewDefinition.h>
    51 #include <CVPbkContactViewDefinition.h>
    52 
    52 
    53 #include <MVPbkContactLink.h>
    53 #include <MVPbkContactLink.h>
    54 #include <s32mem.h>
    54 #include <s32mem.h>
    55 
    55 
    56 #include "NSmlContactsDataStore.h"
    56 #include <NSmlContactsDataStore.h>
    57 #include "NSmlContactsModsFetcher.h"
    57 #include "NSmlContactsModsFetcher.h"
    58 #include "nsmldebug.h"
    58 #include "nsmldebug.h"
    59 #include "nsmlconstants.h"
    59 #include "nsmlconstants.h"
    60 #include "NSmlDataModBase.h"
    60 #include <NSmlDataModBase.h>
    61 #include "nsmlcontactsdefs.h"
    61 #include "nsmlcontactsdefs.h"
    62 #include "nsmldsimpluids.h"
    62 #include "nsmldsimpluids.h"
    63 #include "nsmlsnapshotitem.h"
    63 #include "nsmlsnapshotitem.h"
    64 #include "nsmlchangefinder.h"
    64 #include "nsmlchangefinder.h"
    65 #include <VPbkEng.rsg>
    65 #include <VPbkEng.rsg>
    73 
    73 
    74 
    74 
    75 // ----------------------------------------------------------------------------
    75 // ----------------------------------------------------------------------------
    76 // CNSmlContactsDataStore::CNSmlContactsBufferItem::~CNSmlContactsBufferItem
    76 // CNSmlContactsDataStore::CNSmlContactsBufferItem::~CNSmlContactsBufferItem
    77 // ----------------------------------------------------------------------------
    77 // ----------------------------------------------------------------------------
    78 CNSmlContactsDataStore::CNSmlContactsBufferItem::~CNSmlContactsBufferItem()
    78 EXPORT_C CNSmlContactsDataStore::CNSmlContactsBufferItem::~CNSmlContactsBufferItem()
    79 	{
    79 	{
    80 	delete iItemData;
    80 	delete iItemData;
    81 	delete iMimeType;
    81 	delete iMimeType;
    82 	delete iMimeVersion;
    82 	delete iMimeVersion;
    83 	}
    83 	}
    84 	
    84 	
    85 // ----------------------------------------------------------------------------
    85 // ----------------------------------------------------------------------------
    86 // CNSmlContactsDataStore::NewL
    86 // CNSmlContactsDataStore::NewL
    87 // ----------------------------------------------------------------------------
    87 // ----------------------------------------------------------------------------
    88 CNSmlContactsDataStore* CNSmlContactsDataStore::NewL()
    88 EXPORT_C CNSmlContactsDataStore* CNSmlContactsDataStore::NewL()
    89 	{
    89 	{
    90 	_DBG_FILE("CNSmlContactsDataStore::NewL: BEGIN");
    90 	_DBG_FILE("CNSmlContactsDataStore::NewL: BEGIN");
    91 	CNSmlContactsDataStore* self = new ( ELeave ) CNSmlContactsDataStore();
    91 	CNSmlContactsDataStore* self = new ( ELeave ) CNSmlContactsDataStore();
    92 	CleanupStack::PushL(self);
    92 	CleanupStack::PushL(self);
    93 		
    93 		
    99 	}
    99 	}
   100 
   100 
   101 // ----------------------------------------------------------------------------
   101 // ----------------------------------------------------------------------------
   102 // CNSmlContactsDataStore::CNSmlContactsDataStore() 
   102 // CNSmlContactsDataStore::CNSmlContactsDataStore() 
   103 // ----------------------------------------------------------------------------
   103 // ----------------------------------------------------------------------------
   104 CNSmlContactsDataStore::CNSmlContactsDataStore() : 
   104 EXPORT_C CNSmlContactsDataStore::CNSmlContactsDataStore() : 
   105 	iKey( TKeyArrayFix( _FOFF( TNSmlSnapshotItem,ItemId() ),ECmpTInt )),
   105 	iKey( TKeyArrayFix( _FOFF( TNSmlSnapshotItem,ItemId() ),ECmpTInt )),
   106 	iContactManager(NULL),
   106 	iContactManager(NULL),
   107 	iStore(NULL),
   107 	iStore(NULL),
   108 	iVCardEngine(NULL),
       
   109 	iIdConverter(NULL),
   108 	iIdConverter(NULL),
   110 	iContactLnks(NULL),
       
   111 	iContactViewBase(NULL),
   109 	iContactViewBase(NULL),
   112 	iSize(NULL),	
   110 	iSize(NULL),	
   113 	iBuf(NULL)
   111 	iBuf(NULL),
       
   112 	iVCardEngine(NULL),
       
   113 	iContactLnks(NULL)
   114 	{
   114 	{
   115 	_DBG_FILE("CNSmlContactsDataStore::CNSmlContactsDataStore(): begin");
   115 	_DBG_FILE("CNSmlContactsDataStore::CNSmlContactsDataStore(): begin");
   116 
   116 
   117 	iSyncHistory = EFalse;
   117 	iSyncHistory = EFalse;
   118 	iSnapshotRegistered = EFalse;
   118 	iSnapshotRegistered = EFalse;
   130 	}
   130 	}
   131 	
   131 	
   132 // ----------------------------------------------------------------------------
   132 // ----------------------------------------------------------------------------
   133 // CNSmlContactsDataStore::ConstructL()
   133 // CNSmlContactsDataStore::ConstructL()
   134 // ----------------------------------------------------------------------------
   134 // ----------------------------------------------------------------------------
   135 void CNSmlContactsDataStore::ConstructL()
   135 EXPORT_C void CNSmlContactsDataStore::ConstructL()
   136 	{
   136 	{
   137 	_DBG_FILE("CNSmlContactsDataStore::CNSmlContactsDataStore(): begin");
   137 	_DBG_FILE("CNSmlContactsDataStore::ConstructL(): begin");
   138 	
   138 	
   139 	User::LeaveIfError( iRfs.Connect() );
   139 	ConstructL( ( VPbkContactStoreUris::DefaultCntDbUri() ), KLegacySymbianDatabase );
   140 
       
   141 	iUsedMimeType.Set( KNSmlvCard21Name() );
       
   142 	iUsedMimeVersion.Set( KNSmlvCard21Ver() );
       
   143 	iStringPool.OpenL();
       
   144 	
       
   145 	// Uid Sets
       
   146 	iNewUids = new (ELeave) CNSmlDataItemUidSet();
       
   147 	iDeletedUids = new (ELeave) CNSmlDataItemUidSet();
       
   148 	iSoftDeletedUids = new (ELeave) CNSmlDataItemUidSet();
       
   149 	iMovedUids = new (ELeave) CNSmlDataItemUidSet();
       
   150 	iReplacedUids = new (ELeave) CNSmlDataItemUidSet();
       
   151 
       
   152 	// Create iDataMod
       
   153 	// This should be done after OpenL if there are more than one database
       
   154 	iDataMod = new (ELeave) CNSmlVCardMod();
       
   155 
       
   156 	SetOwnStoreFormatL();
       
   157 	// open  contact database
       
   158 	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
       
   159 	uriArray->AppendL( TVPbkContactStoreUriPtr(VPbkContactStoreUris::DefaultCntDbUri()));
       
   160 	
       
   161 	iContactManager = CVPbkContactManager::NewL(*uriArray);
       
   162 	CleanupStack::PopAndDestroy(uriArray);
       
   163 	//Default store name
       
   164 	iDefaultStoreName = (VPbkContactStoreUris::DefaultCntDbUri()).AllocL();
       
   165 	
       
   166 	//Fill iPacketStoreName buffer with KLegacySymbianDatabase
       
   167     TBuf<KOldSymbianDBLength> dataBase(KLegacySymbianDatabase);
       
   168 	iPacketStoreName = HBufC::NewL(dataBase.Length());        
       
   169 	TPtr pktStorePtr(iPacketStoreName->Des());
       
   170 	pktStorePtr.Copy(dataBase);
       
   171 		
   140 		
   172 	_DBG_FILE("CNSmlContactsDataStore::ConstructL(): end");
   141 	_DBG_FILE("CNSmlContactsDataStore::ConstructL(): end");
   173 	}
   142 	}
   174 	
   143 
       
   144 // ----------------------------------------------------------------------------
       
   145 // CNSmlContactsDataStore::ConstructL()
       
   146 // ----------------------------------------------------------------------------
       
   147 EXPORT_C void CNSmlContactsDataStore::ConstructL(
       
   148     const TDesC& aStoreName, const TDesC& aLegacyStore )
       
   149     {
       
   150     _DBG_FILE("CNSmlContactsDataStore::ConstructL(): begin");
       
   151     
       
   152     User::LeaveIfError( iRfs.Connect() );
       
   153 
       
   154     iStringPool.OpenL();
       
   155     
       
   156     // Uid Sets
       
   157     iNewUids = new (ELeave) CNSmlDataItemUidSet();
       
   158     iDeletedUids = new (ELeave) CNSmlDataItemUidSet();
       
   159     iSoftDeletedUids = new (ELeave) CNSmlDataItemUidSet();
       
   160     iMovedUids = new (ELeave) CNSmlDataItemUidSet();
       
   161     iReplacedUids = new (ELeave) CNSmlDataItemUidSet();
       
   162 
       
   163     // Create iDataMod
       
   164     // This should be done after OpenL if there are more than one database
       
   165     iDataMod = new (ELeave) CNSmlVCardMod();
       
   166 
       
   167     SetOwnStoreFormatL();
       
   168     // open  contact database
       
   169     CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
       
   170     uriArray->AppendL( TVPbkContactStoreUriPtr( aStoreName ));
       
   171     
       
   172     iContactManager = CVPbkContactManager::NewL(*uriArray);
       
   173     CleanupStack::PopAndDestroy(uriArray);
       
   174     //Default store name
       
   175     iDefaultStoreName = aStoreName.AllocL();
       
   176     
       
   177     //Fill iPacketStoreName buffer with legacy store name
       
   178     TBuf<KOldSymbianDBLength> dataBase(aLegacyStore);
       
   179     iPacketStoreName = HBufC::NewL(dataBase.Length());
       
   180     TPtr pktStorePtr(iPacketStoreName->Des());
       
   181     pktStorePtr.Copy(dataBase);
       
   182         
       
   183     _DBG_FILE("CNSmlContactsDataStore::ConstructL(): end");    
       
   184     }
       
   185 
   175 // ----------------------------------------------------------------------------
   186 // ----------------------------------------------------------------------------
   176 // CNSmlContactsDataStore::~CNSmlContactsDataStore()
   187 // CNSmlContactsDataStore::~CNSmlContactsDataStore()
   177 // ----------------------------------------------------------------------------
   188 // ----------------------------------------------------------------------------
   178 CNSmlContactsDataStore::~CNSmlContactsDataStore()
   189 EXPORT_C CNSmlContactsDataStore::~CNSmlContactsDataStore()
   179 	{
   190 	{
   180 	_DBG_FILE("CNSmlContactsDataStore::~CNSmlContactsDataStore(): begin");
   191 	_DBG_FILE("CNSmlContactsDataStore::~CNSmlContactsDataStore(): begin");
   181 	
   192 	
   182 	delete iStoreFormat; // SetOwnStoreFormatL creates
   193 	delete iStoreFormat; // SetOwnStoreFormatL creates
   183 	iStringPool.Close();
   194 	iStringPool.Close();
   206 		delete iContactLink;	
   217 		delete iContactLink;	
   207 		}
   218 		}
   208 	delete iContactViewBase;
   219 	delete iContactViewBase;
   209 	if ( iContactsModsFetcher )
   220 	if ( iContactsModsFetcher )
   210 		{
   221 		{
   211 		iContactsModsFetcher->Cancel(); 
   222 		iContactsModsFetcher->CancelRequest(); 
   212 		delete iContactsModsFetcher;
   223 		delete iContactsModsFetcher;
   213 		}
   224 		}
   214 	if ( iContactManager )
   225 	if ( iContactManager )
   215 		{
   226 		{
   216 			if(iStore)
   227 			if(iStore)
   269 // ----------------------------------------------------------------------------
   280 // ----------------------------------------------------------------------------
   270 // void CNSmlContactsDataStore::DoOpenL(const TDesC& 		  aStoreName, 
   281 // void CNSmlContactsDataStore::DoOpenL(const TDesC& 		  aStoreName, 
   271 //									    MSmlSyncRelationship& aContext,
   282 //									    MSmlSyncRelationship& aContext,
   272 //									    TRequestStatus& 	  aStatus)
   283 //									    TRequestStatus& 	  aStatus)
   273 // ----------------------------------------------------------------------------
   284 // ----------------------------------------------------------------------------
   274 void CNSmlContactsDataStore::DoOpenL( const TDesC& aStoreName, 
   285 EXPORT_C void CNSmlContactsDataStore::DoOpenL( const TDesC& aStoreName, 
   275 									MSmlSyncRelationship& aContext, 
   286 									MSmlSyncRelationship& aContext, 
   276 									TRequestStatus& aStatus )
   287 									TRequestStatus& aStatus )
   277 	{
   288 	{
   278 	DBG_ARGS(_S("CNSmlContactsDataStore::DoOpenL(): '%S' begin"), &aStoreName);
   289 	DBG_ARGS(_S("CNSmlContactsDataStore::DoOpenL(): '%S' begin"), &aStoreName);
   279 
   290 
   327 	
   338 	
   328 	iVCardEngine = CVPbkVCardEng::NewL( *iContactManager );
   339 	iVCardEngine = CVPbkVCardEng::NewL( *iContactManager );
   329 	iIdConverter = CVPbkContactIdConverter::NewL(*iStore );
   340 	iIdConverter = CVPbkContactIdConverter::NewL(*iStore );
   330 	if ( iContactsModsFetcher )
   341 	if ( iContactsModsFetcher )
   331 		{
   342 		{
   332 		iContactsModsFetcher->Cancel();
   343 		iContactsModsFetcher->CancelRequest();
   333 		delete iContactsModsFetcher;
   344 		delete iContactsModsFetcher;
   334 		iContactsModsFetcher = NULL;
   345 		iContactsModsFetcher = NULL;
   335 		}
   346 		}
   336 		
   347 		
   337 	iContactsModsFetcher = new (ELeave) CNSmlContactsModsFetcher( 
   348 	iContactsModsFetcher = CreateModsFetcherL();
   338 							iSnapshotRegistered, *iContactManager,*iStore, iKey, *iChangeFinder );
       
   339 	iContactsModsFetcher->ConstructL();
       
   340 	
   349 	
   341 #ifdef __NSML_MODULETEST__
   350 #ifdef __NSML_MODULETEST__
   342 	CActiveScheduler::Start();
   351 	CActiveScheduler::Start();
   343 #endif
   352 #endif
   344 	
   353 	
   346 	}
   355 	}
   347 
   356 
   348 // ----------------------------------------------------------------------------
   357 // ----------------------------------------------------------------------------
   349 // void CNSmlContactsDataStore::DoCancelRequest()
   358 // void CNSmlContactsDataStore::DoCancelRequest()
   350 // ----------------------------------------------------------------------------
   359 // ----------------------------------------------------------------------------
   351 void CNSmlContactsDataStore::DoCancelRequest()
   360 EXPORT_C void CNSmlContactsDataStore::DoCancelRequest()
   352 	{
   361 	{
   353 	_DBG_FILE("CNSmlContactsDataStore::DoCancelRequest(): begin");
   362 	_DBG_FILE("CNSmlContactsDataStore::DoCancelRequest(): begin");
   354 		if(iContactsModsFetcher)
   363 		if(iContactsModsFetcher)
   355 		{
   364 		{
   356 		iContactsModsFetcher->Cancel();
   365 		iContactsModsFetcher->CancelRequest();
   357 		}
   366 		}
   358 	
   367 	
   359 	_DBG_FILE("CNSmlContactsDataStore::DoCancelRequest(): NOT NEEDED end");
   368 	_DBG_FILE("CNSmlContactsDataStore::DoCancelRequest(): NOT NEEDED end");
   360 	}
   369 	}
   361 
   370 
   362 // ----------------------------------------------------------------------------
   371 // ----------------------------------------------------------------------------
   363 // void CNSmlContactsDataStore::DoStoreName()
   372 // void CNSmlContactsDataStore::DoStoreName()
   364 // ----------------------------------------------------------------------------
   373 // ----------------------------------------------------------------------------
   365 const TDesC& CNSmlContactsDataStore::DoStoreName() const
   374 EXPORT_C const TDesC& CNSmlContactsDataStore::DoStoreName() const
   366 	{
   375 	{
   367 	_DBG_FILE("CNSmlContactsDataStore::DoStoreName(): begin");
   376 	_DBG_FILE("CNSmlContactsDataStore::DoStoreName(): begin");
   368 	_DBG_FILE("CNSmlContactsDataStore::DoStoreName(): end");
   377 	_DBG_FILE("CNSmlContactsDataStore::DoStoreName(): end");
   369 	return *iStoreName;
   378 	return *iStoreName;
   370 	}
   379 	}
   371 
   380 
   372 // ----------------------------------------------------------------------------
   381 // ----------------------------------------------------------------------------
   373 // void CNSmlContactsDataStore::DefaultStoreNameL()
   382 // void CNSmlContactsDataStore::DefaultStoreNameL()
   374 // ----------------------------------------------------------------------------
   383 // ----------------------------------------------------------------------------
   375 const TDesC& CNSmlContactsDataStore::DefaultStoreNameL() const
   384 EXPORT_C const TDesC& CNSmlContactsDataStore::DefaultStoreNameL() const
   376 	{
   385 	{
   377 	_DBG_FILE("CNSmlContactsDataStore::DefaultStoreNameL(): begin");
   386 	_DBG_FILE("CNSmlContactsDataStore::DefaultStoreNameL(): begin");
   378 	
   387 	
   379 	if ( !iDefaultStoreName )
   388 	if ( !iDefaultStoreName )
   380 		{
   389 		{
   387 	}
   396 	}
   388 	
   397 	
   389 // ----------------------------------------------------------------------------
   398 // ----------------------------------------------------------------------------
   390 // void CNSmlContactsDataStore::DoBeginTransactionL()
   399 // void CNSmlContactsDataStore::DoBeginTransactionL()
   391 // ----------------------------------------------------------------------------
   400 // ----------------------------------------------------------------------------
   392 void CNSmlContactsDataStore::DoBeginTransactionL()
   401 EXPORT_C void CNSmlContactsDataStore::DoBeginTransactionL()
   393 	{
   402 	{
   394 	_DBG_FILE("CNSmlContactsDataStore::DoBeginTransactionL(): begin");
   403 	_DBG_FILE("CNSmlContactsDataStore::DoBeginTransactionL(): begin");
   395 	User::Leave( KErrNotSupported );
   404 	User::Leave( KErrNotSupported );
   396 	_DBG_FILE("CNSmlContactsDataStore::DoBeginTransactionL(): end");
   405 	_DBG_FILE("CNSmlContactsDataStore::DoBeginTransactionL(): end");
   397 	}
   406 	}
   398 
   407 
   399 // ----------------------------------------------------------------------------
   408 // ----------------------------------------------------------------------------
   400 // void CNSmlContactsDataStore::DoCommitTransactionL()
   409 // void CNSmlContactsDataStore::DoCommitTransactionL()
   401 // ----------------------------------------------------------------------------
   410 // ----------------------------------------------------------------------------
   402 void CNSmlContactsDataStore::DoCommitTransactionL(TRequestStatus& aStatus)
   411 EXPORT_C void CNSmlContactsDataStore::DoCommitTransactionL(TRequestStatus& aStatus)
   403 	{
   412 	{
   404 	_DBG_FILE("CNSmlContactsDataStore::DoCommitTransactionL(): begin");
   413 	_DBG_FILE("CNSmlContactsDataStore::DoCommitTransactionL(): begin");
   405 	
   414 	
   406 	iCallerStatus = &aStatus;
   415 	iCallerStatus = &aStatus;
   407 	*iCallerStatus = KRequestPending;
   416 	*iCallerStatus = KRequestPending;
   411 	}
   420 	}
   412 
   421 
   413 // ----------------------------------------------------------------------------
   422 // ----------------------------------------------------------------------------
   414 // void CNSmlContactsDataStore::DoRevertTransaction()
   423 // void CNSmlContactsDataStore::DoRevertTransaction()
   415 // ----------------------------------------------------------------------------
   424 // ----------------------------------------------------------------------------
   416 void CNSmlContactsDataStore::DoRevertTransaction(TRequestStatus& aStatus)
   425 EXPORT_C void CNSmlContactsDataStore::DoRevertTransaction(TRequestStatus& aStatus)
   417 	{
   426 	{
   418 	_DBG_FILE("CNSmlContactsDataStore::DoRevertTransaction(): begin");
   427 	_DBG_FILE("CNSmlContactsDataStore::DoRevertTransaction(): begin");
   419 	
   428 	
   420 	iCallerStatus = &aStatus;
   429 	iCallerStatus = &aStatus;
   421 	*iCallerStatus = KRequestPending;
   430 	*iCallerStatus = KRequestPending;
   425 	}
   434 	}
   426 
   435 
   427 // ----------------------------------------------------------------------------
   436 // ----------------------------------------------------------------------------
   428 // void CNSmlContactsDataStore::DoBeginBatchL()
   437 // void CNSmlContactsDataStore::DoBeginBatchL()
   429 // ----------------------------------------------------------------------------
   438 // ----------------------------------------------------------------------------
   430 void CNSmlContactsDataStore::DoBeginBatchL()
   439 EXPORT_C void CNSmlContactsDataStore::DoBeginBatchL()
   431 	{
   440 	{
   432 	_DBG_FILE("CNSmlContactsDataStore::DoBeginBatchL(): begin");
   441 	_DBG_FILE("CNSmlContactsDataStore::DoBeginBatchL(): begin");
   433 	
   442 	
   434 	iBatchMode = ETrue;			// SUPPORTED on Contacts
   443 	iBatchMode = ETrue;			// SUPPORTED on Contacts
   435 
   444 
   437 	}
   446 	}
   438 
   447 
   439 // ----------------------------------------------------------------------------
   448 // ----------------------------------------------------------------------------
   440 // void CNSmlContactsDataStore::DoCommitBatchL()
   449 // void CNSmlContactsDataStore::DoCommitBatchL()
   441 // ----------------------------------------------------------------------------
   450 // ----------------------------------------------------------------------------
   442 void CNSmlContactsDataStore::DoCommitBatchL( RArray<TInt>& aResultArray, TRequestStatus& aStatus )
   451 EXPORT_C void CNSmlContactsDataStore::DoCommitBatchL( RArray<TInt>& aResultArray, TRequestStatus& aStatus )
   443 	{
   452 	{
   444 	_DBG_FILE("CNSmlContactsDataStore::DoCommitBatchL(): begin");
   453 	_DBG_FILE("CNSmlContactsDataStore::DoCommitBatchL(): begin");
   445 
   454 
   446 	iCallerStatus = &aStatus;
   455 	iCallerStatus = &aStatus;
   447 	*iCallerStatus = KRequestPending;
   456 	*iCallerStatus = KRequestPending;
   470 	}
   479 	}
   471 	
   480 	
   472 // ----------------------------------------------------------------------------
   481 // ----------------------------------------------------------------------------
   473 // void CNSmlContactsDataStore::ExecuteBufferL()
   482 // void CNSmlContactsDataStore::ExecuteBufferL()
   474 // ----------------------------------------------------------------------------
   483 // ----------------------------------------------------------------------------
   475 void CNSmlContactsDataStore::ExecuteBufferL() 
   484 EXPORT_C void CNSmlContactsDataStore::ExecuteBufferL() 
   476 	{
   485 	{
   477 	_DBG_FILE("CNSmlContactsDataStore::ExecuteBufferL(): begin");
   486 	_DBG_FILE("CNSmlContactsDataStore::ExecuteBufferL(): begin");
   478 	
   487 	
   479 	TInt  retCommand( KErrNone );
   488 	TInt  retCommand( KErrNone );
   480 	
   489 	
   490 			}
   499 			}
   491 		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemAdd )
   500 		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemAdd )
   492 			{
   501 			{
   493 			retCommand = ExecuteAddL();
   502 			retCommand = ExecuteAddL();
   494 			}
   503 			}
   495 		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemReplace )
   504 		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemReplace ||
       
   505             iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemFieldLevelReplace )
   496 			{
   506 			{
   497 			ExecuteUpdateL();		
   507 			ExecuteUpdateL();		
   498 			}
   508 			}
   499 		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemMove )
   509 		else if( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemMove )
   500 			{
   510 			{
   508 		//
   518 		//
   509 		//	Set allready set commands from iContactsBufferItemList
   519 		//	Set allready set commands from iContactsBufferItemList
   510 		//
   520 		//
   511 		if( ( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemAdd     ||
   521 		if( ( iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemAdd     ||
   512 		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemReplace ||
   522 		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemReplace ||
       
   523 		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemFieldLevelReplace ||
   513 		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemDelete  ||
   524 		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemDelete  ||
   514 		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemSoftDelete ) &&
   525 		      iContactsBufferItemList[iIndex]->iModType == ENSmlCntItemSoftDelete ) &&
   515 		      iContactsBufferItemList[iIndex]->iStatus  != KNSmlNoError )
   526 		      iContactsBufferItemList[iIndex]->iStatus  != KNSmlNoError )
   516 			{
   527 			{
   517 			retCommand = iContactsBufferItemList[iIndex]->iStatus;
   528 			retCommand = iContactsBufferItemList[iIndex]->iStatus;
   531 	
   542 	
   532 // ----------------------------------------------------------------------------
   543 // ----------------------------------------------------------------------------
   533 // void CNSmlContactsDataStore::ExecuteAddL()
   544 // void CNSmlContactsDataStore::ExecuteAddL()
   534 // ----------------------------------------------------------------------------
   545 // ----------------------------------------------------------------------------
   535 	
   546 	
   536 TInt CNSmlContactsDataStore::ExecuteAddL()
   547 EXPORT_C TInt CNSmlContactsDataStore::ExecuteAddL()
   537 	{
   548 	{
   538 	TInt  retCommand( KErrNone );
   549 	TInt  retCommand( KErrNone );
   539 	StripPropertyL( iItemDataAddBatch, KVersitTokenUID() ); // Remove UID's from data
   550 	StripPropertyL( iItemDataAddBatch, KVersitTokenUID() ); // Remove UID's from data
   540 
   551 
   541 	TInt err( KErrNone );
   552 	TInt err( KErrNone );
   574 	
   585 	
   575 // ----------------------------------------------------------------------------
   586 // ----------------------------------------------------------------------------
   576 // void CNSmlContactsDataStore::ExecuteDeleteL()
   587 // void CNSmlContactsDataStore::ExecuteDeleteL()
   577 // ----------------------------------------------------------------------------
   588 // ----------------------------------------------------------------------------
   578 	
   589 	
   579 void CNSmlContactsDataStore:: ExecuteDeleteL()
   590 EXPORT_C void CNSmlContactsDataStore:: ExecuteDeleteL()
   580 	{
   591 	{
   581 	
   592 	
   582 	if(iBatchMode)			
   593 	if(iBatchMode)			
   583 		{
   594 		{
   584 		iContactLnks = CVPbkContactLinkArray::NewL();
   595 		iContactLnks = CVPbkContactLinkArray::NewL();
   627 	
   638 	
   628 // ----------------------------------------------------------------------------
   639 // ----------------------------------------------------------------------------
   629 // void CNSmlContactsDataStore::ExecuteUpdateL()
   640 // void CNSmlContactsDataStore::ExecuteUpdateL()
   630 // ----------------------------------------------------------------------------
   641 // ----------------------------------------------------------------------------
   631 	
   642 	
   632 void CNSmlContactsDataStore::ExecuteUpdateL()
   643 EXPORT_C void CNSmlContactsDataStore::ExecuteUpdateL()
   633 	{
   644 	{
   634 	iUid  = iContactsBufferItemList[iIndex]->iUid;
   645 	iUid  = iContactsBufferItemList[iIndex]->iUid;
   635 
   646 
   636 	iDataMod->SetUsedMimeType( iServerMimeType, iServerMimeVersion );
   647 	iDataMod->SetUsedMimeType( iServerMimeType, iServerMimeVersion );
   637 
   648 
   656 
   667 
   657 // ----------------------------------------------------------------------------
   668 // ----------------------------------------------------------------------------
   658 // void CNSmlContactsDataStore::ExecuteMoveL
   669 // void CNSmlContactsDataStore::ExecuteMoveL
   659 // ----------------------------------------------------------------------------
   670 // ----------------------------------------------------------------------------
   660 
   671 
   661 void CNSmlContactsDataStore::ExecuteMoveL()
   672 EXPORT_C void CNSmlContactsDataStore::ExecuteMoveL()
   662 	{
   673 	{
   663 	// move command is not supported
   674 	// move command is not supported
   664 	if(!iBatchMode)
   675 	if(!iBatchMode)
   665 		{
   676 		{
   666 		ResetBuffer();
   677 		ResetBuffer();
   682 		}
   693 		}
   683 	}
   694 	}
   684 // ----------------------------------------------------------------------------
   695 // ----------------------------------------------------------------------------
   685 // void CNSmlContactsDataStore::DoCancelBatch()
   696 // void CNSmlContactsDataStore::DoCancelBatch()
   686 // ----------------------------------------------------------------------------
   697 // ----------------------------------------------------------------------------
   687 void CNSmlContactsDataStore::DoCancelBatch()
   698 EXPORT_C void CNSmlContactsDataStore::DoCancelBatch()
   688 	{
   699 	{
   689 	_DBG_FILE("CNSmlContactsDataStore::DoCancelBatch(): begin");
   700 	_DBG_FILE("CNSmlContactsDataStore::DoCancelBatch(): begin");
   690 	if( iBatchMode )
   701 	if( iBatchMode )
   691 		{
   702 		{
   692 		iBatchMode = EFalse;
   703 		iBatchMode = EFalse;
   701 	}
   712 	}
   702 
   713 
   703 // ----------------------------------------------------------------------------
   714 // ----------------------------------------------------------------------------
   704 // void CNSmlContactsDataStore::DoSetRemoteStoreFormatL()
   715 // void CNSmlContactsDataStore::DoSetRemoteStoreFormatL()
   705 // ----------------------------------------------------------------------------
   716 // ----------------------------------------------------------------------------
   706 void CNSmlContactsDataStore::DoSetRemoteStoreFormatL( const CSmlDataStoreFormat& aServerDataStoreFormat )
   717 EXPORT_C void CNSmlContactsDataStore::DoSetRemoteStoreFormatL( const CSmlDataStoreFormat& aServerDataStoreFormat )
   707 	{
   718 	{
   708 	_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteStoreFormatL(): begin");
   719 	_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteStoreFormatL(): begin");
   709 	
   720 	
   710 	TBool foundMime = EFalse;
   721 	TBool foundMime = EFalse;
   711 	
   722 	
   745 	}
   756 	}
   746 	
   757 	
   747 // ----------------------------------------------------------------------------
   758 // ----------------------------------------------------------------------------
   748 // void CNSmlContactsDataStore::SetOwnStoreFormatL()
   759 // void CNSmlContactsDataStore::SetOwnStoreFormatL()
   749 // ----------------------------------------------------------------------------
   760 // ----------------------------------------------------------------------------
   750 void CNSmlContactsDataStore::SetOwnStoreFormatL()
   761 EXPORT_C void CNSmlContactsDataStore::SetOwnStoreFormatL()
   751 	{
   762 	{
   752 	_DBG_FILE("CNSmlContactsDataStore::SetOwnStoreFormatL(): begin");
   763 	_DBG_FILE("CNSmlContactsDataStore::SetOwnStoreFormatL(): begin");
   753 	
   764 	
   754 	if( !iStoreFormat )
   765 	if( !iStoreFormat )
   755 		{
   766 		{
   756 		TFileName fileName;
   767 		TFileName fileName;
   757 		TParse parse;
   768 		TParse parse;
   758 
   769 
   759 		// Check correct Data Sync protocol
   770 		parse.Set( GetStoreFormatResourceFileL(), &KDC_RESOURCE_FILES_DIR, NULL  );
   760         TInt value( EDataSyncNotRunning );
       
   761         TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
       
   762                                      KDataSyncStatus,
       
   763                                      value );
       
   764         if ( error == KErrNone &&
       
   765              value == EDataSyncRunning )
       
   766             {
       
   767             parse.Set( KNSmlContactsStoreFormatRsc_1_1_2, &KDC_RESOURCE_FILES_DIR, NULL );
       
   768             }
       
   769         else // error or protocol version 1.2 
       
   770             {
       
   771             parse.Set( KNSmlContactsStoreFormatRsc_1_2, &KDC_RESOURCE_FILES_DIR, NULL );
       
   772             }		
       
   773 
   771 
   774 		fileName = parse.FullName();
   772 		fileName = parse.FullName();
   775 
   773 
   776 		RResourceFile resourceFile; 
   774 		RResourceFile resourceFile; 
   777 		BaflUtils::NearestLanguageFile( iRfs, fileName );
   775 		BaflUtils::NearestLanguageFile( iRfs, fileName );
   789 		
   787 		
   790 		CleanupStack::PopAndDestroy(2); // contactsDataFormat, resourceFile  
   788 		CleanupStack::PopAndDestroy(2); // contactsDataFormat, resourceFile  
   791 		}
   789 		}
   792 		
   790 		
   793 	iDataMod->SetOwnStoreFormat( *iStoreFormat );
   791 	iDataMod->SetOwnStoreFormat( *iStoreFormat );
   794 	
   792 
       
   793 	// Set own MIME type based on store format resource definition. Allows inherited classes to 
       
   794     // use non-standard MIME type by recource change. E.g. Operator specific MIME types can be used.
       
   795     iUsedMimeType.Set( iStoreFormat->MimeFormat(0).MimeType().DesC() );
       
   796     iUsedMimeVersion.Set( iStoreFormat->MimeFormat(0).MimeVersion().DesC() );
       
   797 
   795 	_DBG_FILE("CNSmlContactsDataStore::SetOwnStoreFormatL(): end");
   798 	_DBG_FILE("CNSmlContactsDataStore::SetOwnStoreFormatL(): end");
   796 	return;
   799 	return;
   797 	}
   800 	}
   798 
   801 
   799 // ----------------------------------------------------------------------------
   802 // ----------------------------------------------------------------------------
   800 // void CNSmlContactsDataStore::DoSetRemoteMaxObjectSize()
   803 // void CNSmlContactsDataStore::DoSetRemoteMaxObjectSize()
   801 // ----------------------------------------------------------------------------
   804 // ----------------------------------------------------------------------------
   802 void CNSmlContactsDataStore::DoSetRemoteMaxObjectSize( TInt aServerMaxObjectSize )
   805 EXPORT_C void CNSmlContactsDataStore::DoSetRemoteMaxObjectSize( TInt aServerMaxObjectSize )
   803 	{
   806 	{
   804 	_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteMaxObjectSize(): begin");
   807 	_DBG_FILE("CNSmlContactsDataStore::DoSetRemoteMaxObjectSize(): begin");
   805 	
   808 	
   806 	iServerMaxObjectSize = aServerMaxObjectSize;
   809 	iServerMaxObjectSize = aServerMaxObjectSize;
   807 	
   810 	
   809 	}
   812 	}
   810 
   813 
   811 // ----------------------------------------------------------------------------
   814 // ----------------------------------------------------------------------------
   812 // void CNSmlContactsDataStore::DoMaxObjectSize()
   815 // void CNSmlContactsDataStore::DoMaxObjectSize()
   813 // ----------------------------------------------------------------------------
   816 // ----------------------------------------------------------------------------
   814 TInt CNSmlContactsDataStore::DoMaxObjectSize() const
   817 EXPORT_C TInt CNSmlContactsDataStore::DoMaxObjectSize() const
   815 	{
   818 	{
   816 	_DBG_FILE("CNSmlContactsDataStore::DoMaxObjectSize(): begin");
   819 	_DBG_FILE("CNSmlContactsDataStore::DoMaxObjectSize(): begin");
   817 	_DBG_FILE("CNSmlContactsDataStore::DoMaxObjectSize() 100 k: end");
   820 	_DBG_FILE("CNSmlContactsDataStore::DoMaxObjectSize() 100 k: end");
   818 	return KNSmlDataStoreMaxSize;  // 100 k
   821 	return KNSmlDataStoreMaxSize;  // 100 k
   819 	}
   822 	}
   820 
   823 
   821 // ----------------------------------------------------------------------------
   824 // ----------------------------------------------------------------------------
   822 // void CNSmlContactsDataStore::DoOpenItemL()
   825 // void CNSmlContactsDataStore::DoOpenItemL()
   823 // ----------------------------------------------------------------------------
   826 // ----------------------------------------------------------------------------
   824 void CNSmlContactsDataStore::DoOpenItemL( TSmlDbItemUid aUid, 
   827 EXPORT_C void CNSmlContactsDataStore::DoOpenItemL( TSmlDbItemUid aUid, 
   825 										  TBool& aFieldChange, 
   828 										  TBool& aFieldChange, 
   826 										  TInt& aSize, 
   829 										  TInt& aSize, 
   827 										  TSmlDbItemUid& aParent, 
   830 										  TSmlDbItemUid& aParent, 
   828 										  TDes8& aMimeType, 
   831 										  TDes8& aMimeType, 
   829 										  TDes8& aMimeVer, 
   832 										  TDes8& aMimeVer, 
   866 	}
   869 	}
   867 
   870 
   868 // ----------------------------------------------------------------------------
   871 // ----------------------------------------------------------------------------
   869 // void CNSmlContactsDataStore::DoCreateItemL()
   872 // void CNSmlContactsDataStore::DoCreateItemL()
   870 // ----------------------------------------------------------------------------
   873 // ----------------------------------------------------------------------------
   871 void CNSmlContactsDataStore::DoCreateItemL( TSmlDbItemUid& aUid, 
   874 EXPORT_C void CNSmlContactsDataStore::DoCreateItemL( TSmlDbItemUid& aUid, 
   872 											TInt aSize, 
   875 											TInt aSize, 
   873 											TSmlDbItemUid /*aParent*/, 
   876 											TSmlDbItemUid /*aParent*/, 
   874 											const TDesC8& aMimeType, 
   877 											const TDesC8& aMimeType, 
   875 											const TDesC8& aMimeVer, 
   878 											const TDesC8& aMimeVer, 
   876 											TRequestStatus& aStatus )
   879 											TRequestStatus& aStatus )
   911 		iItemDataAddBatch= CBufFlat::NewL( KNSmlItemDataExpandSize );
   914 		iItemDataAddBatch= CBufFlat::NewL( KNSmlItemDataExpandSize );
   912 		}
   915 		}
   913 		
   916 		
   914 	// Check MimeType and MimeVersion
   917 	// Check MimeType and MimeVersion
   915 	if( ( aMimeType.MatchF( KNSmlvCard21Name ) < 0 ) &&
   918 	if( ( aMimeType.MatchF( KNSmlvCard21Name ) < 0 ) &&
   916 	    ( aMimeType.MatchF( KNSmlvCard30Name ) < 0 ))
   919 	    ( aMimeType.MatchF( KNSmlvCard30Name ) < 0 ) &&
       
   920 	    // Allow using custom MIME type defined in store format resource file
       
   921 	    ( aMimeType.MatchF( iUsedMimeType ) < 0 ) )
   917 		{
   922 		{
   918 		User::RequestComplete( iCallerStatus, KErrNotSupported );
   923 		User::RequestComplete( iCallerStatus, KErrNotSupported );
   919 		_DBG_FILE("CNSmlContactsDataStore::DoCreateItemL - KErrNotSupported: END");
   924 		_DBG_FILE("CNSmlContactsDataStore::DoCreateItemL - KErrNotSupported: END");
   920 		return;
   925 		return;
   921 		}
   926 		}
   947 	}
   952 	}
   948 
   953 
   949 // ----------------------------------------------------------------------------
   954 // ----------------------------------------------------------------------------
   950 // void CNSmlContactsDataStore::DoReplaceItemL()
   955 // void CNSmlContactsDataStore::DoReplaceItemL()
   951 // ----------------------------------------------------------------------------
   956 // ----------------------------------------------------------------------------
   952 void CNSmlContactsDataStore::DoReplaceItemL( TSmlDbItemUid aUid, 
   957 EXPORT_C void CNSmlContactsDataStore::DoReplaceItemL( TSmlDbItemUid aUid, 
   953 											 TInt aSize, 
   958 											 TInt aSize, 
   954 											 TSmlDbItemUid /*aParent*/,
   959 											 TSmlDbItemUid /*aParent*/,
   955 											 TBool aFieldChange, 
   960 											 TBool aFieldChange, 
   956 											 TRequestStatus& aStatus )
   961 											 TRequestStatus& aStatus )
   957 	{
   962 	{
   962 	
   967 	
   963 	TInt err = KErrNone;
   968 	TInt err = KErrNone;
   964 			
   969 			
   965 	iUid      = aUid;
   970 	iUid      = aUid;
   966 	iItemSize = aSize;
   971 	iItemSize = aSize;
   967 	iModType  = ENSmlCntItemReplace;
   972 	iModType  =  aFieldChange ? ENSmlCntItemFieldLevelReplace : ENSmlCntItemReplace;
   968 	
   973 	
   969 	if ( iItemPos == -1 || !iBatchMode )
   974 	if ( iItemPos == -1 || !iBatchMode )
   970 		{
   975 		{
   971 		iItemPos = 0;
   976 		iItemPos = 0;
   972 		}
   977 		}
   973 	
   978 	
   974 	if ( iItemData )
   979 	if ( iItemData )
   975 		{
   980 		{
   976 		iItemData->Reset();
   981 		iItemData->Reset();
   977 		}
   982 		}
   978 		
   983 
   979 	// Field change not supported
   984 	iFieldLevelReplace = aFieldChange;
   980 	if( aFieldChange )
   985 
   981 		{
       
   982 		err = KErrNotSupported;
       
   983 		if( !iBatchMode )
       
   984 			{
       
   985 			User::RequestComplete( iCallerStatus, err );
       
   986 			return;
       
   987 			}
       
   988 		}
       
   989 		
       
   990 	iItemData = AddBufferListL( aUid, aSize, err );
   986 	iItemData = AddBufferListL( aUid, aSize, err );
   991 	
   987 	
   992 	if( iBatchMode )
   988 	if( iBatchMode )
   993 		{
   989 		{
   994 		iState = ENSmlItemUpdating;
   990 		iState = ENSmlItemUpdating;
  1007 	}
  1003 	}
  1008 
  1004 
  1009 // ----------------------------------------------------------------------------
  1005 // ----------------------------------------------------------------------------
  1010 // void CNSmlContactsDataStore::DoReadItemL()
  1006 // void CNSmlContactsDataStore::DoReadItemL()
  1011 // ----------------------------------------------------------------------------
  1007 // ----------------------------------------------------------------------------
  1012 void CNSmlContactsDataStore::DoReadItemL( TDes8& aBuffer )
  1008 EXPORT_C void CNSmlContactsDataStore::DoReadItemL( TDes8& aBuffer )
  1013 	{
  1009 	{
  1014 	_DBG_FILE("CNSmlContactsDataStore::DoReadItemL(): begin");
  1010 	_DBG_FILE("CNSmlContactsDataStore::DoReadItemL(): begin");
  1015 
  1011 
  1016     if ( iState != ENSmlItemOpen || !iItemData )
  1012     if ( iState != ENSmlItemOpen || !iItemData )
  1017         {
  1013         {
  1039 	}
  1035 	}
  1040 
  1036 
  1041 // ----------------------------------------------------------------------------
  1037 // ----------------------------------------------------------------------------
  1042 // void CNSmlContactsDataStore::DoWriteItemL()
  1038 // void CNSmlContactsDataStore::DoWriteItemL()
  1043 // ----------------------------------------------------------------------------
  1039 // ----------------------------------------------------------------------------
  1044 void CNSmlContactsDataStore::DoWriteItemL( const TDesC8& aData )
  1040 EXPORT_C void CNSmlContactsDataStore::DoWriteItemL( const TDesC8& aData )
  1045 	{
  1041 	{
  1046 	_DBG_FILE("CNSmlContactsDataStore::DoWriteItemL(): begin");
  1042 	_DBG_FILE("CNSmlContactsDataStore::DoWriteItemL(): begin");
  1047 
  1043 
  1048 	/* Data must be accumulated from pieces of information */
  1044 	/* Data must be accumulated from pieces of information */
  1049 	if ( iState == ENSmlItemCreating || iState == ENSmlItemUpdating )
  1045 	if ( iState == ENSmlItemCreating || iState == ENSmlItemUpdating )
  1097 	}
  1093 	}
  1098 
  1094 
  1099 // ----------------------------------------------------------------------------
  1095 // ----------------------------------------------------------------------------
  1100 // void CNSmlContactsDataStore::DoCommitItemL()
  1096 // void CNSmlContactsDataStore::DoCommitItemL()
  1101 // ----------------------------------------------------------------------------
  1097 // ----------------------------------------------------------------------------
  1102 void CNSmlContactsDataStore::DoCommitItemL( TRequestStatus& aStatus )
  1098 EXPORT_C void CNSmlContactsDataStore::DoCommitItemL( TRequestStatus& aStatus )
  1103 	{
  1099 	{
  1104 	iCallerStatus = &aStatus;
  1100 	iCallerStatus = &aStatus;
  1105 	*iCallerStatus = KRequestPending;
  1101 	*iCallerStatus = KRequestPending;
  1106 	
  1102 	
  1107 	_DBG_FILE("CNSmlContactsDataStore::DoCommitItemL(): begin");
  1103 	_DBG_FILE("CNSmlContactsDataStore::DoCommitItemL(): begin");
  1116       	    {
  1112       	    {
  1117             iContactsBufferItemList[iContactsBufferItemList.Count()-1]->iStatus  = KNSmlNoError; 
  1113             iContactsBufferItemList[iContactsBufferItemList.Count()-1]->iStatus  = KNSmlNoError; 
  1118       	    }
  1114       	    }
  1119 	    }
  1115 	    }
  1120 	 else if ((iModType   == ENSmlCntItemAdd ||         // If some write problems
  1116 	 else if ((iModType   == ENSmlCntItemAdd ||         // If some write problems
  1121       	       iModType   == ENSmlCntItemReplace) && 
  1117          iModType   == ENSmlCntItemReplace ||
  1122       	       iStateItem != KErrNone &&
  1118          iModType   == ENSmlCntItemFieldLevelReplace ) &&  
  1123       	       iContactsBufferItemList.Count() > 0) 
  1119       	 iStateItem != KErrNone &&
       
  1120       	 iContactsBufferItemList.Count() > 0) 
  1124 	    {
  1121 	    {
  1125         iContactsBufferItemList[iContactsBufferItemList.Count()-1]->iStatus  = iStateItem; 
  1122         iContactsBufferItemList[iContactsBufferItemList.Count()-1]->iStatus  = iStateItem; 
  1126 	    }
  1123 	    }
  1127 
  1124 
  1128 	if( iBatchMode )
  1125 	if( iBatchMode )
  1144 	}
  1141 	}
  1145 
  1142 
  1146 // ----------------------------------------------------------------------------
  1143 // ----------------------------------------------------------------------------
  1147 // void CNSmlContactsDataStore::DoCloseItem()
  1144 // void CNSmlContactsDataStore::DoCloseItem()
  1148 // ----------------------------------------------------------------------------
  1145 // ----------------------------------------------------------------------------
  1149 void CNSmlContactsDataStore::DoCloseItem()
  1146 EXPORT_C void CNSmlContactsDataStore::DoCloseItem()
  1150 	{
  1147 	{
  1151 	_DBG_FILE("CNSmlContactsDataStore::DoCloseItem(): begin");
  1148 	_DBG_FILE("CNSmlContactsDataStore::DoCloseItem(): begin");
  1152 
  1149 
  1153 	if ( iState == ENSmlItemOpen )
  1150 	if ( iState == ENSmlItemOpen )
  1154 		{
  1151 		{
  1165 	}
  1162 	}
  1166 
  1163 
  1167 // ----------------------------------------------------------------------------
  1164 // ----------------------------------------------------------------------------
  1168 // void CNSmlContactsDataStore::DoMoveItemL()
  1165 // void CNSmlContactsDataStore::DoMoveItemL()
  1169 // ----------------------------------------------------------------------------
  1166 // ----------------------------------------------------------------------------
  1170 void CNSmlContactsDataStore::DoMoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid /*aNewParent*/, TRequestStatus& aStatus )
  1167 EXPORT_C void CNSmlContactsDataStore::DoMoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid /*aNewParent*/, TRequestStatus& aStatus )
  1171 	{
  1168 	{
  1172 	_DBG_FILE("CNSmlContactsDataStore::DoMoveItemL(): begin");
  1169 	_DBG_FILE("CNSmlContactsDataStore::DoMoveItemL(): begin");
  1173 	
  1170 	
  1174 	iCallerStatus = &aStatus;
  1171 	iCallerStatus = &aStatus;
  1175 	*iCallerStatus = KRequestPending;
  1172 	*iCallerStatus = KRequestPending;
  1188 	}
  1185 	}
  1189 
  1186 
  1190 // ----------------------------------------------------------------------------
  1187 // ----------------------------------------------------------------------------
  1191 // void CNSmlContactsDataStore::DoDeleteItemL()
  1188 // void CNSmlContactsDataStore::DoDeleteItemL()
  1192 // ----------------------------------------------------------------------------
  1189 // ----------------------------------------------------------------------------
  1193 void CNSmlContactsDataStore::DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus )
  1190 EXPORT_C void CNSmlContactsDataStore::DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus )
  1194 	{
  1191 	{
  1195 	_DBG_FILE("CNSmlContactsDataStore::DoDeleteItemL(): begin");
  1192 	_DBG_FILE("CNSmlContactsDataStore::DoDeleteItemL(): begin");
  1196 	iCallerStatus = &aStatus;
  1193 	iCallerStatus = &aStatus;
  1197 	*iCallerStatus = KRequestPending;
  1194 	*iCallerStatus = KRequestPending;
  1198 		
  1195 		
  1228 	}
  1225 	}
  1229 
  1226 
  1230 // ----------------------------------------------------------------------------
  1227 // ----------------------------------------------------------------------------
  1231 // void CNSmlContactsDataStore::DoSoftDeleteItemL()
  1228 // void CNSmlContactsDataStore::DoSoftDeleteItemL()
  1232 // ----------------------------------------------------------------------------
  1229 // ----------------------------------------------------------------------------
  1233 void CNSmlContactsDataStore::DoSoftDeleteItemL( TSmlDbItemUid /*aUid*/, TRequestStatus& aStatus )
  1230 EXPORT_C void CNSmlContactsDataStore::DoSoftDeleteItemL( TSmlDbItemUid /*aUid*/, TRequestStatus& aStatus )
  1234 	{
  1231 	{
  1235 	_DBG_FILE("CNSmlContactsDataStore::DoSoftDeleteItemL(): begin");
  1232 	_DBG_FILE("CNSmlContactsDataStore::DoSoftDeleteItemL(): begin");
  1236 	iCallerStatus = &aStatus;
  1233 	iCallerStatus = &aStatus;
  1237 	*iCallerStatus = KRequestPending;
  1234 	*iCallerStatus = KRequestPending;
  1238 	User::RequestComplete( iCallerStatus, KErrNotSupported );
  1235 	User::RequestComplete( iCallerStatus, KErrNotSupported );
  1240 	}
  1237 	}
  1241 
  1238 
  1242 // ----------------------------------------------------------------------------
  1239 // ----------------------------------------------------------------------------
  1243 // void CNSmlContactsDataStore::DoDeleteAllItemsL()
  1240 // void CNSmlContactsDataStore::DoDeleteAllItemsL()
  1244 // ----------------------------------------------------------------------------
  1241 // ----------------------------------------------------------------------------
  1245 void CNSmlContactsDataStore::DoDeleteAllItemsL( TRequestStatus& aStatus )
  1242 EXPORT_C void CNSmlContactsDataStore::DoDeleteAllItemsL( TRequestStatus& aStatus )
  1246 	{
  1243 	{
  1247 	_DBG_FILE("CNSmlContactsDataStore::DoDeleteAllItemsL(): begin");
  1244 	_DBG_FILE("CNSmlContactsDataStore::DoDeleteAllItemsL(): begin");
  1248 	
  1245 	
  1249 	iCallerStatus = &aStatus;
  1246 	iCallerStatus = &aStatus;
  1250 	*iCallerStatus = KRequestPending;
  1247 	*iCallerStatus = KRequestPending;
  1261 	}
  1258 	}
  1262 
  1259 
  1263 // ----------------------------------------------------------------------------
  1260 // ----------------------------------------------------------------------------
  1264 // TBool CNSmlContactsDataStore::DoHasSyncHistory()
  1261 // TBool CNSmlContactsDataStore::DoHasSyncHistory()
  1265 // ----------------------------------------------------------------------------
  1262 // ----------------------------------------------------------------------------
  1266 TBool CNSmlContactsDataStore::DoHasSyncHistory() const
  1263 EXPORT_C TBool CNSmlContactsDataStore::DoHasSyncHistory() const
  1267 	{
  1264 	{
  1268 	_DBG_FILE("CNSmlContactsDataStore::DoHasSyncHistory(): begin");
  1265 	_DBG_FILE("CNSmlContactsDataStore::DoHasSyncHistory(): begin");
  1269 	
  1266 	
  1270 	TBool doHasSyncHistory = EFalse;
  1267 	TBool doHasSyncHistory = EFalse;
  1271 	
  1268 	
  1297 	}
  1294 	}
  1298 
  1295 
  1299 // ----------------------------------------------------------------------------
  1296 // ----------------------------------------------------------------------------
  1300 // void CNSmlContactsDataStore::DoAddedItems()
  1297 // void CNSmlContactsDataStore::DoAddedItems()
  1301 // ----------------------------------------------------------------------------
  1298 // ----------------------------------------------------------------------------
  1302 const MSmlDataItemUidSet& CNSmlContactsDataStore::DoAddedItems() const
  1299 EXPORT_C const MSmlDataItemUidSet& CNSmlContactsDataStore::DoAddedItems() const
  1303 	{
  1300 	{
  1304 	_DBG_FILE("CNSmlContactsDataStore::DoAddedItems(): begin");
  1301 	_DBG_FILE("CNSmlContactsDataStore::DoAddedItems(): begin");
  1305 	if ( iState == ENSmlOpenAndWaiting )
  1302 	if ( iState == ENSmlOpenAndWaiting )
  1306 		{
  1303 		{
  1307 		iNewUids->Reset();
  1304 		iNewUids->Reset();
  1321 	}
  1318 	}
  1322 
  1319 
  1323 // ----------------------------------------------------------------------------
  1320 // ----------------------------------------------------------------------------
  1324 // void CNSmlContactsDataStore::DoDeletedItems()
  1321 // void CNSmlContactsDataStore::DoDeletedItems()
  1325 // ----------------------------------------------------------------------------
  1322 // ----------------------------------------------------------------------------
  1326 const MSmlDataItemUidSet& CNSmlContactsDataStore::DoDeletedItems() const
  1323 EXPORT_C const MSmlDataItemUidSet& CNSmlContactsDataStore::DoDeletedItems() const
  1327 	{
  1324 	{
  1328 	_DBG_FILE("CNSmlContactsDataStore::DoDeletedItems(): begin");	
  1325 	_DBG_FILE("CNSmlContactsDataStore::DoDeletedItems(): begin");	
  1329 	if ( iState == ENSmlOpenAndWaiting )
  1326 	if ( iState == ENSmlOpenAndWaiting )
  1330 		{
  1327 		{
  1331 		iDeletedUids->Reset();
  1328 		iDeletedUids->Reset();
  1345 	}
  1342 	}
  1346 
  1343 
  1347 // ----------------------------------------------------------------------------
  1344 // ----------------------------------------------------------------------------
  1348 // void CNSmlContactsDataStore::DoSoftDeletedItems()
  1345 // void CNSmlContactsDataStore::DoSoftDeletedItems()
  1349 // ----------------------------------------------------------------------------
  1346 // ----------------------------------------------------------------------------
  1350 const MSmlDataItemUidSet& CNSmlContactsDataStore::DoSoftDeletedItems() const
  1347 EXPORT_C const MSmlDataItemUidSet& CNSmlContactsDataStore::DoSoftDeletedItems() const
  1351 	{
  1348 	{
  1352 	_DBG_FILE("CNSmlContactsDataStore::DoSoftDeletedItems(): begin");
  1349 	_DBG_FILE("CNSmlContactsDataStore::DoSoftDeletedItems(): begin");
  1353 	if ( iState == ENSmlOpenAndWaiting )
  1350 	if ( iState == ENSmlOpenAndWaiting )
  1354 		{
  1351 		{
  1355 		iSoftDeletedUids->Reset();
  1352 		iSoftDeletedUids->Reset();
  1369 	}
  1366 	}
  1370 
  1367 
  1371 // ----------------------------------------------------------------------------
  1368 // ----------------------------------------------------------------------------
  1372 // void CNSmlContactsDataStore::DoModifiedItems()
  1369 // void CNSmlContactsDataStore::DoModifiedItems()
  1373 // ----------------------------------------------------------------------------
  1370 // ----------------------------------------------------------------------------
  1374 const MSmlDataItemUidSet& CNSmlContactsDataStore::DoModifiedItems() const
  1371 EXPORT_C const MSmlDataItemUidSet& CNSmlContactsDataStore::DoModifiedItems() const
  1375 	{
  1372 	{
  1376 	_DBG_FILE("CNSmlContactsDataStore::DoModifiedItems(): begin");
  1373 	_DBG_FILE("CNSmlContactsDataStore::DoModifiedItems(): begin");
  1377 	if ( iState == ENSmlOpenAndWaiting )
  1374 	if ( iState == ENSmlOpenAndWaiting )
  1378 		{
  1375 		{
  1379 		iReplacedUids->Reset();
  1376 		iReplacedUids->Reset();
  1393 	}
  1390 	}
  1394 
  1391 
  1395 // ----------------------------------------------------------------------------
  1392 // ----------------------------------------------------------------------------
  1396 // void CNSmlContactsDataStore::DoMovedItems()
  1393 // void CNSmlContactsDataStore::DoMovedItems()
  1397 // ----------------------------------------------------------------------------
  1394 // ----------------------------------------------------------------------------
  1398 const MSmlDataItemUidSet& CNSmlContactsDataStore::DoMovedItems() const
  1395 EXPORT_C const MSmlDataItemUidSet& CNSmlContactsDataStore::DoMovedItems() const
  1399 	{
  1396 	{
  1400 	_DBG_FILE("CNSmlContactsDataStore::DoMovedItems(): begin");
  1397 	_DBG_FILE("CNSmlContactsDataStore::DoMovedItems(): begin");
  1401 	
  1398 	
  1402 	if ( iState == ENSmlOpenAndWaiting )
  1399 	if ( iState == ENSmlOpenAndWaiting )
  1403 		{
  1400 		{
  1418 	}
  1415 	}
  1419 
  1416 
  1420 // ----------------------------------------------------------------------------
  1417 // ----------------------------------------------------------------------------
  1421 // void CNSmlContactsDataStore::DoResetChangeInfoL()
  1418 // void CNSmlContactsDataStore::DoResetChangeInfoL()
  1422 // ----------------------------------------------------------------------------
  1419 // ----------------------------------------------------------------------------
  1423 void CNSmlContactsDataStore::DoResetChangeInfoL( TRequestStatus& aStatus )
  1420 EXPORT_C void CNSmlContactsDataStore::DoResetChangeInfoL( TRequestStatus& aStatus )
  1424 	{
  1421 	{
  1425 	_DBG_FILE("CNSmlContactsDataStore::DoResetChangeInfoL(): begin");
  1422 	_DBG_FILE("CNSmlContactsDataStore::DoResetChangeInfoL(): begin");
  1426 	iCallerStatus = &aStatus;
  1423 	iCallerStatus = &aStatus;
  1427 	*iCallerStatus = KRequestPending;
  1424 	*iCallerStatus = KRequestPending;
  1428 	
  1425 	
  1449 	}
  1446 	}
  1450 
  1447 
  1451 // ----------------------------------------------------------------------------
  1448 // ----------------------------------------------------------------------------
  1452 // void CNSmlContactsDataStore::DoCommitChangeInfoL()
  1449 // void CNSmlContactsDataStore::DoCommitChangeInfoL()
  1453 // ----------------------------------------------------------------------------
  1450 // ----------------------------------------------------------------------------
  1454 void CNSmlContactsDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus, 
  1451 EXPORT_C void CNSmlContactsDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus, 
  1455 												  const MSmlDataItemUidSet& aItems )
  1452 												  const MSmlDataItemUidSet& aItems )
  1456 	{
  1453 	{
  1457 	_DBG_FILE("CNSmlContactsDataStore::DoCommitChangeInfoL(aItems): begin");
  1454 	_DBG_FILE("CNSmlContactsDataStore::DoCommitChangeInfoL(aItems): begin");
  1458 	iCallerStatus = &aStatus;
  1455 	iCallerStatus = &aStatus;
  1459 	*iCallerStatus = KRequestPending;
  1456 	*iCallerStatus = KRequestPending;
  1471 	}
  1468 	}
  1472 
  1469 
  1473 // ----------------------------------------------------------------------------
  1470 // ----------------------------------------------------------------------------
  1474 // void CNSmlContactsDataStore::DoCommitChangeInfoL()
  1471 // void CNSmlContactsDataStore::DoCommitChangeInfoL()
  1475 // ----------------------------------------------------------------------------
  1472 // ----------------------------------------------------------------------------
  1476 void CNSmlContactsDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus )
  1473 EXPORT_C void CNSmlContactsDataStore::DoCommitChangeInfoL( TRequestStatus& aStatus )
  1477 	{
  1474 	{
  1478 	_DBG_FILE("CNSmlContactsDataStore::DoCommitChangeInfoL(): begin");
  1475 	_DBG_FILE("CNSmlContactsDataStore::DoCommitChangeInfoL(): begin");
  1479 	iCallerStatus = &aStatus;
  1476 	iCallerStatus = &aStatus;
  1480 	*iCallerStatus = KRequestPending;
  1477 	*iCallerStatus = KRequestPending;
  1481 	
  1478 	
  1492 	}
  1489 	}
  1493 
  1490 
  1494 // ----------------------------------------------------------------------------
  1491 // ----------------------------------------------------------------------------
  1495 // CDesCArray* CNSmlContactsDataStore::DoListStoresLC()
  1492 // CDesCArray* CNSmlContactsDataStore::DoListStoresLC()
  1496 // ----------------------------------------------------------------------------
  1493 // ----------------------------------------------------------------------------
  1497 CDesCArray* CNSmlContactsDataStore::DoListStoresLC()
  1494 EXPORT_C CDesCArray* CNSmlContactsDataStore::DoListStoresLC()
  1498 	{
  1495 	{
  1499 	_DBG_FILE("CNSmlContactsDataStore::DoListStoresLC(): begin");
  1496 	_DBG_FILE("CNSmlContactsDataStore::DoListStoresLC(): begin");
  1500 	
  1497 	
  1501 	MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();
  1498 	MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();
  1502 	CDesCArrayFlat* stores = new (ELeave) CDesCArrayFlat(storeList.Count());
  1499 	CDesCArrayFlat* stores = new (ELeave) CDesCArrayFlat(storeList.Count());
  1527 	}
  1524 	}
  1528 	
  1525 	
  1529 // ------------------------------------------------------------------------------------------------
  1526 // ------------------------------------------------------------------------------------------------
  1530 // TInt CNSmlContactsDataStore::LdoFetchItemL( TSmlDbItemUid& aUid, CBufBase& aItem )
  1527 // TInt CNSmlContactsDataStore::LdoFetchItemL( TSmlDbItemUid& aUid, CBufBase& aItem )
  1531 // ------------------------------------------------------------------------------------------------
  1528 // ------------------------------------------------------------------------------------------------
  1532 void CNSmlContactsDataStore::LdoFetchItemL( TSmlDbItemUid& aUid, CBufBase& aItem )
  1529 EXPORT_C void CNSmlContactsDataStore::LdoFetchItemL( TSmlDbItemUid& aUid, CBufBase& aItem )
  1533 	{
  1530 	{
  1534 	_DBG_FILE("CNSmlContactsDataStore::LdoFetchItemL(): begin");
  1531 	_DBG_FILE("CNSmlContactsDataStore::LdoFetchItemL(): begin");
  1535 	
  1532 	
  1536 	 iWriteStream.Open(aItem);
  1533 	 iWriteStream.Open(aItem);
  1537 		
  1534 		
  1550 //                                           const TDesC8& aItem,
  1547 //                                           const TDesC8& aItem,
  1551 //                                           TInt aSize,
  1548 //                                           TInt aSize,
  1552 //                                           TTime& aLastModified,
  1549 //                                           TTime& aLastModified,
  1553 //                                           TBool& aConfidential )
  1550 //                                           TBool& aConfidential )
  1554 // ------------------------------------------------------------------------------------------------
  1551 // ------------------------------------------------------------------------------------------------
  1555 void CNSmlContactsDataStore::LdoAddItemL( const TDesC8& aItem,
  1552 EXPORT_C void CNSmlContactsDataStore::LdoAddItemL( const TDesC8& aItem,
  1556                                           TInt aSize)
  1553                                           TInt aSize)
  1557 	{
  1554 	{
  1558 	_DBG_FILE("CNSmlContactsDataStore::LdoAddItemL(): begin");
  1555 	_DBG_FILE("CNSmlContactsDataStore::LdoAddItemL(): begin");
  1559 
  1556 
  1560 	if( !iOpened )
  1557 	if( !iOpened )
  1582 	}
  1579 	}
  1583 // ------------------------------------------------------------------------------------------------
  1580 // ------------------------------------------------------------------------------------------------
  1584 // TInt CNSmlContactsDataStore::LdoAddItemsL( CBufBase*& aItems,
  1581 // TInt CNSmlContactsDataStore::LdoAddItemsL( CBufBase*& aItems,
  1585 //                                           TInt aSize)
  1582 //                                           TInt aSize)
  1586 // ------------------------------------------------------------------------------------------------
  1583 // ------------------------------------------------------------------------------------------------
  1587 void CNSmlContactsDataStore::LdoAddItemsL( CBufBase*& aItems,
  1584 EXPORT_C void CNSmlContactsDataStore::LdoAddItemsL( CBufBase*& aItems,
  1588                                           TInt aSize)
  1585                                           TInt aSize)
  1589 	{
  1586 	{
  1590 	_DBG_FILE("CNSmlContactsDataStore::LdoAddItemL(): begin");
  1587 	_DBG_FILE("CNSmlContactsDataStore::LdoAddItemL(): begin");
  1591 
  1588 
  1592 	if( !iOpened )
  1589 	if( !iOpened )
  1612 // TInt CNSmlContactsDataStore::LdoUpdateItemL(TSmlDbItemUid aUid,
  1609 // TInt CNSmlContactsDataStore::LdoUpdateItemL(TSmlDbItemUid aUid,
  1613 //                                             const TDesC8& aItem,
  1610 //                                             const TDesC8& aItem,
  1614 //                                             TInt aSize,
  1611 //                                             TInt aSize,
  1615 //                                             TTime& aLastModified )
  1612 //                                             TTime& aLastModified )
  1616 // ------------------------------------------------------------------------------------------------
  1613 // ------------------------------------------------------------------------------------------------
  1617 void CNSmlContactsDataStore::LdoUpdateItemL()
  1614 EXPORT_C void CNSmlContactsDataStore::LdoUpdateItemL()
  1618 	{
  1615 	{
  1619 	_DBG_FILE("CNSmlContactsDataStore::LdoUpdateItemL(): begin");
  1616 	_DBG_FILE("CNSmlContactsDataStore::LdoUpdateItemL(): begin");
  1620 	
  1617 	
  1621 	iBuf = iContactsBufferItemList[iIndex]->iItemData->Ptr(0).AllocLC();
  1618 	iBuf = iContactsBufferItemList[iIndex]->iItemData->Ptr(0).AllocLC();
  1622 	// Remove UID's from data
  1619 	// Remove UID's from data
  1623 	StripPropertyL( iBuf, KVersitTokenUID() );
  1620 	StripPropertyL( iBuf, KVersitTokenUID() );
  1624 
  1621 
  1625 	iReadStream.Open( *iBuf );
  1622 	iReadStream.Open( *iBuf );
  1626 	MVPbkContactLink* contactLink = iIdConverter->IdentifierToLinkLC(iUid);
  1623 	iContactLink = iIdConverter->IdentifierToLinkLC(iUid);
  1627 	  iVCardEngine->ImportVCardMergeL(*contactLink,*iStore,iReadStream,*this);
  1624 	iVCardEngine->ImportVCardMergeL(*iContactLink, *iStore, iReadStream, *this);
  1628 
  1625 
  1629 	CleanupStack::Pop();
  1626 	CleanupStack::Pop();
  1630 	iLastOperation = ENSMLUpdateImportOp;
  1627 	iLastOperation = ENSMLUpdateImportOp;
  1631 	CleanupStack::Pop(iBuf);
  1628 	CleanupStack::Pop(iBuf);
  1632 	
  1629 	
  1636 
  1633 
  1637 
  1634 
  1638 // ------------------------------------------------------------------------------------------------
  1635 // ------------------------------------------------------------------------------------------------
  1639 // CNSmlContactsDataStore::DriveBelowCriticalLevelL()
  1636 // CNSmlContactsDataStore::DriveBelowCriticalLevelL()
  1640 // ------------------------------------------------------------------------------------------------
  1637 // ------------------------------------------------------------------------------------------------
  1641 TBool CNSmlContactsDataStore::DriveBelowCriticalLevelL( TInt aSize )
  1638 EXPORT_C TBool CNSmlContactsDataStore::DriveBelowCriticalLevelL( TInt aSize )
  1642 	{
  1639 	{
  1643 	return SysUtil::DiskSpaceBelowCriticalLevelL( &iRfs, aSize, iDrive );
  1640 	return SysUtil::DiskSpaceBelowCriticalLevelL( &iRfs, aSize, iDrive );
  1644 	}
  1641 	}
  1645 
  1642 
  1646 // ----------------------------------------------------------------------------
  1643 // ----------------------------------------------------------------------------
  1647 // CBufBase* CNSmlContactsDataStore::AddBufferListL()
  1644 // CBufBase* CNSmlContactsDataStore::AddBufferListL()
  1648 // ----------------------------------------------------------------------------
  1645 // ----------------------------------------------------------------------------
  1649 CBufBase* CNSmlContactsDataStore::AddBufferListL( TSmlDbItemUid& aUid, TInt aSize, TInt aStatus )
  1646 EXPORT_C CBufBase* CNSmlContactsDataStore::AddBufferListL( TSmlDbItemUid& aUid, TInt aSize, TInt aStatus )
  1650 	{
  1647 	{
  1651 	_DBG_FILE("CNSmlContactsDataStore::AddBufferListL(): begin");
  1648 	_DBG_FILE("CNSmlContactsDataStore::AddBufferListL(): begin");
  1652 	
  1649 	
  1653 	CNSmlContactsBufferItem* newBufferItem = new (ELeave) CNSmlContactsBufferItem;
  1650 	CNSmlContactsBufferItem* newBufferItem = new (ELeave) CNSmlContactsBufferItem;
  1654 	CleanupStack::PushL( newBufferItem );
  1651 	CleanupStack::PushL( newBufferItem );
  1698 	}
  1695 	}
  1699 	
  1696 	
  1700 // ------------------------------------------------------------------------------------------------
  1697 // ------------------------------------------------------------------------------------------------
  1701 // void CNSmlContactsDataStore::StripPropertyL( HBufC8*& aItem, const TDesC8& aProperty )
  1698 // void CNSmlContactsDataStore::StripPropertyL( HBufC8*& aItem, const TDesC8& aProperty )
  1702 // ------------------------------------------------------------------------------------------------
  1699 // ------------------------------------------------------------------------------------------------
  1703 void CNSmlContactsDataStore::StripPropertyL( HBufC8*& aItem, const TDesC8& aProperty ) const
  1700 EXPORT_C void CNSmlContactsDataStore::StripPropertyL( HBufC8*& aItem, const TDesC8& aProperty ) const
  1704 	{
  1701 	{
  1705 	_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): begin");
  1702 	_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): begin");
  1706 
  1703 
  1707 	if( !aItem )
  1704 	if( !aItem )
  1708 		{
  1705 		{
  1731 	}
  1728 	}
  1732 	
  1729 	
  1733 // ------------------------------------------------------------------------------------------------
  1730 // ------------------------------------------------------------------------------------------------
  1734 // void CNSmlContactsDataStore::StripPropertyL( CBufBase*& aItem, const TDesC8& aProperty )
  1731 // void CNSmlContactsDataStore::StripPropertyL( CBufBase*& aItem, const TDesC8& aProperty )
  1735 // ------------------------------------------------------------------------------------------------
  1732 // ------------------------------------------------------------------------------------------------
  1736 void CNSmlContactsDataStore::StripPropertyL( CBufBase*& aItem, const TDesC8& aProperty ) const
  1733 EXPORT_C void CNSmlContactsDataStore::StripPropertyL( CBufBase*& aItem, const TDesC8& aProperty ) const
  1737 	{
  1734 	{
  1738 	_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): begin");
  1735 	_DBG_FILE("CNSmlContactsDataStore::StripPropertyL(): begin");
  1739 	
  1736 	
  1740 	if( !aItem )
  1737 	if( !aItem )
  1741 		{
  1738 		{
  1768 	
  1765 	
  1769 // ----------------------------------------------------------------------------
  1766 // ----------------------------------------------------------------------------
  1770 // CNSmlContactsDataStore::IsConfidentialL
  1767 // CNSmlContactsDataStore::IsConfidentialL
  1771 // ----------------------------------------------------------------------------
  1768 // ----------------------------------------------------------------------------
  1772 //	
  1769 //	
  1773 TBool CNSmlContactsDataStore::IsConfidentialL(  MVPbkStoreContact& aItem )
  1770 EXPORT_C TBool CNSmlContactsDataStore::IsConfidentialL(  MVPbkStoreContact& aItem )
  1774     {
  1771     {
  1775     _DBG_FILE("CNSmlContactsDataStore::IsConfidentialL(): begin");
  1772     _DBG_FILE("CNSmlContactsDataStore::IsConfidentialL(): begin");
  1776     TBool ret( EFalse );
  1773     TBool ret( EFalse );
  1777     
  1774     
  1778     //find X-CLASS field type
  1775     //find X-CLASS field type
  1787         const MVPbkContactFieldTextData& data = MVPbkContactFieldTextData::Cast(field->FieldData());
  1784         const MVPbkContactFieldTextData& data = MVPbkContactFieldTextData::Cast(field->FieldData());
  1788         TPtrC ptr = data.Text();
  1785         TPtrC ptr = data.Text();
  1789         //compare the sync type
  1786         //compare the sync type
  1790         if ( ptr.Compare( KNSmlContactSyncNoSync ) == 0 )
  1787         if ( ptr.Compare( KNSmlContactSyncNoSync ) == 0 )
  1791             {
  1788             {
  1792             _DBG_FILE("CNSmlContactsModsFetcher::IsConfidentialL(): \
  1789             _DBG_FILE("CNSmlContactsDataStore::IsConfidentialL(): \
  1793                        find confidential");
  1790                        find confidential");
  1794             ret = ETrue;
  1791             ret = ETrue;
  1795             }
  1792             }
  1796          
  1793          
  1797         }
  1794         }
  1803     
  1800     
  1804  // ----------------------------------------------------------------------------
  1801  // ----------------------------------------------------------------------------
  1805 // CNSmlContactsDataStore::ResetBuffer
  1802 // CNSmlContactsDataStore::ResetBuffer
  1806 // ----------------------------------------------------------------------------
  1803 // ----------------------------------------------------------------------------
  1807 //	
  1804 //	
  1808 void CNSmlContactsDataStore:: ResetBuffer()
  1805 EXPORT_C void CNSmlContactsDataStore:: ResetBuffer()
  1809 	{
  1806 	{
  1810 	if( iItemDataAddBatch )
  1807 	if( iItemDataAddBatch )
  1811 		{
  1808 		{
  1812 		iItemDataAddBatch->Reset();
  1809 		iItemDataAddBatch->Reset();
  1813 		}
  1810 		}
  1816 // -----------------------------------------------------------------------------
  1813 // -----------------------------------------------------------------------------
  1817 // From MVPbkContactStoreListObserver  
  1814 // From MVPbkContactStoreListObserver  
  1818 // Called when a contact store is ready to use.
  1815 // Called when a contact store is ready to use.
  1819 // -----------------------------------------------------------------------------
  1816 // -----------------------------------------------------------------------------
  1820  
  1817  
  1821 void CNSmlContactsDataStore::StoreReady( MVPbkContactStore& /*aContactStore*/ )
  1818 EXPORT_C void CNSmlContactsDataStore::StoreReady( MVPbkContactStore& /*aContactStore*/ )
  1822 	{
  1819 	{
  1823 	_DBG_FILE("CNSmlContactsDataStore::StoreReady(): begin");
  1820 	_DBG_FILE("CNSmlContactsDataStore::StoreReady(): begin");
  1824 	//The contact data base opened successfully
  1821 	//The contact data base opened successfully
  1825 	iOpened = ETrue;
  1822 	iOpened = ETrue;
  1826 	//id to uniquely identify the opened store 
  1823 	//id to uniquely identify the opened store 
  1827 	iOpenedStoreId = DefaultHash::Des16(
  1824 	iOpenedStoreId = DefaultHash::Des16(
  1828 						iStore->StoreProperties().Uri().UriDes());
  1825 						iStore->StoreProperties().Uri().UriDes());
  1829 	
  1826 	
  1830 	TRAPD(error,iContactsModsFetcher->FetchModificationsL( *iCallerStatus ));
  1827 	TRAPD(error, iContactsModsFetcher->FetchModificationsL( *iCallerStatus ));
  1831 	if(error != KErrNone)
  1828 	if(error != KErrNone)
  1832 		{
  1829 		{
  1833 		User::RequestComplete( iCallerStatus, error );
  1830 		User::RequestComplete( iCallerStatus, error );
  1834 		}
  1831 		}
  1835 	_DBG_FILE("CNSmlContactsDataStore::StoreReady(): end");
  1832 	_DBG_FILE("CNSmlContactsDataStore::StoreReady(): end");
  1839 // ---------------------------------------------------------------------------
  1836 // ---------------------------------------------------------------------------
  1840 //  From MVPbkContactStoreListObserver  
  1837 //  From MVPbkContactStoreListObserver  
  1841 //	Called when a contact store becomes unavailable.
  1838 //	Called when a contact store becomes unavailable.
  1842 // ---------------------------------------------------------------------------
  1839 // ---------------------------------------------------------------------------
  1843 //
  1840 //
  1844 void CNSmlContactsDataStore::StoreUnavailable(
  1841 EXPORT_C void CNSmlContactsDataStore::StoreUnavailable(
  1845         MVPbkContactStore& /*aContactStore*/,
  1842         MVPbkContactStore& /*aContactStore*/,
  1846         TInt aReason )
  1843         TInt aReason )
  1847     {
  1844     {
  1848     _DBG_FILE("CNSmlContactsDataStore::StoreUnavailable(): begin");
  1845     _DBG_FILE("CNSmlContactsDataStore::StoreUnavailable(): begin");
  1849 
  1846 
  1860 
  1857 
  1861 // ---------------------------------------------------------------------------
  1858 // ---------------------------------------------------------------------------
  1862 // From MVPbkContactStoreListObserver  
  1859 // From MVPbkContactStoreListObserver  
  1863 // ---------------------------------------------------------------------------
  1860 // ---------------------------------------------------------------------------
  1864 //
  1861 //
  1865 void CNSmlContactsDataStore::HandleStoreEventL(
  1862 EXPORT_C void CNSmlContactsDataStore::HandleStoreEventL(
  1866         MVPbkContactStore& /*aContactStore*/,
  1863         MVPbkContactStore& /*aContactStore*/,
  1867         TVPbkContactStoreEvent /*aStoreEvent*/ )
  1864         TVPbkContactStoreEvent /*aStoreEvent*/ )
  1868 	{
  1865 	{
  1869 	//Indication not needed.
  1866 	//Indication not needed.
  1870 	}
  1867 	}
  1871     
  1868     
  1872 // ---------------------------------------------------------------------------
  1869 // ---------------------------------------------------------------------------
  1873 //  CNSmlContactsDataStore::VPbkSingleContactOperationComplete
  1870 //  CNSmlContactsDataStore::VPbkSingleContactOperationComplete
  1874 // ---------------------------------------------------------------------------
  1871 // ---------------------------------------------------------------------------
  1875 //
  1872 //
  1876     
  1873 EXPORT_C void CNSmlContactsDataStore::VPbkSingleContactOperationComplete(
  1877  void CNSmlContactsDataStore::VPbkSingleContactOperationComplete(
       
  1878 		MVPbkContactOperationBase& aOperation,
  1874 		MVPbkContactOperationBase& aOperation,
  1879 		MVPbkStoreContact* aContact )
  1875 		MVPbkStoreContact* aContact )
  1880 	{
  1876 	{
  1881 	MVPbkContactOperationBase* operation = &aOperation;
  1877 	MVPbkContactOperationBase* operation = &aOperation;
  1882 	if ( operation )
  1878 	if ( operation )
  1894 
  1890 
  1895 // ---------------------------------------------------------------------------
  1891 // ---------------------------------------------------------------------------
  1896 //  CNSmlContactsDataStore::VPbkSingleContactOperationFailed
  1892 //  CNSmlContactsDataStore::VPbkSingleContactOperationFailed
  1897 // ---------------------------------------------------------------------------
  1893 // ---------------------------------------------------------------------------
  1898 //
  1894 //
  1899 void CNSmlContactsDataStore::VPbkSingleContactOperationFailed(
  1895 EXPORT_C void CNSmlContactsDataStore::VPbkSingleContactOperationFailed(
  1900 		MVPbkContactOperationBase& aOperation,
  1896     MVPbkContactOperationBase& aOperation,
  1901 		 TInt aError )
  1897     TInt aError )
  1902 	 {
  1898     {
  1903 	MVPbkContactOperationBase* operation = &aOperation;
  1899 	MVPbkContactOperationBase* operation = &aOperation;
  1904 	if ( operation )
  1900 	if ( operation )
  1905 	{
  1901 	    {
  1906 		delete operation;
  1902 		delete operation;
  1907 		operation = NULL;
  1903 		operation = NULL;
  1908 	}
  1904 	    }
       
  1905 	
  1909 	 if(iLastOperation == ENSMLFetchOp)
  1906 	 if(iLastOperation == ENSMLFetchOp)
  1910 		 {
  1907 		{
  1911 	 	iWriteStream.Close();
  1908 	 	iWriteStream.Close();
  1912 	 	User::RequestComplete( iCallerStatus, aError );
  1909 	 	User::RequestComplete( iCallerStatus, aError );
  1913 	 	}
  1910 	 	}
  1914 	else if (iLastOperation == ENSMLUpdateExportOp)
  1911 	else if (iLastOperation == ENSMLUpdateExportOp)
  1915         {
  1912         {
  1922         {
  1919         {
  1923         if(iBatchMode)
  1920         if(iBatchMode)
  1924             {
  1921             {
  1925             iResultArray->Append( aError ); 
  1922             iResultArray->Append( aError ); 
  1926             } 
  1923             } 
       
  1924 		delete iContactLink;
       
  1925         iContactLink = NULL;	
  1927         delete iBuf;
  1926         delete iBuf;
  1928         iBuf = NULL;
  1927         iBuf = NULL;
  1929         iReadStream.Close();
  1928         iReadStream.Close();
  1930         iIndex++;
  1929         iIndex++;
  1931         if(iIndex == iContactsBufferItemList.Count() )
  1930         if(iIndex == iContactsBufferItemList.Count() )
  1967 	}
  1966 	}
  1968  // ---------------------------------------------------------------------------
  1967  // ---------------------------------------------------------------------------
  1969 //  CNSmlContactsDataStore::VPbkSingleContactOperationFailed
  1968 //  CNSmlContactsDataStore::VPbkSingleContactOperationFailed
  1970 // ---------------------------------------------------------------------------
  1969 // ---------------------------------------------------------------------------
  1971 //
  1970 //
  1972  void CNSmlContactsDataStore::SingleContactOperationCompleteL(
  1971 EXPORT_C void CNSmlContactsDataStore::SingleContactOperationCompleteL(
  1973  		MVPbkStoreContact* aContact)
  1972  		MVPbkStoreContact* aContact)
  1974 	{
  1973 	{
  1975 	if(iLastOperation == ENSMLFetchOp)
  1974 	if(iLastOperation == ENSMLFetchOp)
  1976 		{
  1975 		{
  1977 		iWriteStream.Close();
  1976 		iWriteStream.Close();
  1990 			User::RequestComplete( iCallerStatus, KErrTooBig );
  1989 			User::RequestComplete( iCallerStatus, KErrTooBig );
  1991 			}
  1990 			}
  1992 		}
  1991 		}
  1993 	else if (iLastOperation == ENSMLUpdateExportOp)
  1992 	else if (iLastOperation == ENSMLUpdateExportOp)
  1994 		{
  1993 		{
  1995 		iDataMod->MergeRxL( *iContactsBufferItemList[iIndex]->iItemData, *iMergeItem );
  1994 		iDataMod->MergeRxL( *iContactsBufferItemList[iIndex]->iItemData, 
       
  1995 		    *iMergeItem, iFieldLevelReplace );
  1996 		iWriteStream.Close();
  1996 		iWriteStream.Close();
  1997 		delete iMergeItem;
  1997 		delete iMergeItem;
  1998 		iMergeItem = NULL;
  1998 		iMergeItem = NULL;
  1999 		LdoUpdateItemL();
  1999 		LdoUpdateItemL();
  2000 		}
  2000 		}
  2001 	else if (iLastOperation == ENSMLUpdateImportOp)
  2001 	else if (iLastOperation == ENSMLUpdateImportOp)
  2002 		{
  2002 		{
       
  2003 		iFieldLevelReplace = EFalse;
       
  2004 		
  2003 		if(!IsConfidentialL(*aContact))
  2005 		if(!IsConfidentialL(*aContact))
  2004 			{
  2006 			{
  2005 			TInt32 id = iIdConverter->LinkToIdentifier(*aContact->CreateLinkLC());
  2007 			TInt32 id = iIdConverter->LinkToIdentifier(*aContact->CreateLinkLC());
  2006 			
  2008 			
  2007 			TNSmlSnapshotItem item(id);
  2009 			TNSmlSnapshotItem item(id);
  2023 			if(iBatchMode)
  2025 			if(iBatchMode)
  2024 				{
  2026 				{
  2025 				iResultArray->Append(KErrNone);	
  2027 				iResultArray->Append(KErrNone);	
  2026 				}
  2028 				}
  2027 			
  2029 			
       
  2030 	        delete iContactLink;
       
  2031 	        iContactLink = NULL;
  2028 			
  2032 			
  2029 			delete iBuf;
  2033 			delete iBuf;
  2030 			iBuf = NULL;
  2034 			iBuf = NULL;
  2031 			iReadStream.Close();
  2035 			iReadStream.Close();
  2032 			
       
  2033 			
  2036 			
  2034 			iIndex++;
  2037 			iIndex++;
  2035 			if(iIndex == iContactsBufferItemList.Count() )
  2038 			if(iIndex == iContactsBufferItemList.Count() )
  2036 				{
  2039 				{
  2037 				ResetBuffer();
  2040 				ResetBuffer();
  2089  }
  2092  }
  2090  // ---------------------------------------------------------------------------
  2093  // ---------------------------------------------------------------------------
  2091 //  CNSmlContactsDataStore::ContactsSaved.
  2094 //  CNSmlContactsDataStore::ContactsSaved.
  2092 // ---------------------------------------------------------------------------
  2095 // ---------------------------------------------------------------------------
  2093 //
  2096 //
  2094  void CNSmlContactsDataStore::ContactsSaved( 
  2097 EXPORT_C void CNSmlContactsDataStore::ContactsSaved( 
  2095 		MVPbkContactOperationBase& aOperation,
  2098 		MVPbkContactOperationBase& aOperation,
  2096         MVPbkContactLinkArray* aResults ) 
  2099         MVPbkContactLinkArray* aResults ) 
  2097 	{
  2100 	{
  2098 	MVPbkContactOperationBase* operation = &aOperation;
  2101 	MVPbkContactOperationBase* operation = &aOperation;
  2099 	if ( operation )
  2102 	if ( operation )
  2153         
  2156         
  2154  // ---------------------------------------------------------------------------
  2157  // ---------------------------------------------------------------------------
  2155 //  CNSmlContactsDataStore::ContactsSavingFailed
  2158 //  CNSmlContactsDataStore::ContactsSavingFailed
  2156 // ---------------------------------------------------------------------------
  2159 // ---------------------------------------------------------------------------
  2157 //       
  2160 //       
  2158 void CNSmlContactsDataStore::ContactsSavingFailed( 
  2161 EXPORT_C void CNSmlContactsDataStore::ContactsSavingFailed( 
  2159         MVPbkContactOperationBase& aOperation, TInt aError )
  2162         MVPbkContactOperationBase& aOperation, TInt aError )
  2160 	{
  2163 	{
  2161 	MVPbkContactOperationBase* operation = &aOperation;
  2164 	MVPbkContactOperationBase* operation = &aOperation;
  2162 	if ( operation )
  2165 	if ( operation )
  2163 	{
  2166 	{
  2202 	}
  2205 	}
  2203 // ---------------------------------------------------------------------------
  2206 // ---------------------------------------------------------------------------
  2204 //  CNSmlContactsDataStore::StepComplete
  2207 //  CNSmlContactsDataStore::StepComplete
  2205 // ---------------------------------------------------------------------------
  2208 // ---------------------------------------------------------------------------
  2206 //
  2209 //
  2207 void CNSmlContactsDataStore::StepComplete(
  2210 EXPORT_C void CNSmlContactsDataStore::StepComplete(
  2208 		 MVPbkContactOperationBase& /*aOperation*/, 
  2211 		 MVPbkContactOperationBase& /*aOperation*/, 
  2209         TInt aStepSize )
  2212         TInt aStepSize )
  2210 	{
  2213 	{
  2211 	if(iLastOperation == ENSmlDeleteOp)
  2214 	if(iLastOperation == ENSmlDeleteOp)
  2212 		{
  2215 		{
  2242 	}
  2245 	}
  2243  // ---------------------------------------------------------------------------
  2246  // ---------------------------------------------------------------------------
  2244 //  CNSmlContactsDataStore::StepFailed
  2247 //  CNSmlContactsDataStore::StepFailed
  2245 // ---------------------------------------------------------------------------
  2248 // ---------------------------------------------------------------------------
  2246 //
  2249 //
  2247  TBool CNSmlContactsDataStore::StepFailed(
  2250 EXPORT_C TBool CNSmlContactsDataStore::StepFailed(
  2248         MVPbkContactOperationBase& /*aOperation*/,
  2251         MVPbkContactOperationBase& /*aOperation*/,
  2249         TInt /*aStepSize*/,
  2252         TInt /*aStepSize*/,
  2250         TInt aError )
  2253         TInt aError )
  2251  {
  2254  {
  2252  if(iLastOperation == ENSmlDeleteOp)
  2255  if(iLastOperation == ENSmlDeleteOp)
  2270  }
  2273  }
  2271 // ---------------------------------------------------------------------------
  2274 // ---------------------------------------------------------------------------
  2272 //  CNSmlContactsDataStore::OperationComplete
  2275 //  CNSmlContactsDataStore::OperationComplete
  2273 // ---------------------------------------------------------------------------
  2276 // ---------------------------------------------------------------------------
  2274 //
  2277 //
  2275 void CNSmlContactsDataStore::OperationComplete
  2278 EXPORT_C void CNSmlContactsDataStore::OperationComplete
  2276 		( MVPbkContactOperationBase& aOperation )
  2279 		( MVPbkContactOperationBase& aOperation )
  2277 	{
  2280 	{
  2278 	MVPbkContactOperationBase* operation = &aOperation;
  2281 	MVPbkContactOperationBase* operation = &aOperation;
  2279 	if ( operation )
  2282 	if ( operation )
  2280 	{
  2283 	{
  2291 
  2294 
  2292 // ---------------------------------------------------------------------------
  2295 // ---------------------------------------------------------------------------
  2293 //  CNSmlContactsDataStore::OperationCompleteL
  2296 //  CNSmlContactsDataStore::OperationCompleteL
  2294 // ---------------------------------------------------------------------------
  2297 // ---------------------------------------------------------------------------
  2295 //
  2298 //
  2296 
  2299 EXPORT_C void CNSmlContactsDataStore::OperationCompleteL()
  2297 void CNSmlContactsDataStore::OperationCompleteL()
       
  2298 	{
  2300 	{
  2299 	if(iLastOperation == ENSmlDeleteOp)
  2301 	if(iLastOperation == ENSmlDeleteOp)
  2300 		{
  2302 		{
  2301 		if(iBatchMode )
  2303 		if(iBatchMode )
  2302 			{
  2304 			{
  2359 
  2361 
  2360 // ---------------------------------------------------------------------------
  2362 // ---------------------------------------------------------------------------
  2361 // CNSmlContactsDataStore::ContactViewReady
  2363 // CNSmlContactsDataStore::ContactViewReady
  2362 // Implements the view ready function of MVPbkContactViewObserver
  2364 // Implements the view ready function of MVPbkContactViewObserver
  2363 // --------------------------------------------------------------------------- 
  2365 // --------------------------------------------------------------------------- 
  2364 void CNSmlContactsDataStore::ContactViewReady(
  2366 EXPORT_C void CNSmlContactsDataStore::ContactViewReady(
  2365                 MVPbkContactViewBase& /*aView*/ ) 
  2367                 MVPbkContactViewBase& /*aView*/ ) 
  2366 	{
  2368 	{
  2367 	if(iLastOperation == ENSMLDeleteAllOp)
  2369 	if(iLastOperation == ENSMLDeleteAllOp)
  2368 		{
  2370 		{
  2369 		TRAPD(error,DoDeleteAllContactsL());
  2371 		TRAPD(error,DoDeleteAllContactsL());
  2375 	}
  2377 	}
  2376 // ---------------------------------------------------------------------------
  2378 // ---------------------------------------------------------------------------
  2377 // CNSmlContactsDataStore::PrepareForContactsDeleteL()
  2379 // CNSmlContactsDataStore::PrepareForContactsDeleteL()
  2378 // Delete all the contacts at client
  2380 // Delete all the contacts at client
  2379 // ---------------------------------------------------------------------------	
  2381 // ---------------------------------------------------------------------------	
  2380 void CNSmlContactsDataStore::DoDeleteAllContactsL()
  2382 EXPORT_C void CNSmlContactsDataStore::DoDeleteAllContactsL()
  2381 	{
  2383 	{
  2382 	iContactLnks = CVPbkContactLinkArray::NewL();
  2384 	iContactLnks = CVPbkContactLinkArray::NewL();
  2383 	TInt contactCount = iContactViewBase->ContactCountL();
  2385 	TInt contactCount = iContactViewBase->ContactCountL();
  2384 	//add all the contact links to  ContactLinkArray
  2386 	//add all the contact links to  ContactLinkArray
  2385 	for( TInt i = 0; i < contactCount; i++ )
  2387 	for( TInt i = 0; i < contactCount; i++ )
  2397 
  2399 
  2398 // ---------------------------------------------------------------------------
  2400 // ---------------------------------------------------------------------------
  2399 // CNSmlContactsDataStore::ContactViewUnavailable
  2401 // CNSmlContactsDataStore::ContactViewUnavailable
  2400 // Implements the view unavailable function of MVPbkContactViewObserver
  2402 // Implements the view unavailable function of MVPbkContactViewObserver
  2401 // --------------------------------------------------------------------------- 
  2403 // --------------------------------------------------------------------------- 
  2402 void CNSmlContactsDataStore::ContactViewUnavailable(
  2404 EXPORT_C void CNSmlContactsDataStore::ContactViewUnavailable(
  2403                 MVPbkContactViewBase& /*aView*/ )  
  2405                 MVPbkContactViewBase& /*aView*/ )  
  2404 	{
  2406 	{
  2405 	   
  2407 	   
  2406 	}
  2408 	}
  2407 
  2409 
  2408 // ---------------------------------------------------------------------------
  2410 // ---------------------------------------------------------------------------
  2409 // CNSmlContactsDataStore::ContactAddedToView
  2411 // CNSmlContactsDataStore::ContactAddedToView
  2410 // Implements the add contact function of MVPbkContactViewObserver
  2412 // Implements the add contact function of MVPbkContactViewObserver
  2411 // --------------------------------------------------------------------------- 
  2413 // --------------------------------------------------------------------------- 
  2412 void CNSmlContactsDataStore::ContactAddedToView(
  2414 EXPORT_C void CNSmlContactsDataStore::ContactAddedToView(
  2413             MVPbkContactViewBase& /*aView*/, 
  2415             MVPbkContactViewBase& /*aView*/, 
  2414             TInt /*aIndex*/, 
  2416             TInt /*aIndex*/, 
  2415             const MVPbkContactLink& /*aContactLink*/ ) 
  2417             const MVPbkContactLink& /*aContactLink*/ ) 
  2416 	{
  2418 	{
  2417 	}
  2419 	}
  2418 
  2420 
  2419 // ---------------------------------------------------------------------------
  2421 // ---------------------------------------------------------------------------
  2420 // CNSmlContactsDataStore::ContactRemovedFromView
  2422 // CNSmlContactsDataStore::ContactRemovedFromView
  2421 // Implements the remove contact function of MVPbkContactViewObserver
  2423 // Implements the remove contact function of MVPbkContactViewObserver
  2422 // --------------------------------------------------------------------------- 
  2424 // --------------------------------------------------------------------------- 
  2423 void CNSmlContactsDataStore::ContactRemovedFromView(
  2425 EXPORT_C void CNSmlContactsDataStore::ContactRemovedFromView(
  2424                 MVPbkContactViewBase& /*aView*/, 
  2426                 MVPbkContactViewBase& /*aView*/, 
  2425                 TInt /*aIndex*/, 
  2427                 TInt /*aIndex*/, 
  2426                 const MVPbkContactLink& /*aContactLink*/ )  
  2428                 const MVPbkContactLink& /*aContactLink*/ )  
  2427 	{
  2429 	{
  2428 	}
  2430 	}
  2429 
  2431 
  2430 // ---------------------------------------------------------------------------
  2432 // ---------------------------------------------------------------------------
  2431 // CNSmlContactsDataStore::ContactViewError
  2433 // CNSmlContactsDataStore::ContactViewError
  2432 // Implements the view error function of MVPbkContactViewObserver
  2434 // Implements the view error function of MVPbkContactViewObserver
  2433 // --------------------------------------------------------------------------- 
  2435 // --------------------------------------------------------------------------- 
  2434 void CNSmlContactsDataStore::ContactViewError(
  2436 EXPORT_C void CNSmlContactsDataStore::ContactViewError(
  2435             MVPbkContactViewBase& /*aView*/, 
  2437             MVPbkContactViewBase& /*aView*/, 
  2436             TInt /*aError*/, 
  2438             TInt /*aError*/, 
  2437             TBool /*aErrorNotified*/ )  
  2439             TBool /*aErrorNotified*/ )  
  2438 	{
  2440 	{
  2439 
  2441 
  2441 
  2443 
  2442 // -----------------------------------------------------------------------------
  2444 // -----------------------------------------------------------------------------
  2443 // CNSmlContactsDataStore::CreateViewL()
  2445 // CNSmlContactsDataStore::CreateViewL()
  2444 // Create a contact view 
  2446 // Create a contact view 
  2445 // -----------------------------------------------------------------------------
  2447 // -----------------------------------------------------------------------------
  2446  
  2448 EXPORT_C void CNSmlContactsDataStore::CreateViewL()
  2447 void CNSmlContactsDataStore::CreateViewL()
       
  2448 	{
  2449 	{
  2449 	
  2450 	
  2450 	CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL();
  2451 	CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL();
  2451 	CleanupStack::PushL( viewDef );
  2452 	CleanupStack::PushL( viewDef );
  2452 	viewDef->SetType( EVPbkContactsView );
  2453 	viewDef->SetType( EVPbkContactsView );
  2457 				                         *this, 
  2458 				                         *this, 
  2458 				                         *viewDef, 
  2459 				                         *viewDef, 
  2459 				                         iContactManager->FieldTypes()  );
  2460 				                         iContactManager->FieldTypes()  );
  2460 	CleanupStack::Pop();
  2461 	CleanupStack::Pop();
  2461 	CleanupStack::PopAndDestroy(viewDef);	
  2462 	CleanupStack::PopAndDestroy(viewDef);	
  2462 	
  2463 	}
  2463 	}
  2464 
       
  2465 // ------------------------------------------------------------------------------------------------
       
  2466 // CNSmlContactsDataStore::GetStoreFormatResourceFileL
       
  2467 // ------------------------------------------------------------------------------------------------
       
  2468 EXPORT_C const TDesC& CNSmlContactsDataStore::GetStoreFormatResourceFileL()
       
  2469     {
       
  2470     _DBG_FILE("CNSmlContactsDataStore::GetStoreFormatResourceFileL(): begin");
       
  2471     
       
  2472     // Check correct Data Sync protocol
       
  2473     TInt value( EDataSyncNotRunning );
       
  2474     TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
       
  2475         KDataSyncStatus, value );
       
  2476     if ( error == KErrNone &&
       
  2477          value == EDataSyncRunning )
       
  2478         {
       
  2479         return KNSmlContactsStoreFormatRsc_1_1_2;
       
  2480         }
       
  2481     else // error or protocol version 1.2 
       
  2482         {
       
  2483         return KNSmlContactsStoreFormatRsc_1_2;
       
  2484         }
       
  2485     _DBG_FILE("CNSmlContactsDataStore::GetStoreFormatResourceFileL(): end");
       
  2486     }
       
  2487 
       
  2488 // ------------------------------------------------------------------------------------------------
       
  2489 // CNSmlContactsDataStore::CreateModsFetcherL
       
  2490 // ------------------------------------------------------------------------------------------------
       
  2491 EXPORT_C MContactsModsFetcher* CNSmlContactsDataStore::CreateModsFetcherL()
       
  2492     {
       
  2493     _DBG_FILE("CNSmlContactsDataStore::CreateModsFetcherL(): begin");
       
  2494     CNSmlContactsModsFetcher* modsFetcher = 
       
  2495         new ( ELeave ) CNSmlContactsModsFetcher( iSnapshotRegistered, 
       
  2496         *iContactManager,*iStore, iKey, *iChangeFinder );
       
  2497     CleanupStack::PushL( modsFetcher );
       
  2498     modsFetcher->ConstructL();
       
  2499     CleanupStack::Pop( modsFetcher );
       
  2500     _DBG_FILE("CNSmlContactsDataStore::CreateModsFetcherL(): end");
       
  2501     return modsFetcher;
       
  2502     }
       
  2503 
       
  2504 // ------------------------------------------------------------------------------------------------
       
  2505 // CNSmlContactsDataStore::GetDataMod
       
  2506 // ------------------------------------------------------------------------------------------------
       
  2507 EXPORT_C CNSmlDataModBase& CNSmlContactsDataStore::GetDataMod()
       
  2508     {
       
  2509     _DBG_FILE("CNSmlContactsDataStore::GetDataMod()");
       
  2510     return *iDataMod;
       
  2511     }
  2464 
  2512 
  2465 // End of File  
  2513 // End of File