securitydialogs/Autolock/src/AutoLockValueObserver.cpp
changeset 0 164170e6151a
child 47 63339781d179
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     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 *		Observer for phone events. Used to deactive/active the side-key
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include    <e32property.h>
       
    22 #include	<PSVariables.h>
       
    23 #include <ctsydomainpskeys.h>
       
    24 #include	"AutolockAppUiPS.h"
       
    25 #include	"AutoLockValueObserverPS.h"
       
    26 
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 //
       
    30 // ----------------------------------------------------------
       
    31 // CValueObserver::NewL()
       
    32 // Constructs a new entry with given values.
       
    33 // ----------------------------------------------------------
       
    34 //
       
    35 CValueObserver* CValueObserver::NewL(CAutolockAppUi* aAppUi)
       
    36     {
       
    37     CValueObserver* self = new (ELeave) CValueObserver(aAppUi);
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop();
       
    41     return self;
       
    42     }
       
    43 //
       
    44 // ----------------------------------------------------------
       
    45 // CValueObserver::CValueObserver()
       
    46 // Destructor
       
    47 // ----------------------------------------------------------
       
    48 //
       
    49 CValueObserver::~CValueObserver()
       
    50     {
       
    51     Cancel();
       
    52     }
       
    53 //
       
    54 // ----------------------------------------------------------
       
    55 // CValueObserver::Start()
       
    56 // Starts listening KUidCurrentCall event  
       
    57 // ----------------------------------------------------------
       
    58 //
       
    59 TInt CValueObserver::Start()
       
    60     {
       
    61     if (IsActive())
       
    62         return KErrInUse;
       
    63     iStatus = KRequestPending;
       
    64     iProperty.Attach(KPSUidCtsyCallInformation, KCTsyCallState); 
       
    65     iProperty.Subscribe(iStatus);
       
    66     SetActive();
       
    67     return KErrNone;
       
    68     }
       
    69 //
       
    70 // ----------------------------------------------------------
       
    71 // CValueObserver::Stop()
       
    72 // Stops listening KUidCurrentCall event 
       
    73 // ----------------------------------------------------------
       
    74 //
       
    75 void CValueObserver::Stop()
       
    76 	{
       
    77 	Cancel();
       
    78 	}
       
    79 //
       
    80 // ----------------------------------------------------------
       
    81 // CLockObserver::CLockObserver()
       
    82 // C++ constructor
       
    83 // ----------------------------------------------------------
       
    84 // 
       
    85 CValueObserver::CValueObserver(CAutolockAppUi* aAppUi) : CActive(0), iAppUi(aAppUi)
       
    86 	{                            
       
    87     }
       
    88 //
       
    89 // ----------------------------------------------------------
       
    90 // CLockObserver::ConstructL()
       
    91 // Symbian OS default constructor
       
    92 // ----------------------------------------------------------
       
    93 // 
       
    94 void CValueObserver::ConstructL()
       
    95     {
       
    96     // Add this active object to the scheduler.
       
    97 	CActiveScheduler::Add(this);	
       
    98     }
       
    99 //
       
   100 // ----------------------------------------------------------
       
   101 // CValueObserver::RunL()
       
   102 // 
       
   103 // ----------------------------------------------------------
       
   104 // 
       
   105 void CValueObserver::RunL()
       
   106 	{
       
   107     TInt callState;
       
   108     iProperty.Get( callState );
       
   109     if (callState == EPSCTsyCallStateNone && !iAppUi->IsForeground())
       
   110         {
       
   111 		// app back to foreground
       
   112 		iAppUi->BringAppToForegroundL();
       
   113 		}
       
   114     else
       
   115 		{
       
   116 		Start();
       
   117 		}
       
   118 	
       
   119 	}
       
   120 //
       
   121 // ----------------------------------------------------------
       
   122 // CValueObserver::DoCancel()
       
   123 // Cancels event listening
       
   124 // ----------------------------------------------------------
       
   125 // 
       
   126 void CValueObserver::DoCancel()
       
   127     {
       
   128     iProperty.Cancel();
       
   129     }
       
   130 
       
   131 // End of file