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 "LOGDUP.H"
|
sl@0
|
17 |
#include "LOGFILTQ.H"
|
sl@0
|
18 |
#include "LOGQUERY.H"
|
sl@0
|
19 |
#include "logservpanic.h"
|
sl@0
|
20 |
#include "LogServDatabaseTransactionInterface.h"
|
sl@0
|
21 |
#include "LogServResourceInterpreter.h"
|
sl@0
|
22 |
#include "LogServDatabaseChangeInterface.h"
|
sl@0
|
23 |
#include "LogServSqlStrings.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
CLogDuplicate::CLogDuplicate(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority) :
|
sl@0
|
26 |
CLogActive(aPriority),
|
sl@0
|
27 |
iDatabase(aDatabase)
|
sl@0
|
28 |
{
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
CLogDuplicate::~CLogDuplicate()
|
sl@0
|
32 |
{
|
sl@0
|
33 |
Cancel();
|
sl@0
|
34 |
delete iFilterList;
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
void CLogDuplicate::ConstructL()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
iFilterList = new(ELeave) CLogFilterList;
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
CLogDuplicate* CLogDuplicate::NewL(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
CLogDuplicate* self = new(ELeave) CLogDuplicate(aDatabase, aPriority);
|
sl@0
|
45 |
CleanupStack::PushL(self);
|
sl@0
|
46 |
self->ConstructL();
|
sl@0
|
47 |
CleanupStack::Pop(self);
|
sl@0
|
48 |
return self;
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
TBool CLogDuplicate::StartL(TLogId aId, TLogRecentList aRecentList, const CLogFilter& aFilter, TRequestStatus& aStatus)
|
sl@0
|
52 |
{
|
sl@0
|
53 |
if (aRecentList == KLogNullRecentList)
|
sl@0
|
54 |
return EFalse;
|
sl@0
|
55 |
|
sl@0
|
56 |
iId = aId;
|
sl@0
|
57 |
iRecentList = aRecentList;
|
sl@0
|
58 |
iFilterList->Reset();
|
sl@0
|
59 |
iFilterList->AppendL(&aFilter);
|
sl@0
|
60 |
|
sl@0
|
61 |
Queue(aStatus);
|
sl@0
|
62 |
TRequestStatus* status = &iStatus;
|
sl@0
|
63 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
64 |
SetActive();
|
sl@0
|
65 |
return ETrue;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
void CLogDuplicate::DoRunL()
|
sl@0
|
69 |
{
|
sl@0
|
70 |
RLogDynBuf expr;
|
sl@0
|
71 |
TLogFilterExprBuilder exprBuilder(iDatabase);
|
sl@0
|
72 |
exprBuilder.BuildExprLC(expr, *iFilterList, KLogAnd);
|
sl@0
|
73 |
TheSql.Format(KLogSqlSelectDuplicateString, iRecentList, &expr.DesC(), iId);
|
sl@0
|
74 |
CleanupStack::PopAndDestroy(&expr);
|
sl@0
|
75 |
|
sl@0
|
76 |
RLogDbView view;
|
sl@0
|
77 |
view.PrepareLC(iDatabase.DTIDatabase(), TheSql);
|
sl@0
|
78 |
if(view.FirstL())
|
sl@0
|
79 |
{
|
sl@0
|
80 |
// Begin a transaction
|
sl@0
|
81 |
TBool inTransaction = iDatabase.DTIInTransaction();
|
sl@0
|
82 |
if(!inTransaction)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
iDatabase.DTIBeginWithRollBackProtectionLC();
|
sl@0
|
85 |
}
|
sl@0
|
86 |
// Get column ids
|
sl@0
|
87 |
static TDbColNo idColNo = 0;
|
sl@0
|
88 |
static TDbColNo duplicateColNo = 0;
|
sl@0
|
89 |
if(idColNo == 0)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
CDbColSet* cs = view.ColSetL();
|
sl@0
|
92 |
idColNo = cs->ColNo(KLogFieldIdString);
|
sl@0
|
93 |
duplicateColNo = cs->ColNo(KLogFieldEventDuplicateString);
|
sl@0
|
94 |
delete cs;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
// Iterate through the events
|
sl@0
|
97 |
do
|
sl@0
|
98 |
{
|
sl@0
|
99 |
// Get current event id
|
sl@0
|
100 |
view.GetL();
|
sl@0
|
101 |
const TLogId id = view.ColInt32(idColNo);
|
sl@0
|
102 |
// Set the latest recent?
|
sl@0
|
103 |
if(iId < 0)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
iId = id;
|
sl@0
|
106 |
}
|
sl@0
|
107 |
// Make the change
|
sl@0
|
108 |
view.UpdateL();
|
sl@0
|
109 |
iId == id ? view.SetColNullL(duplicateColNo) : view.SetColL(duplicateColNo, iId);
|
sl@0
|
110 |
view.PutL();
|
sl@0
|
111 |
// This is a "hidden" change. It may affect the contents of a view, but the actual event hasn't changed
|
sl@0
|
112 |
iDatabase.DTIChangeInterface().DCISubmitChangedEventContextL(ELogChangeTypeEventChangedHidden, id);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
while(view.NextL());
|
sl@0
|
115 |
// Commit changes
|
sl@0
|
116 |
if(!inTransaction)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
iDatabase.DTICommitAndCancelRollbackProtectionL();
|
sl@0
|
119 |
}
|
sl@0
|
120 |
}
|
sl@0
|
121 |
CleanupStack::PopAndDestroy(&view);
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
void CLogDuplicate::DoComplete(TInt& aStatus)
|
sl@0
|
125 |
{
|
sl@0
|
126 |
// Ignoring all errors because if an error occurs whilst detecting duplicate events
|
sl@0
|
127 |
// it should not stop us actually adding the event to the log
|
sl@0
|
128 |
aStatus = KErrNone;
|
sl@0
|
129 |
}
|