os/persistentdata/loggingservices/eventlogger/LogCli/src/LOGFILT.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <logcli.h>
sl@0
    17
#include <logwraplimits.h>
sl@0
    18
#include "LogCliServShared.h"
sl@0
    19
#include "logcntdef.h"
sl@0
    20
#include "logclipanic.h"
sl@0
    21
sl@0
    22
const TInt KLogFilterListGranuality = 10;
sl@0
    23
sl@0
    24
//**********************************
sl@0
    25
// CLogFilter
sl@0
    26
//**********************************
sl@0
    27
sl@0
    28
/** Creates a new filter object.
sl@0
    29
sl@0
    30
All fields in the new instance are initialised to default values, so that 
sl@0
    31
if none of the fields are changed, the filter has no effect on the selection 
sl@0
    32
of events in view.
sl@0
    33
sl@0
    34
@return A pointer to the new event object. */
sl@0
    35
EXPORT_C CLogFilter* CLogFilter::NewL()
sl@0
    36
	{
sl@0
    37
	CLogFilter* self = new(ELeave)CLogFilter;
sl@0
    38
	CleanupStack::PushL(self);
sl@0
    39
	self->ConstructL();
sl@0
    40
	CleanupStack::Pop(); // self
sl@0
    41
	return self;
sl@0
    42
	}
sl@0
    43
sl@0
    44
CLogFilter::CLogFilter()
sl@0
    45
: iDurationType(KLogNullDurationType), iContact(KLogNullContactId), iFlags(KLogNullFlags),
sl@0
    46
iStartTime(TTime(0)), iEndTime(TTime(0))
sl@0
    47
	{
sl@0
    48
	}
sl@0
    49
sl@0
    50
void CLogFilter::ConstructL()
sl@0
    51
	{
sl@0
    52
	iRemoteParty = HBufC::NewL(KLogMaxRemotePartyLength);
sl@0
    53
	iDirection = HBufC::NewL(KLogMaxDirectionLength);
sl@0
    54
	iStatus = HBufC::NewL(KLogMaxStatusLength);
sl@0
    55
	iNumber = HBufC::NewL(KLogMaxNumberLength);
sl@0
    56
	}
sl@0
    57
sl@0
    58
/** Frees all resource owned by the object prior to its destruction. */
sl@0
    59
EXPORT_C CLogFilter::~CLogFilter()
sl@0
    60
	{
sl@0
    61
	delete iRemoteParty;
sl@0
    62
	delete iDirection;
sl@0
    63
	delete iStatus;
sl@0
    64
	delete iNumber;
sl@0
    65
	}
sl@0
    66
sl@0
    67
/** Makes a copy of a filter.
sl@0
    68
sl@0
    69
@param aFilter The filter object to be copied. */
sl@0
    70
EXPORT_C void CLogFilter::Copy(const CLogFilter& aFilter)
sl@0
    71
	{
sl@0
    72
	SetEventType(aFilter.EventType());
sl@0
    73
	SetDurationType(aFilter.DurationType());
sl@0
    74
	SetContact(aFilter.Contact());
sl@0
    75
	SetRemoteParty(aFilter.RemoteParty());
sl@0
    76
	SetDirection(aFilter.Direction());
sl@0
    77
	SetStatus(aFilter.Status());
sl@0
    78
	SetNumber(aFilter.Number());
sl@0
    79
	SetNullFields(aFilter.NullFields());
sl@0
    80
sl@0
    81
	ClearFlags(KLogFlagsMask);
sl@0
    82
	SetFlags(aFilter.Flags());
sl@0
    83
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
sl@0
    84
	SetSimId(aFilter.SimId());
sl@0
    85
#endif
sl@0
    86
	}
sl@0
    87
sl@0
    88
void CLogFilter::InternalizeL(RReadStream& aStream)
sl@0
    89
	{
sl@0
    90
	TBuf<KLogMaxDateLength> buf;
sl@0
    91
	aStream >> iEventType;
sl@0
    92
	aStream >> iDurationType;
sl@0
    93
	aStream >> iContact;
sl@0
    94
	InternalizeBufL(aStream, iRemoteParty);
sl@0
    95
	InternalizeBufL(aStream, iDirection);
sl@0
    96
	InternalizeBufL(aStream, iStatus);
sl@0
    97
	InternalizeBufL(aStream, iNumber);
sl@0
    98
	aStream >> iNullFields;
sl@0
    99
	aStream >> iFlags;
sl@0
   100
	aStream >> buf;
sl@0
   101
	iStartTime.Parse(buf);
sl@0
   102
	buf.FillZ();
sl@0
   103
	aStream >> buf;
sl@0
   104
	iEndTime.Parse(buf);
sl@0
   105
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
sl@0
   106
	aStream >> iSimId;
sl@0
   107
#endif
sl@0
   108
	}
sl@0
   109
sl@0
   110
void CLogFilter::InternalizeBufL(RReadStream& aStream, HBufC*& aDes)
sl@0
   111
	{
sl@0
   112
	TPtr ptr(aDes->Des());
sl@0
   113
	HBufC* temp = HBufC::NewL(aStream, ptr.MaxLength());
sl@0
   114
	ptr.Zero();
sl@0
   115
	ptr.Copy(*temp);
sl@0
   116
	delete temp;
sl@0
   117
	}
sl@0
   118
sl@0
   119
