Update contrib.
1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <logwraplimits.h>
18 #include "LogCliServShared.h"
19 #include "logcntdef.h"
20 #include "logclipanic.h"
22 const TInt KLogFilterListGranuality = 10;
24 //**********************************
26 //**********************************
28 /** Creates a new filter object.
30 All fields in the new instance are initialised to default values, so that
31 if none of the fields are changed, the filter has no effect on the selection
34 @return A pointer to the new event object. */
35 EXPORT_C CLogFilter* CLogFilter::NewL()
37 CLogFilter* self = new(ELeave)CLogFilter;
38 CleanupStack::PushL(self);
40 CleanupStack::Pop(); // self
44 CLogFilter::CLogFilter()
45 : iDurationType(KLogNullDurationType), iContact(KLogNullContactId), iFlags(KLogNullFlags),
46 iStartTime(TTime(0)), iEndTime(TTime(0))
50 void CLogFilter::ConstructL()
52 iRemoteParty = HBufC::NewL(KLogMaxRemotePartyLength);
53 iDirection = HBufC::NewL(KLogMaxDirectionLength);
54 iStatus = HBufC::NewL(KLogMaxStatusLength);
55 iNumber = HBufC::NewL(KLogMaxNumberLength);
58 /** Frees all resource owned by the object prior to its destruction. */
59 EXPORT_C CLogFilter::~CLogFilter()
67 /** Makes a copy of a filter.
69 @param aFilter The filter object to be copied. */
70 EXPORT_C void CLogFilter::Copy(const CLogFilter& aFilter)
72 SetEventType(aFilter.EventType());
73 SetDurationType(aFilter.DurationType());
74 SetContact(aFilter.Contact());
75 SetRemoteParty(aFilter.RemoteParty());
76 SetDirection(aFilter.Direction());
77 SetStatus(aFilter.Status());
78 SetNumber(aFilter.Number());
79 SetNullFields(aFilter.NullFields());
81 ClearFlags(KLogFlagsMask);
82 SetFlags(aFilter.Flags());
83 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
84 SetSimId(aFilter.SimId());
88 void CLogFilter::InternalizeL(RReadStream& aStream)
90 TBuf<KLogMaxDateLength> buf;
91 aStream >> iEventType;
92 aStream >> iDurationType;
94 InternalizeBufL(aStream, iRemoteParty);
95 InternalizeBufL(aStream, iDirection);
96 InternalizeBufL(aStream, iStatus);
97 InternalizeBufL(aStream, iNumber);
98 aStream >> iNullFields;
101 iStartTime.Parse(buf);
105 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
110 void CLogFilter::InternalizeBufL(RReadStream& aStream, HBufC*& aDes)
112 TPtr ptr(aDes->Des());
113 HBufC* temp = HBufC::NewL(aStream, ptr.MaxLength());
119 void CLogFilter::ExternalizeL(RWriteStream& aStream) const
121 TBuf<KLogMaxDateLength> buf;
122 aStream << iEventType;
123 aStream << iDurationType;
125 aStream << *iRemoteParty;
126 aStream << *iDirection;
129 aStream << iNullFields;
131 if (iStartTime != TTime(0))
132 iStartTime.FormatL(buf, LogUtils::DateFormatForLocale());
135 if (iEndTime != TTime(0))
136 iEndTime.FormatL(buf, LogUtils::DateFormatForLocale());
138 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
143 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
146 Sets the short Id of the SIM card that will be used by the filter.
148 @param aSimId SIM card short Id;
150 EXPORT_C void CLogFilter::SetSimId(TSimId aSimId)
151 {//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined
156 Returns the short Id of the SIM card that is used by the filter.
158 @return SIM card short Id;
160 EXPORT_C TSimId CLogFilter::SimId() const
161 {//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined
165 #else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
167 #pragma BullseyeCoverage off
172 EXPORT_C void CLogFilter::SetSimId(TSimId)
173 {//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined
174 __ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported));
180 EXPORT_C TSimId CLogFilter::SimId() const
181 {//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined
182 __ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported));
186 #pragma BullseyeCoverage on
188 #endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
190 //**********************************
192 //**********************************
194 /** Constructs a flat array of pointers to const CLogFilter objects. */
195 EXPORT_C CLogFilterList::CLogFilterList()
196 : CArrayPtrFlat<const CLogFilter>(KLogFilterListGranuality)
200 /** Creates a copy of this set of event view filters.
202 @return A pointer to the new copy of the set of event view filters. */
203 EXPORT_C CLogFilterList* CLogFilterList::CopyL() const
205 CLogFilterList* newList = CopyLC();
210 /** Creates a copy of this set of event view filters and puts a pointer to the
211 copy onto the cleanup stack.
213 @return A pointer to the new copy of the set of event view filters. */
214 EXPORT_C CLogFilterList* CLogFilterList::CopyLC() const
216 CLogFilterList* newList = new(ELeave)CLogFilterList;
217 CleanupStack::PushL(newList);
220 newList->ResizeL(Count(), NULL);
221 Mem::Copy(newList->Back(0), Back(0), Count() * sizeof(const CLogFilter*));
226 void CLogFilterList::InternalizeL(RReadStream& aStream)
230 count = aStream.ReadInt32L();
233 CLogFilter* filter = CLogFilter::NewL();
234 CleanupStack::PushL(filter);
235 filter->InternalizeL(aStream);
237 CleanupStack::Pop(filter);
241 void CLogFilterList::ExternalizeL(RWriteStream& aStream) const
243 aStream.WriteInt32L(Count());
244 for(TInt index = 0; index < Count(); index++)
246 At(index)->ExternalizeL(aStream);