|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // CUserActivityManager class |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef ACTIVITYMANAGER_H |
|
19 #define ACTIVITYMANAGER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 /** |
|
24 The CUserActivityManager API allows clients to easily monitor for |
|
25 user inactivity and activity. It is a key part in implementing functionality |
|
26 such as power management and screen savers. |
|
27 |
|
28 Clients construct the object using NewL() and call Start() to register |
|
29 callbacks to begin [in]activity monitoring. Monitoring continues until the |
|
30 object is destroyed. Clients can call SetInactivityTimeout() to adjust the |
|
31 inactivity interval once started. |
|
32 |
|
33 Callbacks supplied by clients should: |
|
34 - complete quickly with minimal blocking. |
|
35 - never call CUserActivityManager APIs as reentrancy is not supported. |
|
36 - never leave otherwise it can lead to panics. |
|
37 |
|
38 This API uses "CUserActivityManager" category panics for its error strategy as |
|
39 it has few error return code paths. Specific panics raised by APIs through |
|
40 improper use can be seen in the API documentation. KErrGeneral is raised |
|
41 when the internal state is irrecoverable. |
|
42 |
|
43 @see CTimer |
|
44 @see TCallback |
|
45 |
|
46 @publishedPartner |
|
47 @released |
|
48 */ |
|
49 NONSHARABLE_CLASS(CUserActivityManager) : public CTimer |
|
50 { |
|
51 public: |
|
52 IMPORT_C static CUserActivityManager* NewL(TInt aPriority); |
|
53 IMPORT_C ~CUserActivityManager(); |
|
54 IMPORT_C void Start(TTimeIntervalSeconds aInterval, |
|
55 TCallBack aInactiveCallback, |
|
56 TCallBack aActiveCallback); |
|
57 IMPORT_C void SetInactivityTimeout(TTimeIntervalSeconds aInterval); |
|
58 private: |
|
59 void RunL(); |
|
60 CUserActivityManager(TInt aPriority); |
|
61 void MonitorInactivity(); |
|
62 private: |
|
63 |
|
64 /** @internalComponent */ |
|
65 enum TState { |
|
66 EStUndefined = 0, //< Never used, reserved |
|
67 EStNotActive, //< Constructed but not started |
|
68 EStMonForInactivity, //< Monitoring user inactivity mode |
|
69 EStMonForActivity //< Monitoring user activity mode |
|
70 }; |
|
71 |
|
72 /** Inactivity interval */ |
|
73 TTimeIntervalSeconds iInterval; |
|
74 |
|
75 /** Callback to be used in case that user inactivity is detected */ |
|
76 TCallBack iInactiveCallback; |
|
77 |
|
78 /** Callback to be used in case of user activity after inactivity period */ |
|
79 TCallBack iActiveCallback; |
|
80 |
|
81 /** State of object, what form of monitoring is active. */ |
|
82 TState iState; |
|
83 }; |
|
84 |
|
85 #endif // ACTIVITYMANAGER_H |