loggingservices/eventlogger/LogServ/src/LogServRecentCondition.cpp
changeset 0 08ec8eefde2f
child 55 44f437012c90
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <barsread.h>
       
    17 #include <logcli.h>
       
    18 #include <logfilterandeventconstants.hrh>
       
    19 #include "LogServRecentCondition.h"
       
    20 #include "logservpanic.h"
       
    21 #include "LogServSqlStrings.h"
       
    22 
       
    23 
       
    24 /////////////////////////////////////////////////////////////////////////////////////////
       
    25 // -----> CLogServRecentCondition (source)
       
    26 /////////////////////////////////////////////////////////////////////////////////////////
       
    27 
       
    28 CLogServRecentCondition* CLogServRecentCondition::NewL(TResourceReader& aReader)
       
    29 	{
       
    30 	CLogServRecentCondition* self = new(ELeave)CLogServRecentCondition();
       
    31 	CleanupStack::PushL(self);
       
    32 	self->ConstructL(aReader);
       
    33 	CleanupStack::Pop();
       
    34 	return self;
       
    35 	}
       
    36 
       
    37 CLogServRecentCondition::~CLogServRecentCondition()
       
    38 	{
       
    39 	delete iString;
       
    40 	}
       
    41 
       
    42 TBool CLogServRecentCondition::IsMatch(const CLogEvent& aEvent) const
       
    43 	{
       
    44 	TBool match = EFalse;
       
    45 	switch (iField)
       
    46 		{
       
    47 		case ELogContactField:
       
    48 			match = (aEvent.Contact() == (TLogContactItemId )iValue);
       
    49 			break;
       
    50 
       
    51 		case ELogDirectionField:
       
    52 			match = (iString && aEvent.Direction().CompareF(*iString) == 0);
       
    53 			break;
       
    54 
       
    55 		case ELogDurationTypeField:
       
    56 			match = (aEvent.DurationType() == (TLogDurationType)iValue);
       
    57 			break;
       
    58 
       
    59 		case ELogEventTypeField:
       
    60 			match = (aEvent.EventType() == TUid::Uid(iValue));
       
    61 			break;
       
    62 
       
    63 		case ELogNumberField:
       
    64 			match = (iString && aEvent.Number().CompareF(*iString) == 0);
       
    65 			break;
       
    66 
       
    67 		case ELogRemotePartyField:
       
    68 			match = (iString && aEvent.RemoteParty().CompareF(*iString) == 0);
       
    69 			break;
       
    70 
       
    71 		case ELogStatusField:
       
    72 			match = (iString && aEvent.Status().CompareF(*iString) == 0);
       
    73 			break;
       
    74 
       
    75 		case ELogFlagsField:
       
    76 			match = (aEvent.Flags() & iValue);
       
    77 			break;
       
    78 
       
    79 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
       
    80 		case ELogSimIdField:
       
    81 			match = (aEvent.SimId() == (TSimId)iValue);
       
    82 			break;
       
    83 #endif			
       
    84 			
       
    85 		default:
       
    86 			__ASSERT_DEBUG(EFalse, Panic(ELogUnknownField));
       
    87 			break;
       
    88 		}
       
    89 
       
    90 	return match;
       
    91 	}
       
    92 
       
    93 void CLogServRecentCondition::ConstructL(TResourceReader& aReader)
       
    94 	{
       
    95 	iField = (TUint16)aReader.ReadUint16();
       
    96 	TPtrC string(aReader.ReadTPtrC());
       
    97 	iValue = aReader.ReadInt32();
       
    98 
       
    99 	if (string.Length() > 0)
       
   100 		{
       
   101 		iString = string.AllocL();
       
   102 		}
       
   103 	}
       
   104 
       
   105 #ifdef SYSLIBS_TEST
       
   106 
       
   107 #pragma BullseyeCoverage off
       
   108 
       
   109 //When SYSLIBS_TEST macro is defined, creates a test recent list condition.
       
   110 //Used from the unit tests to cover many of the production code branches, otherwise uncovered,
       
   111 //because the recent list conditions can be loaded only from the resource file.
       
   112 CLogServRecentCondition* CLogServRecentCondition::TestNewL(TUint16 aField)
       
   113 	{
       
   114 	CLogServRecentCondition* self = new(ELeave)CLogServRecentCondition;
       
   115 	CleanupStack::PushL(self);
       
   116 	self->TestConstructL(aField);
       
   117 	CleanupStack::Pop();
       
   118 	return self;
       
   119 	}
       
   120 
       
   121 //When SYSLIBS_TEST macro is defined, creates a test recent list condition.
       
   122 //Used from the unit tests to cover many of the production code branches, otherwise uncovered,
       
   123 //because the recent list conditions can be loaded only from the resource file.
       
   124 void CLogServRecentCondition::TestConstructL(TUint16 aField)
       
   125 	{
       
   126 	iField = aField;
       
   127 	switch(iField)
       
   128 		{
       
   129 	case ELogDirectionField:
       
   130 		iString = HBufC::NewL(16);
       
   131 		*iString = KLogRctTListDirection;
       
   132 		break;
       
   133 	case ELogDurationTypeField:
       
   134 		iValue = KLogRctTListDurationType;
       
   135 		break;
       
   136 	case ELogNumberField:
       
   137 		iString = HBufC::NewL(16);
       
   138 		*iString = KLogRctTListNumber;
       
   139 		break;
       
   140 	case ELogRemotePartyField:
       
   141 		iString = HBufC::NewL(16);
       
   142 		*iString = KLogRctTListRemoteParty;
       
   143 		break;
       
   144 	case ELogStatusField:
       
   145 		iString = HBufC::NewL(16);
       
   146 		*iString = KLogRctTListStatus;
       
   147 		break;
       
   148 	case ELogFlagsField:
       
   149 		iValue = KLogRctTListFlags;
       
   150 		break;
       
   151 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
       
   152 	case ELogSimIdField:
       
   153 		iValue = KLogRctTListSimId;
       
   154 		break;
       
   155 #endif		
       
   156 	default:
       
   157 		__ASSERT_DEBUG(EFalse, Panic(ELogUnknownField));
       
   158 		break;
       
   159 		}
       
   160 	}
       
   161 
       
   162 #pragma BullseyeCoverage on
       
   163 
       
   164 #endif//SYSLIBS_TEST