|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <logcli.h> |
|
17 #include <logwraplimits.h> |
|
18 #include "LogCliServShared.h" |
|
19 #include "logcntdef.h" |
|
20 #include "logclipanic.h" |
|
21 |
|
22 const TInt KLogFilterListGranuality = 10; |
|
23 |
|
24 //********************************** |
|
25 // CLogFilter |
|
26 //********************************** |
|
27 |
|
28 /** Creates a new filter object. |
|
29 |
|
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 |
|
32 of events in view. |
|
33 |
|
34 @return A pointer to the new event object. */ |
|
35 EXPORT_C CLogFilter* CLogFilter::NewL() |
|
36 { |
|
37 CLogFilter* self = new(ELeave)CLogFilter; |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(); // self |
|
41 return self; |
|
42 } |
|
43 |
|
44 CLogFilter::CLogFilter() |
|
45 : iDurationType(KLogNullDurationType), iContact(KLogNullContactId), iFlags(KLogNullFlags), |
|
46 iStartTime(TTime(0)), iEndTime(TTime(0)) |
|
47 { |
|
48 } |
|
49 |
|
50 void CLogFilter::ConstructL() |
|
51 { |
|
52 iRemoteParty = HBufC::NewL(KLogMaxRemotePartyLength); |
|
53 iDirection = HBufC::NewL(KLogMaxDirectionLength); |
|
54 iStatus = HBufC::NewL(KLogMaxStatusLength); |
|
55 iNumber = HBufC::NewL(KLogMaxNumberLength); |
|
56 } |
|
57 |
|
58 /** Frees all resource owned by the object prior to its destruction. */ |
|
59 EXPORT_C CLogFilter::~CLogFilter() |
|
60 { |
|
61 delete iRemoteParty; |
|
62 delete iDirection; |
|
63 delete iStatus; |
|
64 delete iNumber; |
|
65 } |
|
66 |
|
67 /** Makes a copy of a filter. |
|
68 |
|
69 @param aFilter The filter object to be copied. */ |
|
70 EXPORT_C void CLogFilter::Copy(const CLogFilter& aFilter) |
|
71 { |
|
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()); |
|
80 |
|
81 ClearFlags(KLogFlagsMask); |
|
82 SetFlags(aFilter.Flags()); |
|
83 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
84 SetSimId(aFilter.SimId()); |
|
85 #endif |
|
86 } |
|
87 |
|
88 void CLogFilter::InternalizeL(RReadStream& aStream) |
|
89 { |
|
90 TBuf<KLogMaxDateLength> buf; |
|
91 aStream >> iEventType; |
|
92 aStream >> iDurationType; |
|
93 aStream >> iContact; |
|
94 InternalizeBufL(aStream, iRemoteParty); |
|
95 InternalizeBufL(aStream, iDirection); |
|
96 InternalizeBufL(aStream, iStatus); |
|
97 InternalizeBufL(aStream, iNumber); |
|
98 aStream >> iNullFields; |
|
99 aStream >> iFlags; |
|
100 aStream >> buf; |
|
101 iStartTime.Parse(buf); |
|
102 buf.FillZ(); |
|
103 aStream >> buf; |
|
104 iEndTime.Parse(buf); |
|
105 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
106 aStream >> iSimId; |
|
107 #endif |
|
108 } |
|
109 |
|
110 void CLogFilter::InternalizeBufL(RReadStream& aStream, HBufC*& aDes) |
|
111 { |
|
112 TPtr ptr(aDes->Des()); |
|
113 HBufC* temp = HBufC::NewL(aStream, ptr.MaxLength()); |
|
114 ptr.Zero(); |
|
115 ptr.Copy(*temp); |
|
116 delete temp; |
|
117 } |
|
118 |
|
119 void CLogFilter::ExternalizeL(RWriteStream& aStream) const |
|
120 { |
|
121 TBuf<KLogMaxDateLength> buf; |
|
122 aStream << iEventType; |
|
123 aStream << iDurationType; |
|
124 aStream << iContact; |
|
125 aStream << *iRemoteParty; |
|
126 aStream << *iDirection; |
|
127 aStream << *iStatus; |
|
128 aStream << *iNumber; |
|
129 aStream << iNullFields; |
|
130 aStream << iFlags; |
|
131 if (iStartTime != TTime(0)) |
|
132 iStartTime.FormatL(buf, LogUtils::DateFormatForLocale()); |
|
133 aStream << buf; |
|
134 buf.FillZ(); |
|
135 if (iEndTime != TTime(0)) |
|
136 iEndTime.FormatL(buf, LogUtils::DateFormatForLocale()); |
|
137 aStream << buf; |
|
138 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
139 aStream << iSimId; |
|
140 #endif |
|
141 } |
|
142 |
|
143 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
144 |
|
145 /** |
|
146 Sets the short Id of the SIM card that will be used by the filter. |
|
147 |
|
148 @param aSimId SIM card short Id; |
|
149 */ |
|
150 EXPORT_C void CLogFilter::SetSimId(TSimId aSimId) |
|
151 {//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined |
|
152 iSimId = aSimId; |
|
153 } |
|
154 |
|
155 /** |
|
156 Returns the short Id of the SIM card that is used by the filter. |
|
157 |
|
158 @return SIM card short Id; |
|
159 */ |
|
160 EXPORT_C TSimId CLogFilter::SimId() const |
|
161 {//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined |
|
162 return iSimId; |
|
163 } |
|
164 |
|
165 #else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
166 |
|
167 #pragma BullseyeCoverage off |
|
168 |
|
169 /** |
|
170 Not supported. |
|
171 */ |
|
172 EXPORT_C void CLogFilter::SetSimId(TSimId) |
|
173 {//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined |
|
174 __ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported)); |
|
175 } |
|
176 |
|
177 /** |
|
178 Not supported. |
|
179 */ |
|
180 EXPORT_C TSimId CLogFilter::SimId() const |
|
181 {//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined |
|
182 __ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported)); |
|
183 return 0; |
|
184 } |
|
185 |
|
186 #pragma BullseyeCoverage on |
|
187 |
|
188 #endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM |
|
189 |
|
190 //********************************** |
|
191 // CLogFilterList |
|
192 //********************************** |
|
193 |
|
194 /** Constructs a flat array of pointers to const CLogFilter objects. */ |
|
195 EXPORT_C CLogFilterList::CLogFilterList() |
|
196 : CArrayPtrFlat<const CLogFilter>(KLogFilterListGranuality) |
|
197 { |
|
198 } |
|
199 |
|
200 /** Creates a copy of this set of event view filters. |
|
201 |
|
202 @return A pointer to the new copy of the set of event view filters. */ |
|
203 EXPORT_C CLogFilterList* CLogFilterList::CopyL() const |
|
204 { |
|
205 CLogFilterList* newList = CopyLC(); |
|
206 CleanupStack::Pop(); |
|
207 return newList; |
|
208 } |
|
209 |
|
210 /** Creates a copy of this set of event view filters and puts a pointer to the |
|
211 copy onto the cleanup stack. |
|
212 |
|
213 @return A pointer to the new copy of the set of event view filters. */ |
|
214 EXPORT_C CLogFilterList* CLogFilterList::CopyLC() const |
|
215 { |
|
216 CLogFilterList* newList = new(ELeave)CLogFilterList; |
|
217 CleanupStack::PushL(newList); |
|
218 if (Count()) |
|
219 { |
|
220 newList->ResizeL(Count(), NULL); |
|
221 Mem::Copy(newList->Back(0), Back(0), Count() * sizeof(const CLogFilter*)); |
|
222 } |
|
223 return newList; |
|
224 } |
|
225 |
|
226 void CLogFilterList::InternalizeL(RReadStream& aStream) |
|
227 { |
|
228 ResetAndDestroy(); |
|
229 TInt count; |
|
230 count = aStream.ReadInt32L(); |
|
231 while(count--) |
|
232 { |
|
233 CLogFilter* filter = CLogFilter::NewL(); |
|
234 CleanupStack::PushL(filter); |
|
235 filter->InternalizeL(aStream); |
|
236 AppendL(filter); |
|
237 CleanupStack::Pop(filter); |
|
238 } |
|
239 } |
|
240 |
|
241 void CLogFilterList::ExternalizeL(RWriteStream& aStream) const |
|
242 { |
|
243 aStream.WriteInt32L(Count()); |
|
244 for(TInt index = 0; index < Count(); index++) |
|
245 { |
|
246 At(index)->ExternalizeL(aStream); |
|
247 } |
|
248 } |