os/persistentdata/loggingservices/eventlogger/LogCli/src/LOGFILT.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogCli/src/LOGFILT.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,248 @@
     1.4 +// Copyright (c) 2003-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 <logcli.h>
    1.20 +#include <logwraplimits.h>
    1.21 +#include "LogCliServShared.h"
    1.22 +#include "logcntdef.h"
    1.23 +#include "logclipanic.h"
    1.24 +
    1.25 +const TInt KLogFilterListGranuality = 10;
    1.26 +
    1.27 +//**********************************
    1.28 +// CLogFilter
    1.29 +//**********************************
    1.30 +
    1.31 +/** Creates a new filter object.
    1.32 +
    1.33 +All fields in the new instance are initialised to default values, so that 
    1.34 +if none of the fields are changed, the filter has no effect on the selection 
    1.35 +of events in view.
    1.36 +
    1.37 +@return A pointer to the new event object. */
    1.38 +EXPORT_C CLogFilter* CLogFilter::NewL()
    1.39 +	{
    1.40 +	CLogFilter* self = new(ELeave)CLogFilter;
    1.41 +	CleanupStack::PushL(self);
    1.42 +	self->ConstructL();
    1.43 +	CleanupStack::Pop(); // self
    1.44 +	return self;
    1.45 +	}
    1.46 +
    1.47 +CLogFilter::CLogFilter()
    1.48 +: iDurationType(KLogNullDurationType), iContact(KLogNullContactId), iFlags(KLogNullFlags),
    1.49 +iStartTime(TTime(0)), iEndTime(TTime(0))
    1.50 +	{
    1.51 +	}
    1.52 +
    1.53 +void CLogFilter::ConstructL()
    1.54 +	{
    1.55 +	iRemoteParty = HBufC::NewL(KLogMaxRemotePartyLength);
    1.56 +	iDirection = HBufC::NewL(KLogMaxDirectionLength);
    1.57 +	iStatus = HBufC::NewL(KLogMaxStatusLength);
    1.58 +	iNumber = HBufC::NewL(KLogMaxNumberLength);
    1.59 +	}
    1.60 +
    1.61 +/** Frees all resource owned by the object prior to its destruction. */
    1.62 +EXPORT_C CLogFilter::~CLogFilter()
    1.63 +	{
    1.64 +	delete iRemoteParty;
    1.65 +	delete iDirection;
    1.66 +	delete iStatus;
    1.67 +	delete iNumber;
    1.68 +	}
    1.69 +
    1.70 +/** Makes a copy of a filter.
    1.71 +
    1.72 +@param aFilter The filter object to be copied. */
    1.73 +EXPORT_C void CLogFilter::Copy(const CLogFilter& aFilter)
    1.74 +	{
    1.75 +	SetEventType(aFilter.EventType());
    1.76 +	SetDurationType(aFilter.DurationType());
    1.77 +	SetContact(aFilter.Contact());
    1.78 +	SetRemoteParty(aFilter.RemoteParty());
    1.79 +	SetDirection(aFilter.Direction());
    1.80 +	SetStatus(aFilter.Status());
    1.81 +	SetNumber(aFilter.Number());
    1.82 +	SetNullFields(aFilter.NullFields());
    1.83 +
    1.84 +	ClearFlags(KLogFlagsMask);
    1.85 +	SetFlags(aFilter.Flags());
    1.86 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
    1.87 +	SetSimId(aFilter.SimId());
    1.88 +#endif
    1.89 +	}
    1.90 +
    1.91 +void CLogFilter::InternalizeL(RReadStream& aStream)
    1.92 +	{
    1.93 +	TBuf<KLogMaxDateLength> buf;
    1.94 +	aStream >> iEventType;
    1.95 +	aStream >> iDurationType;
    1.96 +	aStream >> iContact;
    1.97 +	InternalizeBufL(aStream, iRemoteParty);
    1.98 +	InternalizeBufL(aStream, iDirection);
    1.99 +	InternalizeBufL(aStream, iStatus);
   1.100 +	InternalizeBufL(aStream, iNumber);
   1.101 +	aStream >> iNullFields;
   1.102 +	aStream >> iFlags;
   1.103 +	aStream >> buf;
   1.104 +	iStartTime.Parse(buf);
   1.105 +	buf.FillZ();
   1.106 +	aStream >> buf;
   1.107 +	iEndTime.Parse(buf);
   1.108 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
   1.109 +	aStream >> iSimId;
   1.110 +#endif
   1.111 +	}
   1.112 +
   1.113 +void CLogFilter::InternalizeBufL(RReadStream& aStream, HBufC*& aDes)
   1.114 +	{
   1.115 +	TPtr ptr(aDes->Des());
   1.116 +	HBufC* temp = HBufC::NewL(aStream, ptr.MaxLength());
   1.117 +	ptr.Zero();
   1.118 +	ptr.Copy(*temp);
   1.119 +	delete temp;
   1.120 +	}
   1.121 +
   1.122 +void CLogFilter::ExternalizeL(RWriteStream& aStream) const
   1.123 +	{
   1.124 +	TBuf<KLogMaxDateLength> buf;  
   1.125 +	aStream << iEventType;
   1.126 +	aStream << iDurationType;
   1.127 +	aStream << iContact;
   1.128 +	aStream << *iRemoteParty;
   1.129 +	aStream << *iDirection;
   1.130 +	aStream << *iStatus;
   1.131 +	aStream << *iNumber;
   1.132 +	aStream << iNullFields;
   1.133 +	aStream << iFlags;
   1.134 +	if (iStartTime != TTime(0))
   1.135 +		iStartTime.FormatL(buf, LogUtils::DateFormatForLocale());
   1.136 +	aStream << buf;
   1.137 +	buf.FillZ();
   1.138 +	if (iEndTime != TTime(0))
   1.139 +		iEndTime.FormatL(buf, LogUtils::DateFormatForLocale());
   1.140 +	aStream << buf;
   1.141 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
   1.142 +	aStream << iSimId;
   1.143 +#endif
   1.144 +	}
   1.145 +
   1.146 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
   1.147 +
   1.148 +/**
   1.149 +Sets the short Id of the SIM card that will be used by the filter.
   1.150 +
   1.151 +@param aSimId SIM card short Id;  
   1.152 +*/
   1.153 +EXPORT_C void CLogFilter::SetSimId(TSimId aSimId)
   1.154 +	{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined
   1.155 +	iSimId = aSimId;
   1.156 +	}
   1.157 +
   1.158 +/**
   1.159 +Returns the short Id of the SIM card that is used by the filter.
   1.160 +
   1.161 +@return SIM card short Id;  
   1.162 +*/
   1.163 +EXPORT_C TSimId CLogFilter::SimId() const
   1.164 +	{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined
   1.165 +	return iSimId;
   1.166 +	}
   1.167 +
   1.168 +#else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
   1.169 +
   1.170 +#pragma BullseyeCoverage off
   1.171 +
   1.172 +/**
   1.173 +Not supported. 
   1.174 +*/
   1.175 +EXPORT_C void CLogFilter::SetSimId(TSimId)
   1.176 +	{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined
   1.177 +	__ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported));
   1.178 +	}
   1.179 +
   1.180 +/**
   1.181 +Not supported. 
   1.182 +*/
   1.183 +EXPORT_C TSimId CLogFilter::SimId() const
   1.184 +	{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined
   1.185 +	__ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported));
   1.186 +	return 0;
   1.187 +	}
   1.188 +
   1.189 +#pragma BullseyeCoverage on
   1.190 +
   1.191 +#endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
   1.192 +
   1.193 +//**********************************
   1.194 +// CLogFilterList
   1.195 +//**********************************
   1.196 +
   1.197 +/** Constructs a flat array of pointers to const CLogFilter objects. */
   1.198 +EXPORT_C CLogFilterList::CLogFilterList()
   1.199 +: CArrayPtrFlat<const CLogFilter>(KLogFilterListGranuality)
   1.200 +	{
   1.201 +	}
   1.202 +
   1.203 +/** Creates a copy of this set of event view filters.
   1.204 +
   1.205 +@return A pointer to the new copy of the set of event view filters. */
   1.206 +EXPORT_C CLogFilterList* CLogFilterList::CopyL() const
   1.207 +	{
   1.208 +	CLogFilterList* newList = CopyLC();
   1.209 +	CleanupStack::Pop();
   1.210 +	return newList;
   1.211 +	}
   1.212 +
   1.213 +/** Creates a copy of this set of event view filters and puts a pointer to the 
   1.214 +copy onto the cleanup stack.
   1.215 +
   1.216 +@return A pointer to the new copy of the set of event view filters. */
   1.217 +EXPORT_C CLogFilterList* CLogFilterList::CopyLC() const
   1.218 +	{
   1.219 +	CLogFilterList* newList = new(ELeave)CLogFilterList;
   1.220 +	CleanupStack::PushL(newList);
   1.221 +	if (Count())
   1.222 +		{
   1.223 +		newList->ResizeL(Count(), NULL);
   1.224 +		Mem::Copy(newList->Back(0), Back(0), Count() * sizeof(const CLogFilter*));	
   1.225 +		}
   1.226 +	return newList;
   1.227 +	}
   1.228 +
   1.229 +void CLogFilterList::InternalizeL(RReadStream& aStream)
   1.230 +	{
   1.231 +	ResetAndDestroy();
   1.232 +	TInt count;
   1.233 +	count = aStream.ReadInt32L();
   1.234 +	while(count--)
   1.235 +		{
   1.236 +		CLogFilter* filter = CLogFilter::NewL();
   1.237 +		CleanupStack::PushL(filter);
   1.238 +		filter->InternalizeL(aStream);
   1.239 +		AppendL(filter); 
   1.240 +		CleanupStack::Pop(filter);
   1.241 +		}
   1.242 +	}
   1.243 +
   1.244 +void CLogFilterList::ExternalizeL(RWriteStream& aStream) const
   1.245 +	{
   1.246 +	aStream.WriteInt32L(Count());	
   1.247 +	for(TInt index = 0; index < Count(); index++)
   1.248 +		{
   1.249 +		At(index)->ExternalizeL(aStream);
   1.250 +		}
   1.251 +	}