sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "UT_STD.H" sl@0: sl@0: // Class CDbRecordBase sl@0: sl@0: EXPORT_C TBool CDbRecordBase::DoRestoreL() sl@0: // sl@0: // If we haven't been opened, then try to restore the state sl@0: // sl@0: { sl@0: TBool broken=RestoreL(); sl@0: iFlags|=broken ? EBroken : EOpen; sl@0: return broken; sl@0: } sl@0: sl@0: EXPORT_C void CDbRecordBase::TouchL() sl@0: // sl@0: // if we are not modified then mark sl@0: // Can touch a broken object, will not invoke AboutToModifyL() sl@0: // sl@0: { sl@0: __ASSERT(iFlags&(EOpen|EBroken)); sl@0: if (!(iFlags&EModified)) sl@0: { sl@0: if (!(iFlags&EBroken)) sl@0: AboutToModifyL(); sl@0: iFlags|=EModified; sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void CDbRecordBase::FlushL() sl@0: // sl@0: // If we are open, modified and not broken then flush sl@0: // Must allow un-opened Flush during framework cleanup on failed open sl@0: // sl@0: { sl@0: if (iFlags==(EOpen|EModified)) sl@0: { sl@0: SynchL(); sl@0: iFlags&=~EModified; sl@0: } sl@0: } sl@0: sl@0: void CDbRecordBase::DoAbandon(CDbRecordBase* aRec) sl@0: { sl@0: aRec->Abandon(); sl@0: } sl@0: sl@0: void CDbRecordBase::DoFlushL(CDbRecordBase* aRec) sl@0: { sl@0: aRec->FlushL(); sl@0: } sl@0: sl@0: void CDbRecordBase::DoDelete(CDbRecordBase* aRec) sl@0: { sl@0: delete aRec; sl@0: } sl@0: sl@0: EXPORT_C TBool CDbRecordBase::RestoreL() sl@0: // sl@0: // default to do nothing sl@0: // sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: EXPORT_C void CDbRecordBase::AboutToModifyL() sl@0: // sl@0: // default to do nothing sl@0: // sl@0: {} sl@0: sl@0: EXPORT_C void CDbRecordBase::SynchL() sl@0: // sl@0: // default to do nothing sl@0: // sl@0: {} sl@0: sl@0: sl@0: // Class CDbRecordIter sl@0: sl@0: EXPORT_C CDbRecordIter::CDbRecordIter(CDbRecordBase& aHost) sl@0: :iHost(aHost) sl@0: {} sl@0: sl@0: EXPORT_C CDbRecordIter::~CDbRecordIter() sl@0: {} sl@0: sl@0: sl@0: // Class CDbRecordSpace sl@0: sl@0: TUint8* CDbRecordSpace::ReplaceL(TDbRecordId aRecordId,TInt aRecordSize) sl@0: { sl@0: __ASSERT(!IsBroken()); sl@0: TouchL(); sl@0: return DoReplaceL(aRecordId,aRecordSize); sl@0: } sl@0: sl@0: TUint8* CDbRecordSpace::NewL(TInt aRecordSize) sl@0: { sl@0: __ASSERT(!IsBroken()); sl@0: TouchL(); sl@0: return DoNewL(aRecordSize); sl@0: } sl@0: sl@0: void CDbRecordSpace::EraseL(TDbRecordId aRecordId) sl@0: { sl@0: __ASSERT(!IsBroken()); sl@0: TouchL(); sl@0: DoEraseL(aRecordId); sl@0: } sl@0: sl@0: // Class CDbBlobSpace sl@0: sl@0: EXPORT_C MStreamBuf* CDbBlobSpace::ReadLC(TDbBlobId aBlobId,TDbColType aType) const sl@0: { sl@0: MStreamBuf* buf=ReadL(aBlobId,aType); sl@0: buf->PushL(); sl@0: return buf; sl@0: } sl@0: sl@0: EXPORT_C MStreamBuf* CDbBlobSpace::CreateL(TDbBlobId &aBlobId,TDbColType aType) sl@0: { sl@0: __ASSERT(!IsBroken()); sl@0: TouchL(); sl@0: return DoCreateL(aBlobId,aType); sl@0: } sl@0: sl@0: EXPORT_C TDbBlobId CDbBlobSpace::CreateL(TDbColType aType,const TAny* aData,TInt aLength) sl@0: // sl@0: // Create a blob containing the data buffer sl@0: // sl@0: { sl@0: TDbBlobId id; sl@0: MStreamBuf* buf=CreateL(id,aType); sl@0: buf->PushL(); sl@0: buf->WriteL(aData,aLength); sl@0: buf->SynchL(); sl@0: CleanupStack::PopAndDestroy(); sl@0: return id; sl@0: } sl@0: sl@0: EXPORT_C void CDbBlobSpace::DeleteL(TDbBlobId aBlobId) sl@0: { sl@0: if (aBlobId!=KDbNullBlobId) sl@0: { sl@0: __ASSERT(!IsBroken()); sl@0: TouchL(); sl@0: DoDeleteL(aBlobId); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C TInt CDbBlobSpace::Delete(TDbBlobId aBlobId) sl@0: { sl@0: TRAPD(r,DeleteL(aBlobId)); sl@0: return r; sl@0: } sl@0: sl@0: // Class CDbRecordIndex sl@0: sl@0: TBool CDbRecordIndex::InsertL(TDbRecordId aRecordId,const RDbTableRow& aRow) sl@0: { sl@0: __ASSERT(!IsBroken()); sl@0: TouchL(); sl@0: return DoInsertL(aRecordId,aRow); sl@0: } sl@0: sl@0: void CDbRecordIndex::DeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow) sl@0: { sl@0: __ASSERT(!IsBroken()); sl@0: TouchL(); sl@0: DoDeleteL(aRecordId,aRow); sl@0: }