os/persistentdata/loggingservices/eventlogger/LogCli/src/LogViewWindowChangeObserver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogCli/src/LogViewWindowChangeObserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,100 @@
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 "LogViewWindowChangeObserver.h"
1.20 +
1.21 +// Constants
1.22 +const TInt KLogViewIgnoreStackGranularity = 3;
1.23 +
1.24 +
1.25 +/////////////////////////////////////////////////////////////////////////////////////////
1.26 +// -----> CLogViewWindowChangeObserver (source)
1.27 +/////////////////////////////////////////////////////////////////////////////////////////
1.28 +
1.29 +CLogViewWindowChangeObserver::CLogViewWindowChangeObserver(MLogViewChangeObserverInternal& aObserver)
1.30 +: iObserver(aObserver), iIgnoreStack(KLogViewIgnoreStackGranularity)
1.31 + {
1.32 + }
1.33 +
1.34 +CLogViewWindowChangeObserver::~CLogViewWindowChangeObserver()
1.35 + {
1.36 + iIgnoreStack.Close();
1.37 + }
1.38 +
1.39 +/////////////////////////////////////////////////////////////////////////////////////////
1.40 +/////////////////////////////////////////////////////////////////////////////////////////
1.41 +/////////////////////////////////////////////////////////////////////////////////////////
1.42 +
1.43 +void CLogViewWindowChangeObserver::IgnoreNextEventL(TLogId aId, TType aType)
1.44 + {
1.45 + TIgnoreEvent event(aId, aType);
1.46 + User::LeaveIfError(iIgnoreStack.Append(event));
1.47 + }
1.48 +
1.49 +/////////////////////////////////////////////////////////////////////////////////////////
1.50 +/////////////////////////////////////////////////////////////////////////////////////////
1.51 +/////////////////////////////////////////////////////////////////////////////////////////
1.52 +
1.53 +void CLogViewWindowChangeObserver::HandleLogViewChangeEventAddedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount)
1.54 + {
1.55 + const TInt index = Find(aId, ELogEventTypeAdd);
1.56 + if (index == KErrNotFound)
1.57 + iObserver.HandleLogViewChangeEventAddedL(aId, aViewIndex, aChangeIndex, aTotalChangeCount);
1.58 + else
1.59 + iIgnoreStack.Remove(index);
1.60 + }
1.61 +
1.62 +void CLogViewWindowChangeObserver::HandleLogViewChangeEventChangedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount)
1.63 + {
1.64 + const TInt index = Find(aId, ELogEventTypeChange);
1.65 + if (index == KErrNotFound)
1.66 + iObserver.HandleLogViewChangeEventChangedL(aId, aViewIndex, aChangeIndex, aTotalChangeCount);
1.67 + else
1.68 + iIgnoreStack.Remove(index);
1.69 + }
1.70 +
1.71 +void CLogViewWindowChangeObserver::HandleLogViewChangeEventDeletedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount)
1.72 + {
1.73 + const TInt index = Find(aId, ELogEventTypeDelete);
1.74 + if (index == KErrNotFound)
1.75 + iObserver.HandleLogViewChangeEventDeletedL(aId, aViewIndex, aChangeIndex, aTotalChangeCount);
1.76 + else
1.77 + iIgnoreStack.Remove(index);
1.78 + }
1.79 +
1.80 +/////////////////////////////////////////////////////////////////////////////////////////
1.81 +/////////////////////////////////////////////////////////////////////////////////////////
1.82 +/////////////////////////////////////////////////////////////////////////////////////////
1.83 +
1.84 +void CLogViewWindowChangeObserver::HandleLogViewChangeEventLogClearedL()
1.85 + {
1.86 + iObserver.HandleLogViewChangeEventLogClearedL();
1.87 + }
1.88 +
1.89 +/////////////////////////////////////////////////////////////////////////////////////////
1.90 +/////////////////////////////////////////////////////////////////////////////////////////
1.91 +/////////////////////////////////////////////////////////////////////////////////////////
1.92 +
1.93 +TInt CLogViewWindowChangeObserver::Find(TLogId aId, TType aType) const
1.94 + {
1.95 + const TInt count = iIgnoreStack.Count();
1.96 + for(TInt i=0; i<count; i++)
1.97 + {
1.98 + const TIgnoreEvent& event = iIgnoreStack[i];
1.99 + if (event.iId == aId && event.iType == aType)
1.100 + return i;
1.101 + }
1.102 + return KErrNotFound;
1.103 + }