securitydialogs/Autolock/src/AutolockFpsStatusObserver.cpp
branchRCL_3
changeset 22 03674e5abf46
parent 0 164170e6151a
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
       
     1 /*
       
     2 * Copyright (c) 2002 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32base.h>
       
    19 #include <e32debug.h>
       
    20 #include <AknCapServerDefs.h>
       
    21 #include <apgtask.h>
       
    22 #include "AutolockFpsStatusObserver.h"
       
    23 
       
    24 
       
    25 EXPORT_C CAutolockFpsStatusObserver* CAutolockFpsStatusObserver::NewL( MAutolockFpsStatusObserver* aObserver, RWsSession& aSession )
       
    26     {
       
    27     CAutolockFpsStatusObserver* self = new (ELeave) CAutolockFpsStatusObserver( aSession );
       
    28     CleanupStack::PushL( self );
       
    29     self->ConstructL( aObserver );
       
    30     CleanupStack::Pop( self );
       
    31     return self;
       
    32     }
       
    33 
       
    34 void CAutolockFpsStatusObserver::ConstructL( MAutolockFpsStatusObserver* aObserver )
       
    35     {
       
    36     #if defined(_DEBUG)
       
    37     RDebug::Print(_L("(AUTOLOCK)CAutolockFpsStatusObserver::ConstructL") );
       
    38     #endif
       
    39 const TUid KUidFpsCategory = {0x1020507E };
       
    40 
       
    41 // PnS key
       
    42 const TUint32 KFpsAuthenticationKey = 0x00000001;
       
    43 
       
    44     TInt err = iFpsStatus.Attach( KUidFpsCategory, KFpsAuthenticationKey );
       
    45     if ( err )
       
    46         {
       
    47         #if defined(_DEBUG)
       
    48         RDebug::Print(_L("(AUTOLOCK)ERROR: Attach failed, err %d"), err );
       
    49         #endif
       
    50         }
       
    51     iObserver = aObserver;
       
    52     CActiveScheduler::Add( this );
       
    53     iFpsStatus.Subscribe( iStatus );
       
    54     SetActive();
       
    55     }
       
    56 
       
    57 CAutolockFpsStatusObserver::CAutolockFpsStatusObserver( RWsSession& aSession ) : CActive( EPriorityIdle ), iSession( aSession )
       
    58     {
       
    59     }
       
    60 
       
    61 CAutolockFpsStatusObserver::~CAutolockFpsStatusObserver()
       
    62     {
       
    63     #if defined(_DEBUG)
       
    64     RDebug::Print(_L("(AUTOLOCK)CAutolockFpsStatusObserver::~CAutolockFpsStatusObserver") );
       
    65     #endif
       
    66     Cancel();
       
    67     iFpsStatus.Close();
       
    68     }
       
    69 
       
    70 void CAutolockFpsStatusObserver::DoCancel()
       
    71     {
       
    72     #if defined(_DEBUG)
       
    73     RDebug::Print(_L("(AUTOLOCK)CAutolockFpsStatusObserver::DoCancel") );
       
    74     #endif
       
    75     iFpsStatus.Cancel();
       
    76     }
       
    77 
       
    78 void CAutolockFpsStatusObserver::RunL()
       
    79     {
       
    80     #if defined(_DEBUG)
       
    81     RDebug::Print(_L("(AUTOLOCK)CAutolockFpsStatusObserver::RunL") );
       
    82     #endif
       
    83     iFpsStatus.Subscribe( iStatus );
       
    84     SetActive();
       
    85     
       
    86     TInt FpsStatus;
       
    87     TInt err = iFpsStatus.Get( FpsStatus );
       
    88     if( !err )
       
    89     	{
       
    90         FpsStatusChangedL( FpsStatus );
       
    91         }
       
    92     }
       
    93 
       
    94 void CAutolockFpsStatusObserver::FpsStatusChangedL( TInt aFpsStatus )
       
    95     {
       
    96 const TUint32 ESwipeValid = 0x00000001;
       
    97     if( aFpsStatus == ESwipeValid )
       
    98     	{
       
    99         #if defined(_DEBUG)
       
   100     	RDebug::Print(_L("(AUTOLOCK)CAutolockFpsStatusObserver::FpsStatusChangedL => Fps opened"));
       
   101     	#endif 
       
   102     	if( iObserver->DeviceLockStatus() )
       
   103     		{
       
   104             #if defined(_DEBUG)
       
   105         	RDebug::Print(_L("(AUTOLOCK)CAutolockFpsStatusObserver::FpsStatusChangedL => unlocking"));
       
   106         	#endif
       
   107 		iObserver->DeviceFpsLock(1);
       
   108     		}
       
   109     	else
       
   110     		{
       
   111             #if defined(_DEBUG)
       
   112         	RDebug::Print(_L("(AUTOLOCK)CAutolockFpsStatusObserver::FpsStatusChangedL => locking"));
       
   113         	#endif
       
   114 		iObserver->DeviceFpsLock(0);
       
   115     		}
       
   116         }
       
   117     }
       
   118 
       
   119 // End of File