messagingfw/msgsrvnstore/server/inc/msvindexadapter.h
changeset 22 bde600d88860
parent 0 8e480a14352b
equal deleted inserted replaced
21:08008ce8a6df 22:bde600d88860
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __MSVINDEXADAPTER_H__
       
    17 #define __MSVINDEXADAPTER_H__
       
    18 
       
    19 
       
    20 /**
       
    21  * HEADER FILES
       
    22  */
       
    23 #include <e32def.h>
       
    24 #include <e32base.h>
       
    25 #include <msvuids.h>
       
    26 #include <msvipc.h>
       
    27 #include "msvdbadapter.h"
       
    28 #include "msvcachevisiblefolder.h"
       
    29 
       
    30 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
    31 	#include "msvpreferreddrivelist.h"	
       
    32 #endif    // #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
    33 
       
    34 
       
    35 /**
       
    36  * FORWARD DECLARATION
       
    37  */
       
    38 class CMsvEntryArray;
       
    39 class CMsvServer;
       
    40 class CMsvCacheEntry;
       
    41 class CMsvCacheVisibleFolder;
       
    42 class CMsvEntryFreePool;
       
    43 class CMsvSearchSortDeltaCache;
       
    44 
       
    45 
       
    46 
       
    47 /**
       
    48  * Class: CMsvIndexAdapter
       
    49  * 
       
    50  * The class encapsulates DB adapter class (which queries the database
       
    51  * for index entries) and cache (which stores recently accessed entry in
       
    52  * memory). The class also manages the data structure for cache and also 
       
    53  * works as background active object to perform low-priority job required
       
    54  * for cache management. 
       
    55  */
       
    56 
       
    57 /**
       
    58 @internalComponent
       
    59 @released
       
    60 */
       
    61 NONSHARABLE_CLASS (CMsvIndexAdapter) : public CActive
       
    62 	{
       
    63 // Interfaces
       
    64 public:
       
    65 	class TMsvServerEntryInfo
       
    66 		{
       
    67 	public:
       
    68 		TMsvServerEntryInfo();
       
    69 		void Reset();
       
    70 	public:
       
    71 		TMsvId			iId;				// Masked TMsvId in PREQ 557.
       
    72 		TMsvId			iTopFolder;			// Masked TMsvId in PREQ 557.
       
    73 		TMsvId			iService;			// Unmasked TMsvId in PREQ 557.
       
    74 		TUid			iMtm;
       
    75 		TUid			iType;
       
    76 		TUid			iServiceMtm;
       
    77 		TSecureId		iEntryOwnerId;
       
    78 		TSecureId		iParentOwnerId;
       
    79 		TBool			iPartOfMessage;
       
    80 		};
       
    81 	class CNonCommittedAddedEntries
       
    82 		{
       
    83 	public:	
       
    84 		CNonCommittedAddedEntries(TMsvId aId, CMsvCacheEntry *aEntry):iVisibleFolder(aId),entry(aEntry)  {}
       
    85 		TMsvId iVisibleFolder;
       
    86 		CMsvCacheEntry *entry;
       
    87 		};
       
    88 	class TNonCommittedChangedEntries
       
    89 		{
       
    90 		public:	
       
    91             TNonCommittedChangedEntries(CMsvCacheVisibleFolder *aOldFolderNode, CMsvCacheVisibleFolder* aNewFolderNode, 
       
    92                                         CMsvCacheEntry *aEntry, CMsvCacheEntry* aBkpEntry, 
       
    93                                         CMsvCacheEntry *aOldParentEntry, CMsvCacheEntry* aNewParentEntry, 
       
    94                                         CMsvEntrySelection* aDescendentList, TBool aResetOldParentOwnerFlag)
       
    95 				:iOldVisibleFolderNode(aOldFolderNode),iNewVisibleFolderNode(aNewFolderNode), iEntry(aEntry), 
       
    96 				 iBkpEntry(aBkpEntry), iOldParentEntry(aOldParentEntry), iNewParentEntry(aNewParentEntry),
       
    97 				 iDescendentList(aDescendentList), iResetOldParentOwnerFlag(aResetOldParentOwnerFlag)  {}
       
    98 			CMsvCacheVisibleFolder *iOldVisibleFolderNode;
       
    99 			CMsvCacheVisibleFolder *iNewVisibleFolderNode;
       
   100 			CMsvCacheEntry *iEntry;
       
   101 			CMsvCacheEntry *iBkpEntry;
       
   102 			CMsvCacheEntry *iOldParentEntry;
       
   103 			CMsvCacheEntry *iNewParentEntry;
       
   104 			CMsvEntrySelection* iDescendentList;
       
   105 			TBool iResetOldParentOwnerFlag;
       
   106 		};
       
   107 public:		
       
   108 
       
   109 	// New API added in PREQ 557.
       
   110 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   111 	static CMsvIndexAdapter* NewL(CMsvServer& aServer);
       
   112 	void GetChildrenAllL(TMsvId aId, CArrayPtr<const TMsvEntry>& aSelection, const TMsvSelectionOrdering& aOrdering, TUid aMtm, TBool aFilterByOwnerId, TSecureId aOwnerId);
       
   113 	TInt GetChildrenIdAll(TMsvId aId, const CMsvEntryFilter& aFilter, CMsvEntrySelection& aSelection);	
       
   114 	TInt GetChildrenIdAll(TMsvId aId, const CMsvEntryFilter& aFilter, CMsvEntrySelection& aSelection, TBool aFilterByOwnerId, TSecureId aOwnerId);
       
   115 	void RemoveDriveL(TUint aDriveId, TUint aDriveIndex, TBool aIsStdFolderVisible = ETrue);
       
   116 	void GetInPreparationIds(CMsvEntrySelection& aSelection, TUint aDriveId = 0 /* All Drives */);
       
   117 	void AddDriveL(TUint aDrivePriority);
       
   118 	void ChangeDriveL(TUint aNewDriveIndex, TBool aIsStdFolderVisible = ETrue);	
       
   119 	inline TMsvId NextId(TUint aDriveId);
       
   120 	void ReloadCacheL();
       
   121 #else
       
   122 	// Functions to create class instance
       
   123 	static CMsvIndexAdapter* NewL(CMsvServer& aServer, const TFileName& aFileName);
       
   124 	static CMsvIndexAdapter* OpenL(CMsvServer& aServer, const TFileName& aFileName);	
       
   125 	inline TMsvId NextId();
       
   126 	void GetInPreparationIds(CMsvEntrySelection& aSelection);
       
   127 	inline void OpenclosedL(const TFileName& aDbFileName);
       
   128 #endif		// #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   129 
       
   130 	~CMsvIndexAdapter();
       
   131 	void SetLocalServiceComplete();
       
   132 	TInt AddEntry(TMsvEntry& aEntry, TSecureId aOwnerId, TBool aAutoAssignId);
       
   133 	TInt AddEntryToCommitListL(TMsvEntry& aEntry, TSecureId aOwnerId, TBool aAutoAssignId);
       
   134 	TInt AddEntryNoCommit(TMsvEntry& aEntry, TSecureId aOwnerId, TBool aAutoAssignId);
       
   135 	
       
   136 	TInt DeleteEntry(TMsvId aId);
       
   137 	TInt DeleteSelection(const CMsvEntrySelection& aSelection);
       
   138 	TInt ExpandSelectionRecursively(CMsvEntrySelection& aSelection);
       
   139 	
       
   140 	TInt ChangeEntry(const TMsvEntry& aEntry, TSecureId aOwnerId, TBool aForcedUpdate);
       
   141 	TInt ChangeEntryNoCommit(const TMsvEntry& aEntry, TSecureId aOwnerId, TBool aForcedUpdate);
       
   142 	TInt ChangeEntryInternal(const TMsvEntry& aEntry, TSecureId aOwnerId);
       
   143 	TInt GetEntry(TMsvId aId, TMsvEntry*& aEntry);
       
   144 	TInt GetEntry(TMsvId aId, TMsvEntry*& aEntry, TSecureId& aOwnerId);
       
   145 	TInt GetEntryNoCache(TMsvId aId, TMsvEntry* aEntry);
       
   146 	
       
   147 	void GetChildrenL(TMsvId aId, CArrayPtr<const TMsvEntry>& aSelection, const TMsvSelectionOrdering& aOrdering, TUid aMtm=KUidMsvNullEntry);
       
   148 	TInt GetChildrenId(TMsvId aId, const CMsvEntryFilter& aFilter, CMsvEntrySelection& aSelection);
       
   149 	void GetChildrenL(TMsvId aId, CArrayPtr<const TMsvEntry>& aSelection, const TMsvSelectionOrdering& aOrdering, TUid aMtm, TBool aFilterByOwnerId, TSecureId aOwnerId);
       
   150 	TInt GetChildrenId(TMsvId aId, const CMsvEntryFilter& aFilter, CMsvEntrySelection& aSelection, TBool aFilterByOwnerId, TSecureId aOwnerId);
       
   151 
       
   152 	TInt LockEntry(TMsvId aId);
       
   153 	TInt ReleaseEntry(TMsvId aId);
       
   154 	TInt IsEntryLocked(TMsvId aId, TBool& aLocked);
       
   155 	TInt LockStore(TMsvId aId);
       
   156 	TInt ReleaseStore(TMsvId aId);
       
   157 	TInt IsStoreLocked(TMsvId aId, TBool& aLocked);
       
   158 	TInt LockEntryAndStore(TMsvId aId);
       
   159 	TInt ReleaseEntryAndStore(TMsvId aId);
       
   160 	TInt IsEntryOrStoreLocked(TMsvId aId, TBool& aLocked);
       
   161 	TInt IsStoreReadingLocked(TMsvId aId, TBool& aLocked);
       
   162 	TInt IncStoreReaderCount(TMsvId aId);
       
   163 	TInt DecStoreReaderCount(TMsvId aId);
       
   164 	TInt OwningService(TMsvId aId, TMsvId& aService);
       
   165 	TInt IsLocal(TMsvId aId, TBool& aLocal);
       
   166 	TInt MoveEntry(TMsvId aId, TMsvId aTarget, CMsvEntrySelection* aDescendents = NULL);
       
   167 	TInt IsADescendent(TMsvId aAscendentId, TMsvId aDescendentId, TBool& aDescendent);
       
   168 	TBool EntryExists(TMsvId aId);
       
   169 	TInt ChangeTemporaryData(const TMsvEntry& aNewEntryContents);
       
   170 	TInt ChangeAttributes(CMsvEntrySelection& aSelection, TUint aSetAttributes, TUint aClearAttributes);
       
   171 	inline void SetNextId(TMsvId aSeedId);
       
   172 	inline void SetErrorState(TInt aError);
       
   173 	inline TInt ErrorState();
       
   174 	inline void DeleteDbAdapter();
       
   175 	TMsvIndexProgress& Progress();
       
   176 	TInt EntryTreeInfo(TMsvId aId, TMsvServerEntryInfo& aEntryInfo);
       
   177 	void CommitNonCommitedEntries();
       
   178 	TInt GetInternalEntry(TMsvId aId, CMsvCacheEntry*& aEntry) ;
       
   179 	TBool GetNextSiblingL(TMsvId aId,TMsvId aParentId,TMsvId& aNextSiblingId);
       
   180 	TBool GetFirstChildIdL(TMsvId aParentId,TMsvId& aFirstChild);	
       
   181 	void UpdateDBWithCommitListL();	
       
   182 	TBool IsEntryOrStoreLocked(TMsvId aId);
       
   183 	void AddEntryNoVisibleL(CMsvCacheEntry* aEntry);
       
   184 	TInt DeleteSelectionUsingTransaction(const CMsvEntrySelection& aSelection);
       
   185 	TInt ForceDeleteEntry(TMsvId aId);
       
   186 	void BeginTransaction();
       
   187 	void CommitTransaction();
       
   188 	CMsvDBAdapter* GetDbAdapter();
       
   189 	void BackupDbAdpter();
       
   190 	void RestoreDbAdpter();
       
   191 	
       
   192 #ifdef SYMBIAN_MESSAGESTORE_UNIT_TESTCODE
       
   193 	inline TDblQueIter<CMsvCacheVisibleFolder> GetVisibleFolderQueue();
       
   194 	void GetNonComittedAddedEntry(RPointerArray<CNonCommittedAddedEntries>*& a)	{a=&iNonCommittedAddedEntryList;}
       
   195 	RArray<TNonCommittedChangedEntries>& GetNonComittedChangedEntry()	{return iNonCommittedChangedEntryList;}
       
   196 #ifdef _DEBUG
       
   197 	void PrintL();
       
   198 #endif		// #ifdef _DEBUG
       
   199 #endif
       
   200 	
       
   201 private:
       
   202 	
       
   203 	// Constructors
       
   204 	CMsvIndexAdapter(CMsvServer& aServer);
       
   205 	void RunL();
       
   206 	void DoCancel();
       
   207 
       
   208 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   209 	void ConstructL();
       
   210 	TUint GetNextAvailableDriveId();
       
   211 #else
       
   212 	void ConstructNewL(const TFileName& aDbFileName);
       
   213 	void ConstructOpenL(const TFileName& aDbFileName);
       
   214 	void CreateInitialSetOfEntriesL();
       
   215 	void CreateInitialCacheL();
       
   216 #endif
       
   217 	
       
   218 	void GetChildrenIdL(TMsvId aId, CMsvEntrySelection& aSelection);
       
   219 	TBool NewAttributes(const TMsvEntry& aEntry, TInt32& aNewData, TInt32& aNewPcSyncCount, TUint aSetAttributes, TUint aClearAttributes, TBool& aPersistedFlagsChanged);
       
   220 	TBool FindEntryInCache(TMsvId aId, CMsvCacheEntry*& aEntry);
       
   221 	TBool FindEntryL(TMsvId aId, CMsvCacheEntry*& aEntry, TBool aAddEntryToCache = ETrue);
       
   222 	CMsvCacheVisibleFolder* AddEntryToCacheL(TMsvId aVisibleEntryId, CMsvCacheEntry* aEntry);
       
   223 	void DoAddEntryL(TMsvEntry& aEntry, TSecureId aOwnerId, TBool aAutoAssignId, TBool aCommitToDb = ETrue);
       
   224 	TBool GetVisibleFolderId(TMsvId aParentId, TMsvId& aVisibleFolderId);
       
   225 	CMsvEntryArray* DoGetChildrenL(TMsvId aId, const CMsvEntryFilter& aFilter, TBool aFilterByOwnerId, TSecureId aOwnerId);
       
   226 	void FilterChildrenListL(TMsvId aId, RPointerArray<CMsvCacheEntry> aChacheEntry, CMsvEntryArray& aEntryArray, const CMsvEntryFilter& aFilter, TBool aFilterByOwnerId, TSecureId aOwnerId);
       
   227 	void DoChangeAttributesL(CMsvEntrySelection& aSelection, TUint aSetAttributes, TUint aClearAttributes);
       
   228 	void DoChangeEntryL(const TMsvEntry& aNewEntryContents, TSecureId aOwnerId, TBool aChangeStandardFolder, TBool aForcedUpdate, TBool aCommitToFile);
       
   229 	void DoExpandSelectionRecursivelyL(TMsvId aId);
       
   230 	void DoDeleteSelectionL(const CMsvEntrySelection& aSelection);
       
   231 	void UpdateDates(CMsvCacheEntry& aEntry, TBool aSetCreatedDate);
       
   232 	void DoMoveEntryL(TMsvId aId, TMsvId aTarget, CMsvEntrySelection* aDescendents = NULL);
       
   233 	void RollbackAdditions();
       
   234 	void RollbackChanges();
       
   235 	void ShiftEntryFolderL(TMsvId aNewVisibleFolderId, CMsvCacheVisibleFolder* aOldFolderNode, CMsvCacheEntry* aNewEntry);
       
   236 	void UpdateEntryInCacheL(CMsvCacheVisibleFolder*, TMsvId, TMsvId, CMsvCacheEntry*);
       
   237 	CMsvCacheVisibleFolder* UpdateCacheForMoveEntryL(TMsvId aNewVisibleFolderId, CMsvCacheEntry*& aOrigEntry, CMsvCacheVisibleFolder* aOldVisibleFolderNode, CMsvEntrySelection* aDescendents, TBool& aIsChildEntriesNeedsUpdation);
       
   238 	CMsvCacheVisibleFolder* DoChangeEntryPreambleL(CMsvCacheEntry*& aOldEntry, TMsvId aNewParentId, CMsvCacheEntry*& aOldParentEntry, CMsvCacheEntry*& aNewParentEntry, TMsvId aOldVisibleFolderId, TBool& aResetOldParentOwnerFlag, CMsvEntrySelection*& aDescendentList);
       
   239 	void DoChangeEntryPostamble(CMsvCacheVisibleFolder* aOldFolderNode, TMsvId aNewVisibleFolderId, TMsvId aEntryId, CMsvEntrySelection* aDescendentList, CMsvCacheEntry* aNewParentEntry, CMsvCacheEntry* aOldParentEntry, TBool aResetOldParentOwnerFlag);
       
   240 	void GetVisibleFolderDetailsL(TMsvId aEntryId, CMsvCacheEntry*& aEntry, CMsvCacheVisibleFolder*& aVisibleFolder);
       
   241 
       
   242 	void DoDeleteSelectionUsingTransactionL(const CMsvEntrySelection& aSelection);
       
   243 	void DoForceDeleteEntryL(TMsvId aId);
       
   244 	
       
   245 	static TBool BackGroundOperations(TAny* aPtr);
       
   246 	TBool DoBackGroundOperations();
       
   247 	void DoBackGroundOperationsL(TBool& aStopBackgroundOperation);
       
   248 	TBool DoRemoveDeletedEntriesL();
       
   249 	TBool CheckAndAllocateMemoryL();
       
   250 	void SplitBlockL();
       
   251 	void CompleteSelf();
       
   252 	
       
   253 // Data
       
   254 private:
       
   255 	// Required for server logging and file handling.
       
   256 	CMsvServer& 					iServer;
       
   257 	
       
   258 	// Global Error for the class.
       
   259 	TInt 							iErrorState;
       
   260 
       
   261 	// Entry Cache
       
   262 	TDblQue<CMsvCacheVisibleFolder> iFolderListHeader;
       
   263 	
       
   264 	// Reference to freepool object.
       
   265 	CMsvEntryFreePool* 				iFreePoolInstance;
       
   266 	
       
   267 	// The database pointer for DB operation.
       
   268 	CMsvDBAdapter* 					iDbAdapter;
       
   269 	// It's just a temporary iDbAdapter pointer to handle backup/restore scenario's
       
   270 	CMsvDBAdapter* 					iTempDbAdapter;
       
   271 	
       
   272 	TInt 							iOrigEntryPos;
       
   273 	CMsvEntrySelection*				iRecursionSelection;
       
   274 	TInt 							iRecursionIndex;
       
   275 		
       
   276 	// List of newly added non committed entries.
       
   277 	RPointerArray<CNonCommittedAddedEntries> iNonCommittedAddedEntryList;
       
   278 	// List of newly changed non committed entries.
       
   279 	RArray<TNonCommittedChangedEntries> iNonCommittedChangedEntryList;
       
   280 	CIdle* 							iIdle;	
       
   281 	CMsvCacheEntry*					iRootEntry;
       
   282 	TMsvIndexProgress 				iProgress;
       
   283 	TInt 							iBackgroundOperationPerformed;
       
   284 	enum  {
       
   285 		   ENoOperation,
       
   286 		   ERemoveDeletedEntries,
       
   287 		   EAllocateMemoryOperation,
       
   288 		   ECheckBlockSize
       
   289 		   } iBackgroundOperationState;
       
   290 
       
   291 		   
       
   292 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   293 	TUint 							iFirstFreeDriveId;
       
   294 	RArray<TMsvId>					iMaxMsvIdList;
       
   295 	CMsvCacheVisibleFolder*			iRootNode;
       
   296 #else
       
   297 	// Next unused TMsvId. To be used while creating new entry.
       
   298 	TMsvId 							iNextCreateId;
       
   299 #endif
       
   300 
       
   301 	friend class CMsvSearchSortCacheEntry;
       
   302 #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
       
   303 	friend class CTestIndexAdapter;
       
   304 	friend class CTestIndexContext;
       
   305 #endif
       
   306 	};
       
   307 
       
   308 
       
   309 
       
   310 /**
       
   311  ***********  INLINE FUNCTIONS   ************
       
   312  */
       
   313  
       
   314  
       
   315 inline void CMsvIndexAdapter::SetErrorState(TInt aError)
       
   316 	{
       
   317 	iErrorState = aError;
       
   318 	}
       
   319 
       
   320 
       
   321 inline TInt CMsvIndexAdapter::ErrorState()
       
   322 	{
       
   323 	return iErrorState;
       
   324 	}
       
   325 
       
   326 
       
   327 inline CMsvDBAdapter* CMsvIndexAdapter::GetDbAdapter()
       
   328 	{
       
   329 	return iDbAdapter;
       
   330 	}
       
   331 
       
   332 inline void CMsvIndexAdapter::DeleteDbAdapter()
       
   333 	{
       
   334 	delete iDbAdapter;
       
   335 	iDbAdapter = NULL;
       
   336 	}
       
   337 
       
   338 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   339 // Code added for PREQ 557.
       
   340 inline TMsvId CMsvIndexAdapter::NextId(TUint aDriveId)
       
   341 	{
       
   342 	aDriveId = (aDriveId == 0)? KCurrentDriveId : aDriveId;
       
   343 	return iMaxMsvIdList[aDriveId]++;
       
   344 	}
       
   345 	
       
   346 
       
   347 inline TUint GetDriveId(TMsvId aMaskedId)
       
   348 	{
       
   349 	TUint driveId = ( (aMaskedId & ~KDriveMask) >> 28);
       
   350 	if(0 == driveId)
       
   351 		{
       
   352 		driveId = KCurrentDriveId;	
       
   353 		}
       
   354 	return driveId;
       
   355 	}
       
   356 	
       
   357 inline TMsvId UnmaskTMsvId(TMsvId aMaskedId)
       
   358 	{
       
   359 	return (aMaskedId & KDriveMask);
       
   360 	}
       
   361 
       
   362 inline TBool IsStandardId(TMsvId aId)
       
   363 	{
       
   364 	if(UnmaskTMsvId(aId) < KMsvUnkownServiceIndexEntryIdValue)
       
   365 		{
       
   366 		return ETrue;
       
   367 		}
       
   368 	return EFalse;
       
   369 	}
       
   370 
       
   371 inline TBool IsStandardFolder(TMsvId aId)
       
   372 	{
       
   373 	if(UnmaskTMsvId(aId) < KMsvUnkownServiceIndexEntryIdValue &&
       
   374 	   UnmaskTMsvId(aId) > KMsvLocalServiceIndexEntryIdValue )
       
   375 		{
       
   376 		return ETrue;
       
   377 		}
       
   378 	return EFalse;
       
   379 	}
       
   380 	
       
   381 inline TMsvId MaskTMsvId(TUint aDriveId, TMsvId aUnmaskedId)
       
   382 	{
       
   383 	__ASSERT_DEBUG(aDriveId <= 7, User::Invariant());
       
   384 	return (UnmaskTMsvId(aUnmaskedId) | (aDriveId << 28));
       
   385 	}
       
   386 
       
   387 
       
   388 // Wrap DB error and return KErrGeneral instead.
       
   389 inline void WrapDBErrorL(TInt err)
       
   390 	{	
       
   391 	// Do not return DB error.
       
   392 	if(err <= KSqlErrGeneral)
       
   393 		{
       
   394 		// If DB Error, return KErrGeneral.
       
   395 		User::LeaveIfError(KErrGeneral);
       
   396 		}
       
   397 	else
       
   398 		{
       
   399 		User::LeaveIfError(err);
       
   400 		}
       
   401 	}
       
   402 	
       
   403 inline void CMsvIndexAdapter::BackupDbAdpter()
       
   404 	{
       
   405 	iTempDbAdapter = iDbAdapter;
       
   406 	iDbAdapter = NULL;
       
   407 	}
       
   408 
       
   409 inline void CMsvIndexAdapter::RestoreDbAdpter()
       
   410 	{
       
   411 	iDbAdapter = iTempDbAdapter;
       
   412 	iTempDbAdapter = NULL;
       
   413 	}
       
   414 #else		// #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   415 
       
   416 inline TMsvId CMsvIndexAdapter::NextId()
       
   417 	{
       
   418 	return iNextCreateId++;
       
   419 	}
       
   420 	
       
   421 
       
   422 inline void CMsvIndexAdapter::OpenclosedL(const TFileName& aDbFileName)
       
   423 	{
       
   424 	iDbAdapter = CMsvDBAdapter::OpenL(aDbFileName);
       
   425 	}
       
   426 
       
   427 
       
   428 #endif     	// #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   429 
       
   430 
       
   431 
       
   432 #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
       
   433 inline TDblQueIter<CMsvCacheVisibleFolder> CMsvIndexAdapter::GetVisibleFolderQueue()
       
   434 	{
       
   435 	return iFolderListHeader;	
       
   436 	}	
       
   437 #endif		// #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
       
   438 
       
   439 
       
   440 #endif // __MSVINDEXADAPTER_H__