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