os/persistentdata/loggingservices/eventlogger/LogServ/src/LOGDEL.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-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 #include "LOGDEL.H"
    17 #include "LOGQUERY.H"
    18 #include "logservpanic.h"
    19 #include "LogServDatabaseTransactionInterface.h"
    20 #include "LogServResourceInterpreter.h"
    21 #include "LogServCacheTypes.h"
    22 #include "LogServDatabaseChangeInterface.h"
    23 #include "LogServSqlStrings.h"
    24 
    25 CLogDeleteEvent::CLogDeleteEvent(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
    26 : CLogActive(aPriority), iDatabase(aDatabase)
    27 	{
    28 	}
    29 
    30 CLogDeleteEvent::~CLogDeleteEvent()
    31 	{
    32 	Cancel();
    33 	}
    34 
    35 CLogDeleteEvent* CLogDeleteEvent::NewL(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
    36 	{
    37 	return new (ELeave) CLogDeleteEvent(aDatabase, aPriority);
    38 	}
    39 	
    40 
    41 void CLogDeleteEvent::StartL(TLogId aId, TRequestStatus& aStatus, const RMessage2& aMessage)
    42 	{
    43 	__ASSERT_DEBUG(!IsActive(), Panic(ELogAlreadyActive6));
    44 	
    45 	iMessage = const_cast<RMessage2*>(&aMessage);	// how to avoid this cast?
    46 	iId = aId;
    47 	
    48     Queue(aStatus);
    49     TRequestStatus* status = &iStatus;
    50     User::RequestComplete(status, KErrNone);
    51     SetActive();
    52 	}
    53 
    54 void CLogDeleteEvent::DoRunL()
    55 	{
    56 	RLogEventDbTable tbl;
    57 	tbl.OpenLC(iDatabase.DTIDatabase());
    58     User::LeaveIfError(tbl.SetIndex(KLogNameEventIdx1));
    59     //Find event
    60     if(!tbl.SeekL(TDbSeekKey((TInt)iId)))
    61         {
    62         iMessage->Complete(KErrNotFound);
    63         DoCancel();
    64         User::Leave(KErrNotFound);
    65         }
    66     tbl.GetL();
    67     //Platsec check
    68     TLogTypeId logTypeId = tbl.ColUint8(RLogEventDbTable::iTypeColNo);
    69     const TLogServCacheTypeEntry& entry = iDatabase.DTICacheTypes().FindById(logTypeId);
    70     __ASSERT_DEBUG(entry.iEventTypeId != KLogNullTypeId, Panic(ELogNoEventTypeAtId));
    71     if(!iDatabase.DTIIsAllowed(EWriteOp, *iMessage, entry.iEventType->Uid()))
    72         {
    73         User::Leave(KErrPermissionDenied);
    74         }
    75     User::LeaveIfError(iDatabase.DTIBegin());
    76     //Process duplicates 
    77     ::LogResetDuplicatesL(iDatabase, iId);
    78     //Delete the event
    79     tbl.DeleteL();
    80     iDatabase.DTIChangeInterface().DCISubmitChangedEventContextL(ELogChangeTypeEventDeleted, iId);
    81     //
    82     CleanupStack::PopAndDestroy(&tbl);
    83 	}
    84 
    85 
    86 void CLogDeleteEvent::DoCancel()
    87 	{
    88 	CLogActive::DoCancel();
    89 	}
    90 
    91 void CLogDeleteEvent::DoComplete(TInt& aStatus)
    92 	{
    93 	// Attempt to commit the transaction
    94 	if (iDatabase.DTIInTransaction())
    95 		{
    96 		if (aStatus == KErrNone)
    97 			aStatus = iDatabase.DTICommitAndEnd();
    98 
    99 		if (aStatus < KErrNone)
   100 			iDatabase.DTIRollBack();
   101 		}
   102 	}