messagingfw/msgsrvnstore/server/src/msvindexadapter.cpp
branchRCL_3
changeset 22 d2c4c66342f3
parent 12 8147bfb6c710
child 23 d51193d814ea
equal deleted inserted replaced
21:e5b3a2155e1a 22:d2c4c66342f3
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   107         {
   107         {
   108         folderNode->iDlink.Deque();
   108         folderNode->iDlink.Deque();
   109         delete folderNode;
   109         delete folderNode;
   110         }
   110         }
   111     
   111     
   112     iFreePoolInstance->ReleaseEntry(iRootEntry);
   112     iFreePoolInstance->ReleaseEntryL(iRootEntry);
   113     iRootEntry = NULL;
   113     iRootEntry = NULL;
   114 
   114 
   115     // 3. Delete internal data structure.
   115     // 3. Delete internal data structure.
   116     iNonCommittedAddedEntryList.ResetAndDestroy();
   116     iNonCommittedAddedEntryList.ResetAndDestroy();
   117     iNonCommittedChangedEntryList.Reset();
   117     iNonCommittedChangedEntryList.Reset();
   430 
   430 
   431 #ifndef _NO_SERVER_LOGGING_
   431 #ifndef _NO_SERVER_LOGGING_
   432 	iServer.Log(_L("Cache initialized succesfully."));
   432 	iServer.Log(_L("Cache initialized succesfully."));
   433 #endif
   433 #endif
   434 
   434 
   435 	TMsvId tmpNextId = NULL;
   435 	TMsvId tmpNextId = 0;
   436 	iDbAdapter->GetMaxTMsvIdL(tmpNextId);
   436 	iDbAdapter->GetMaxTMsvIdL(tmpNextId);
   437 	iNextCreateId = (tmpNextId >= KFirstFreeEntryId)? (tmpNextId+1) : KFirstFreeEntryId;
   437 	iNextCreateId = (tmpNextId >= KFirstFreeEntryId)? (tmpNextId+1) : KFirstFreeEntryId;
   438 	
   438 	
   439 	iIdle = CIdle::NewL(CActive::EPriorityIdle);
   439 	iIdle = CIdle::NewL(CActive::EPriorityIdle);
   440 	CompleteSelf();
   440 	CompleteSelf();
   974 	CMsvCacheEntry* entry = NULL;
   974 	CMsvCacheEntry* entry = NULL;
   975 	TBool releaseEntry = FindEntryL(aSelection.At(0), entry, EFalse);
   975 	TBool releaseEntry = FindEntryL(aSelection.At(0), entry, EFalse);
   976 	TMsvId parentId = entry->Entry().Parent();
   976 	TMsvId parentId = entry->Entry().Parent();
   977 	if(releaseEntry)
   977 	if(releaseEntry)
   978 		{
   978 		{
   979 		iFreePoolInstance->ReleaseEntry(entry, ETrue);
   979 		iFreePoolInstance->ReleaseEntryL(entry, ETrue);
   980 		}
   980 		}
   981 	CMsvEntrySelection* children = new(ELeave)CMsvEntrySelection;
   981 	CMsvEntrySelection* children = new(ELeave)CMsvEntrySelection;
   982 	CleanupStack::PushL(children);
   982 	CleanupStack::PushL(children);
   983 	
   983 	
   984 	for (TInt index=0; index<count; ++index)
   984 	for (TInt index=0; index<count; ++index)
  1049 			}
  1049 			}
  1050 		);
  1050 		);
  1051 	// Release the entry, since it is not added to cache.
  1051 	// Release the entry, since it is not added to cache.
  1052 	if(releaseEntry)
  1052 	if(releaseEntry)
  1053 		{
  1053 		{
  1054 		iFreePoolInstance->ReleaseEntry(entry, ETrue);
  1054 		iFreePoolInstance->ReleaseEntryL(entry, ETrue);
  1055 		}
  1055 		}
  1056 	User::LeaveIfError(err);
  1056 	User::LeaveIfError(err);
  1057 	CleanupStack::PopAndDestroy(); //children
  1057 	CleanupStack::PopAndDestroy(); //children
  1058 	}
  1058 	}
  1059 
  1059 
  1421         iFreePoolInstance->ReleaseEntryWithoutTransaction(bkpEntry);
  1421         iFreePoolInstance->ReleaseEntryWithoutTransaction(bkpEntry);
  1422         if(newVisibleFolderNode)
  1422         if(newVisibleFolderNode)
  1423             newVisibleFolderNode->DeleteEntryL(oldEntry->GetId());
  1423             newVisibleFolderNode->DeleteEntryL(oldEntry->GetId());
  1424         User::Leave(err);
  1424         User::Leave(err);
  1425         }
  1425         }
  1426     UpdateDates(*oldEntry, EFalse);
  1426  
  1427     
  1427 	UpdateDates(*oldEntry, EFalse);
  1428     if(aForcedUpdate || changedPrivateInfo && aOwnerId != KMsvServerId )
  1428 	if(aForcedUpdate || changedPrivateInfo && aOwnerId != KMsvServerId )
  1429         {
  1429         {
  1430         oldEntry->SetEntryOwnerId(aOwnerId);
  1430         oldEntry->SetEntryOwnerId(aOwnerId);
  1431         }
  1431         }
  1432 
  1432 
  1433     TRAP(err, 
  1433     TRAP(err, 
  1485                                                  bkpEntry,
  1485                                                  bkpEntry,
  1486                                                  oldParentEntry, 
  1486                                                  oldParentEntry, 
  1487                                                  newParentEntry,
  1487                                                  newParentEntry,
  1488                                                  descendentList,
  1488                                                  descendentList,
  1489                                                  resetOldParentOwnerFlag);
  1489                                                  resetOldParentOwnerFlag);
  1490         iNonCommittedChangedEntryList.Append(entryDetails);
  1490         iNonCommittedChangedEntryList.AppendL(entryDetails);
  1491         if(descendentList)
  1491         if(descendentList)
  1492             CleanupStack::Pop(descendentList);
  1492             CleanupStack::Pop(descendentList);
  1493         }
  1493         }
  1494 
  1494 
  1495     // Update entry in SearchSort delta cache.
  1495     // Update entry in SearchSort delta cache.
  1670 		// If entry is not present in cache,
  1670 		// If entry is not present in cache,
  1671 		// it should be handled carefully.
  1671 		// it should be handled carefully.
  1672 		if(aIsDanglingEntry)
  1672 		if(aIsDanglingEntry)
  1673 			{
  1673 			{
  1674 			// Release CMsvCacheEntry to freepool.
  1674 			// Release CMsvCacheEntry to freepool.
  1675 			iFreePoolInstance->ReleaseEntry(serverEntry, ETrue);
  1675 			iFreePoolInstance->ReleaseEntryL(serverEntry, ETrue);
  1676 			}		
  1676 			}		
  1677 		return KErrNone;	
  1677 		return KErrNone;	
  1678 		}
  1678 		}
  1679 	else
  1679 	else
  1680 		{
  1680 		{
  3668 	TRAPD(err, iDbAdapter->DeleteEntryL(aId));
  3668 	TRAPD(err, iDbAdapter->DeleteEntryL(aId));
  3669 	// If the entry does not exists in cache,
  3669 	// If the entry does not exists in cache,
  3670 	// we need to release the entry explicitly.
  3670 	// we need to release the entry explicitly.
  3671 	if(releaseEntry)
  3671 	if(releaseEntry)
  3672 		{
  3672 		{
  3673 		iFreePoolInstance->ReleaseEntry(entry, ETrue);
  3673 		iFreePoolInstance->ReleaseEntryL(entry, ETrue);
  3674 		User::LeaveIfError(err);
  3674 		User::LeaveIfError(err);
  3675 		}
  3675 		}
  3676 	else
  3676 	else
  3677 		{
  3677 		{
  3678 		User::LeaveIfError(err);
  3678 		User::LeaveIfError(err);
  3701 			entry->Entry().SetOwner(EFalse);
  3701 			entry->Entry().SetOwner(EFalse);
  3702 			}
  3702 			}
  3703 		);
  3703 		);
  3704 	if(releaseEntry)
  3704 	if(releaseEntry)
  3705 		{
  3705 		{
  3706 		iFreePoolInstance->ReleaseEntry(entry, ETrue);
  3706 		iFreePoolInstance->ReleaseEntryL(entry, ETrue);
  3707 		}
  3707 		}
  3708 	User::LeaveIfError(err);
  3708 	User::LeaveIfError(err);
  3709 	CleanupStack::PopAndDestroy(); //children
  3709 	CleanupStack::PopAndDestroy(); //children
  3710 	}
  3710 	}
  3711 
  3711 
  3755     CMsvCacheEntry* entry = NULL;
  3755     CMsvCacheEntry* entry = NULL;
  3756     TBool releaseEntry = FindEntryL(aSelection.At(0), entry, EFalse);
  3756     TBool releaseEntry = FindEntryL(aSelection.At(0), entry, EFalse);
  3757     TMsvId parentId = entry->Entry().Parent();
  3757     TMsvId parentId = entry->Entry().Parent();
  3758     if(releaseEntry)
  3758     if(releaseEntry)
  3759         {
  3759         {
  3760         iFreePoolInstance->ReleaseEntry(entry, ETrue);
  3760         iFreePoolInstance->ReleaseEntryL(entry, ETrue);
  3761         }
  3761         }
  3762 
  3762 
  3763     // Find the parent in the cache - we may need to update its owner status flag both in cache and DB.
  3763     // Find the parent in the cache - we may need to update its owner status flag both in cache and DB.
  3764     TBool updateTheParent = ETrue;
  3764     TBool updateTheParent = ETrue;
  3765     TRAPD(err, releaseEntry = FindEntryL(parentId, entry, EFalse)); // can't let it leave - need to delete the child in any case.
  3765     TRAPD(err, releaseEntry = FindEntryL(parentId, entry, EFalse)); // can't let it leave - need to delete the child in any case.
  3766     if(err == KErrNotFound)
  3766     if(err == KErrNotFound)
  3767         {
  3767         {
  3768         updateTheParent = EFalse;
  3768         updateTheParent = EFalse;
  3769         if(releaseEntry)
  3769         if(releaseEntry)
  3770             {
  3770             {
  3771             iFreePoolInstance->ReleaseEntry(entry, ETrue);
  3771             iFreePoolInstance->ReleaseEntryL(entry, ETrue);
  3772             }
  3772             }
  3773         }
  3773         }
  3774     else
  3774     else
  3775         {
  3775         {
  3776         // Get parent's children.
  3776         // Get parent's children.