remotelock/RemoteLockEngine/Src/RLLockObserver.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 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:  Implementation of Unlocking event observer
       
    15 *
       
    16 */
       
    17 
       
    18 #include    <PSVariables.h>
       
    19 #include    <coreapplicationuisdomainpskeys.h>
       
    20 #include    "RLLockObserver.h"	
       
    21 #include    "RemoteLockTrace.h"
       
    22 
       
    23 
       
    24 // ================= MEMBER FUNCTIONS =======================
       
    25 //
       
    26 // ----------------------------------------------------------
       
    27 // CRLLockObserver::NewL()
       
    28 // Constructs a new entry with given values.
       
    29 // ----------------------------------------------------------
       
    30 //
       
    31 CRLLockObserver* CRLLockObserver::NewL( MRLLockObserverHandler* aHandler )
       
    32     {
       
    33     CRLLockObserver* self = new (ELeave) CRLLockObserver( aHandler );
       
    34     CleanupStack::PushL( self );
       
    35     self->ConstructL();
       
    36     CleanupStack::Pop( self );
       
    37     return self;
       
    38     }
       
    39 //
       
    40 // ----------------------------------------------------------
       
    41 // CRLLockObserver::CRLLockObserver()
       
    42 // Destructor
       
    43 // ----------------------------------------------------------
       
    44 //
       
    45 CRLLockObserver::~CRLLockObserver()
       
    46     {
       
    47     Cancel();
       
    48     }
       
    49 //
       
    50 // ----------------------------------------------------------
       
    51 // CRLLockObserver::Start()
       
    52 // Starts listening KCoreAppUIsAutolockStatus/
       
    53 // KPSUidAutolockStatusValue event 
       
    54 // ----------------------------------------------------------
       
    55 //
       
    56 TInt CRLLockObserver::Start()
       
    57     {
       
    58     RL_TRACE_PRINT(" [ rl.exe ] CLockObserver::Start() "); 
       
    59     
       
    60     if (IsActive())
       
    61         {
       
    62         return KErrInUse;
       
    63         }   
       
    64         
       
    65     iStatus = KRequestPending;
       
    66     
       
    67     #ifndef RD_STARTUP_CHANGE   
       
    68     iProperty.Attach( KUidSystemCategory, KPSUidAutolockStatusValue ); 
       
    69     #else //RD_STARTUP_CHANGE
       
    70     iProperty.Attach( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus ); 
       
    71     #endif //RD_STARTUP_CHANGE    
       
    72     iProperty.Subscribe(iStatus);
       
    73     
       
    74     SetActive();
       
    75     return KErrNone;
       
    76     }
       
    77 //
       
    78 // ----------------------------------------------------------
       
    79 // CRLLockObserver::CRLLockObserver()
       
    80 // C++ constructor
       
    81 // ----------------------------------------------------------
       
    82 // 
       
    83 CRLLockObserver::CRLLockObserver( MRLLockObserverHandler* aHandler ) 
       
    84     : CActive(0), iHandler( aHandler )
       
    85     {                            
       
    86     }
       
    87 //
       
    88 // ----------------------------------------------------------
       
    89 // CRLLockObserver::ConstructL()
       
    90 // ----------------------------------------------------------
       
    91 // 
       
    92 void CRLLockObserver::ConstructL()
       
    93     {
       
    94     RL_TRACE_PRINT(" [ rl.exe ] CLockObserver::ConstructL() ");
       
    95     // Add this active object to the scheduler.
       
    96     CActiveScheduler::Add(this);
       
    97     //Start listenning
       
    98     Start();
       
    99     }
       
   100 //
       
   101 // ----------------------------------------------------------
       
   102 // CRLLockObserver::RunL()
       
   103 // Called when device (autolock) is activated from menu.
       
   104 // ----------------------------------------------------------
       
   105 // 
       
   106 void CRLLockObserver::RunL()
       
   107     {
       
   108     RL_TRACE_PRINT(" [ rl.exe ] CLockObserver::RunL() ");
       
   109 
       
   110     TInt autolockState;
       
   111     iProperty.Get( autolockState );
       
   112     
       
   113     #ifndef RD_STARTUP_CHANGE
       
   114     if (autolockState == EPSAutolockOff )
       
   115     #else //RD_STARTUP_CHANGE
       
   116     if (autolockState == EAutolockOff )
       
   117     #endif //RD_STARTUP_CHANGE
       
   118         {
       
   119         RL_TRACE_PRINT(" [ rl.exe ] CLockObserver::RunL remove Memory card Password ");
       
   120         iHandler->HandleUnlockEvent();
       
   121         } 
       
   122     Start();
       
   123     }
       
   124 //
       
   125 // ----------------------------------------------------------
       
   126 // CRLLockObserver::DoCancel()
       
   127 // Cancels event listening
       
   128 // ----------------------------------------------------------
       
   129 // 
       
   130 void CRLLockObserver::DoCancel()
       
   131     {
       
   132     RL_TRACE_PRINT(" [ rl.exe ] CLockObserver::DoCancel() ");
       
   133     iProperty.Cancel();
       
   134     }
       
   135     
       
   136 // End of file
       
   137