eventsui/eventsutils/src/evtkeylockhandler.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2008 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:  Key Lock Settings Handler.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System Includes
       
    20 
       
    21 // User Includes
       
    22 #include "evtkeylockhandler.h"
       
    23 #include "evtdebug.h"
       
    24 
       
    25 // ================ Member funtions for CEvtKeyLockHandler class ===============
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // CEvtKeyLockHandler::CEvtKeyLockHandler
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CEvtKeyLockHandler::CEvtKeyLockHandler( ) : iKeyLocked(EFalse)
       
    32 	{
       
    33 	}
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // CEvtKeyLockHandler::~CEvtKeyLockHandler
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CEvtKeyLockHandler::~CEvtKeyLockHandler()
       
    40 	{
       
    41 	iKeyLock.Close();
       
    42 	}
       
    43 	
       
    44 // ---------------------------------------------------------------------------
       
    45 // CEvtKeyLockHandler::NewL
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CEvtKeyLockHandler* CEvtKeyLockHandler::NewL( )
       
    49     {
       
    50 	CEvtKeyLockHandler* self = NewLC( );
       
    51 	CleanupStack::Pop( self );
       
    52 	return self;
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CEvtKeyLockHandler::NewLC
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C CEvtKeyLockHandler* CEvtKeyLockHandler::NewLC( )
       
    60     {
       
    61 	CEvtKeyLockHandler* self = new ( ELeave )CEvtKeyLockHandler( );
       
    62 	CleanupStack::PushL( self );
       
    63 	self->ConstructL( );
       
    64 	return self;
       
    65     } 
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CEvtKeyLockHandler::ConstructL
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void CEvtKeyLockHandler::ConstructL()
       
    72     {
       
    73     EVTUIDEBUG( "+ CEvtKeyLockHandler::ConstructL()" );
       
    74     
       
    75 	User::LeaveIfError( iKeyLock.Connect() );
       
    76 	
       
    77     EVTUIDEBUG( "- CEvtKeyLockHandler::ConstructL()" );
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CEvtKeyLockHandler::MaintainState
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 EXPORT_C void CEvtKeyLockHandler::MaintainState( )
       
    85 	{
       
    86 	iKeyLocked = iKeyLock.IsKeyLockEnabled();
       
    87 	
       
    88 	// Disable the Key Lock without showing the Note.
       
    89     if( iKeyLocked )
       
    90 		{
       
    91     	iKeyLock.DisableWithoutNote();
       
    92 		}
       
    93     EVTUIDEBUG1( "= CEvtKeyLockHandler::MaintainState() - %d", iKeyLocked );
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CEvtKeyLockHandler::UpdateStateWithNote
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 EXPORT_C void CEvtKeyLockHandler::UpdateStateWithNote( )
       
   101 	{
       
   102     EVTUIDEBUG1( "= CEvtKeyLockHandler::UpdateStateWithNote() - %d", iKeyLocked );
       
   103 	
       
   104 	// Check the previously Maintained key lock state and the current key lock state.
       
   105 	// This avoids updation if both the states are same.
       
   106     if( iKeyLocked && !iKeyLock.IsKeyLockEnabled() )
       
   107 		{
       
   108 		iKeyLock.EnableKeyLock();
       
   109 		}
       
   110     else if( !iKeyLocked && iKeyLock.IsKeyLockEnabled() )
       
   111     	{
       
   112 		iKeyLock.DisableKeyLock();
       
   113 		}
       
   114 	iKeyLocked = EFalse;
       
   115     EVTUIDEBUG( "- CEvtKeyLockHandler::UpdateStateWithNote() - Key Lock Updated" );
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CEvtKeyLockHandler::UpdateStateWithoutNote
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 EXPORT_C void CEvtKeyLockHandler::UpdateStateWithoutNote( )
       
   123 	{
       
   124     EVTUIDEBUG1( "= CEvtKeyLockHandler::UpdateStateWithoutNote() - %d", iKeyLocked );
       
   125 	
       
   126 	// Check the previously Maintained key lock state and the current key lock state.
       
   127 	// This avoids updation if both the states are same.
       
   128     if( iKeyLocked && !iKeyLock.IsKeyLockEnabled() )
       
   129 		{
       
   130 		iKeyLock.EnableWithoutNote();
       
   131 		}
       
   132     else if( !iKeyLocked && iKeyLock.IsKeyLockEnabled() )
       
   133     	{
       
   134 		iKeyLock.DisableWithoutNote();
       
   135 		}
       
   136 	iKeyLocked = EFalse;
       
   137     EVTUIDEBUG( "- CEvtKeyLockHandler::UpdateStateWithoutNote() - Key Lock Updated" );
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // CEvtKeyLockHandler::EnableKeyLock
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C void CEvtKeyLockHandler::EnableKeyLock( TBool aFlag )
       
   145 	{
       
   146     iKeyLocked = aFlag;
       
   147     EVTUIDEBUG1( "= CEvtKeyLockHandler::EnableKeyLock() - %d", iKeyLocked );
       
   148     }