os/persistentdata/loggingservices/eventlogger/LogServ/src/LogServRecentCondition.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/src/LogServRecentCondition.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,164 @@
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 <barsread.h>
1.20 +#include <logcli.h>
1.21 +#include <logfilterandeventconstants.hrh>
1.22 +#include "LogServRecentCondition.h"
1.23 +#include "logservpanic.h"
1.24 +#include "LogServSqlStrings.h"
1.25 +
1.26 +
1.27 +/////////////////////////////////////////////////////////////////////////////////////////
1.28 +// -----> CLogServRecentCondition (source)
1.29 +/////////////////////////////////////////////////////////////////////////////////////////
1.30 +
1.31 +CLogServRecentCondition* CLogServRecentCondition::NewL(TResourceReader& aReader)
1.32 + {
1.33 + CLogServRecentCondition* self = new(ELeave)CLogServRecentCondition();
1.34 + CleanupStack::PushL(self);
1.35 + self->ConstructL(aReader);
1.36 + CleanupStack::Pop();
1.37 + return self;
1.38 + }
1.39 +
1.40 +CLogServRecentCondition::~CLogServRecentCondition()
1.41 + {
1.42 + delete iString;
1.43 + }
1.44 +
1.45 +TBool CLogServRecentCondition::IsMatch(const CLogEvent& aEvent) const
1.46 + {
1.47 + TBool match = EFalse;
1.48 + switch (iField)
1.49 + {
1.50 + case ELogContactField:
1.51 + match = (aEvent.Contact() == (TLogContactItemId )iValue);
1.52 + break;
1.53 +
1.54 + case ELogDirectionField:
1.55 + match = (iString && aEvent.Direction().CompareF(*iString) == 0);
1.56 + break;
1.57 +
1.58 + case ELogDurationTypeField:
1.59 + match = (aEvent.DurationType() == (TLogDurationType)iValue);
1.60 + break;
1.61 +
1.62 + case ELogEventTypeField:
1.63 + match = (aEvent.EventType() == TUid::Uid(iValue));
1.64 + break;
1.65 +
1.66 + case ELogNumberField:
1.67 + match = (iString && aEvent.Number().CompareF(*iString) == 0);
1.68 + break;
1.69 +
1.70 + case ELogRemotePartyField:
1.71 + match = (iString && aEvent.RemoteParty().CompareF(*iString) == 0);
1.72 + break;
1.73 +
1.74 + case ELogStatusField:
1.75 + match = (iString && aEvent.Status().CompareF(*iString) == 0);
1.76 + break;
1.77 +
1.78 + case ELogFlagsField:
1.79 + match = (aEvent.Flags() & iValue);
1.80 + break;
1.81 +
1.82 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
1.83 + case ELogSimIdField:
1.84 + match = (aEvent.SimId() == (TSimId)iValue);
1.85 + break;
1.86 +#endif
1.87 +
1.88 + default:
1.89 + __ASSERT_DEBUG(EFalse, Panic(ELogUnknownField));
1.90 + break;
1.91 + }
1.92 +
1.93 + return match;
1.94 + }
1.95 +
1.96 +void CLogServRecentCondition::ConstructL(TResourceReader& aReader)
1.97 + {
1.98 + iField = (TUint16)aReader.ReadUint16();
1.99 + TPtrC string(aReader.ReadTPtrC());
1.100 + iValue = aReader.ReadInt32();
1.101 +
1.102 + if (string.Length() > 0)
1.103 + {
1.104 + iString = string.AllocL();
1.105 + }
1.106 + }
1.107 +
1.108 +#ifdef SYSLIBS_TEST
1.109 +
1.110 +#pragma BullseyeCoverage off
1.111 +
1.112 +//When SYSLIBS_TEST macro is defined, creates a test recent list condition.
1.113 +//Used from the unit tests to cover many of the production code branches, otherwise uncovered,
1.114 +//because the recent list conditions can be loaded only from the resource file.
1.115 +CLogServRecentCondition* CLogServRecentCondition::TestNewL(TUint16 aField)
1.116 + {
1.117 + CLogServRecentCondition* self = new(ELeave)CLogServRecentCondition;
1.118 + CleanupStack::PushL(self);
1.119 + self->TestConstructL(aField);
1.120 + CleanupStack::Pop();
1.121 + return self;
1.122 + }
1.123 +
1.124 +//When SYSLIBS_TEST macro is defined, creates a test recent list condition.
1.125 +//Used from the unit tests to cover many of the production code branches, otherwise uncovered,
1.126 +//because the recent list conditions can be loaded only from the resource file.
1.127 +void CLogServRecentCondition::TestConstructL(TUint16 aField)
1.128 + {
1.129 + iField = aField;
1.130 + switch(iField)
1.131 + {
1.132 + case ELogDirectionField:
1.133 + iString = HBufC::NewL(16);
1.134 + *iString = KLogRctTListDirection;
1.135 + break;
1.136 + case ELogDurationTypeField:
1.137 + iValue = KLogRctTListDurationType;
1.138 + break;
1.139 + case ELogNumberField:
1.140 + iString = HBufC::NewL(16);
1.141 + *iString = KLogRctTListNumber;
1.142 + break;
1.143 + case ELogRemotePartyField:
1.144 + iString = HBufC::NewL(16);
1.145 + *iString = KLogRctTListRemoteParty;
1.146 + break;
1.147 + case ELogStatusField:
1.148 + iString = HBufC::NewL(16);
1.149 + *iString = KLogRctTListStatus;
1.150 + break;
1.151 + case ELogFlagsField:
1.152 + iValue = KLogRctTListFlags;
1.153 + break;
1.154 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
1.155 + case ELogSimIdField:
1.156 + iValue = KLogRctTListSimId;
1.157 + break;
1.158 +#endif
1.159 + default:
1.160 + __ASSERT_DEBUG(EFalse, Panic(ELogUnknownField));
1.161 + break;
1.162 + }
1.163 + }
1.164 +
1.165 +#pragma BullseyeCoverage on
1.166 +
1.167 +#endif//SYSLIBS_TEST