idlefw/src/framework/aikeylockobserver.cpp
branchRCL_3
changeset 8 d0529222e3f0
parent 4 1a2a00e78665
child 11 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 8:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Focus observer for Active idle 2
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <aipspropertyobserver.h>
       
    20 #include <activeidle2domainpskeys.h>
       
    21 #include <avkondomainpskeys.h>      // KPSUidAvkonDomain, KAknKeyguardStatus, TAknKeyguardStatus
       
    22 #include "aistatemanager.h"
       
    23 #include "aikeylockobserver.h"
       
    24 #include "aifwpanic.h"
       
    25 #include "debug.h"
       
    26 
       
    27 CAiKeylockObserver::CAiKeylockObserver()
       
    28     {
       
    29     }
       
    30     
       
    31 CAiKeylockObserver::~CAiKeylockObserver()
       
    32     {
       
    33     }
       
    34 
       
    35 CAiKeylockObserver* CAiKeylockObserver::NewL(
       
    36                                         MAiStateManager* aStateManager )
       
    37     {
       
    38     CAiKeylockObserver* self = new (ELeave) CAiKeylockObserver();
       
    39     CleanupStack::PushL(self);
       
    40     self->ConstructL( aStateManager );
       
    41     CleanupStack::Pop(self);
       
    42     return self;
       
    43     }
       
    44 
       
    45 void CAiKeylockObserver::ConstructL( MAiStateManager* aStateManager )
       
    46     {
       
    47     BaseConstructL( TCallBack( HandleKeylockStatusEvent, this ),
       
    48                     KPSUidAvkonDomain, 
       
    49                     KAknKeyguardStatus, 
       
    50                     aStateManager );
       
    51     }
       
    52     
       
    53 TAiStateChanges CAiKeylockObserver::Status()
       
    54     {
       
    55 	TInt value;
       
    56 	TInt err = iObserver->Get( value );
       
    57 	if( err != KErrNone ) 
       
    58 	    {
       
    59 	    return ESMAIKeylockDisabled;
       
    60 	    }
       
    61 	    
       
    62 	switch( value ) 
       
    63 	    {
       
    64 	    case EKeyguardLocked:
       
    65 	    case EKeyguardAutolockEmulation: // fallthorugh
       
    66 	        {
       
    67 	        return ESMAIKeylockEnabled;
       
    68 	        }
       
    69 	    case EKeyguardNotActive:
       
    70 	    default: // fallthorugh
       
    71 	        {
       
    72 	        return ESMAIKeylockDisabled;
       
    73 	        }
       
    74 	    }
       
    75     }
       
    76 
       
    77 TInt CAiKeylockObserver::HandleKeylockStatusEvent( TAny* aPtr )
       
    78     {
       
    79     CAiKeylockObserver* self =
       
    80                 static_cast<CAiKeylockObserver*>( aPtr );
       
    81     
       
    82     __ASSERT_DEBUG( self, 
       
    83                     AiFwPanic::Panic( AiFwPanic::EAiFwPanic_NullPointerReference ) );
       
    84     
       
    85     TAiStateChanges stateChange = self->Status();
       
    86     self->iStateManager->ReportStateChange( stateChange );
       
    87     return KErrNone;
       
    88     }
       
    89