uifw/AvKon/src/AknEcs.cpp
branchRCL_3
changeset 4 8ca85d2f0db7
parent 0 2f259fa3e83a
child 9 aabf2c525e0f
equal deleted inserted replaced
0:2f259fa3e83a 4:8ca85d2f0db7
    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 
    38 
       
    39 #include "akntrace.h"
    39 
    40 
    40 // CLASS DECLARATIONS
    41 // CLASS DECLARATIONS
    41 
    42 
    42 /** Class for getting emergency call events */
    43 /** Class for getting emergency call events */
    43 NONSHARABLE_CLASS(CPhCltEmergencyCallObserver) : public CBase,
    44 NONSHARABLE_CLASS(CPhCltEmergencyCallObserver) : public CBase,
   218 
   219 
   219 
   220 
   220 CAknMatchingCharacterQueue::CAknMatchingCharacterQueue( CPhCltEmergencyCall* aPhCltEmergencyCall ) 
   221 CAknMatchingCharacterQueue::CAknMatchingCharacterQueue( CPhCltEmergencyCall* aPhCltEmergencyCall ) 
   221         : iPhCltEmergencyCall( aPhCltEmergencyCall )
   222         : iPhCltEmergencyCall( aPhCltEmergencyCall )
   222     {
   223     {
       
   224     _AKNTRACE_FUNC_ENTER;
   223     Reset();
   225     Reset();
       
   226     _AKNTRACE_FUNC_EXIT;
   224     }
   227     }
   225 
   228 
   226 CAknMatchingCharacterQueue::~CAknMatchingCharacterQueue( )
   229 CAknMatchingCharacterQueue::~CAknMatchingCharacterQueue( )
   227     {
   230     {
   228     }
   231     }
   231     {
   234     {
   232     }
   235     }
   233 
   236 
   234 void CAknMatchingCharacterQueue::Reset()
   237 void CAknMatchingCharacterQueue::Reset()
   235     {
   238     {
       
   239     _AKNTRACE_FUNC_ENTER;
   236     iMatchPosition = 0;
   240     iMatchPosition = 0;
   237     iCharBuffer.Zero();
   241     iCharBuffer.Zero();
       
   242     _AKNTRACE_FUNC_EXIT;
   238     }
   243     }
   239 
   244 
   240 void CAknMatchingCharacterQueue::AddChar( TText aNewChar )
   245 void CAknMatchingCharacterQueue::AddChar( TText aNewChar )
   241     {    
   246     {    
       
   247     _AKNTRACE_FUNC_ENTER;
       
   248     _AKNTRACE( "[%s][%s] aNewChar: %s", "CAknMatchingCharacterQueue", 
       
   249         		__FUNCTION__,&aNewChar);
       
   250     
   242     TInt length = iCharBuffer.Length();
   251     TInt length = iCharBuffer.Length();
   243     TInt maxLenght = iCharBuffer.MaxLength();
   252     TInt maxLenght = iCharBuffer.MaxLength();
   244     if (length >= maxLenght)
   253     if (length >= maxLenght)
   245         {
   254         {
   246         iCharBuffer = iCharBuffer.Right(length - 1);
   255         iCharBuffer = iCharBuffer.Right(length - 1);
   247         }
   256         }
   248     iCharBuffer.Append( aNewChar );
   257     iCharBuffer.Append( aNewChar );
   249     UpdateStatus( EFalse );
   258     UpdateStatus( EFalse );
       
   259     _AKNTRACE_FUNC_ENTER;
   250     }
   260     }
   251 
   261 
   252 void CAknMatchingCharacterQueue::SetBuffer( const TDesC& aNewBuffer )
   262 void CAknMatchingCharacterQueue::SetBuffer( const TDesC& aNewBuffer )
   253     {    
   263     {    
       
   264     _AKNTRACE_FUNC_ENTER;
       
   265     _AKNTRACE( "[%s][%s] aNewBuffer: %s", "CAknMatchingCharacterQueue", 
       
   266             		__FUNCTION__,&aNewBuffer);
       
   267     
   254     TInt maxLenght = iCharBuffer.MaxLength();
   268     TInt maxLenght = iCharBuffer.MaxLength();
   255     TInt length = aNewBuffer.Length();
   269     TInt length = aNewBuffer.Length();
   256     if ( length > maxLenght )
   270     if ( length > maxLenght )
   257         {
   271         {
   258         length = maxLenght;
   272         length = maxLenght;
   259         }
   273         }
   260     iCharBuffer = aNewBuffer.Left( length );
   274     iCharBuffer = aNewBuffer.Left( length );
   261     UpdateStatus( ETrue );
   275     UpdateStatus( ETrue );
       
   276     _AKNTRACE_FUNC_EXIT;
   262     }
   277     }
   263 
   278 
   264 TInt CAknMatchingCharacterQueue::Count() const
   279 TInt CAknMatchingCharacterQueue::Count() const
   265     {
   280     {
   266     return iCharBuffer.Length();
   281     return iCharBuffer.Length();
   281     return iMatchPosition;
   296     return iMatchPosition;
   282     }
   297     }
   283 
   298 
   284 void CAknMatchingCharacterQueue::UpdateStatus( TBool aBufferMode )
   299 void CAknMatchingCharacterQueue::UpdateStatus( TBool aBufferMode )
   285     {
   300     {
       
   301     _AKNTRACE_FUNC_ENTER;
   286     TBool isEmergency = EFalse;
   302     TBool isEmergency = EFalse;
   287     TInt err = KErrNone;
   303     TInt err = KErrNone;
   288     TPhCltTelephoneNumber buffer = iCharBuffer;
   304     TPhCltTelephoneNumber buffer = iCharBuffer;
   289     if (iPhCltEmergencyCall)
   305     if (iPhCltEmergencyCall)
   290         {
   306         {
   311     else
   327     else
   312         {
   328         {
   313         iMatchPosition = cbLength;
   329         iMatchPosition = cbLength;
   314         iStatus = ENoMatch;
   330         iStatus = ENoMatch;
   315         }
   331         }
       
   332     
       
   333     _AKNTRACE( "[%s][%s] iStatus: %d", "CAknMatchingCharacterQueue", 
       
   334                 		__FUNCTION__,iStatus );
       
   335     _AKNTRACE_FUNC_EXIT;
   316     }
   336     }
   317 
   337 
   318 
   338 
   319 //
   339 //
   320 //
   340 //
   323 //
   343 //
   324 //
   344 //
   325 
   345 
   326 EXPORT_C CAknEcsDetector::CAknEcsDetector()
   346 EXPORT_C CAknEcsDetector::CAknEcsDetector()
   327     {
   347     {
       
   348     _AKNTRACE_FUNC_ENTER;
   328     iCoeEnv = CCoeEnv::Static();
   349     iCoeEnv = CCoeEnv::Static();
   329     iState = ENotFullyConstructed;
   350     iState = ENotFullyConstructed;
       
   351     _AKNTRACE_FUNC_EXIT;
   330     }
   352     }
   331 
   353 
   332 EXPORT_C CAknEcsDetector::~CAknEcsDetector()
   354 EXPORT_C CAknEcsDetector::~CAknEcsDetector()
   333     {
   355     {
       
   356     _AKNTRACE_FUNC_ENTER;
   334     // Must close this in order to remove any observers from the AppUi's monitor
   357     // Must close this in order to remove any observers from the AppUi's monitor
   335     CloseEventSource();
   358     CloseEventSource();
   336     delete iPhCltEmergencyCall;
   359     delete iPhCltEmergencyCall;
   337     delete iEmergencyCallObserver;
   360     delete iEmergencyCallObserver;
   338     delete iQueue;
   361     delete iQueue;
   339     delete iIdler;
   362     delete iIdler;
   340     delete iKeyTimeoutTimer;
   363     delete iKeyTimeoutTimer;
       
   364     _AKNTRACE_FUNC_EXIT;
   341     }
   365     }
   342 
   366 
   343 EXPORT_C void CAknEcsDetector::ConstructL()
   367 EXPORT_C void CAknEcsDetector::ConstructL()
   344     {
   368     {
       
   369     _AKNTRACE_FUNC_ENTER;
   345     iEmergencyCallObserver = new (ELeave) CPhCltEmergencyCallObserver( this );
   370     iEmergencyCallObserver = new (ELeave) CPhCltEmergencyCallObserver( this );
   346     // Phone client interface
   371     // Phone client interface
   347     iPhCltEmergencyCall = CPhCltEmergencyCall::NewL( iEmergencyCallObserver );
   372     iPhCltEmergencyCall = CPhCltEmergencyCall::NewL( iEmergencyCallObserver );
   348     iQueue = new (ELeave) CAknMatchingCharacterQueue(iPhCltEmergencyCall);
   373     iQueue = new (ELeave) CAknMatchingCharacterQueue(iPhCltEmergencyCall);
   349     iQueue->ConstructL();
   374     iQueue->ConstructL();
   353     // Idler for delaying the change of state to Call Attempted
   378     // Idler for delaying the change of state to Call Attempted
   354     iIdler = CIdle::NewL( CActive::EPriorityLow );
   379     iIdler = CIdle::NewL( CActive::EPriorityLow );
   355 
   380 
   356     // Timer for timing the timeout between keys
   381     // Timer for timing the timeout between keys
   357     iKeyTimeoutTimer = CPeriodic::NewL( CActive::EPriorityLow);
   382     iKeyTimeoutTimer = CPeriodic::NewL( CActive::EPriorityLow);
       
   383     _AKNTRACE_FUNC_EXIT;
   358     }
   384     }
   359 
   385 
   360 EXPORT_C CAknEcsDetector* CAknEcsDetector::NewL()
   386 EXPORT_C CAknEcsDetector* CAknEcsDetector::NewL()
   361     { // static
   387     { // static
       
   388     _AKNTRACE_FUNC_ENTER;
   362     CAknEcsDetector* self = new (ELeave) CAknEcsDetector();
   389     CAknEcsDetector* self = new (ELeave) CAknEcsDetector();
   363     CleanupStack::PushL( self );
   390     CleanupStack::PushL( self );
   364     self->ConstructL();
   391     self->ConstructL();
   365     CleanupStack::Pop(); //self
   392     CleanupStack::Pop(); //self
       
   393     _AKNTRACE_FUNC_EXIT;
   366     return self;
   394     return self;
   367     }
   395     }
   368 
   396 
   369 EXPORT_C TBool CAknEcsDetector::ConnectToEventSource()
   397 EXPORT_C TBool CAknEcsDetector::ConnectToEventSource()
   370     {
   398     {
   390         }
   418         }
   391     }
   419     }
   392 
   420 
   393 EXPORT_C void CAknEcsDetector::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* /* aDestination  */)
   421 EXPORT_C void CAknEcsDetector::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* /* aDestination  */)
   394     {
   422     {
       
   423     _AKNTRACE_FUNC_ENTER;
       
   424     _AKNTRACE( "[%s][%s] aEvent.type(): %d, aEvent.Key()->iScanCode :%d", "CAknEcsDetector", 
       
   425                             		__FUNCTION__,aEvent.Type(),aEvent.Key()->iScanCode );
       
   426     
   395     if ( aEvent.Type() == EEventKeyDown || 
   427     if ( aEvent.Type() == EEventKeyDown || 
   396     // EKeyPhoneEnd/EKeyNo doesn't send EEVentKeyDown events, so EEventKey is used instead
   428     // EKeyPhoneEnd/EKeyNo doesn't send EEVentKeyDown events, so EEventKey is used instead
   397     ( ( aEvent.Key()->iScanCode == EStdKeyNo ) && ( aEvent.Type() == EEventKey ) ) 
   429     ( ( aEvent.Key()->iScanCode == EStdKeyNo ) && ( aEvent.Type() == EEventKey ) ) 
   398         )
   430         )
   399         {
   431         {
   400         AddChar( (TText)(aEvent.Key()->iScanCode ) ); // top 16 ( in Unicode build) bits removed
   432         AddChar( (TText)(aEvent.Key()->iScanCode ) ); // top 16 ( in Unicode build) bits removed
   401         }    
   433         }    
       
   434     _AKNTRACE_FUNC_EXIT;
   402     }
   435     }
   403 
   436 
   404 
   437 
   405 EXPORT_C void CAknEcsDetector::AddChar( TText aNewChar )
   438 EXPORT_C void CAknEcsDetector::AddChar( TText aNewChar )
   406     {
   439     {
       
   440     _AKNTRACE_FUNC_ENTER;
       
   441     _AKNTRACE( "[%s][%s] aNewChar: %s", "CAknEcsDetector", 
       
   442                                 		__FUNCTION__, &aNewChar );
       
   443     
       
   444     if (aNewChar == EKeyQwertyOn || aNewChar == EKeyQwertyOff)
       
   445     	{ 
       
   446         _AKNTRACE_FUNC_EXIT;
       
   447     	return;   // return directly if the aNewChar is slide open/closed.
       
   448     	}
       
   449 
   407     iKeyTimeoutTimer->Cancel(); // there might be pending timeout; clear it
   450     iKeyTimeoutTimer->Cancel(); // there might be pending timeout; clear it
   408     if ( aNewChar == EStdKeyYes || aNewChar ==EKeyPhoneSend )
   451     if ( aNewChar == EStdKeyYes || aNewChar ==EKeyPhoneSend )
   409         {
   452         {
   410         if ( State() == ECompleteMatch )
   453         if ( State() == ECompleteMatch )
   411             {
   454             {
       
   455             _AKNTRACE( "[%s][%s] SetState( ECompleteMatchThenSendKey )", "CAknEcsDetector", 
       
   456                                             		__FUNCTION__ );
   412             SetState( ECompleteMatchThenSendKey );
   457             SetState( ECompleteMatchThenSendKey );
   413             }
   458             }
   414         // else do nothing with it...
   459         // else do nothing with it...
   415         }
   460         }
   416     else
   461     else
   516         
   561         
   517         iQueue->AddChar( scanCode );
   562         iQueue->AddChar( scanCode );
   518         DetermineState();
   563         DetermineState();
   519         iKeyTimeoutTimer->Start( KEcsInterKeyTimeout, KEcsInterKeyTimeout, TCallBack( CancelMatch, this ) );
   564         iKeyTimeoutTimer->Start( KEcsInterKeyTimeout, KEcsInterKeyTimeout, TCallBack( CancelMatch, this ) );
   520         }
   565         }
       
   566     _AKNTRACE_FUNC_EXIT;
   521     }
   567     }
   522 
   568 
   523 
   569 
   524 void CAknEcsDetector::DetermineState()
   570 void CAknEcsDetector::DetermineState()
   525     {
   571     {
       
   572     _AKNTRACE_FUNC_ENTER;
   526     TState bestState = ENoMatch;
   573     TState bestState = ENoMatch;
   527 
   574 
   528     if ( iQueue->Count() == 0 )
   575     if ( iQueue->Count() == 0 )
   529         {
   576         {
   530         bestState = EEmpty;
   577         bestState = EEmpty;
   545                 __ASSERT_DEBUG( 0, Panic(EAknEcsPanicBadState) );
   592                 __ASSERT_DEBUG( 0, Panic(EAknEcsPanicBadState) );
   546                 break;
   593                 break;
   547             }
   594             }
   548         SetState(bestState);
   595         SetState(bestState);
   549         }
   596         }
       
   597     _AKNTRACE( "[%s][%s] bestState: %d", "CAknEcsDetector", 
       
   598                                     		__FUNCTION__, bestState );
       
   599     _AKNTRACE_FUNC_EXIT;
   550     }
   600     }
   551 
   601 
   552 EXPORT_C void CAknEcsDetector::ReportEvent(TState aNewState )
   602 EXPORT_C void CAknEcsDetector::ReportEvent(TState aNewState )
   553     {
   603     {
   554     if (iObserver)
   604     if (iObserver)
   572     {
   622     {
   573     return iState;
   623     return iState;
   574     }
   624     }
   575 EXPORT_C void CAknEcsDetector::SetBuffer( const TDesC& aNewBuffer )
   625 EXPORT_C void CAknEcsDetector::SetBuffer( const TDesC& aNewBuffer )
   576     {
   626     {
       
   627     _AKNTRACE_FUNC_ENTER;
       
   628     _AKNTRACE( "[%s][%s] aNewBuffer: %s", "CAknEcsDetector", 
       
   629                                         		__FUNCTION__, &aNewBuffer );
       
   630         
   577     iKeyTimeoutTimer->Cancel(); // there might be pending timeout; clear it
   631     iKeyTimeoutTimer->Cancel(); // there might be pending timeout; clear it
   578     iQueue->Reset();
   632     iQueue->Reset();
   579     iQueue->SetBuffer(aNewBuffer);
   633     iQueue->SetBuffer(aNewBuffer);
   580     DetermineState();
   634     DetermineState();
   581     if ( State() == ECompleteMatch )
   635     if ( State() == ECompleteMatch )
   582         {
   636         {
       
   637         _AKNTRACE( "[%s][%s] State() == ECompleteMatch ", "CAknEcsDetector", 
       
   638                                                 		__FUNCTION__ );
   583         iKeyTimeoutTimer->Start( KEcsInterKeyTimeout,
   639         iKeyTimeoutTimer->Start( KEcsInterKeyTimeout,
   584             KEcsInterKeyTimeout, TCallBack( CancelMatch, this ) );
   640             KEcsInterKeyTimeout, TCallBack( CancelMatch, this ) );
   585         }
   641         }
       
   642     _AKNTRACE_FUNC_EXIT;
   586     }
   643     }
   587 
   644 
   588 EXPORT_C void CAknEcsDetector::SetState( TState aNewState )
   645 EXPORT_C void CAknEcsDetector::SetState( TState aNewState )
   589     {
   646     {
       
   647     _AKNTRACE_FUNC_ENTER;
       
   648     _AKNTRACE( "[%s][%s] aNewState: %d", "CAknEcsDetector", 
       
   649                                             		__FUNCTION__, aNewState );
   590     ReportEvent( aNewState );
   650     ReportEvent( aNewState );
   591 
   651 
   592     TInt oldState = iState;
   652     TInt oldState = iState;
   593     iState = aNewState;
   653     iState = aNewState;
   594 
   654 
   609 
   669 
   610                 TBool proceedWithCall = ETrue;
   670                 TBool proceedWithCall = ETrue;
   611                 proceedWithCall = OfferEmergencyCall();
   671                 proceedWithCall = OfferEmergencyCall();
   612                 if ( proceedWithCall )
   672                 if ( proceedWithCall )
   613                     {
   673                     {
       
   674                     _AKNTRACE( "[%s][%s] Attempt Emergency Call", "CAknEcsDetector", 
       
   675                                                                 		__FUNCTION__);
   614                     AttemptEmergencyCall();
   676                     AttemptEmergencyCall();
   615                     }
   677                     }
   616                 else
   678                 else
   617                     {  // Pass through this state immediately
   679                     {  // Pass through this state immediately
       
   680                     _AKNTRACE( "[%s][%s] Reset", "CAknEcsDetector", __FUNCTION__);
   618                     iQueue->Reset();
   681                     iQueue->Reset();
   619                     SetState( EEmpty );
   682                     SetState( EEmpty );
   620                     }
   683                     }
   621                 }
   684                 }
   622             break;
   685             break;
   623 
   686 
   624         default:
   687         default:
   625             break;
   688             break;
   626 
   689 
   627         }
   690         }
       
   691     _AKNTRACE_FUNC_EXIT;
   628     }
   692     }
   629 
   693 
   630 EXPORT_C void CAknEcsDetector::Reset()
   694 EXPORT_C void CAknEcsDetector::Reset()
   631     {
   695     {
       
   696     _AKNTRACE_FUNC_ENTER;
   632     iQueue->Reset();
   697     iQueue->Reset();
   633     SetState( EEmpty );
   698     SetState( EEmpty );
       
   699     _AKNTRACE_FUNC_EXIT;
   634     }
   700     }
   635 
   701 
   636 /**
   702 /**
   637 * This may be re-implemented to add a confirm query. Re-implementation must not leave
   703 * This may be re-implemented to add a confirm query. Re-implementation must not leave
   638 *
   704 *
   655     groupWin.CancelCaptureKey( iCapturedKey );
   721     groupWin.CancelCaptureKey( iCapturedKey );
   656     }
   722     }
   657 
   723 
   658 void CAknEcsDetector::AttemptEmergencyCall()
   724 void CAknEcsDetector::AttemptEmergencyCall()
   659     {
   725     {
       
   726     _AKNTRACE_FUNC_ENTER;
   660 #ifdef AVKON_RDEBUG_INFO
   727 #ifdef AVKON_RDEBUG_INFO
   661     _LIT(KDebugAttemptEmergencyCall, "Attempt Emergency Call From Detector");
   728     _LIT(KDebugAttemptEmergencyCall, "Attempt Emergency Call From Detector");
   662     RDebug::Print(KDebugAttemptEmergencyCall);
   729     RDebug::Print(KDebugAttemptEmergencyCall);
   663 #endif
   730 #endif
   664 
   731 
   666     __ASSERT_DEBUG( err==KErrNone, Panic( EAknEcsPanicDialLLeft ) );
   733     __ASSERT_DEBUG( err==KErrNone, Panic( EAknEcsPanicDialLLeft ) );
   667     if(err != KErrNone)
   734     if(err != KErrNone)
   668         {
   735         {
   669         err = KErrNone;
   736         err = KErrNone;
   670         }
   737         }
       
   738     _AKNTRACE_FUNC_EXIT;
   671     }
   739     }
   672 
   740 
   673 EXPORT_C void CAknEcsDetector::SetObserver( MAknEcsObserver* aObserver )
   741 EXPORT_C void CAknEcsDetector::SetObserver( MAknEcsObserver* aObserver )
   674     {
   742     {
   675     iObserver = aObserver;
   743     iObserver = aObserver;
   688     * This is meant to be called asynchronously in order for the Observer to destroy itself
   756     * This is meant to be called asynchronously in order for the Observer to destroy itself
   689     *
   757     *
   690     */
   758     */
   691 TInt CAknEcsDetector::CallAttemptedCallback(TAny* aSelf)
   759 TInt CAknEcsDetector::CallAttemptedCallback(TAny* aSelf)
   692     { // static
   760     { // static
       
   761     _AKNTRACE_FUNC_ENTER;
   693     REINTERPRET_CAST(CAknEcsDetector*,aSelf)->SetState( ECallAttempted );
   762     REINTERPRET_CAST(CAknEcsDetector*,aSelf)->SetState( ECallAttempted );
   694 #ifdef AVKON_RDEBUG_INFO
   763 #ifdef AVKON_RDEBUG_INFO
   695     _LIT(KDebugCallAttemptedCallback, "CallAttemptedCallback");
   764     _LIT(KDebugCallAttemptedCallback, "CallAttemptedCallback");
   696     RDebug::Print(KDebugCallAttemptedCallback);
   765     RDebug::Print(KDebugCallAttemptedCallback);
   697 #endif
   766 #endif
       
   767     _AKNTRACE_FUNC_EXIT;
   698     return 0;
   768     return 0;
   699     }
   769     }
   700 
   770 
   701 TInt CAknEcsDetector::CancelMatch(TAny* aThis)
   771 TInt CAknEcsDetector::CancelMatch(TAny* aThis)
   702     {
   772     {
       
   773     _AKNTRACE_FUNC_ENTER;
   703     static_cast<CAknEcsDetector*>(aThis)->Reset();
   774     static_cast<CAknEcsDetector*>(aThis)->Reset();
   704     static_cast<CAknEcsDetector*>(aThis)->iKeyTimeoutTimer->Cancel();
   775     static_cast<CAknEcsDetector*>(aThis)->iKeyTimeoutTimer->Cancel();
       
   776     _AKNTRACE_FUNC_EXIT;
   705     return 0; // Do not repeat the operation
   777     return 0; // Do not repeat the operation
   706     }
   778     }
   707 
   779 
   708 // End of File
   780 // End of File