vtuis/videotelui/src/CVtUiNumberEntryActivationControl.cpp
branchRCL_3
changeset 24 f15ac8e65a02
parent 23 890b5dd735f8
child 25 779871d1e4f4
equal deleted inserted replaced
23:890b5dd735f8 24:f15ac8e65a02
     1 /*
       
     2 * Copyright (c) 2004 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:  Implementation of the CVtUiNumberEntryActivationControl
       
    15 *                control class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include    "CVtUiNumberEntryActivationControl.h"
       
    23 #include    "CVtUiAppUi.h"
       
    24 #include    "VtUiUtility.h"
       
    25 
       
    26 #include    <AknUtils.h>
       
    27 #include    <AknsUtils.h>
       
    28 #include    <eikenv.h>
       
    29 #include    <cvtlogger.h>
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // Control priority for the forwarder control. Above all other controls.
       
    34 extern const TInt KVtUiNumberEntryActivationPriority =
       
    35     ECoeStackPriorityEnvironmentFilter + 100;
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CVtUiNumberEntryActivationControl::CVtUiNumberEntryActivationControl
       
    41 // C++ constructor can NOT contain any code, that
       
    42 // might leave.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CVtUiNumberEntryActivationControl::CVtUiNumberEntryActivationControl(
       
    46         CVtUiAppUi& aAppUi )
       
    47     : iAppUi( aAppUi ), iIsActive ( ETrue )
       
    48     {
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CVtUiNumberEntryActivationControl::ConstructL
       
    53 // Symbian 2nd phase constructor.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 void CVtUiNumberEntryActivationControl::ConstructL( const TRect& aRect )
       
    57     {
       
    58     // Create invisible control.
       
    59     CreateWindowL();
       
    60     MakeVisible( EFalse );
       
    61     SetRect( aRect );
       
    62 
       
    63     iAppUi.AddToStackL(
       
    64         this,
       
    65         KVtUiNumberEntryActivationPriority,
       
    66         ECoeStackFlagRefusesFocus );
       
    67     iAddedToStack = ETrue;
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CVtUiNumberEntryActivationControl::~CVtUiNumberEntryActivationControl
       
    72 // Destructor.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 CVtUiNumberEntryActivationControl::~CVtUiNumberEntryActivationControl()
       
    76     {
       
    77     AknsUtils::DeregisterControlPosition( this );
       
    78 
       
    79     if ( iAddedToStack )
       
    80         {
       
    81         iAppUi.RemoveFromStack( this );
       
    82         }
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CVtUiNumberEntryActivationControl::Draw
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CVtUiNumberEntryActivationControl::Draw( const TRect& /*aRect*/ ) const
       
    90     {
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CVtUiNumberEntryActivationControl::SizeChanged
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 void CVtUiNumberEntryActivationControl::SizeChanged()
       
    98     {
       
    99     AknsUtils::RegisterControlPosition( this );
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CVtUiNumberEntryActivationControl::PositionChanged
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CVtUiNumberEntryActivationControl::PositionChanged()
       
   107     {
       
   108     AknsUtils::RegisterControlPosition( this );
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CVtUiNumberEntryActivationControl::OfferKeyEventL
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 TKeyResponse CVtUiNumberEntryActivationControl::OfferKeyEventL(
       
   116         const TKeyEvent& aKeyEvent,
       
   117         TEventCode aType )
       
   118     {
       
   119     __VTPRINTENTER( "VtUiNumberEntryAC.OfferKeyEvent" )
       
   120     TBool numberEntryOpen = EFalse;
       
   121     TChar dtmfTone;
       
   122     TBool playDtmfTone = EFalse;
       
   123     TKeyResponse keyResponse = EKeyWasNotConsumed;
       
   124     if ( aKeyEvent.iScanCode == EStdKeyYes )
       
   125         {
       
   126         // send key is always consumed to prevent event forwarding to telephony
       
   127         // EStdKeyYes is scan code for send key, iCode cannot be used because
       
   128         // it is valid only when event type is EEventKey (not in up/down events)
       
   129         keyResponse = EKeyWasConsumed;
       
   130         }    
       
   131     if ( !iIsActive )
       
   132         {
       
   133         return keyResponse;
       
   134         }
       
   135 
       
   136     if ( !aKeyEvent.iRepeats )
       
   137         {
       
   138         if ( VtUiUtility::IsDTMFEvent( aKeyEvent, dtmfTone ) )
       
   139             {
       
   140             numberEntryOpen = iAppUi.OpenNumberEntryL();
       
   141             playDtmfTone = ( aType == EEventKey );
       
   142             }
       
   143         else if ( aKeyEvent.iCode == EKeyPhoneSend )
       
   144             {
       
   145             keyResponse = iAppUi.HandlePhoneSendKeyL( aKeyEvent, aType );
       
   146             }
       
   147         }
       
   148 
       
   149     if ( numberEntryOpen )
       
   150         {
       
   151         iEikonEnv->SyncNotifyFocusObserversOfChangeInFocus();
       
   152         }
       
   153 
       
   154     // Tone actions are delegated to current state for validation.
       
   155     if ( playDtmfTone )
       
   156         {        
       
   157         iAppUi.State().StartDtmfTone( dtmfTone );
       
   158         }
       
   159     else if ( aType == EEventKeyUp )
       
   160         {
       
   161         iAppUi.State().StopDtmfTone();
       
   162         } 
       
   163     __VTPRINTEXITR( "VtUiNumberEntryAC.OfferKeyEvent %d", keyResponse )
       
   164     return keyResponse;
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CVtUiNumberEntryActivationControl::SetActive
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CVtUiNumberEntryActivationControl::SetActive( TBool aIsActive )
       
   172     {
       
   173     iIsActive = aIsActive;
       
   174     }
       
   175 
       
   176 //  End of File