sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "LOGDEL.H"
|
sl@0
|
17 |
#include "LOGQUERY.H"
|
sl@0
|
18 |
#include "logservpanic.h"
|
sl@0
|
19 |
#include "LogServDatabaseTransactionInterface.h"
|
sl@0
|
20 |
#include "LogServResourceInterpreter.h"
|
sl@0
|
21 |
#include "LogServCacheTypes.h"
|
sl@0
|
22 |
#include "LogServDatabaseChangeInterface.h"
|
sl@0
|
23 |
#include "LogServSqlStrings.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
CLogDeleteEvent::CLogDeleteEvent(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
|
sl@0
|
26 |
: CLogActive(aPriority), iDatabase(aDatabase)
|
sl@0
|
27 |
{
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
CLogDeleteEvent::~CLogDeleteEvent()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
Cancel();
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
CLogDeleteEvent* CLogDeleteEvent::NewL(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
return new (ELeave) CLogDeleteEvent(aDatabase, aPriority);
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
void CLogDeleteEvent::StartL(TLogId aId, TRequestStatus& aStatus, const RMessage2& aMessage)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
__ASSERT_DEBUG(!IsActive(), Panic(ELogAlreadyActive6));
|
sl@0
|
44 |
|
sl@0
|
45 |
iMessage = const_cast<RMessage2*>(&aMessage); // how to avoid this cast?
|
sl@0
|
46 |
iId = aId;
|
sl@0
|
47 |
|
sl@0
|
48 |
Queue(aStatus);
|
sl@0
|
49 |
TRequestStatus* status = &iStatus;
|
sl@0
|
50 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
51 |
SetActive();
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
void CLogDeleteEvent::DoRunL()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
RLogEventDbTable tbl;
|
sl@0
|
57 |
tbl.OpenLC(iDatabase.DTIDatabase());
|
sl@0
|
58 |
User::LeaveIfError(tbl.SetIndex(KLogNameEventIdx1));
|
sl@0
|
59 |
//Find event
|
sl@0
|
60 |
if(!tbl.SeekL(TDbSeekKey((TInt)iId)))
|
sl@0
|
61 |
{
|
sl@0
|
62 |
iMessage->Complete(KErrNotFound);
|
sl@0
|
63 |
DoCancel();
|
sl@0
|
64 |
User::Leave(KErrNotFound);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
tbl.GetL();
|
sl@0
|
67 |
//Platsec check
|
sl@0
|
68 |
TLogTypeId logTypeId = tbl.ColUint8(RLogEventDbTable::iTypeColNo);
|
sl@0
|
69 |
const TLogServCacheTypeEntry& entry = iDatabase.DTICacheTypes().FindById(logTypeId);
|
sl@0
|
70 |
__ASSERT_DEBUG(entry.iEventTypeId != KLogNullTypeId, Panic(ELogNoEventTypeAtId));
|
sl@0
|
71 |
if(!iDatabase.DTIIsAllowed(EWriteOp, *iMessage, entry.iEventType->Uid()))
|
sl@0
|
72 |
{
|
sl@0
|
73 |
User::Leave(KErrPermissionDenied);
|
sl@0
|
74 |
}
|
sl@0
|
75 |
User::LeaveIfError(iDatabase.DTIBegin());
|
sl@0
|
76 |
//Process duplicates
|
sl@0
|
77 |
::LogResetDuplicatesL(iDatabase, iId);
|
sl@0
|
78 |
//Delete the event
|
sl@0
|
79 |
tbl.DeleteL();
|
sl@0
|
80 |
iDatabase.DTIChangeInterface().DCISubmitChangedEventContextL(ELogChangeTypeEventDeleted, iId);
|
sl@0
|
81 |
//
|
sl@0
|
82 |
CleanupStack::PopAndDestroy(&tbl);
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
|
sl@0
|
86 |
void CLogDeleteEvent::DoCancel()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
CLogActive::DoCancel();
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
void CLogDeleteEvent::DoComplete(TInt& aStatus)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
// Attempt to commit the transaction
|
sl@0
|
94 |
if (iDatabase.DTIInTransaction())
|
sl@0
|
95 |
{
|
sl@0
|
96 |
if (aStatus == KErrNone)
|
sl@0
|
97 |
aStatus = iDatabase.DTICommitAndEnd();
|
sl@0
|
98 |
|
sl@0
|
99 |
if (aStatus < KErrNone)
|
sl@0
|
100 |
iDatabase.DTIRollBack();
|
sl@0
|
101 |
}
|
sl@0
|
102 |
}
|