securitydialogs/lockapp/src/lockappidlecontrol.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Idle (unlocked) UI
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "lockappidlecontrol.h"
       
    20 #include "lockappstatecontrolinterface.h"
       
    21 #include "lockapputils.h"
       
    22 #include "lockapplockednote.h" // keyguard notes
       
    23 #include "lockappkeycapturecontroller.h"
       
    24 
       
    25 #include <avkon.rsg> // general avkon resources
       
    26 
       
    27 #include <aknnotpi.rsg> // keyguard spesific resources
       
    28 
       
    29 #include <featmgr.h> // feature manager
       
    30 
       
    31 // from keyguard ui spesification, 6 sec.
       
    32 const TInt KAknOfferKeyguardTimeout = 6000000;
       
    33 
       
    34 // Asterisk key code for the keylock
       
    35 const TUint KStdKeyAsterisk = 42;
       
    36 //const TUint KAknChineseAsterisk = 0xFF0A;
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // Standard Symbian OS construction sequence
       
    40 // ---------------------------------------------------------------------------
       
    41 CLockAppIdleControl* CLockAppIdleControl::NewL(MLockAppStateControl& aStateControl )
       
    42     {
       
    43     CLockAppIdleControl* self = new (ELeave) CLockAppIdleControl( aStateControl );
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL( );
       
    46     CleanupStack::Pop( self );
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // Constructor passes the reference of the main state control.
       
    52 // ---------------------------------------------------------------------------
       
    53 CLockAppIdleControl::CLockAppIdleControl( MLockAppStateControl& aStateControl ) :
       
    54     CLockAppBaseControl( aStateControl )
       
    55     {
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // Destructor.
       
    60 // ---------------------------------------------------------------------------
       
    61 CLockAppIdleControl::~CLockAppIdleControl( )
       
    62     {
       
    63     delete iOfferLockNote;
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // Idle UI constructor reserves localized resources, configures itself
       
    68 // using CenRep and FeatureManager and reserves child controls.
       
    69 // ---------------------------------------------------------------------------
       
    70 void CLockAppIdleControl::ConstructL( )
       
    71     {
       
    72     INFO( "CLockAppIdleControl::ConstructL started" );
       
    73     CLockAppBaseControl::ConstructL( );
       
    74 
       
    75     iOfferLockNote = new (ELeave) CLockAppLockedNote(this);
       
    76     iOfferLockNote->ConstructSleepingNoteL( R_KEYLOCK_OFFER_LOCK_NOTE );
       
    77     iOfferLockNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( 0, 2 );
       
    78     
       
    79     // Setup key pattern matcher
       
    80     if ( !SetupKeyPatternsWithPolicyL( EPolicyActivateKeyguard ) )
       
    81         {
       
    82         INFO( "CLockAppIdleControl::ConstructL - No CenRep policy defined" );
       
    83         iKeyPattern->AddPattern( EStdKeyDevice0, KStdKeyAsterisk ); // LSK + *
       
    84         }
       
    85 #ifdef __WINS__
       
    86     iKeyPattern->AddPattern( EStdKeyDevice0, EStdKeyNkpAsterisk ); // LSK + *
       
    87 #endif
       
    88                                                                                                                                                                                                            
       
    89     INFO( "CLockAppIdleControl::ConstructL completed" );
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // Offers keylock.
       
    94 // ---------------------------------------------------------------------------
       
    95 void CLockAppIdleControl::OfferKeyLock( )
       
    96     {
       
    97     ShowNote( iOfferLockNote, (CAknNoteDialog::TTimeout)KAknOfferKeyguardTimeout, CAknNoteDialog::ENoTone );
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // Cancels offering keylock.
       
   102 // ---------------------------------------------------------------------------
       
   103 void CLockAppIdleControl::CancelOfferKeyLock( )
       
   104     {
       
   105     CancelNote( );
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // Activate control
       
   110 // ---------------------------------------------------------------------------
       
   111 void CLockAppIdleControl::HandleActivateEventL( TUint aEnvMask )
       
   112     {  
       
   113 		RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
   114     CLockAppBaseControl::HandleActivateEventL( aEnvMask );
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // DeActivate control
       
   119 // ---------------------------------------------------------------------------
       
   120 void CLockAppIdleControl::HandleDeActivateEventL( TUint aEnvMask )
       
   121     {
       
   122     CLockAppBaseControl::HandleDeActivateEventL( aEnvMask );
       
   123     CancelOfferKeyLock( );
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // Idle UI key events are handled trough here.
       
   128 // ---------------------------------------------------------------------------
       
   129 TKeyResponse CLockAppIdleControl::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/ )
       
   130     {
       
   131 		RDebug::Printf( "%s %s (%u) aKeyEvent.iCode=%x 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyEvent.iCode, 1 );
       
   132     TKeyResponse keyResponse = EKeyWasNotConsumed;
       
   133     if ( iActive )
       
   134         {
       
   135         if ( iOfferLockNote->IsVisible( ) )
       
   136             {
       
   137             // if keylock has been offered
       
   138             switch ( aKeyEvent.iCode )
       
   139                 {
       
   140                 case EKeyOK:
       
   141                     iStateControl.EnableKeyguardL( ETrue );
       
   142                     keyResponse = EKeyWasConsumed;
       
   143                     break;
       
   144                 case EKeyLeftArrow:
       
   145                 case EKeyRightArrow:
       
   146                 case EKeyUpArrow:
       
   147                 case EKeyDownArrow:
       
   148                 case EKeyApplication:
       
   149                     keyResponse = EKeyWasConsumed;
       
   150                     break;
       
   151                 default:
       
   152                     break;
       
   153                 }
       
   154             }
       
   155         else
       
   156             {
       
   157             // keys pressed normally in idle - however keys are not captured
       
   158             // this is where locking policy could be monitored to check keyguard activation
       
   159             /*if ( aType == EEventKeyDown )
       
   160                 {
       
   161                 switch ( iKeyPattern->HandleKeyEvent( aKeyEvent.iScanCode ) )
       
   162                     {
       
   163                     case EPatternNoMatch:
       
   164                     case EPatternPrimaryMatch:
       
   165                         break;
       
   166                     case EPatternSecondaryMatch:
       
   167                         iStateControl.EnableKeyguardL( ETrue );
       
   168                         keyResponse = EKeyWasConsumed;
       
   169                         break;
       
   170                     default:
       
   171                         break;
       
   172                     }
       
   173                 }
       
   174             */
       
   175             }
       
   176         }
       
   177     return keyResponse;
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // Handle UI commands received from the child controls
       
   182 // ---------------------------------------------------------------------------
       
   183 void CLockAppIdleControl::ProcessCommandL(TInt aCommandId )
       
   184     {
       
   185     // handle command
       
   186 		RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
   187     switch ( aCommandId )
       
   188         {
       
   189         case EAknSoftkeyLock:
       
   190             {
       
   191             // user has accepted offer keyguard enquiry - lock keys
       
   192             iStateControl.EnableKeyguardL( ETrue );
       
   193             }
       
   194             break;
       
   195         case EAknSoftkeyExit:
       
   196         case KNoteCmdFocusLost:
       
   197             {
       
   198             // user has declined offer keyguard enquiry -  cancel offer
       
   199             CancelOfferKeyLock( );
       
   200             }
       
   201             break;
       
   202         default:
       
   203             break;
       
   204         }
       
   205     }
       
   206 
       
   207 TInt CLockAppIdleControl::CountComponentControls( ) const
       
   208     {
       
   209     return 0;
       
   210     }
       
   211 
       
   212 CCoeControl* CLockAppIdleControl::ComponentControl(TInt /*aIndex*/) const
       
   213     {
       
   214     return NULL;
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // Notification if layout changes.
       
   219 // ---------------------------------------------------------------------------
       
   220 void CLockAppIdleControl::HandleResourceChange(TInt aType )
       
   221     {
       
   222     CCoeControl::HandleResourceChange( aType );
       
   223     }