securitydialogs/lockclient/src/keyguardaccessapi.cpp
changeset 0 164170e6151a
child 15 318c4eab2439
child 49 09b1ac925e3f
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:  Interface to access keyguard.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <keyguardaccessapi.h>
       
    20 #include <lockappclientserver.h>
       
    21 #include "lockaccessextension.h"
       
    22 
       
    23 #include <avkondomainpskeys.h>      // KPSUidAvkonDomain, KAknKeyguardStatus, TAknKeyguardStatus
       
    24 #include <e32property.h> // P&S API
       
    25 #include <e32debug.h>
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Standard Symbian OS construction sequence
       
    29 // ---------------------------------------------------------------------------
       
    30 EXPORT_C CKeyguardAccessApi* CKeyguardAccessApi::NewL( )
       
    31     {
       
    32     CKeyguardAccessApi* self = new (ELeave) CKeyguardAccessApi( );
       
    33     CleanupStack::PushL( self );
       
    34     self->ConstructL( );
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // Constructor.
       
    41 // ---------------------------------------------------------------------------
       
    42 CKeyguardAccessApi::CKeyguardAccessApi()
       
    43     {
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // Destructor.
       
    48 // ---------------------------------------------------------------------------
       
    49 EXPORT_C CKeyguardAccessApi::~CKeyguardAccessApi( )
       
    50     {
       
    51     if ( iLockAccessExtension )
       
    52         {
       
    53         iLockAccessExtension->Close( );
       
    54         delete iLockAccessExtension;
       
    55         iLockAccessExtension = NULL;
       
    56         }
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // Second phase construction
       
    61 // ---------------------------------------------------------------------------
       
    62 void CKeyguardAccessApi::ConstructL( )
       
    63     {
       
    64     iLockAccessExtension = new (ELeave) RLockAccessExtension;
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // Checks if the phone has been locked using P&S key storing lock states
       
    69 // ---------------------------------------------------------------------------
       
    70 EXPORT_C TBool CKeyguardAccessApi::IsKeylockEnabled()
       
    71     {
       
    72     TInt value;
       
    73     TInt err = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, value);
       
    74     if ( err == KErrNone )
       
    75         {
       
    76         switch( value )
       
    77             {
       
    78             case EKeyguardLocked:
       
    79             case EKeyguardAutolockEmulation:
       
    80                 return ETrue;
       
    81             case EKeyguardNotActive:
       
    82             default:
       
    83                 return EFalse;
       
    84             }
       
    85         }
       
    86     else
       
    87         {
       
    88         return EFalse;
       
    89         }
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // Checks if the keyguard is enabled or not
       
    94 // ---------------------------------------------------------------------------
       
    95 EXPORT_C TBool CKeyguardAccessApi::IsKeyguardEnabled()
       
    96     {
       
    97     TInt value;
       
    98     TInt err = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, value);
       
    99     if ( err == KErrNone )
       
   100         {
       
   101         switch( value )
       
   102             {
       
   103             case EKeyguardLocked:
       
   104                 return ETrue;
       
   105             case EKeyguardAutolockEmulation:
       
   106             case EKeyguardNotActive:
       
   107             default:
       
   108                 return EFalse;
       
   109             }
       
   110         }
       
   111     else
       
   112         {
       
   113         return EFalse;
       
   114         }
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // Requests lockapp server to enable keyguard with or without note.
       
   119 // ---------------------------------------------------------------------------
       
   120 EXPORT_C TInt CKeyguardAccessApi::EnableKeyguard( TBool aWithNote )
       
   121     {
       
   122     if ( iLockAccessExtension )
       
   123         {
       
   124         return iLockAccessExtension->SendMessage( ELockAppEnableKeyguard, aWithNote );
       
   125         }
       
   126     else
       
   127         {
       
   128         return KErrNotFound;
       
   129         }
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // Requests lockapp server to disable keyguard with or without note.
       
   134 // ---------------------------------------------------------------------------
       
   135 EXPORT_C TInt CKeyguardAccessApi::DisableKeyguard( TBool aWithNote )
       
   136     {
       
   137     if ( iLockAccessExtension )
       
   138         {
       
   139         return iLockAccessExtension->SendMessage( ELockAppDisableKeyguard, aWithNote );
       
   140         }
       
   141     else
       
   142         {
       
   143         return KErrNotFound;
       
   144         }
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // Requests lockapp server to offer keyguard to user.
       
   149 // ---------------------------------------------------------------------------
       
   150 EXPORT_C TInt CKeyguardAccessApi::OfferKeyguard()
       
   151     {
       
   152     if ( iLockAccessExtension )
       
   153         {
       
   154         return iLockAccessExtension->SendMessage( ELockAppOfferKeyguard );
       
   155         }
       
   156     else
       
   157         {
       
   158         return KErrNotFound;
       
   159         }
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // Shows note informing that keys are locked. Only works if keyguard is already enabled.
       
   164 // ---------------------------------------------------------------------------
       
   165 EXPORT_C TInt CKeyguardAccessApi::ShowKeysLockedNote()
       
   166     {
       
   167     if ( iLockAccessExtension )
       
   168         {
       
   169         return iLockAccessExtension->SendMessage( ELockAppShowKeysLockedNote );
       
   170         }
       
   171     else
       
   172         {
       
   173         return KErrNotFound;
       
   174         }
       
   175     }
       
   176 
       
   177 
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // 
       
   181 // ---------------------------------------------------------------------------
       
   182 EXPORT_C TInt CKeyguardAccessApi::TestInternal( )
       
   183     {
       
   184 #ifdef _DEBUG
       
   185     if ( iLockAccessExtension )
       
   186         {
       
   187         return iLockAccessExtension->SendMessage( ELockAppTestInternal );
       
   188         }
       
   189     else
       
   190         {
       
   191         return KErrNotFound;
       
   192         }
       
   193 #else
       
   194     return KErrNotSupported;
       
   195 #endif
       
   196     }
       
   197 
       
   198 // ---------------------------------------------------------------------------
       
   199 // 
       
   200 // ---------------------------------------------------------------------------
       
   201 EXPORT_C TInt CKeyguardAccessApi::TestDestruct( )
       
   202     {
       
   203 #ifdef _DEBUG
       
   204     if ( iLockAccessExtension )
       
   205         {
       
   206         return iLockAccessExtension->SendMessage( ELockAppTestDestruct );
       
   207         }
       
   208     else
       
   209         {
       
   210         return KErrNotFound;
       
   211         }
       
   212 #else
       
   213     return KErrNotSupported;
       
   214 #endif
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // 
       
   219 // ---------------------------------------------------------------------------
       
   220 EXPORT_C TInt CKeyguardAccessApi::TestPanicClient( )
       
   221     {
       
   222 #ifdef _DEBUG
       
   223     if ( iLockAccessExtension )
       
   224         {
       
   225         return iLockAccessExtension->SendMessage( ELockAppTestPanicClient );
       
   226         }
       
   227     else
       
   228         {
       
   229         return KErrNotFound;
       
   230         }
       
   231 #else
       
   232     return KErrNotSupported;
       
   233 #endif
       
   234     }
       
   235 
       
   236 
       
   237 // End of File