sl@0: // Copyright (c) 2002-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 "LOGDEL.H" sl@0: #include "LOGQUERY.H" sl@0: #include "logservpanic.h" sl@0: #include "LogServDatabaseTransactionInterface.h" sl@0: #include "LogServResourceInterpreter.h" sl@0: #include "LogServCacheTypes.h" sl@0: #include "LogServDatabaseChangeInterface.h" sl@0: #include "LogServSqlStrings.h" sl@0: sl@0: CLogDeleteEvent::CLogDeleteEvent(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority) sl@0: : CLogActive(aPriority), iDatabase(aDatabase) sl@0: { sl@0: } sl@0: sl@0: CLogDeleteEvent::~CLogDeleteEvent() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: CLogDeleteEvent* CLogDeleteEvent::NewL(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority) sl@0: { sl@0: return new (ELeave) CLogDeleteEvent(aDatabase, aPriority); sl@0: } sl@0: sl@0: sl@0: void CLogDeleteEvent::StartL(TLogId aId, TRequestStatus& aStatus, const RMessage2& aMessage) sl@0: { sl@0: __ASSERT_DEBUG(!IsActive(), Panic(ELogAlreadyActive6)); sl@0: sl@0: iMessage = const_cast(&aMessage); // how to avoid this cast? sl@0: iId = aId; sl@0: sl@0: Queue(aStatus); sl@0: TRequestStatus* status = &iStatus; sl@0: User::RequestComplete(status, KErrNone); sl@0: SetActive(); sl@0: } sl@0: sl@0: void CLogDeleteEvent::DoRunL() sl@0: { sl@0: RLogEventDbTable tbl; sl@0: tbl.OpenLC(iDatabase.DTIDatabase()); sl@0: User::LeaveIfError(tbl.SetIndex(KLogNameEventIdx1)); sl@0: //Find event sl@0: if(!tbl.SeekL(TDbSeekKey((TInt)iId))) sl@0: { sl@0: iMessage->Complete(KErrNotFound); sl@0: DoCancel(); sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: tbl.GetL(); sl@0: //Platsec check sl@0: TLogTypeId logTypeId = tbl.ColUint8(RLogEventDbTable::iTypeColNo); sl@0: const TLogServCacheTypeEntry& entry = iDatabase.DTICacheTypes().FindById(logTypeId); sl@0: __ASSERT_DEBUG(entry.iEventTypeId != KLogNullTypeId, Panic(ELogNoEventTypeAtId)); sl@0: if(!iDatabase.DTIIsAllowed(EWriteOp, *iMessage, entry.iEventType->Uid())) sl@0: { sl@0: User::Leave(KErrPermissionDenied); sl@0: } sl@0: User::LeaveIfError(iDatabase.DTIBegin()); sl@0: //Process duplicates sl@0: ::LogResetDuplicatesL(iDatabase, iId); sl@0: //Delete the event sl@0: tbl.DeleteL(); sl@0: iDatabase.DTIChangeInterface().DCISubmitChangedEventContextL(ELogChangeTypeEventDeleted, iId); sl@0: // sl@0: CleanupStack::PopAndDestroy(&tbl); sl@0: } sl@0: sl@0: sl@0: void CLogDeleteEvent::DoCancel() sl@0: { sl@0: CLogActive::DoCancel(); sl@0: } sl@0: sl@0: void CLogDeleteEvent::DoComplete(TInt& aStatus) sl@0: { sl@0: // Attempt to commit the transaction sl@0: if (iDatabase.DTIInTransaction()) sl@0: { sl@0: if (aStatus == KErrNone) sl@0: aStatus = iDatabase.DTICommitAndEnd(); sl@0: sl@0: if (aStatus < KErrNone) sl@0: iDatabase.DTIRollBack(); sl@0: } sl@0: }