messagingfw/msgsrvnstore/server/src/msvindexadapter.cpp
changeset 40 320ec5cd0227
parent 22 bde600d88860
child 47 d176b53f330f
equal deleted inserted replaced
33:61f466445ae5 40:320ec5cd0227
     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();
   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 
  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.