secsrv_plat/keylock_policy_api/inc/keylockpolicyapi.h
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 #ifndef ___CKEYLOCKPOLICYAPI__
       
    20 #define ___CKEYLOCKPOLICYAPI__
       
    21 
       
    22 #include <w32std.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 /**
       
    26  * Keylock policy component supports three policy types:
       
    27  *
       
    28  * EPolicyActivateKeyguard keys used for keyguard locking
       
    29  * EPolicyDeactivateKeyguard keys used for keyguard unlocking
       
    30  * EPolicyDevicelockQuery keys used for showing devicelock query
       
    31  */
       
    32 enum TLockPolicyType
       
    33 	{
       
    34 	EPolicyActivateKeyguard = 1,
       
    35 	EPolicyDeactivateKeyguard,
       
    36 	EPolicyDevicelockQuery,
       
    37 	};
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class CKeyLockPolicyApiImpl;
       
    41 
       
    42 /**
       
    43  *  CKeyLockPolicyApi. Trough CKeyLockPolicyApi users can
       
    44  *
       
    45  *  @lib keylockpolicy.lib
       
    46  *  @since 3.2
       
    47  */
       
    48 class CKeyLockPolicyApi : public CBase
       
    49 	{
       
    50 public:
       
    51 
       
    52 	/**
       
    53 	 * Use this to create keylock policy
       
    54 	 * @param TLockPolicyType aType the policy used
       
    55 	 */
       
    56 	IMPORT_C static CKeyLockPolicyApi* NewL( TLockPolicyType aType );
       
    57 
       
    58 	/**
       
    59 	 * Destructor.
       
    60 	 */
       
    61 	IMPORT_C ~CKeyLockPolicyApi();
       
    62 
       
    63 	/**
       
    64 	 * If no policy has been defined for the type it cannot be used.
       
    65 	 * @return ETrue if has succesfully loaded policy
       
    66 	 */
       
    67 	IMPORT_C TBool HasConfiguration();
       
    68 
       
    69 	/**
       
    70 	 * Activates support for keyguard feature so  the phone keys cannot
       
    71 	 * be locked with keyguard. Does not affect the devicelock.
       
    72 	 * @return standard Symbian error code
       
    73 	 */
       
    74 	IMPORT_C TInt EnableKeyguardFeature();
       
    75 
       
    76 	/**
       
    77 	 * Disables support for keyguard feature so the phone keys cannot
       
    78 	 * be locked with keyguard. Does not affect the devicelock.
       
    79 	 * @return standard Symbian error code
       
    80 	 */
       
    81 	IMPORT_C TInt DisableKeyguardFeature();
       
    82 
       
    83 	/**
       
    84 	 * Whether keyguard feature is currently enabled or disabled.
       
    85 	 * @return ETrue if keyguard can be locked.
       
    86 	 */
       
    87 	IMPORT_C TBool static KeyguardAllowed();
       
    88 
       
    89 	/**
       
    90 	 * Adds a key combination for the policy type defined in the construction.
       
    91 	 *
       
    92 	 * @param TUint scan code for primary key
       
    93 	 * @param TUint scan code for secondary key
       
    94 	 * @return standard Symbian error code
       
    95 	 */
       
    96 	IMPORT_C TInt AddKeyCombination(TUint32 aPrimaryKey, TUint32 aSecondaryKey);
       
    97 
       
    98 	/**
       
    99 	 * Removes a key combination for the policy type defined in the construction.
       
   100 	 *
       
   101 	 * @param TUint scan code for primary key
       
   102 	 * @param TUint scan code for secondary key
       
   103 	 * @return standard Symbian error code
       
   104 	 */
       
   105 	IMPORT_C TInt RemoveKeyCombination(TUint32 aPrimaryKey, TUint32 aSecondaryKey);
       
   106 
       
   107 	/**
       
   108 	 * Retrieve a key combination on the given index.
       
   109 	 *
       
   110 	 * @param TInt aIndex index on the list that stores key combinations
       
   111 	 * @param TUint key code for primary key
       
   112 	 * @param TUint key code for secondary key
       
   113 	 * @return standard Symbian error code
       
   114 	 */
       
   115 	IMPORT_C TInt GetKeyCombination(TInt aIndex, TUint32 &aPrimaryKey, TUint32 &aSecondaryKey);
       
   116 
       
   117 	/**
       
   118 	 * Clears all the defined key combinations from the policy.
       
   119 	 *
       
   120 	 * @return standard Symbian error code
       
   121 	 */
       
   122 	IMPORT_C TInt ClearKeycombinations();
       
   123 
       
   124 	/**
       
   125 	 * Handles Key events, returns ETrue the key events match any of the
       
   126 	 * defined key combinations. Only uses scancodes with type EEventKeyDown.
       
   127 	 *
       
   128 	 * @param TKeyEvent aKeyEvent the actual key event
       
   129 	 * @param TEventCode aType the type of the received key event
       
   130 	 * @return ETrue if a match was found.
       
   131 	 */
       
   132 	IMPORT_C TBool HandleKeyEventL(const TKeyEvent& aKeyEvent, const TEventCode aType );
       
   133 
       
   134 	/**
       
   135 	 * Returns true if primary button is pressed and note should be shown.
       
   136 	 * @return boolean true if primary key is pressed.
       
   137 	 */
       
   138 	IMPORT_C TBool PrimaryKeyPressed();
       
   139 
       
   140 	/**
       
   141 	 * Returns Primary key scan code that has been pressed last.
       
   142 	 * @return scan code value of the primary key if found, NULL if not
       
   143 	 */
       
   144 	IMPORT_C TUint GetLastPrimaryKey();
       
   145 
       
   146 private:
       
   147 
       
   148 	/**
       
   149 	 * C++ default constructor (private so cannot be derived).
       
   150 	 */
       
   151 	CKeyLockPolicyApi( );
       
   152 
       
   153 	/**
       
   154 	 * Second constructor initializes the policy
       
   155 	 * @param TLockPolicyType aType the policy (TLockPolicyType) used
       
   156 	 */
       
   157 	void ConstructL( TLockPolicyType aType );
       
   158 
       
   159 private:
       
   160 
       
   161 	/**
       
   162 	 * Actual implemetation.
       
   163 	 */
       
   164 	CKeyLockPolicyApiImpl* iKeylockpolicyImplementation;
       
   165 
       
   166 	};
       
   167 
       
   168 #endif // ___CKEYLOCKPOLICYAPI__
       
   169