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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include "logservpanic.h"
20 #include "LogServDatabaseTransactionInterface.h"
21 #include "LogServResourceInterpreter.h"
22 #include "LogServDatabaseChangeInterface.h"
23 #include "LogServSqlStrings.h"
25 CLogDuplicate::CLogDuplicate(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority) :
26 CLogActive(aPriority),
31 CLogDuplicate::~CLogDuplicate()
37 void CLogDuplicate::ConstructL()
39 iFilterList = new(ELeave) CLogFilterList;
42 CLogDuplicate* CLogDuplicate::NewL(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
44 CLogDuplicate* self = new(ELeave) CLogDuplicate(aDatabase, aPriority);
45 CleanupStack::PushL(self);
47 CleanupStack::Pop(self);
51 TBool CLogDuplicate::StartL(TLogId aId, TLogRecentList aRecentList, const CLogFilter& aFilter, TRequestStatus& aStatus)
53 if (aRecentList == KLogNullRecentList)
57 iRecentList = aRecentList;
59 iFilterList->AppendL(&aFilter);
62 TRequestStatus* status = &iStatus;
63 User::RequestComplete(status, KErrNone);
68 void CLogDuplicate::DoRunL()
71 TLogFilterExprBuilder exprBuilder(iDatabase);
72 exprBuilder.BuildExprLC(expr, *iFilterList, KLogAnd);
73 TheSql.Format(KLogSqlSelectDuplicateString, iRecentList, &expr.DesC(), iId);
74 CleanupStack::PopAndDestroy(&expr);
77 view.PrepareLC(iDatabase.DTIDatabase(), TheSql);
80 // Begin a transaction
81 TBool inTransaction = iDatabase.DTIInTransaction();
84 iDatabase.DTIBeginWithRollBackProtectionLC();
87 static TDbColNo idColNo = 0;
88 static TDbColNo duplicateColNo = 0;
91 CDbColSet* cs = view.ColSetL();
92 idColNo = cs->ColNo(KLogFieldIdString);
93 duplicateColNo = cs->ColNo(KLogFieldEventDuplicateString);
96 // Iterate through the events
99 // Get current event id
101 const TLogId id = view.ColInt32(idColNo);
102 // Set the latest recent?
109 iId == id ? view.SetColNullL(duplicateColNo) : view.SetColL(duplicateColNo, iId);
111 // This is a "hidden" change. It may affect the contents of a view, but the actual event hasn't changed
112 iDatabase.DTIChangeInterface().DCISubmitChangedEventContextL(ELogChangeTypeEventChangedHidden, id);
118 iDatabase.DTICommitAndCancelRollbackProtectionL();
121 CleanupStack::PopAndDestroy(&view);
124 void CLogDuplicate::DoComplete(TInt& aStatus)
126 // Ignoring all errors because if an error occurs whilst detecting duplicate events
127 // it should not stop us actually adding the event to the log