securitydialogs/lockapp/src/lockappstatepublisher.cpp
branchRCL_3
changeset 21 09b1ac925e3f
parent 20 63339781d179
child 22 03674e5abf46
equal deleted inserted replaced
20:63339781d179 21:09b1ac925e3f
     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:  Publishes LockApp states to other applications
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "lockappstatepublisher.h"
       
    20 #include "lockapputils.h"
       
    21 
       
    22 // defines keys KPSUidAvkonDomain, KAknKeyguardStatus, TAknKeyguardStatus
       
    23 #include <avkondomainpskeys.h>
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // Standard Symbian OS construction sequence
       
    27 // ---------------------------------------------------------------------------
       
    28 CLockAppStatePublisher* CLockAppStatePublisher::NewL( )
       
    29     {
       
    30     CLockAppStatePublisher* self = new (ELeave) CLockAppStatePublisher();
       
    31     CleanupStack::PushL( self );
       
    32     self->ConstructL( );
       
    33     CleanupStack::Pop( self );
       
    34     return self;
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // Standard C++ constructor
       
    39 // ---------------------------------------------------------------------------
       
    40 CLockAppStatePublisher::CLockAppStatePublisher()
       
    41     {
       
    42     // no implementation required
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Closes the property handle.
       
    47 // ---------------------------------------------------------------------------
       
    48 CLockAppStatePublisher::~CLockAppStatePublisher()
       
    49     {
       
    50     iStatusProperty.Close();
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // Defines the P&S key storing keyguard status
       
    55 // ---------------------------------------------------------------------------
       
    56 void CLockAppStatePublisher::ConstructL()
       
    57     {
       
    58     // for some reason P&S capability policy macros do not work with codetest
       
    59 #ifdef _LOCKAPP_CODETEST_DEBUG
       
    60     RProperty::Define(
       
    61         KPSUidAvkonDomain,
       
    62         KAknKeyguardStatus,
       
    63         RProperty::EInt,
       
    64         TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
       
    65         TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
       
    66 #else
       
    67     // defines the P&S key
       
    68     _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData);
       
    69     RProperty::Define(
       
    70         KPSUidAvkonDomain,
       
    71         KAknKeyguardStatus,
       
    72         RProperty::EInt,
       
    73         TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
       
    74         KWritePolicy);
       
    75 #endif
       
    76     // creates handle to property
       
    77     iStatusProperty.Attach(KPSUidAvkonDomain, KAknKeyguardStatus);
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // From @c CLockAppStateObserver. Used to publish lockapp state
       
    82 // to external parties.
       
    83 // ---------------------------------------------------------------------------
       
    84 void CLockAppStatePublisher::HandleLockStatusChangedL( TLockStatus aLockStatus )
       
    85     {
       
    86     switch ( aLockStatus )
       
    87         {
       
    88         case ELockNotActive:
       
    89             {
       
    90             iStatusProperty.Set(EKeyguardNotActive);
       
    91             }
       
    92             break;
       
    93         case EDevicelockActive:
       
    94             {
       
    95             iStatusProperty.Set(EKeyguardAutolockEmulation);
       
    96             }
       
    97             break;
       
    98         case EKeyguardActive:
       
    99             {
       
   100             iStatusProperty.Set(EKeyguardLocked);
       
   101             }
       
   102             break;
       
   103         default:
       
   104             DoPanic(ELockUnknownValue);
       
   105             break;
       
   106         }
       
   107     }