1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/src/LOGDUP.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,129 @@
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 "LOGDUP.H"
1.20 +#include "LOGFILTQ.H"
1.21 +#include "LOGQUERY.H"
1.22 +#include "logservpanic.h"
1.23 +#include "LogServDatabaseTransactionInterface.h"
1.24 +#include "LogServResourceInterpreter.h"
1.25 +#include "LogServDatabaseChangeInterface.h"
1.26 +#include "LogServSqlStrings.h"
1.27 +
1.28 +CLogDuplicate::CLogDuplicate(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority) :
1.29 + CLogActive(aPriority),
1.30 + iDatabase(aDatabase)
1.31 + {
1.32 + }
1.33 +
1.34 +CLogDuplicate::~CLogDuplicate()
1.35 + {
1.36 + Cancel();
1.37 + delete iFilterList;
1.38 + }
1.39 +
1.40 +void CLogDuplicate::ConstructL()
1.41 + {
1.42 + iFilterList = new(ELeave) CLogFilterList;
1.43 + }
1.44 +
1.45 +CLogDuplicate* CLogDuplicate::NewL(MLogServDatabaseTransactionInterface& aDatabase, TInt aPriority)
1.46 + {
1.47 + CLogDuplicate* self = new(ELeave) CLogDuplicate(aDatabase, aPriority);
1.48 + CleanupStack::PushL(self);
1.49 + self->ConstructL();
1.50 + CleanupStack::Pop(self);
1.51 + return self;
1.52 + }
1.53 +
1.54 +TBool CLogDuplicate::StartL(TLogId aId, TLogRecentList aRecentList, const CLogFilter& aFilter, TRequestStatus& aStatus)
1.55 + {
1.56 + if (aRecentList == KLogNullRecentList)
1.57 + return EFalse;
1.58 +
1.59 + iId = aId;
1.60 + iRecentList = aRecentList;
1.61 + iFilterList->Reset();
1.62 + iFilterList->AppendL(&aFilter);
1.63 +
1.64 + Queue(aStatus);
1.65 + TRequestStatus* status = &iStatus;
1.66 + User::RequestComplete(status, KErrNone);
1.67 + SetActive();
1.68 + return ETrue;
1.69 + }
1.70 +
1.71 +void CLogDuplicate::DoRunL()
1.72 + {
1.73 + RLogDynBuf expr;
1.74 + TLogFilterExprBuilder exprBuilder(iDatabase);
1.75 + exprBuilder.BuildExprLC(expr, *iFilterList, KLogAnd);
1.76 + TheSql.Format(KLogSqlSelectDuplicateString, iRecentList, &expr.DesC(), iId);
1.77 + CleanupStack::PopAndDestroy(&expr);
1.78 +
1.79 + RLogDbView view;
1.80 + view.PrepareLC(iDatabase.DTIDatabase(), TheSql);
1.81 + if(view.FirstL())
1.82 + {
1.83 + // Begin a transaction
1.84 + TBool inTransaction = iDatabase.DTIInTransaction();
1.85 + if(!inTransaction)
1.86 + {
1.87 + iDatabase.DTIBeginWithRollBackProtectionLC();
1.88 + }
1.89 + // Get column ids
1.90 + static TDbColNo idColNo = 0;
1.91 + static TDbColNo duplicateColNo = 0;
1.92 + if(idColNo == 0)
1.93 + {
1.94 + CDbColSet* cs = view.ColSetL();
1.95 + idColNo = cs->ColNo(KLogFieldIdString);
1.96 + duplicateColNo = cs->ColNo(KLogFieldEventDuplicateString);
1.97 + delete cs;
1.98 + }
1.99 + // Iterate through the events
1.100 + do
1.101 + {
1.102 + // Get current event id
1.103 + view.GetL();
1.104 + const TLogId id = view.ColInt32(idColNo);
1.105 + // Set the latest recent?
1.106 + if(iId < 0)
1.107 + {
1.108 + iId = id;
1.109 + }
1.110 + // Make the change
1.111 + view.UpdateL();
1.112 + iId == id ? view.SetColNullL(duplicateColNo) : view.SetColL(duplicateColNo, iId);
1.113 + view.PutL();
1.114 + // This is a "hidden" change. It may affect the contents of a view, but the actual event hasn't changed
1.115 + iDatabase.DTIChangeInterface().DCISubmitChangedEventContextL(ELogChangeTypeEventChangedHidden, id);
1.116 + }
1.117 + while(view.NextL());
1.118 + // Commit changes
1.119 + if(!inTransaction)
1.120 + {
1.121 + iDatabase.DTICommitAndCancelRollbackProtectionL();
1.122 + }
1.123 + }
1.124 + CleanupStack::PopAndDestroy(&view);
1.125 + }
1.126 +
1.127 +void CLogDuplicate::DoComplete(TInt& aStatus)
1.128 + {
1.129 + // Ignoring all errors because if an error occurs whilst detecting duplicate events
1.130 + // it should not stop us actually adding the event to the log
1.131 + aStatus = KErrNone;
1.132 + }