33 #include <MPhCltEmergencyCallObserver.h> |
33 #include <MPhCltEmergencyCallObserver.h> |
34 #include <PhCltTypes.h> |
34 #include <PhCltTypes.h> |
35 #include <AvkonInternalCRKeys.h> |
35 #include <AvkonInternalCRKeys.h> |
36 #include <PtiDefs.h> |
36 #include <PtiDefs.h> |
37 #include <e32property.h> |
37 #include <e32property.h> |
|
38 #include <AiwCommon.hrh> |
|
39 #include <aiwdialdata.h> |
|
40 #include <AiwServiceHandler.h> |
|
41 #include <centralrepository.h> |
38 |
42 |
39 #include "akntrace.h" |
43 #include "akntrace.h" |
|
44 |
|
45 const TInt KAknKeyScanCodeBegin = 33; |
|
46 const TInt KAknKeyScanCodeEnd = 126; |
40 |
47 |
41 // CLASS DECLARATIONS |
48 // CLASS DECLARATIONS |
42 |
49 |
43 /** Class for getting emergency call events */ |
50 /** Class for getting emergency call events */ |
44 NONSHARABLE_CLASS(CPhCltEmergencyCallObserver) : public CBase, |
51 NONSHARABLE_CLASS(CPhCltEmergencyCallObserver) : public CBase, |
322 if ( isEmergency ) |
343 if ( isEmergency ) |
323 { |
344 { |
324 iMatchPosition = cbLength - bLength; |
345 iMatchPosition = cbLength - bLength; |
325 iStatus = ECompleteMatch; |
346 iStatus = ECompleteMatch; |
326 } |
347 } |
|
348 else if ( iServiceCallFeature && cbLength >= KAknServiceCallMinLength ) |
|
349 { |
|
350 // Check if this is a service call |
|
351 TBool isServiceNum = EFalse; |
|
352 TRAP_IGNORE( isServiceNum = ValidateServiceNumberL( iCharBuffer ) ); |
|
353 |
|
354 if ( isServiceNum ) |
|
355 { |
|
356 iMatchPosition = 0; |
|
357 iStatus = EServiceNumMatch; |
|
358 } |
|
359 else |
|
360 { |
|
361 iMatchPosition = cbLength; |
|
362 iStatus = ENoMatch; |
|
363 } |
|
364 } |
327 else |
365 else |
328 { |
366 { |
329 iMatchPosition = cbLength; |
367 iMatchPosition = cbLength; |
330 iStatus = ENoMatch; |
368 iStatus = ENoMatch; |
331 } |
369 } |
332 |
|
333 _AKNTRACE( "[%s][%s] iStatus: %d", "CAknMatchingCharacterQueue", |
370 _AKNTRACE( "[%s][%s] iStatus: %d", "CAknMatchingCharacterQueue", |
334 __FUNCTION__,iStatus ); |
371 __FUNCTION__,iStatus ); |
335 _AKNTRACE_FUNC_EXIT; |
372 _AKNTRACE_FUNC_EXIT; |
336 } |
373 } |
337 |
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CAknMatchingCharacterQueue::ValidateServiceNumber |
|
377 // |
|
378 // Validates the service phone number. |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 TBool CAknMatchingCharacterQueue::ValidateServiceNumberL( const TDesC& aNumber ) |
|
382 { |
|
383 _AKNTRACE_FUNC_ENTER; |
|
384 TBool isServiceNum = EFalse; |
|
385 HBufC* serviceNum = HBufC::NewLC( KAknEcsMaxMatchingLength ); |
|
386 CRepository* cenRep = CRepository::NewLC( KCRUidAvkon ); |
|
387 TPtr bufPtr = serviceNum->Des(); |
|
388 |
|
389 if( cenRep->Get( KAknServiceCallNumber, bufPtr ) != KErrNone ) |
|
390 { |
|
391 CleanupStack::PopAndDestroy( cenRep ); |
|
392 CleanupStack::PopAndDestroy( serviceNum ); |
|
393 return EFalse; |
|
394 } |
|
395 |
|
396 // Check if aNumber matches serviceNum |
|
397 if ( aNumber.Compare( *serviceNum ) == 0 ) |
|
398 { |
|
399 isServiceNum = ETrue; |
|
400 } |
|
401 |
|
402 CleanupStack::PopAndDestroy( cenRep ); |
|
403 CleanupStack::PopAndDestroy( serviceNum ); |
|
404 _AKNTRACE_FUNC_EXIT; |
|
405 return isServiceNum; |
|
406 } |
338 |
407 |
339 // |
408 // |
340 // |
409 // |
341 // Implementation of CAknEcsDetector |
410 // Implementation of CAknEcsDetector |
342 // (Emergency Call Support Detector) |
411 // (Emergency Call Support Detector) |
368 { |
437 { |
369 _AKNTRACE_FUNC_ENTER; |
438 _AKNTRACE_FUNC_ENTER; |
370 iEmergencyCallObserver = new (ELeave) CPhCltEmergencyCallObserver( this ); |
439 iEmergencyCallObserver = new (ELeave) CPhCltEmergencyCallObserver( this ); |
371 // Phone client interface |
440 // Phone client interface |
372 iPhCltEmergencyCall = CPhCltEmergencyCall::NewL( iEmergencyCallObserver ); |
441 iPhCltEmergencyCall = CPhCltEmergencyCall::NewL( iEmergencyCallObserver ); |
373 iQueue = new (ELeave) CAknMatchingCharacterQueue(iPhCltEmergencyCall); |
442 |
|
443 // Check if service call is allowed during device and key lock |
|
444 iServiceCallEnabled = |
|
445 FeatureManager::FeatureSupported( KFeatureIdFfServiceCallWhilePhoneLocked ); |
|
446 |
|
447 iQueue = new (ELeave) CAknMatchingCharacterQueue( iPhCltEmergencyCall, iServiceCallEnabled ); |
374 iQueue->ConstructL(); |
448 iQueue->ConstructL(); |
375 |
449 |
376 DetermineState(); |
450 DetermineState(); |
377 |
451 |
378 // Idler for delaying the change of state to Call Attempted |
452 // Idler for delaying the change of state to Call Attempted |
421 EXPORT_C void CAknEcsDetector::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* /* aDestination */) |
495 EXPORT_C void CAknEcsDetector::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* /* aDestination */) |
422 { |
496 { |
423 _AKNTRACE_FUNC_ENTER; |
497 _AKNTRACE_FUNC_ENTER; |
424 _AKNTRACE( "[%s][%s] aEvent.type(): %d, aEvent.Key()->iScanCode :%d", "CAknEcsDetector", |
498 _AKNTRACE( "[%s][%s] aEvent.type(): %d, aEvent.Key()->iScanCode :%d", "CAknEcsDetector", |
425 __FUNCTION__,aEvent.Type(),aEvent.Key()->iScanCode ); |
499 __FUNCTION__,aEvent.Type(),aEvent.Key()->iScanCode ); |
426 |
|
427 if ( aEvent.Type() == EEventKeyDown || |
500 if ( aEvent.Type() == EEventKeyDown || |
428 // EKeyPhoneEnd/EKeyNo doesn't send EEVentKeyDown events, so EEventKey is used instead |
501 // EKeyPhoneEnd/EKeyNo doesn't send EEVentKeyDown events, so EEventKey is used instead |
429 ( ( aEvent.Key()->iScanCode == EStdKeyNo ) && ( aEvent.Type() == EEventKey ) ) |
502 ( ( aEvent.Key()->iScanCode == EStdKeyNo ) && ( aEvent.Type() == EEventKey ) ) ) |
430 ) |
|
431 { |
503 { |
432 AddChar( (TText)(aEvent.Key()->iScanCode ) ); // top 16 ( in Unicode build) bits removed |
504 AddChar( (TText)(aEvent.Key()->iScanCode ) ); // top 16 ( in Unicode build) bits removed |
433 } |
505 } |
|
506 |
|
507 if ( iServiceCallEnabled ) |
|
508 { |
|
509 // When Cancel is pressed we need to clear the queue |
|
510 if ( iState == EServiceNumMatch && aEvent.Type() == EEventPointer && |
|
511 aEvent.Pointer()->iType == TPointerEvent::EButton1Down ) |
|
512 { |
|
513 // Clear the queue, set state to EEmpty, and cancel any pending timeout |
|
514 Reset(); |
|
515 iKeyTimeoutTimer->Cancel(); |
|
516 } |
|
517 } |
434 _AKNTRACE_FUNC_EXIT; |
518 _AKNTRACE_FUNC_EXIT; |
435 } |
519 } |
436 |
520 |
437 |
521 |
438 EXPORT_C void CAknEcsDetector::AddChar( TText aNewChar ) |
522 EXPORT_C void CAknEcsDetector::AddChar( TText aNewChar ) |
439 { |
523 { |
440 _AKNTRACE_FUNC_ENTER; |
524 _AKNTRACE_FUNC_ENTER; |
441 _AKNTRACE( "[%s][%s] aNewChar: %s", "CAknEcsDetector", |
525 _AKNTRACE( "[%s][%s] aNewChar: %s", "CAknEcsDetector", |
442 __FUNCTION__, &aNewChar ); |
526 __FUNCTION__, &aNewChar ); |
443 |
527 |
444 if (aNewChar == EKeyQwertyOn || aNewChar == EKeyQwertyOff) |
528 if (aNewChar == EKeyQwertyOn || aNewChar == EKeyQwertyOff) |
445 { |
529 { |
446 _AKNTRACE_FUNC_EXIT; |
530 _AKNTRACE_FUNC_EXIT; |
447 return; // return directly if the aNewChar is slide open/closed. |
531 return; // return directly if the aNewChar is slide open/closed. |
448 } |
532 } |
449 |
533 |
450 iKeyTimeoutTimer->Cancel(); // there might be pending timeout; clear it |
534 iKeyTimeoutTimer->Cancel(); // there might be pending timeout; clear it |
451 if ( aNewChar == EStdKeyYes || aNewChar ==EKeyPhoneSend ) |
535 if ( aNewChar == EStdKeyYes || aNewChar == EKeyPhoneSend ) |
452 { |
536 { |
453 if ( State() == ECompleteMatch ) |
537 if ( iServiceCallEnabled ) |
454 { |
538 { |
455 _AKNTRACE( "[%s][%s] SetState( ECompleteMatchThenSendKey )", "CAknEcsDetector", |
539 if ( iState == ECompleteMatch || iState == EServiceNumMatch ) |
456 __FUNCTION__ ); |
540 { |
457 SetState( ECompleteMatchThenSendKey ); |
541 _AKNTRACE( "[%s][%s] SetState( ECompleteMatchThenSendKey )", "CAknEcsDetector", |
|
542 __FUNCTION__ ); |
|
543 SetState( ECompleteMatchThenSendKey ); |
|
544 } |
|
545 } |
|
546 else |
|
547 { |
|
548 if ( iState == ECompleteMatch ) |
|
549 { |
|
550 _AKNTRACE( "[%s][%s] SetState( ECompleteMatchThenSendKey )", "CAknEcsDetector", |
|
551 __FUNCTION__ ); |
|
552 SetState( ECompleteMatchThenSendKey ); |
|
553 } |
458 } |
554 } |
459 // else do nothing with it... |
555 // else do nothing with it... |
460 } |
556 } |
461 else |
557 else |
462 { |
558 { |
463 TText scanCode = aNewChar; |
559 TText scanCode = aNewChar; |
|
560 |
|
561 if ( scanCode < KAknKeyScanCodeBegin || scanCode > KAknKeyScanCodeEnd ) |
|
562 { |
|
563 // Just return since it is an invalid character |
|
564 return; |
|
565 } |
|
566 |
464 #ifdef RD_INTELLIGENT_TEXT_INPUT |
567 #ifdef RD_INTELLIGENT_TEXT_INPUT |
465 // Convert scan code to number value here |
568 // Convert scan code to number value here |
466 // for 4*10, 3*11, half-qwerty key pad |
569 // for 4*10, 3*11, half-qwerty key pad |
467 // The convert value is referenced from KeymapBuilder.pl in ptienginev2 |
570 // The convert value is referenced from KeymapBuilder.pl in ptienginev2 |
468 // Note: if the product change the scancode defintion,pls change the following |
571 // Note: if the product change the scancode defintion,pls change the following |
630 |
740 |
631 iKeyTimeoutTimer->Cancel(); // there might be pending timeout; clear it |
741 iKeyTimeoutTimer->Cancel(); // there might be pending timeout; clear it |
632 iQueue->Reset(); |
742 iQueue->Reset(); |
633 iQueue->SetBuffer(aNewBuffer); |
743 iQueue->SetBuffer(aNewBuffer); |
634 DetermineState(); |
744 DetermineState(); |
635 if ( State() == ECompleteMatch ) |
745 |
636 { |
746 if ( iServiceCallEnabled ) |
637 _AKNTRACE( "[%s][%s] State() == ECompleteMatch ", "CAknEcsDetector", |
747 { |
638 __FUNCTION__ ); |
748 if ( iState == ECompleteMatch || iState == EServiceNumMatch ) |
639 iKeyTimeoutTimer->Start( KEcsInterKeyTimeout, |
749 { |
640 KEcsInterKeyTimeout, TCallBack( CancelMatch, this ) ); |
750 iKeyTimeoutTimer->Start( KEcsInterKeyTimeout, |
|
751 KEcsInterKeyTimeout, TCallBack( CancelMatch, this ) ); |
|
752 } |
|
753 } |
|
754 else |
|
755 { |
|
756 if ( iState == ECompleteMatch ) |
|
757 { |
|
758 _AKNTRACE( "[%s][%s] State() == ECompleteMatch ", "CAknEcsDetector", |
|
759 __FUNCTION__ ); |
|
760 iKeyTimeoutTimer->Start( KEcsInterKeyTimeout, |
|
761 KEcsInterKeyTimeout, TCallBack( CancelMatch, this ) ); |
|
762 } |
641 } |
763 } |
642 _AKNTRACE_FUNC_EXIT; |
764 _AKNTRACE_FUNC_EXIT; |
643 } |
765 } |
644 |
766 |
645 EXPORT_C void CAknEcsDetector::SetState( TState aNewState ) |
767 EXPORT_C void CAknEcsDetector::SetState( TState aNewState ) |
732 TRAPD( err, iPhCltEmergencyCall->DialEmergencyCallL( CurrentMatch() ) ); |
867 TRAPD( err, iPhCltEmergencyCall->DialEmergencyCallL( CurrentMatch() ) ); |
733 __ASSERT_DEBUG( err==KErrNone, Panic( EAknEcsPanicDialLLeft ) ); |
868 __ASSERT_DEBUG( err==KErrNone, Panic( EAknEcsPanicDialLLeft ) ); |
734 if(err != KErrNone) |
869 if(err != KErrNone) |
735 { |
870 { |
736 err = KErrNone; |
871 err = KErrNone; |
|
872 } |
|
873 _AKNTRACE_FUNC_EXIT; |
|
874 } |
|
875 |
|
876 void CAknEcsDetector::MakeServiceCallL() |
|
877 { |
|
878 _AKNTRACE_FUNC_ENTER; |
|
879 if ( iServiceCallEnabled ) |
|
880 { |
|
881 CAiwServiceHandler* aiwServiceHandler = CAiwServiceHandler::NewLC(); |
|
882 RCriteriaArray interest; |
|
883 CleanupClosePushL( interest ); |
|
884 |
|
885 CAiwCriteriaItem* criteria = CAiwCriteriaItem::NewLC( KAiwCmdCall, |
|
886 KAiwCmdCall, _L8( "*" ) ); |
|
887 TUid base; |
|
888 base.iUid = KAiwClassBase; |
|
889 criteria->SetServiceClass( base ); |
|
890 User::LeaveIfError( interest.Append( criteria ) ); |
|
891 aiwServiceHandler->AttachL( interest ); |
|
892 |
|
893 CAiwDialData* dialData = CAiwDialData::NewLC(); |
|
894 dialData->SetCallType( CAiwDialData::EAIWForcedCS ); |
|
895 dialData->SetPhoneNumberL( CurrentMatch() ); |
|
896 dialData->SetWindowGroup( AIWDialData::KAiwGoToIdle ); |
|
897 |
|
898 CAiwGenericParamList& paramList = aiwServiceHandler->InParamListL(); |
|
899 dialData->FillInParamListL( paramList ); |
|
900 |
|
901 TRAPD( err, aiwServiceHandler->ExecuteServiceCmdL( KAiwCmdCall, paramList, |
|
902 aiwServiceHandler->OutParamListL(), 0, NULL ) ); |
|
903 __ASSERT_DEBUG( err == KErrNone, Panic( EAknEcsPanicDialLLeft ) ); |
|
904 |
|
905 //reset the queue |
|
906 iQueue->Reset(); |
|
907 |
|
908 CleanupStack::PopAndDestroy( dialData ); |
|
909 CleanupStack::PopAndDestroy( criteria ); |
|
910 CleanupStack::PopAndDestroy( &interest ); |
|
911 CleanupStack::PopAndDestroy( aiwServiceHandler ); |
|
912 |
|
913 if( err != KErrNone ) |
|
914 { |
|
915 User::Leave( err ); |
|
916 } |
737 } |
917 } |
738 _AKNTRACE_FUNC_EXIT; |
918 _AKNTRACE_FUNC_EXIT; |
739 } |
919 } |
740 |
920 |
741 EXPORT_C void CAknEcsDetector::SetObserver( MAknEcsObserver* aObserver ) |
921 EXPORT_C void CAknEcsDetector::SetObserver( MAknEcsObserver* aObserver ) |