securitydialogs/lockapp/inc/lockappstatecontrol.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:  Controls lock states (keyguard locked/unlocked, devicelock)
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __LOCKAPPSTATECONTROL_H__
       
    20 #define __LOCKAPPSTATECONTROL_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include "lockappobserverlist.h"
       
    24 #include "lockappstatecontrolinterface.h"
       
    25 #include "lockappobserverinterface.h"
       
    26 #include <lockappclientserver.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CLockAppBaseControl;
       
    30 class CLockAppIdleControl;
       
    31 class CLockAppKeyguardControl;
       
    32 class CLockAppDevicelockControl;
       
    33 class CLockAppEcsDetector;
       
    34 class CLockAppPubSubObserver;
       
    35 class CAknIncallBubble;
       
    36 
       
    37 /**
       
    38  *  CLockAppStateControl class is the main locking state control class. 
       
    39  *  Class is derived from CLockAppObserverList observer list class. 
       
    40  *  Does not own visible user interface, but directs window server events like 
       
    41  *  key events to window-owning child controls (keyguard ui, emergency support). 
       
    42  *  All lock state changes should be handled through this class.
       
    43  *
       
    44  *  @lib    lockapp
       
    45  *  @since  5.0
       
    46  *  @author Joona Petrell
       
    47  *  @author Tamas Koteles
       
    48  */
       
    49 class CLockAppStateControl : public CLockAppObserverList, public MLockAppStateControl,
       
    50 		public MLockAppObserverInterface
       
    51 	{
       
    52 	public:
       
    53 
       
    54 		/**
       
    55 		 * Two-phased constructor.
       
    56 		 */
       
    57 		static CLockAppStateControl* NewL( );
       
    58 
       
    59 		/**
       
    60 		 * Destructor.
       
    61 		 */
       
    62 		~CLockAppStateControl( );
       
    63 
       
    64 	private:
       
    65 
       
    66 		/**
       
    67 		 * C++ default constructor.
       
    68 		 */
       
    69 		CLockAppStateControl( );
       
    70 
       
    71 		/**
       
    72 		 * Second phase constructor allowed to fail (leave).
       
    73 		 */
       
    74 		void ConstructL( );
       
    75 
       
    76 	public:
       
    77 
       
    78 		/**
       
    79 		 * Activate keyguard lock.
       
    80 		 *
       
    81 		 * @param aWithNote if "keys locked" note is shown
       
    82 		 * @return KErrAlreadyExists if already enabled
       
    83 		 *         KErrPermissionDenied if devicelock is activated
       
    84 		 *         KErrNone if succeeded
       
    85 		 */
       
    86 		TInt EnableKeyguardL( TBool aWithNote );
       
    87 
       
    88 		/**
       
    89 		 * Dectivate keyguard lock.
       
    90 		 *
       
    91 		 * @param aWithNote if "keys active" note is shown.
       
    92 		 * @return KErrAlreadyExists if already disabled
       
    93 		 *         KErrPermissionDenied if devicelock is activated
       
    94 		 *         KErrNone if succeeded
       
    95 		 */
       
    96 		TInt DisableKeyguardL( TBool aWithNote );
       
    97 
       
    98 		/**
       
    99 		 * Activate devicelock.
       
   100 		 *
       
   101 		 * @param aReason the device locking reason.
       
   102 		 * @return KErrAlreadyExists if already enabled.
       
   103 		 *         KErrNone if succeeded
       
   104 		 */
       
   105 		TInt EnableDevicelockL( TDevicelockReason aReason = EDevicelockManual );
       
   106 
       
   107 		/**
       
   108 		 * Dectivate devicelock.
       
   109 		 *
       
   110 		 * @return KErrAlreadyExists if already disabled
       
   111 		 *         KErrPermissionDenied if keyguard is activated
       
   112 		 *         KErrNone if succeeded
       
   113 		 */
       
   114 		TInt DisableDevicelockL( );
       
   115 
       
   116 		/**
       
   117 		 * Offer to enable keyguard by showing "offerkeylock" note.
       
   118 		 * @return KErrPermissionDenied if keyguard/devicelock already activated
       
   119 		 *         KErrNone if succeeded
       
   120 		 */
       
   121 		TInt OfferKeyguard( );
       
   122 
       
   123 		/**
       
   124 		 * Offer to enable keyguard by showing "offerkeylock" note.
       
   125 		 * 
       
   126 		 * @return KErrNone if succeeded
       
   127 		 *         KErrPermissionDenied if keyguard not enabled
       
   128 		 */
       
   129 		TInt ShowKeysLockedNote( );
       
   130 
       
   131 		/**
       
   132 		 * External access to lock state
       
   133 		 *
       
   134 		 * @return Current lock state
       
   135 		 */
       
   136 		TLockStatus LockStatus( ) const;
       
   137 
       
   138 		/**
       
   139 		 * External access to lock environment
       
   140 		 *
       
   141 		 * @return Current environment state mask
       
   142 		 */
       
   143 		TUint EnvironmentStatus( ) const;
       
   144 
       
   145 		/**
       
   146 		 * Only used for internal testing.
       
   147 		 * @return error code
       
   148 		 */
       
   149 		TInt ExecuteInternalTest( );
       
   150 
       
   151 	public:
       
   152 		// From MLockAppObserverInterface
       
   153 
       
   154 		/**
       
   155 		 * Handle Central Repository observer callback.
       
   156 		 */
       
   157 		void HandleCenRepNotify( TUid aCenRepUid, TUint32 aKeyId, TInt aValue );
       
   158 
       
   159 		/**
       
   160 		 * Handle Publish & Subscribe observer callback.
       
   161 		 */
       
   162 		void HandlePubSubNotify( TUid aPubSubUid, TUint aKeyId, TInt aValue );
       
   163 
       
   164 	public:
       
   165 		// from CCoeControl
       
   166 
       
   167 		TInt CountComponentControls( ) const;
       
   168 
       
   169 		CCoeControl* ComponentControl( TInt aIndex ) const;
       
   170 
       
   171 		TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   172 
       
   173 		void HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination );
       
   174 
       
   175 		void HandleResourceChange( TInt aType );
       
   176 
       
   177 	private:
       
   178 
       
   179 		/**
       
   180 		 * Creates the second "visibility gate" window group.
       
   181 		 */
       
   182 		void CreateVisibilityGateWgL( );
       
   183 
       
   184 		/**
       
   185 		 * Logs the telephony P&S call state.
       
   186 		 */
       
   187 		void PrintCallState( TInt aValue );
       
   188 
       
   189 		/**
       
   190 		 * Update the environment variable with the event.
       
   191 		 * @return ETrue if the environment value has changed
       
   192 		 *         EFalse otherwise
       
   193 		 */
       
   194 		TBool HandleEnvironmentChange( TUint aEventMask, TBool aEnable );
       
   195 
       
   196 		/**
       
   197 		 * Check if given transition is valid.
       
   198 		 * @return KErrNone if transition is legal
       
   199 		 *         KErrAlreadyExists if LockApp already is in requested state
       
   200 		 *         KErrPermissionDenied if illegal transition
       
   201 		 */
       
   202 		TInt CheckIfLegal( TLockAppMessageReason aReason );
       
   203 
       
   204 		/**
       
   205 		 * Handle lock state change. Should only called from
       
   206 		 * method PostStatusChangeL.
       
   207 		 *
       
   208 		 * @param aLockStatus The new lock state
       
   209 		 */
       
   210 		void HandleLockStatusChangedL( TLockStatus aLockStatus );
       
   211 
       
   212 		void BringForward( TBool aForeground );
       
   213 
       
   214 		/**
       
   215 		 * Mute/Unmute key sounds when phone is locked/unlocked.
       
   216 		 * 
       
   217 		 * @param aMuteSounds mute switch
       
   218 		 */
       
   219 		void MuteSounds( TBool aMuteSounds );
       
   220 
       
   221 		/**
       
   222 		 * Prescreen key events for special cases before giving them to child controls.
       
   223 		 */
       
   224 		TKeyResponse PreCheckKeyEvents( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   225 
       
   226 		/**
       
   227 		 * Power key needs to always activate lights.
       
   228 		 */
       
   229 		void CheckForPowerKeyLights( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   230 
       
   231 		/**
       
   232 		 * Green and Red keys should be passed to Phone during phone call.
       
   233 		 * @return ETrue if the keys have been forwarded
       
   234 		 *         EFalse otherwise
       
   235 		 */
       
   236 		TBool CheckForPhoneKeys( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   237 
       
   238 	private:
       
   239 
       
   240 		/**
       
   241 		 * Internal lock state.
       
   242 		 */
       
   243 		TLockStatus iLockStatus;
       
   244 
       
   245 		/**
       
   246 		 * Current control;
       
   247 		 */
       
   248 		CLockAppBaseControl* iCurrentControl;
       
   249 
       
   250 		/**
       
   251 		 * Idle UI.
       
   252 		 * Owned by superclass.
       
   253 		 */
       
   254 		CLockAppIdleControl* iIdle; // owned by superclass
       
   255 
       
   256 		/**
       
   257 		 * Keyguard UI.
       
   258 		 * Owned by superclass.
       
   259 		 */
       
   260 		CLockAppKeyguardControl* iKeyguard; // owned by superclass
       
   261 
       
   262 		/**
       
   263 		 * Autolock UI
       
   264 		 * Owned by superclass. 
       
   265 		 */
       
   266 		CLockAppDevicelockControl* iDevicelock;
       
   267 
       
   268 		/**
       
   269 		 * Emergency call detector with emergency note.
       
   270 		 * Owned by superclass.
       
   271 		 */
       
   272 		CLockAppEcsDetector* iLockEcsDetector;
       
   273 
       
   274 		/**
       
   275 		 * PubSub observers
       
   276 		 */
       
   277 		CLockAppPubSubObserver* iPSScreenSaverObserver;
       
   278 		CLockAppPubSubObserver* iPSTelephonyObserver;
       
   279 		CLockAppPubSubObserver* iPSGripObserver;
       
   280 		CLockAppPubSubObserver* iPSFPSObserver;
       
   281 
       
   282 		/**
       
   283 		 * Application's main window group - Event gate
       
   284 		 */
       
   285 		RWindowGroup& iWGEventGate;
       
   286 
       
   287 		/**
       
   288 		 * Visibility gate (owned)
       
   289 		 */
       
   290 		RWindowGroup iWGVisibilityGate;
       
   291 
       
   292 		/**
       
   293 		 * Incall Bubble. (owned)
       
   294 		 */
       
   295 		CAknIncallBubble* iIncallBubble;
       
   296 
       
   297 	private:
       
   298 
       
   299 		/**
       
   300 		 *  feature manager keys
       
   301 		 */
       
   302 		TBool iFeatureNoPowerkey;
       
   303 
       
   304 		/**
       
   305 		 * Offset value used to free reserved localization resources
       
   306 		 */
       
   307 		TInt iResourceFileOffset;
       
   308 
       
   309 		/**
       
   310 		 * if sounds are muted
       
   311 		 */
       
   312 		TBool iSoundsMuted;
       
   313 
       
   314 		/**
       
   315 		 * Environment state descriptor bit-mask
       
   316 		 */
       
   317 		TUint iEnvState;
       
   318 
       
   319 	};
       
   320 
       
   321 #endif // __LOCKAPPSTATECONTROL_H__
       
   322 // End of File