|
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 * Implements interface for Logs event |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <logwrap.hrh> |
|
22 #include <AiwPoCParameters.h> //EPoCAdhocDialoutGroupMO etc... |
|
23 #include <CPhCltEmergencyCall.h> |
|
24 |
|
25 #include "CLogsEvent.h" |
|
26 #include "CLogsEventData.h" |
|
27 #include "LogsEngConsts.h" |
|
28 #include "LogsApiConsts.h" //Additional event UIDs |
|
29 |
|
30 // CONSTANTS |
|
31 const TInt KMaxDuplicates = 99; |
|
32 |
|
33 #ifdef _DEBUG |
|
34 _LIT(KPanicMsg,"CLogsEvent"); |
|
35 #endif |
|
36 |
|
37 |
|
38 // ---------------------------------------------------------------------------- |
|
39 // CLogsEvent::NewLC |
|
40 // ---------------------------------------------------------------------------- |
|
41 // |
|
42 CLogsEvent* CLogsEvent::NewLC() |
|
43 { |
|
44 CLogsEvent* self = new (ELeave) CLogsEvent; |
|
45 CleanupStack::PushL( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ---------------------------------------------------------------------------- |
|
50 // CLogsEvent::CLogsEvent |
|
51 // ---------------------------------------------------------------------------- |
|
52 // |
|
53 CLogsEvent::CLogsEvent() |
|
54 { |
|
55 iRemoteParty = 0; |
|
56 iNumber = 0; |
|
57 iLogsEventData = 0; |
|
58 iRingDuration = 0; |
|
59 iNumberFieldType = -1; |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CLogsEvent::~CLogsEvent |
|
64 // ---------------------------------------------------------------------------- |
|
65 // |
|
66 CLogsEvent::~CLogsEvent() |
|
67 { |
|
68 delete iRemoteParty; |
|
69 delete iNumber; |
|
70 delete iLogsEventData; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CLogsEvent::InitializeEventL |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 void CLogsEvent::InitializeEventL( |
|
78 const CLogEvent& aSource, |
|
79 TLogsEventStrings aStrings, |
|
80 TLogsModel aModel ) |
|
81 { |
|
82 delete iRemoteParty; |
|
83 iRemoteParty = 0; |
|
84 delete iNumber; |
|
85 iNumber = 0; |
|
86 |
|
87 delete iLogsEventData; |
|
88 iLogsEventData = 0; |
|
89 |
|
90 SetDuplicates( 0 ); |
|
91 SetDirection( EDirUndefined ); |
|
92 SetEventType( ETypeUsual ); |
|
93 SetALS(EFalse); |
|
94 SetNumberFieldType(-1); |
|
95 |
|
96 //For SMS'es part data is packed into data field (by sms stack), so in this case there is no |
|
97 //need to try to parse S60 specific data from it). Later this parsing can be move here from |
|
98 TBool readMessageParts = ( |
|
99 aSource.EventType() == KLogShortMessageEventTypeUid || |
|
100 aSource.EventType() == KLogsEngMmsEventTypeUid ); |
|
101 |
|
102 MLogsEventData* logsEventData = CLogsEventData::NewL( aSource.Data(), readMessageParts ) ; |
|
103 SetLogsEventData( logsEventData ); //Ownership transferred to this object |
|
104 |
|
105 // TIME NOT needed in event list view (skip to optimise performance of event list view) |
|
106 if( aModel != ELogsMainModel ) |
|
107 { |
|
108 TTime universal; |
|
109 TTime home; |
|
110 TTimeIntervalMinutes interval; |
|
111 |
|
112 universal.UniversalTime(); |
|
113 home.HomeTime(); |
|
114 TInt err = home.MinutesFrom( universal, interval ); |
|
115 |
|
116 if( err ) |
|
117 { |
|
118 SetTime( aSource.Time() ); |
|
119 } |
|
120 else |
|
121 { |
|
122 SetTime( aSource.Time() + interval ); |
|
123 } |
|
124 } |
|
125 else |
|
126 { |
|
127 iTimeSet = EFalse; |
|
128 } |
|
129 |
|
130 // LOG ID |
|
131 SetLogId( aSource.Id() ); |
|
132 |
|
133 // DIRECTION |
|
134 if( aSource.Direction() == aStrings.iInDirection || |
|
135 aSource.Direction() == aStrings.iInDirectionAlt ) |
|
136 { |
|
137 SetDirection( EDirIn ); |
|
138 } |
|
139 else if( aSource.Direction() == aStrings.iOutDirection || |
|
140 aSource.Direction() == aStrings.iOutDirectionAlt ) |
|
141 { |
|
142 SetDirection( EDirOut ); |
|
143 } |
|
144 else if( aSource.Direction() == aStrings.iMissedDirection ) |
|
145 { |
|
146 SetDirection( EDirMissed ); |
|
147 } |
|
148 |
|
149 // UID |
|
150 SetEventUid( aSource.EventType() ); |
|
151 |
|
152 // EVENT TYPE |
|
153 TUid uid = aSource.EventType(); |
|
154 |
|
155 // Private, unknown or payphone call |
|
156 if( aSource.RemoteParty().Length() > 0 ) |
|
157 { |
|
158 // if "Unknown" in remote party and no number/url, type of event is unknown |
|
159 if( aSource.RemoteParty() == aStrings.iUnKnownNumber && |
|
160 aSource.Number().Length() == 0 && |
|
161 LogsEventData()->Url().Length() == 0 ) |
|
162 { |
|
163 SetEventType( ETypeUnknown ); |
|
164 } |
|
165 // if "Private" in remote party and no number/url, type of event is private |
|
166 else if( aSource.RemoteParty() == KLogsPrivateText && |
|
167 aSource.Number().Length() == 0 && |
|
168 LogsEventData()->Url().Length() == 0 ) //"Private" LogsEngConsts.h |
|
169 { |
|
170 SetEventType( ETypePrivate ); |
|
171 } |
|
172 // if "Payphone" in remote party and no number/url, type of event is payphone |
|
173 else if( aSource.RemoteParty() == KLogsPayphoneText && |
|
174 aSource.Number().Length() == 0 && |
|
175 LogsEventData()->Url().Length() == 0 ) //"Payphone" LogsEngConsts.h |
|
176 { |
|
177 SetEventType( ETypePayphone ); |
|
178 } |
|
179 } |
|
180 // Poc group call |
|
181 else if( LogsEventData()->PoC() && //EventData initialised already (above), so we can use dest here |
|
182 ( TPoCOperationTypeId( LogsEventData()->Type() ) == EPoCAdhocDialoutGroupMO || //See TPoCOperationTypeId in |
|
183 TPoCOperationTypeId( LogsEventData()->Type() ) == EPoCAdhocDialoutGroupMT || //AiwPoCParameters.h |
|
184 TPoCOperationTypeId( LogsEventData()->Type() ) == EPoCPredefDialoutGroupMO || |
|
185 TPoCOperationTypeId( LogsEventData()->Type() ) == EPoCPredefDialoutGroupMT ) ) |
|
186 //Dialin groups (EPoCDialinGroupMO) are NOT group calls |
|
187 { |
|
188 SetEventType( ETypePoCGroupCall ); |
|
189 } |
|
190 // SAT event (SIM application toolkit) |
|
191 else if( ( uid == KLogCallEventTypeUid || |
|
192 uid == KLogDataEventTypeUid || |
|
193 uid == KLogShortMessageEventTypeUid ) && |
|
194 aSource.Number().Length() == 0 && |
|
195 LogsEventData()->Url().Length() == 0 && //Url set above so we can use it here: If URL, |
|
196 // then not SAT event but normal Voip or PoC call |
|
197 ( aSource.Direction() == aStrings.iOutDirection || |
|
198 aSource.Direction() == aStrings.iOutDirectionAlt ) ) |
|
199 { |
|
200 SetEventType( ETypeSAT ); |
|
201 } |
|
202 // Fallback in case entry wrongly written (is unknown but no "unknown" in remote party) |
|
203 else if ( ( aSource.RemoteParty().Length() == 0 ) && |
|
204 ( aSource.Number().Length() == 0 ) && |
|
205 LogsEventData()->Url().Length() == 0 ) //Url set above so we can use it here |
|
206 { |
|
207 SetEventType( ETypeUnknown ); |
|
208 } |
|
209 |
|
210 // Emergency call. |
|
211 if( aSource.Number().Length() > 0 ) |
|
212 { |
|
213 if( IsEmergencyNumberL( aSource.Number()) ) // The new Emergency call API tells this is an emergency number |
|
214 { |
|
215 SetEventType( ETypeEmerg ); |
|
216 } |
|
217 } |
|
218 |
|
219 // NUMBER |
|
220 if( EventType() == ETypeUsual || EventType() == ETypeEmerg ) |
|
221 { |
|
222 if( aSource.Number().Length() ) |
|
223 { |
|
224 SetNumber( aSource.Number().AllocL() ); |
|
225 } |
|
226 } |
|
227 |
|
228 // REMOTE PARTY |
|
229 if( EventType() == ETypeUsual || EventType() == ETypePoCGroupCall ) |
|
230 { |
|
231 if( aSource.RemoteParty().Length() ) |
|
232 { |
|
233 SetRemoteParty( aSource.RemoteParty().AllocL() ); |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 //NUMBER FIELD TYEP |
|
239 if( EventType() == ETypeUsual ) |
|
240 { |
|
241 if( aSource.Subject().Length() ) |
|
242 { |
|
243 TLex lex( aSource.Subject() ); |
|
244 TInt tmp; |
|
245 TInt err = lex.Val( tmp ); |
|
246 if( KErrNone == err ) |
|
247 { |
|
248 SetNumberFieldType( tmp ); |
|
249 } |
|
250 } |
|
251 } |
|
252 |
|
253 // Set ALS on/off. A logical AND of KLogEventALS and the event flags passed in. |
|
254 SetALS( (aSource.Flags() & KLogEventALS ) ); |
|
255 |
|
256 // We set iIsRead on/off according to flags for indicate new missed calls feature. |
|
257 // Used in missed calls view only. |
|
258 if (aSource.Direction() == aStrings.iMissedDirection) |
|
259 { |
|
260 // A logical AND of KLogEventRead and the event flags passed in. |
|
261 SetIsRead(aSource.Flags() & KLogEventRead); |
|
262 } |
|
263 else // Otherwise set to already read |
|
264 { // so dialled and received views |
|
265 SetIsRead(ETrue); // wont show the icon |
|
266 } |
|
267 |
|
268 //For ring duation feature |
|
269 if ( aSource.Direction() == aStrings.iMissedDirection ) |
|
270 { |
|
271 SetDirection( EDirMissed ); |
|
272 SetRingDuration( aSource.Duration() ); |
|
273 } |
|
274 } |
|
275 |
|
276 |
|
277 // ---------------------------------------------------------------------------- |
|
278 // CLogsEvent::IsEmergencyNumber |
|
279 // Checks wether the number is an emergency number |
|
280 // ---------------------------------------------------------------------------- |
|
281 |
|
282 TBool CLogsEvent::IsEmergencyNumberL(const TDesC& aNumber) |
|
283 { |
|
284 TBool isEmergencyNumber(EFalse); |
|
285 |
|
286 |
|
287 // Check first the hardcoded values "112" and "911" |
|
288 // plus the possible tag Phone app might have set |
|
289 if ( aNumber.Compare( KLogsEmergencyCall ) == 0 || //112 (however,not in e.g cdma (iStaticEmerg is false)) |
|
290 aNumber.Compare( KLogsEmergencyCall911 ) == 0 || //911 |
|
291 LogsEventData()->Emerg()) //Other emergency numbers that Phone app logs using data tag EMERG |
|
292 { |
|
293 isEmergencyNumber = ETrue; |
|
294 } |
|
295 |
|
296 |
|
297 // If the above does not prove the number to be an emergency number |
|
298 // check number using phoneclient emergencycall API |
|
299 else if (aNumber.Length() <= KPhCltEmergencyNumberSize) |
|
300 { |
|
301 CPhCltEmergencyCall* emergencyCallAPI = CPhCltEmergencyCall::NewL(NULL); |
|
302 TPhCltEmergencyNumber emergNumber = aNumber; |
|
303 |
|
304 if (emergencyCallAPI) |
|
305 { |
|
306 TInt result = emergencyCallAPI->IsEmergencyPhoneNumber(emergNumber, |
|
307 isEmergencyNumber ); |
|
308 |
|
309 delete emergencyCallAPI; |
|
310 if ( result != KErrNone ) |
|
311 { |
|
312 return EFalse; |
|
313 } |
|
314 } |
|
315 } |
|
316 |
|
317 return isEmergencyNumber; |
|
318 } |
|
319 |
|
320 |
|
321 // ---------------------------------------------------------------------------- |
|
322 // CLogsEvent::SetALS() |
|
323 // ---------------------------------------------------------------------------- |
|
324 // |
|
325 void CLogsEvent::SetALS( TBool aALS ) |
|
326 { |
|
327 iALS = aALS; |
|
328 } |
|
329 |
|
330 // ---------------------------------------------------------------------------- |
|
331 // CLogsEvent::SetLogId |
|
332 // ---------------------------------------------------------------------------- |
|
333 // |
|
334 void CLogsEvent::SetLogId( const TLogId aLogId ) |
|
335 { |
|
336 iLogId = aLogId; |
|
337 } |
|
338 |
|
339 // ---------------------------------------------------------------------------- |
|
340 // CLogsEvent::SetNumber |
|
341 // ---------------------------------------------------------------------------- |
|
342 // |
|
343 void CLogsEvent::SetNumber( HBufC* aNumber ) |
|
344 { |
|
345 delete iNumber; |
|
346 iNumber = 0; |
|
347 iNumber = aNumber; |
|
348 } |
|
349 |
|
350 // ---------------------------------------------------------------------------- |
|
351 // CLogsEvent::SetRemoteParty |
|
352 // ---------------------------------------------------------------------------- |
|
353 // |
|
354 void CLogsEvent::SetRemoteParty( HBufC* aRemoteParty ) |
|
355 { |
|
356 delete iRemoteParty; |
|
357 iRemoteParty = 0; |
|
358 iRemoteParty = aRemoteParty; |
|
359 } |
|
360 |
|
361 // ---------------------------------------------------------------------------- |
|
362 // CLogsEvent::SetDirection |
|
363 // ---------------------------------------------------------------------------- |
|
364 // |
|
365 void CLogsEvent::SetDirection( const TLogsDirection aDirection ) |
|
366 { |
|
367 iDirection = static_cast<TInt8>( aDirection ); |
|
368 } |
|
369 |
|
370 // ---------------------------------------------------------------------------- |
|
371 // CLogsEvent::SetEventUid |
|
372 // ---------------------------------------------------------------------------- |
|
373 // |
|
374 void CLogsEvent::SetEventUid( const TUid aUid ) |
|
375 { |
|
376 iUid = aUid; |
|
377 } |
|
378 |
|
379 // ---------------------------------------------------------------------------- |
|
380 // CLogsEvent::SetEventType |
|
381 // ---------------------------------------------------------------------------- |
|
382 // |
|
383 void CLogsEvent::SetEventType( const TLogsEventType aEventType ) |
|
384 { |
|
385 iEventType = static_cast<TInt8>( aEventType ); |
|
386 } |
|
387 |
|
388 // ---------------------------------------------------------------------------- |
|
389 // CLogsEvent::ALS() |
|
390 // ---------------------------------------------------------------------------- |
|
391 // |
|
392 TBool CLogsEvent::ALS() const |
|
393 { |
|
394 return iALS; |
|
395 } |
|
396 |
|
397 // ---------------------------------------------------------------------------- |
|
398 // CLogsEvent::LogId |
|
399 // ---------------------------------------------------------------------------- |
|
400 // |
|
401 TLogId CLogsEvent::LogId() const |
|
402 { |
|
403 return iLogId; |
|
404 } |
|
405 |
|
406 // ---------------------------------------------------------------------------- |
|
407 // CLogsEvent::SetIsRead |
|
408 // ---------------------------------------------------------------------------- |
|
409 void CLogsEvent::SetIsRead(const TBool aIsRead) |
|
410 { |
|
411 iIsRead = aIsRead; |
|
412 } |
|
413 |
|
414 |
|
415 // ---------------------------------------------------------------------------- |
|
416 // CLogsEvent::Number |
|
417 // ---------------------------------------------------------------------------- |
|
418 // |
|
419 HBufC* CLogsEvent::Number() |
|
420 { |
|
421 return iNumber; |
|
422 } |
|
423 |
|
424 // ---------------------------------------------------------------------------- |
|
425 // CLogsEvent::RemoteParty |
|
426 // ---------------------------------------------------------------------------- |
|
427 // |
|
428 HBufC* CLogsEvent::RemoteParty() |
|
429 { |
|
430 return iRemoteParty; |
|
431 } |
|
432 |
|
433 // ---------------------------------------------------------------------------- |
|
434 // CLogsEvent::Direction |
|
435 // ---------------------------------------------------------------------------- |
|
436 // |
|
437 TLogsDirection CLogsEvent::Direction() const |
|
438 { |
|
439 return static_cast<TLogsDirection>( iDirection ); |
|
440 } |
|
441 |
|
442 // ---------------------------------------------------------------------------- |
|
443 // CLogsEvent::EventUid |
|
444 // ---------------------------------------------------------------------------- |
|
445 // |
|
446 TUid CLogsEvent::EventUid() const |
|
447 { |
|
448 return iUid; |
|
449 } |
|
450 |
|
451 // ---------------------------------------------------------------------------- |
|
452 // CLogsEvent::EventType |
|
453 // ---------------------------------------------------------------------------- |
|
454 // |
|
455 TLogsEventType CLogsEvent::EventType() const |
|
456 { |
|
457 return static_cast<TLogsEventType>( iEventType ); |
|
458 } |
|
459 |
|
460 |
|
461 // ---------------------------------------------------------------------------- |
|
462 // CLogsEvent::IsRead |
|
463 // ---------------------------------------------------------------------------- |
|
464 TBool CLogsEvent::IsRead() const |
|
465 { |
|
466 return iIsRead; |
|
467 } |
|
468 |
|
469 // ---------------------------------------------------------------------------- |
|
470 // CLogsEvent::RingDuration |
|
471 // |
|
472 // For ring duation feature |
|
473 // ---------------------------------------------------------------------------- |
|
474 // |
|
475 TLogDuration CLogsEvent::RingDuration() const |
|
476 { |
|
477 return iRingDuration; |
|
478 } |
|
479 |
|
480 // ---------------------------------------------------------------------------- |
|
481 // CLogsEvent::SetRingDuration |
|
482 // ---------------------------------------------------------------------------- |
|
483 // |
|
484 void CLogsEvent::SetRingDuration( TLogDuration aRingDuration ) |
|
485 { |
|
486 iRingDuration = aRingDuration; |
|
487 } |
|
488 |
|
489 // ---------------------------------------------------------------------------- |
|
490 // CLogsEvent::LogsEventData |
|
491 // ---------------------------------------------------------------------------- |
|
492 // |
|
493 MLogsEventData* CLogsEvent::LogsEventData() const |
|
494 { |
|
495 return iLogsEventData; |
|
496 } |
|
497 |
|
498 // ---------------------------------------------------------------------------- |
|
499 // CLogsEvent::SetLogsEventData |
|
500 // ---------------------------------------------------------------------------- |
|
501 // |
|
502 void CLogsEvent::SetLogsEventData( MLogsEventData* aLogsEventData ) |
|
503 { |
|
504 delete iLogsEventData; |
|
505 iLogsEventData = 0; |
|
506 iLogsEventData = aLogsEventData; |
|
507 } |
|
508 |
|
509 |
|
510 |
|
511 /////////////////////////////////////////////////////////////////////////////// |
|
512 // |
|
513 // Additional data that is only needed in specific views |
|
514 // |
|
515 /////////////////////////////////////////////////////////////////////////////// |
|
516 |
|
517 |
|
518 // ---------------------------------------------------------------------------- |
|
519 // CLogsEvent::SetTime |
|
520 // |
|
521 // Time needed in recent views and in detail view (not needed in event view) |
|
522 // ---------------------------------------------------------------------------- |
|
523 // |
|
524 void CLogsEvent::SetTime( const TTime aTime ) |
|
525 { |
|
526 iTime = aTime; |
|
527 iTimeSet = ETrue; |
|
528 } |
|
529 |
|
530 // ---------------------------------------------------------------------------- |
|
531 // CLogsEvent::Time |
|
532 // ---------------------------------------------------------------------------- |
|
533 // |
|
534 TTime CLogsEvent::Time() const |
|
535 { |
|
536 // Time not needed in event list view, so this should not be called in those circumstances |
|
537 __ASSERT_DEBUG( iTimeSet, User::Panic(KPanicMsg, KErrNotSupported) ); |
|
538 return iTime; |
|
539 } |
|
540 |
|
541 // ---------------------------------------------------------------------------- |
|
542 // CLogsEvent::SetDuplicates |
|
543 // |
|
544 // Duplicates needed only in missed calls view |
|
545 // ---------------------------------------------------------------------------- |
|
546 // |
|
547 void CLogsEvent::SetDuplicates( const TInt8 aDuplicates ) |
|
548 { |
|
549 iDuplicates = aDuplicates; |
|
550 } |
|
551 |
|
552 // ---------------------------------------------------------------------------- |
|
553 // CLogsEvent::Duplicates |
|
554 // ---------------------------------------------------------------------------- |
|
555 // |
|
556 TInt8 CLogsEvent::Duplicates() const |
|
557 { |
|
558 if( iDuplicates <= KMaxDuplicates ) |
|
559 { |
|
560 return iDuplicates; |
|
561 } |
|
562 return KMaxDuplicates; |
|
563 } |
|
564 |
|
565 // ---------------------------------------------------------------------------- |
|
566 // CLogsEvent::SetNumberFieldType |
|
567 // ---------------------------------------------------------------------------- |
|
568 // |
|
569 void CLogsEvent::SetNumberFieldType( const TInt aNumberFieldType ) |
|
570 { |
|
571 iNumberFieldType = aNumberFieldType; |
|
572 } |
|
573 |
|
574 // ---------------------------------------------------------------------------- |
|
575 // CLogsEvent::NumberFieldType |
|
576 // ---------------------------------------------------------------------------- |
|
577 // |
|
578 TInt CLogsEvent::NumberFieldType() const |
|
579 { |
|
580 return iNumberFieldType; |
|
581 } |
|
582 |
|
583 // End of file |
|
584 |