securitydialogs/Autolock/src/AutoKeyguardObserver.cpp
branchRCL_3
changeset 36 2ca12c9f635b
parent 0 164170e6151a
child 47 63339781d179
equal deleted inserted replaced
24:fabe5ded361a 36:2ca12c9f635b
    32 #include <ScreensaverInternalPSKeys.h>
    32 #include <ScreensaverInternalPSKeys.h>
    33 #include <hwrmdomainpskeys.h>
    33 #include <hwrmdomainpskeys.h>
    34 #include "AutoKeyguardCenRepI.h"
    34 #include "AutoKeyguardCenRepI.h"
    35 #include "AutoKeyguardObserver.h"
    35 #include "AutoKeyguardObserver.h"
    36 #include "AutolockPrivateCRKeys.h"
    36 #include "AutolockPrivateCRKeys.h"
       
    37 #include "AutolockAppUiInterface.h"
    37 
    38 
    38 const TInt AutoKeyguardOff(60000);
    39 const TInt AutoKeyguardOff(60000);
    39 // Screensaver "On" status value
    40 // Screensaver "On" status value
    40 const TInt KSsOn = 1;
    41 const TInt KSsOn = 1;
    41 // Screensaver started fron idle status value
    42 // Screensaver started fron idle status value
    48 // ----------------------------------------------------------
    49 // ----------------------------------------------------------
    49 // CAutoKeyguardObserver::NewL()
    50 // CAutoKeyguardObserver::NewL()
    50 // ----------------------------------------------------------
    51 // ----------------------------------------------------------
    51 //
    52 //
    52 
    53 
    53 CAutoKeyguardObserver* CAutoKeyguardObserver::NewL()
    54 CAutoKeyguardObserver* CAutoKeyguardObserver::NewL( MAutolockAppUiInterface* aAppUiI )
    54 	{
    55 	{
    55 	#ifdef RD_AUTO_KEYGUARD
    56 	#ifdef RD_AUTO_KEYGUARD
    56 	#if defined(_DEBUG)
    57 	#if defined(_DEBUG)
    57     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::NewL() BEGIN"));
    58     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::NewL() BEGIN"));
    58     #endif
    59     #endif
    59 	CAutoKeyguardObserver* self = new (ELeave) CAutoKeyguardObserver();
    60 	CAutoKeyguardObserver* self = new (ELeave) CAutoKeyguardObserver( aAppUiI );
    60 	CleanupStack::PushL(self);
    61 	CleanupStack::PushL(self);
    61 	self->ConstructL(self);
    62 	self->ConstructL(self);
    62 	CleanupStack::Pop(); //self
    63 	CleanupStack::Pop(); //self
    63 	#if defined(_DEBUG)
    64 	#if defined(_DEBUG)
    64     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::NewL() END"));
    65     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::NewL() END"));
    72 // ----------------------------------------------------------
    73 // ----------------------------------------------------------
    73 // CAutoKeyguardObserver::CAutoKeyguardObserver()
    74 // CAutoKeyguardObserver::CAutoKeyguardObserver()
    74 // C++ default constructor
    75 // C++ default constructor
    75 // ----------------------------------------------------------
    76 // ----------------------------------------------------------
    76 // 
    77 // 
    77 CAutoKeyguardObserver::CAutoKeyguardObserver()	
    78 CAutoKeyguardObserver::CAutoKeyguardObserver( MAutolockAppUiInterface* aAppUiI ):
       
    79     iAppUiI( aAppUiI )
    78 	{
    80 	{
    79 	}
    81 	}
    80 
    82 
    81 //
    83 //
    82 // ----------------------------------------------------------
    84 // ----------------------------------------------------------
   339 	TInt callState = EPSCTsyCallStateNone;
   341 	TInt callState = EPSCTsyCallStateNone;
   340 	TBool okToLock = EFalse;
   342 	TBool okToLock = EFalse;
   341 	TBool screenSaverOn = EFalse;
   343 	TBool screenSaverOn = EFalse;
   342 	TBool screenSaverStertedFromIdle = EFalse;
   344 	TBool screenSaverStertedFromIdle = EFalse;
   343         TBool startupOver = EFalse;
   345         TBool startupOver = EFalse;
       
   346 	TBool codeQueryOpen = EFalse;
   344     //Get keyguard status
   347     //Get keyguard status
   345     RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, value);
   348     RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, value);
   346     keylockOn = (value == EKeyguardLocked);
   349     keylockOn = (value == EKeyguardLocked);
   347     //Get call state
   350     //Get call state
   348     RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState);
   351     RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState);
   372         
   375         
   373     #if defined(_DEBUG)
   376     #if defined(_DEBUG)
   374     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::LockKeysL() startupOver: %d"), startupOver);
   377     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::LockKeysL() startupOver: %d"), startupOver);
   375     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::LockKeysL() Startup state: %d"), value);
   378     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::LockKeysL() Startup state: %d"), value);
   376     #endif
   379     #endif
       
   380 	//See if the lock code query is open
       
   381     codeQueryOpen = iAppUiI->DeviceLockQueryStatus();
       
   382     #if defined(_DEBUG)
       
   383     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::LockKeysL() codeQueryOpen: %d"), codeQueryOpen);
       
   384     RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::LockKeysL() autolockOn: %d"), autolockOn);
       
   385     #endif
   377     if (startupOver)
   386     if (startupOver)
   378         {
   387         {
       
   388 		// If lock code query is open and device lock is on, cancel the query.
       
   389         // AppUi will enable keylock when the query is cancelled
       
   390         if (autolockOn && codeQueryOpen)
       
   391             {
       
   392             #if defined(_DEBUG)
       
   393             RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardObserver::LockKeysL() Query open, cancel it"));
       
   394             #endif
       
   395             iAppUiI->CancelDeviceLockQuery();
       
   396             return;
       
   397             }
   379         // If keylock is already ON, there is a ongoing call, 
   398         // If keylock is already ON, there is a ongoing call, 
   380         // autolock is already ON or phone is not in idle, don't lock.
   399         // autolock is already ON or phone is not in idle, don't lock.
   381         if (keylockOn || (callState > EPSCTsyCallStateNone) || autolockOn || !idle)
   400         if (keylockOn || (callState > EPSCTsyCallStateNone) || autolockOn || !idle)
   382             {
   401             {
   383         	    #if defined(_DEBUG)
   402         	    #if defined(_DEBUG)