harvester/harvesterserver/inc/cactivitymanager.h
changeset 23 d4d56f5e7c55
child 24 65456528cac2
equal deleted inserted replaced
20:556534771396 23:d4d56f5e7c55
       
     1 /*
       
     2 * Copyright (c) 2010 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 *
       
    16 */
       
    17 
       
    18 #include <e32base.h>
       
    19 #include <hwrmlight.h>
       
    20 
       
    21 #ifndef CACTIVITYMANAGER_H_
       
    22 #define CACTIVITYMANAGER_H_
       
    23 
       
    24 class MActivityManagerObserver
       
    25 {
       
    26 public :
       
    27     virtual void ActivityChanged(const TBool aActive) = 0;
       
    28 };
       
    29 
       
    30 //#define MONITOR_LIGHTS
       
    31 class CActivityManager : public CActive
       
    32 #ifdef MONITOR_LIGHTS   
       
    33                            ,public MHWRMLightObserver
       
    34 #endif
       
    35 
       
    36 {
       
    37 public:
       
    38 
       
    39     /**
       
    40      * Two-phased constructor.
       
    41      *     
       
    42      */
       
    43     static CActivityManager* NewL(MActivityManagerObserver* aObserver, TInt aTimeout = 60);
       
    44 
       
    45     /**
       
    46      * Destructor
       
    47      *     
       
    48      */
       
    49     virtual ~CActivityManager();
       
    50     void SetTimeout(TInt aTimeout);
       
    51     void Start();
       
    52     void Reset();
       
    53     void Stop();
       
    54     TBool IsInactive();
       
    55 
       
    56 
       
    57 protected: // from CActive
       
    58     void DoCancel();
       
    59     void RunL();
       
    60     TInt RunError(TInt aError);
       
    61 
       
    62 protected:
       
    63     CActivityManager(MActivityManagerObserver* aObserver, TInt aTimeout);
       
    64     void ConstructL();
       
    65     void NotifyObserver();
       
    66     
       
    67 #ifdef MONITOR_LIGHTS
       
    68 private: //From MHWRMLightObserver
       
    69     void LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus);
       
    70 #endif
       
    71     
       
    72 protected:
       
    73     enum TWatch { ENone = 0, EWaitingForInactivity, EWaitingForActivity };
       
    74 
       
    75 protected:
       
    76     RTimer iTimer;
       
    77     TWatch iWatch;
       
    78     MActivityManagerObserver* iObserver; ///The observer of activity status
       
    79     TInt iTimeout; ///Current inactivity period
       
    80     
       
    81 #ifdef MONITOR_LIGHTS
       
    82     //Backlight control 
       
    83     CHWRMLight* iLight;
       
    84     //backlight status
       
    85     TBool iLights;
       
    86 #endif
       
    87     //previous status
       
    88     TInt iPreviousStatus;
       
    89     TBool iFirstRound;
       
    90 };
       
    91 #endif /* CACTIVITYMANAGER_H_ */