|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Main list reader |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
22 #include <logengevents.h> |
|
23 #include <logfilterandeventconstants.hrh> |
|
24 #endif |
|
25 #include <logview.h> |
|
26 #include "CLogsMainReader.h" |
|
27 #include "MLogsObserver.h" |
|
28 #include "MLogsEvent.h" |
|
29 #include "MLogsReaderConfig.h" |
|
30 #include "LogsApiConsts.h" //additional event uids |
|
31 #include "MLogsEventArray.h" |
|
32 // CONSTANTS |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CLogsMainReader::NewL |
|
36 // ---------------------------------------------------------------------------- |
|
37 // |
|
38 CLogsMainReader* CLogsMainReader::NewL( |
|
39 RFs& aFsSession, |
|
40 MLogsEventArray& aEventArray, |
|
41 TLogsEventStrings& aStrings, |
|
42 TLogsModel aModelId, |
|
43 MLogsObserver* aObserver, |
|
44 CLogsEngine* aLogsEngineRef ) |
|
45 { |
|
46 CLogsMainReader* self = new (ELeave) CLogsMainReader |
|
47 ( aFsSession |
|
48 , aEventArray |
|
49 , aStrings |
|
50 , aModelId |
|
51 , aObserver |
|
52 , aLogsEngineRef |
|
53 ); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CLogsMainReader::CLogsMainReader |
|
62 // ---------------------------------------------------------------------------- |
|
63 // |
|
64 CLogsMainReader::CLogsMainReader( |
|
65 RFs& aFsSession, |
|
66 MLogsEventArray& aEventArray, |
|
67 TLogsEventStrings& aStrings, |
|
68 TLogsModel aModelId, |
|
69 MLogsObserver* aObserver, |
|
70 CLogsEngine* aLogsEngineRef ) : |
|
71 CLogsBaseReader( |
|
72 aFsSession, |
|
73 aEventArray, |
|
74 aStrings, |
|
75 aModelId, |
|
76 aObserver, |
|
77 aLogsEngineRef ) |
|
78 { |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CLogsMainReader::~CLogsMainReader |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CLogsMainReader::~CLogsMainReader() |
|
86 { |
|
87 Cancel(); |
|
88 delete iLogViewEvent; |
|
89 |
|
90 if( iFilterList ) |
|
91 { |
|
92 iFilterList->ResetAndDestroy(); |
|
93 delete iFilterList; |
|
94 } |
|
95 } |
|
96 |
|
97 // ---------------------------------------------------------------------------- |
|
98 // CLogsMainReader::DoCancel |
|
99 // ---------------------------------------------------------------------------- |
|
100 // |
|
101 void CLogsMainReader::DoCancel() |
|
102 { |
|
103 CLogsBaseReader::DoCancel(); |
|
104 iLogViewEvent->Cancel(); |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CLogsMainReader::ConstructL |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 void CLogsMainReader::ConstructL() |
|
112 { |
|
113 BaseConstructL(); |
|
114 iLogClientRef->SetGlobalChangeObserverL( this ); |
|
115 iLogViewEvent = CLogViewEvent::NewL( *iLogClientRef, *this ); |
|
116 CActiveScheduler::Add( this ); |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CLogsMainReader::DoNextL |
|
121 // ---------------------------------------------------------------------------- |
|
122 // |
|
123 TBool CLogsMainReader::DoNextL() |
|
124 { |
|
125 TBool rc( EFalse ); |
|
126 |
|
127 switch( iPhase ) |
|
128 { |
|
129 case ERead: |
|
130 rc = iLogViewEvent->NextL( iStatus ); |
|
131 break; |
|
132 |
|
133 case EFilter: |
|
134 rc = iLogViewEvent->FirstL( iStatus ); |
|
135 if( rc ) |
|
136 { |
|
137 iPhase = ERead; |
|
138 |
|
139 } |
|
140 else |
|
141 { |
|
142 iPhase = EDone; |
|
143 iObserver->StateChangedL( this ); |
|
144 } |
|
145 break; |
|
146 |
|
147 default: |
|
148 break; |
|
149 } |
|
150 |
|
151 return rc; |
|
152 } |
|
153 |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CLogsMainReader::SetOneFilterLC |
|
157 // ---------------------------------------------------------------------------- |
|
158 // |
|
159 CLogFilter* CLogsMainReader::SetOneFilterLC( TUid aFilterType ) |
|
160 { |
|
161 CLogFilter* filter = CLogFilter::NewL(); |
|
162 CleanupStack::PushL( filter ); |
|
163 filter->SetEventType( aFilterType ); |
|
164 |
|
165 //For message type events we only include events that have already been |
|
166 //searched for remoty party information (CLogsSMSEventUpdater::RunL) |
|
167 if( aFilterType == KLogShortMessageEventTypeUid || |
|
168 aFilterType == KLogsEngMmsEventTypeUid ) |
|
169 { |
|
170 filter->SetFlags( KLogEventContactSearched ); |
|
171 } |
|
172 return filter; |
|
173 } |
|
174 |
|
175 |
|
176 // ---------------------------------------------------------------------------- |
|
177 // CLogsMainReader::SetOneFilterLC |
|
178 // ---------------------------------------------------------------------------- |
|
179 // |
|
180 CLogFilter* CLogsMainReader::SetOneFilterLC( TLogString& aDirection ) |
|
181 { |
|
182 CLogFilter* filter = CLogFilter::NewL(); |
|
183 CleanupStack::PushL( filter ); |
|
184 filter->SetDirection( aDirection ); |
|
185 return filter; |
|
186 } |
|
187 |
|
188 // ---------------------------------------------------------------------------- |
|
189 // CLogsMainReader::SetOneFilterLC |
|
190 // ---------------------------------------------------------------------------- |
|
191 // |
|
192 CLogFilter* CLogsMainReader::SetOneFilterLC( |
|
193 const TDesC* aNumber, |
|
194 const TDesC* aName ) |
|
195 { |
|
196 CLogFilter* filter = CLogFilter::NewL(); |
|
197 CleanupStack::PushL( filter ); |
|
198 |
|
199 if( aNumber->Length() > 0 ) |
|
200 { |
|
201 filter->SetNumber( *aNumber ); |
|
202 } |
|
203 else |
|
204 { |
|
205 filter->SetNullFields( ELogNumberField ); |
|
206 } |
|
207 |
|
208 if( aName->Length() > 0 ) |
|
209 { |
|
210 filter->SetRemoteParty( *aName ); |
|
211 } |
|
212 else |
|
213 { |
|
214 filter->SetNullFields( ELogRemotePartyField ); |
|
215 } |
|
216 |
|
217 return filter; |
|
218 } |
|
219 |
|
220 |
|
221 |
|
222 // ---------------------------------------------------------------------------- |
|
223 // CLogsMainReader::SetFilterL |
|
224 // ---------------------------------------------------------------------------- |
|
225 // |
|
226 void CLogsMainReader::SetFilterL( |
|
227 const TLogsFilter aFilter, |
|
228 const TDesC* aNumber, |
|
229 const TDesC* aName ) |
|
230 { |
|
231 //We first empty the event array so that listing new filtered entries in the UI will always start from |
|
232 //beginning of an empty list without any old entries. This is because user may very quickly scroll to end |
|
233 //of list in UI by scrolling up in the top of the list. This may cause problems because old lines will be |
|
234 //soon deleted or replaced by new filtered lines. |
|
235 iEventArray.Reset(); |
|
236 |
|
237 if( iFilterList ) |
|
238 { |
|
239 iFilterList->ResetAndDestroy(); |
|
240 delete iFilterList; |
|
241 iFilterList = NULL; |
|
242 } |
|
243 |
|
244 iFilterList = new ( ELeave ) CLogFilterList; |
|
245 |
|
246 switch( aFilter ) |
|
247 { |
|
248 case ELogsFilterVoice: |
|
249 iFilterList->AppendL( SetOneFilterLC( KLogCallEventTypeUid ) ); |
|
250 CleanupStack::Pop(); |
|
251 //Show also Poc info events here |
|
252 iFilterList->AppendL( SetOneFilterLC( KLogsEngPocInfoEventTypeUid ) ); |
|
253 CleanupStack::Pop(); |
|
254 break; |
|
255 |
|
256 case ELogsFilterData: |
|
257 iFilterList->AppendL( SetOneFilterLC( KLogDataEventTypeUid ) ); |
|
258 CleanupStack::Pop(); |
|
259 break; |
|
260 |
|
261 case ELogsFilterMessages: |
|
262 iFilterList->AppendL( SetOneFilterLC( KLogShortMessageEventTypeUid ) ); |
|
263 CleanupStack::Pop(); |
|
264 // Mms events not (yet) logged to log db: |
|
265 // iFilterList->AppendL( SetOneFilterLC( KLogsEngMmsEventTypeUid ) ); |
|
266 // CleanupStack::Pop(); |
|
267 break; |
|
268 |
|
269 case ELogsFilterPacket: |
|
270 iFilterList->AppendL( SetOneFilterLC( KLogPacketDataEventTypeUid ) ); |
|
271 CleanupStack::Pop(); |
|
272 break; |
|
273 |
|
274 case ELogsFilterWlan: |
|
275 iFilterList->AppendL( SetOneFilterLC( KLogsEngWlanEventTypeUid ) ); |
|
276 CleanupStack::Pop(); |
|
277 break; |
|
278 |
|
279 case ELogsFilterPerson: |
|
280 iFilterList->AppendL( SetOneFilterLC( aNumber, aName ) ); |
|
281 CleanupStack::Pop(); |
|
282 break; |
|
283 |
|
284 case ELogsFilterIncoming: |
|
285 iFilterList->AppendL( SetOneFilterLC( iStrings.iInDirection ) ); |
|
286 CleanupStack::Pop(); |
|
287 iFilterList->AppendL( SetOneFilterLC( iStrings.iInDirectionAlt ) ); |
|
288 CleanupStack::Pop(); |
|
289 break; |
|
290 |
|
291 case ELogsFilterOutgoing: |
|
292 iFilterList->AppendL( SetOneFilterLC( iStrings.iOutDirection ) ); |
|
293 CleanupStack::Pop(); |
|
294 iFilterList->AppendL( SetOneFilterLC( iStrings.iOutDirectionAlt ) ); |
|
295 CleanupStack::Pop(); |
|
296 break; |
|
297 |
|
298 case ELogsFilterAllComms: |
|
299 iFilterList->AppendL( SetOneFilterLC( KLogShortMessageEventTypeUid ) ); |
|
300 CleanupStack::Pop(); |
|
301 // Mms events not (yet) logged to log db: |
|
302 // iFilterList->AppendL( SetOneFilterLC( KLogsEngMmsEventTypeUid ) ); |
|
303 // CleanupStack::Pop(); |
|
304 iFilterList->AppendL( SetOneFilterLC( KLogCallEventTypeUid ) ); |
|
305 CleanupStack::Pop(); |
|
306 iFilterList->AppendL( SetOneFilterLC( KLogDataEventTypeUid ) ); |
|
307 CleanupStack::Pop(); |
|
308 iFilterList->AppendL( SetOneFilterLC( KLogFaxEventTypeUid ) ); |
|
309 CleanupStack::Pop(); |
|
310 iFilterList->AppendL( SetOneFilterLC( KLogPacketDataEventTypeUid ) ); |
|
311 CleanupStack::Pop(); |
|
312 iFilterList->AppendL( SetOneFilterLC( KLogsEngWlanEventTypeUid ) ); |
|
313 CleanupStack::Pop(); |
|
314 iFilterList->AppendL( SetOneFilterLC( KLogsEngPocInfoEventTypeUid ) ); |
|
315 CleanupStack::Pop(); |
|
316 break; |
|
317 |
|
318 default: |
|
319 break; |
|
320 } |
|
321 } |
|
322 |
|
323 |
|
324 // ---------------------------------------------------------------------------- |
|
325 // CLogsMainReader::Stop |
|
326 // ---------------------------------------------------------------------------- |
|
327 // |
|
328 void CLogsMainReader::Stop() |
|
329 { |
|
330 Cancel(); |
|
331 } |
|
332 |
|
333 // ---------------------------------------------------------------------------- |
|
334 // CLogsMainReader::StartL |
|
335 // ---------------------------------------------------------------------------- |
|
336 // |
|
337 void CLogsMainReader::StartL() |
|
338 { |
|
339 iIndex = 0; |
|
340 Cancel(); |
|
341 iDirty = EFalse; |
|
342 iInterrupted = EFalse; |
|
343 |
|
344 TBool rc( EFalse ); |
|
345 |
|
346 if( ! iFilterList ) |
|
347 { |
|
348 // opened first time |
|
349 SetFilterL( ELogsFilterAllComms ); |
|
350 } |
|
351 |
|
352 if( iFilterList ) |
|
353 { |
|
354 TRAPD( err |
|
355 , rc = iLogViewEvent->SetFilterParseFilterByFilterL |
|
356 ( *iFilterList |
|
357 , iStatus |
|
358 ) |
|
359 ); |
|
360 if( err == KErrAccessDenied ) |
|
361 { |
|
362 iDirty = ETrue; |
|
363 return; |
|
364 } |
|
365 User::LeaveIfError(err); |
|
366 } |
|
367 |
|
368 if( rc ) |
|
369 { |
|
370 iPhase = EFilter; |
|
371 iState = EStateInitializing; |
|
372 SetActive(); |
|
373 } |
|
374 else if( iObserver ) |
|
375 { |
|
376 iEventArray.Reset(); |
|
377 iPhase = EDone; |
|
378 iState = EStateFinished; |
|
379 iObserver->StateChangedL( this ); |
|
380 } |
|
381 } |
|
382 |
|
383 // ---------------------------------------------------------------------------- |
|
384 // CLogsMainReader::ConfigureL |
|
385 // ---------------------------------------------------------------------------- |
|
386 // |
|
387 void CLogsMainReader::ConfigureL( const MLogsReaderConfig* aConfig ) |
|
388 { |
|
389 SetFilterL |
|
390 ( aConfig->Filter() |
|
391 , &aConfig->Number() |
|
392 , &aConfig->RemoteParty() |
|
393 ); |
|
394 } |
|
395 |
|
396 |
|
397 // ---------------------------------------------------------------------------- |
|
398 // CLogsMainReader::ViewCountL |
|
399 // ---------------------------------------------------------------------------- |
|
400 // |
|
401 TInt CLogsMainReader::ViewCountL() const |
|
402 { |
|
403 return iLogViewEvent->CountL(); |
|
404 } |
|
405 |
|
406 |
|
407 // ---------------------------------------------------------------------------- |
|
408 // CLogsMainReader::Event |
|
409 // ---------------------------------------------------------------------------- |
|
410 // |
|
411 CLogEvent& CLogsMainReader::Event() const |
|
412 { |
|
413 //The RVCT compiler provides warnings "type qualifier on return type is meaningless" |
|
414 //for functions that return const values. In order to avoid these numerous warnings and |
|
415 //const cascading, the CLogEvent is const_casted here. |
|
416 return const_cast<CLogEvent&>( iLogViewEvent->Event() ); |
|
417 } |
|
418 |
|
419 // ---------------------------------------------------------------------------- |
|
420 // CLogsMainReader::ConstructEventL |
|
421 // ---------------------------------------------------------------------------- |
|
422 // |
|
423 void CLogsMainReader::ConstructEventL( |
|
424 MLogsEvent& aDest, |
|
425 const CLogEvent& aSource ) |
|
426 { |
|
427 BaseConstructEventL( aDest, aSource ); |
|
428 } |
|
429 |
|
430 |
|
431 // ---------------------------------------------------------------------------- |
|
432 // CLogsMainReader::HandleLogClientChangeEventL |
|
433 // |
|
434 // Called by Log Database engine when it notifies a change in database (e.g. |
|
435 // Log database cleared) |
|
436 // ---------------------------------------------------------------------------- |
|
437 // |
|
438 void CLogsMainReader::HandleLogClientChangeEventL( |
|
439 TUid aChangeType, |
|
440 TInt /*aChangeParam1*/, |
|
441 TInt /*aChangeParam2*/, |
|
442 TInt /*aChangeParam3*/ ) |
|
443 { |
|
444 if( aChangeType == KLogClientChangeEventLogCleared ) |
|
445 { |
|
446 HandleViewChangeL(); |
|
447 } |
|
448 } |