os/persistentdata/loggingservices/eventlogger/LogServ/src/LOGDEL.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/src/LOGDEL.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,102 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "LOGDEL.H"
    1.20 +#include "LOGQUERY.H"
    1.21 +#include "logservpanic.h"
    1.22 +#include "LogServDatabaseTransactionInterface.h"
    1.23 +#include "LogServResourceInterpreter.h"
    1.24 +#include "LogServCacheTypes.h"
    1.25 +#include "LogServDatabaseChangeInterface.h"
    1.26 +#include "LogServSqlStrings.h"
    1.27 +
    1.28 +CLogDeleteEvent::CLogDeleteEvent(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
    1.29 +: CLogActive(aPriority), iDatabase(aDatabase)
    1.30 +	{
    1.31 +	}
    1.32 +
    1.33 +CLogDeleteEvent::~CLogDeleteEvent()
    1.34 +	{
    1.35 +	Cancel();
    1.36 +	}
    1.37 +
    1.38 +CLogDeleteEvent* CLogDeleteEvent::NewL(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
    1.39 +	{
    1.40 +	return new (ELeave) CLogDeleteEvent(aDatabase, aPriority);
    1.41 +	}
    1.42 +	
    1.43 +
    1.44 +void CLogDeleteEvent::StartL(TLogId aId, TRequestStatus& aStatus, const RMessage2& aMessage)
    1.45 +	{
    1.46 +	__ASSERT_DEBUG(!IsActive(), Panic(ELogAlreadyActive6));
    1.47 +	
    1.48 +	iMessage = const_cast<RMessage2*>(&aMessage);	// how to avoid this cast?
    1.49 +	iId = aId;
    1.50 +	
    1.51 +    Queue(aStatus);
    1.52 +    TRequestStatus* status = &iStatus;
    1.53 +    User::RequestComplete(status, KErrNone);
    1.54 +    SetActive();
    1.55 +	}
    1.56 +
    1.57 +void CLogDeleteEvent::DoRunL()
    1.58 +	{
    1.59 +	RLogEventDbTable tbl;
    1.60 +	tbl.OpenLC(iDatabase.DTIDatabase());
    1.61 +    User::LeaveIfError(tbl.SetIndex(KLogNameEventIdx1));
    1.62 +    //Find event
    1.63 +    if(!tbl.SeekL(TDbSeekKey((TInt)iId)))
    1.64 +        {
    1.65 +        iMessage->Complete(KErrNotFound);
    1.66 +        DoCancel();
    1.67 +        User::Leave(KErrNotFound);
    1.68 +        }
    1.69 +    tbl.GetL();
    1.70 +    //Platsec check
    1.71 +    TLogTypeId logTypeId = tbl.ColUint8(RLogEventDbTable::iTypeColNo);
    1.72 +    const TLogServCacheTypeEntry& entry = iDatabase.DTICacheTypes().FindById(logTypeId);
    1.73 +    __ASSERT_DEBUG(entry.iEventTypeId != KLogNullTypeId, Panic(ELogNoEventTypeAtId));
    1.74 +    if(!iDatabase.DTIIsAllowed(EWriteOp, *iMessage, entry.iEventType->Uid()))
    1.75 +        {
    1.76 +        User::Leave(KErrPermissionDenied);
    1.77 +        }
    1.78 +    User::LeaveIfError(iDatabase.DTIBegin());
    1.79 +    //Process duplicates 
    1.80 +    ::LogResetDuplicatesL(iDatabase, iId);
    1.81 +    //Delete the event
    1.82 +    tbl.DeleteL();
    1.83 +    iDatabase.DTIChangeInterface().DCISubmitChangedEventContextL(ELogChangeTypeEventDeleted, iId);
    1.84 +    //
    1.85 +    CleanupStack::PopAndDestroy(&tbl);
    1.86 +	}
    1.87 +
    1.88 +
    1.89 +void CLogDeleteEvent::DoCancel()
    1.90 +	{
    1.91 +	CLogActive::DoCancel();
    1.92 +	}
    1.93 +
    1.94 +void CLogDeleteEvent::DoComplete(TInt& aStatus)
    1.95 +	{
    1.96 +	// Attempt to commit the transaction
    1.97 +	if (iDatabase.DTIInTransaction())
    1.98 +		{
    1.99 +		if (aStatus == KErrNone)
   1.100 +			aStatus = iDatabase.DTICommitAndEnd();
   1.101 +
   1.102 +		if (aStatus < KErrNone)
   1.103 +			iDatabase.DTIRollBack();
   1.104 +		}
   1.105 +	}