void CLogFilter::ExternalizeL(RWriteStream& aStream) const
sl@0
   120
	{
sl@0
   121
	TBuf<KLogMaxDateLength> buf;  
sl@0
   122
	aStream << iEventType;
sl@0
   123
	aStream << iDurationType;
sl@0
   124
	aStream << iContact;
sl@0
   125
	aStream << *iRemoteParty;
sl@0
   126
	aStream << *iDirection;
sl@0
   127
	aStream << *iStatus;
sl@0
   128
	aStream << *iNumber;
sl@0
   129
	aStream << iNullFields;
sl@0
   130
	aStream << iFlags;
sl@0
   131
	if (iStartTime != TTime(0))
sl@0
   132
		iStartTime.FormatL(buf, LogUtils::DateFormatForLocale());
sl@0
   133
	aStream << buf;
sl@0
   134
	buf.FillZ();
sl@0
   135
	if (iEndTime != TTime(0))
sl@0
   136
		iEndTime.FormatL(buf, LogUtils::DateFormatForLocale());
sl@0
   137
	aStream << buf;
sl@0
   138
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
sl@0
   139
	aStream << iSimId;
sl@0
   140
#endif
sl@0
   141
	}
sl@0
   142
sl@0
   143
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
sl@0
   144
sl@0
   145
/**
sl@0
   146
Sets the short Id of the SIM card that will be used by the filter.
sl@0
   147
sl@0
   148
@param aSimId SIM card short Id;  
sl@0
   149
*/
sl@0
   150
EXPORT_C void CLogFilter::SetSimId(TSimId aSimId)
sl@0
   151
	{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined
sl@0
   152
	iSimId = aSimId;
sl@0
   153
	}
sl@0
   154
sl@0
   155
/**
sl@0
   156
Returns the short Id of the SIM card that is used by the filter.
sl@0
   157
sl@0
   158
@return SIM card short Id;  
sl@0
   159
*/
sl@0
   160
EXPORT_C TSimId CLogFilter::SimId() const
sl@0
   161
	{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined
sl@0
   162
	return iSimId;
sl@0
   163
	}
sl@0
   164
sl@0
   165
#else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
sl@0
   166
sl@0
   167
#pragma BullseyeCoverage off
sl@0
   168
sl@0
   169
/**
sl@0
   170
Not supported. 
sl@0
   171
*/
sl@0
   172
EXPORT_C void CLogFilter::SetSimId(TSimId)
sl@0
   173
	{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined
sl@0
   174
	__ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported));
sl@0
   175
	}
sl@0
   176
sl@0
   177
/**
sl@0
   178
Not supported. 
sl@0
   179
*/
sl@0
   180
EXPORT_C TSimId CLogFilter::SimId() const
sl@0
   181
	{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined
sl@0
   182
	__ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported));
sl@0
   183
	return 0;
sl@0
   184
	}
sl@0
   185
sl@0
   186
#pragma BullseyeCoverage on
sl@0
   187
sl@0
   188
#endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
sl@0
   189
sl@0
   190
//**********************************
sl@0
   191
// CLogFilterList
sl@0
   192
//**********************************
sl@0
   193
sl@0
   194
/** Constructs a flat array of pointers to const CLogFilter objects. */
sl@0
   195
EXPORT_C CLogFilterList::CLogFilterList()
sl@0
   196
: CArrayPtrFlat<const CLogFilter>(KLogFilterListGranuality)
sl@0
   197
	{
sl@0
   198
	}
sl@0
   199
sl@0
   200
/** Creates a copy of this set of event view filters.
sl@0
   201
sl@0
   202
@return A pointer to the new copy of the set of event view filters. */
sl@0
   203
EXPORT_C CLogFilterList* CLogFilterList::CopyL() const
sl@0
   204
	{
sl@0
   205
	CLogFilterList* newList = CopyLC();
sl@0
   206
	CleanupStack::Pop();
sl@0
   207
	return newList;
sl@0
   208
	}
sl@0
   209
sl@0
   210
/** Creates a copy of this set of event view filters and puts a pointer to the 
sl@0
   211
copy onto the cleanup stack.
sl@0
   212
sl@0
   213
@return A pointer to the new copy of the set of event view filters. */
sl@0
   214
EXPORT_C CLogFilterList* CLogFilterList::CopyLC() const
sl@0
   215
	{
sl@0
   216
	CLogFilterList* newList = new(ELeave)CLogFilterList;
sl@0
   217
	CleanupStack::PushL(newList);
sl@0
   218
	if (Count())
sl@0
   219
		{
sl@0
   220
		newList->ResizeL(Count(), NULL);
sl@0
   221
		Mem::Copy(newList->Back(0), Back(0), Count() * sizeof(const CLogFilter*));	
sl@0
   222
		}
sl@0
   223
	return newList;
sl@0
   224
	}
sl@0
   225
sl@0
   226
void CLogFilterList::InternalizeL(RReadStream& aStream)
sl@0
   227
	{
sl@0
   228
	ResetAndDestroy();
sl@0
   229
	TInt count;
sl@0
   230
	count = aStream.ReadInt32L();
sl@0
   231
	while(count--)
sl@0
   232
		{
sl@0
   233
		CLogFilter* filter = CLogFilter::NewL();
sl@0
   234
		CleanupStack::PushL(filter);
sl@0
   235
		filter->InternalizeL(aStream);
sl@0
   236
		AppendL(filter); 
sl@0
   237
		CleanupStack::Pop(filter);
sl@0
   238
		}
sl@0
   239
	}
sl@0
   240
sl@0
   241
void CLogFilterList::ExternalizeL(RWriteStream& aStream) const
sl@0
   242
	{
sl@0
   243
	aStream.WriteInt32L(Count());	
sl@0
   244
	for(TInt index = 0; index < Count(); index++)
sl@0
   245
		{
sl@0
   246
		At(index)->ExternalizeL(aStream);
sl@0
   247
		}
sl@0
   248
	}