securitydialogs/keylockpolicyapi/src/keylockpolicyapi.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:  Keylock policy component offers a configuration support for keyguard
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "keylockpolicyapi.h"
       
    20 #include "keylockpolicyapiimpl.h"
       
    21 
       
    22 // ---------------------------------------------------------------------------
       
    23 // Standard two-phased construction
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 EXPORT_C CKeyLockPolicyApi* CKeyLockPolicyApi::NewL( TLockPolicyType aType )
       
    27 	{
       
    28 	CKeyLockPolicyApi *self = new ( ELeave ) CKeyLockPolicyApi( );
       
    29 	CleanupStack::PushL( self );
       
    30 	self->ConstructL( aType );
       
    31 	CleanupStack::Pop( self );
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // Destructor
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C CKeyLockPolicyApi::~CKeyLockPolicyApi( )
       
    40 	{
       
    41 	delete iKeylockpolicyImplementation;
       
    42 	iKeylockpolicyImplementation = NULL;
       
    43 	}
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Returns true if the policy initialization has been successful.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 EXPORT_C TBool CKeyLockPolicyApi::HasConfiguration( )
       
    50 	{
       
    51 	return iKeylockpolicyImplementation->HasConfiguration( );
       
    52 	}
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Set the central repository key to allow keyguard
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 EXPORT_C TInt CKeyLockPolicyApi::EnableKeyguardFeature( )
       
    59 	{
       
    60 	return iKeylockpolicyImplementation->EnableKeyguardFeature( );
       
    61 	}
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Set the central repository key to disable keyguard
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 EXPORT_C TInt CKeyLockPolicyApi::DisableKeyguardFeature( )
       
    68 	{
       
    69 	return iKeylockpolicyImplementation->DisableKeyguardFeature( );
       
    70 	}
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // Return true if keyguard feature is allowed
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C TBool CKeyLockPolicyApi::KeyguardAllowed( )
       
    77 	{
       
    78 	return CKeyLockPolicyApiImpl::KeyguardAllowed( );
       
    79 	}
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // Add new key combination to the selected policy type+mode combination
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 EXPORT_C TInt CKeyLockPolicyApi::AddKeyCombination( TUint32 aPrimaryKey, TUint32 aSecondaryKey )
       
    86 	{
       
    87 	return iKeylockpolicyImplementation->AddKeyCombination(aPrimaryKey, aSecondaryKey);
       
    88 	}
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // Removes a key set defined in the selected policy type+mode combination
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 EXPORT_C TInt CKeyLockPolicyApi::RemoveKeyCombination( TUint32 aPrimaryKey, TUint32 aSecondaryKey )
       
    95 	{
       
    96 	return iKeylockpolicyImplementation->RemoveKeyCombination(aPrimaryKey, aSecondaryKey);
       
    97 	}
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // Receives a key set from spesified index
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 EXPORT_C TInt CKeyLockPolicyApi::GetKeyCombination( TInt aIndex, TUint32 &aPrimaryKey, TUint32 &aSecondaryKey )
       
   104 	{
       
   105 	return iKeylockpolicyImplementation->GetKeyCombination(aIndex, aPrimaryKey, aSecondaryKey);
       
   106 	}
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // Clear all key combinations from the selected policy type+mode combination
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 EXPORT_C TInt CKeyLockPolicyApi::ClearKeycombinations( )
       
   113 	{
       
   114 	return iKeylockpolicyImplementation->ClearKeycombinations( );
       
   115 	}
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // Receives keys and checks whether they match any primary+secondary key combination
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C TBool CKeyLockPolicyApi::HandleKeyEventL( const TKeyEvent& aKeyEvent, const TEventCode aType )
       
   122 	{
       
   123 	return iKeylockpolicyImplementation->HandleKeyEventL(aKeyEvent, aType);
       
   124 	}
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // Returns true if the last received key matched any of the primary keys
       
   128 // stored in the policy
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 EXPORT_C TBool CKeyLockPolicyApi::PrimaryKeyPressed( )
       
   132 	{
       
   133 	return iKeylockpolicyImplementation->PrimaryKeyPressed( );
       
   134 	}
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // Returns the last received key if it was a primary key
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 EXPORT_C TUint CKeyLockPolicyApi::GetLastPrimaryKey( )
       
   141 	{
       
   142 	return iKeylockpolicyImplementation->GetLastPrimaryKey( );
       
   143 	}
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // Default C++ constructor
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 CKeyLockPolicyApi::CKeyLockPolicyApi( )
       
   150 	{
       
   151 	}
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // Keylock policy construction
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CKeyLockPolicyApi::ConstructL( TLockPolicyType aType )
       
   158 	{
       
   159 	iKeylockpolicyImplementation = CKeyLockPolicyApiImpl::NewL( aType );
       
   160 	}
       
   161 
       
   162 // EOF