|
1 /* |
|
2 * Copyright (c) 2005-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: Controls display backlight |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CMIDDEVICECONTROL_H |
|
21 #define CMIDDEVICECONTROL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <lcdui.h> |
|
26 #include <hwrmlight.h> |
|
27 |
|
28 // CLASS DECLARATION |
|
29 |
|
30 /** |
|
31 * Controls display backlight. |
|
32 * With this class it is possible to set the backlight level. |
|
33 * |
|
34 * @since 3.0 |
|
35 */ |
|
36 NONSHARABLE_CLASS(CMIDDeviceControl): public CBase, |
|
37 public MMIDComponent, public MHWRMLightObserver, public MMIDEnvObserver |
|
38 { |
|
39 public: // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 * Leaves object in cleanup stack. |
|
44 */ |
|
45 static CMIDDeviceControl* NewLC(MMIDEnv& aEnv); |
|
46 |
|
47 /** |
|
48 * Destructor. |
|
49 */ |
|
50 virtual ~CMIDDeviceControl(); |
|
51 |
|
52 public: // New functions |
|
53 |
|
54 /** |
|
55 * Gets the time since the last user activity. |
|
56 * @return returns user inactivity time in seconds |
|
57 * @since 9.1 |
|
58 */ |
|
59 void GetUserInactivityTimeL(TInt* aRetVal); |
|
60 static void StaticGetUserInactivityTimeL(CMIDDeviceControl* aDC, |
|
61 TInt* aRetVal); |
|
62 |
|
63 |
|
64 /** |
|
65 * Resets all user inactivity timers. |
|
66 * Can be used to prevent e.g. screen saver to appear on screen. |
|
67 * @since 9.1 |
|
68 */ |
|
69 void ResetUserInactivityTimeL(); |
|
70 static void StaticResetUserInactivityTimeL(CMIDDeviceControl* aDC); |
|
71 |
|
72 /** |
|
73 * Sets the backlight level. |
|
74 * @since 3.0 |
|
75 * @param aLevel Backlight level, 0-100, 0 = off. |
|
76 */ |
|
77 void SetLightL(TInt aLevel); |
|
78 static void StaticSetLightL(CMIDDeviceControl* aDC, TInt aLevel); |
|
79 |
|
80 /** |
|
81 * Flashes the backlight for given duration |
|
82 * @since 3.1 |
|
83 * @param aDuration Duration of flashing, in milliseconds |
|
84 * @return ETrue if flashing is possible |
|
85 */ |
|
86 TBool FlashBacklightL(TInt aDuration); |
|
87 static void StaticFlashBacklightL( |
|
88 CMIDDeviceControl* aDC, |
|
89 TInt aDuration, |
|
90 TBool* aRetVal); |
|
91 |
|
92 /** |
|
93 * Returns the backlight to sensor mode, and releases resources. |
|
94 * @since 3.0 |
|
95 */ |
|
96 void Release(); |
|
97 static void StaticRelease(CMIDDeviceControl* aDC); |
|
98 |
|
99 public: // From MMIDComponent |
|
100 void Dispose(); |
|
101 |
|
102 public: // From MHWRMLightObserver |
|
103 void LightStatusChanged(TInt aTarget, |
|
104 CHWRMLight::TLightStatus aStatus); |
|
105 |
|
106 |
|
107 // From MMIDEnvObserver |
|
108 void HandleSwitchOnL(TBool aSwitchOn); |
|
109 void HandleForegroundL(TBool aForeground); |
|
110 void HandleResourceChangeL(TInt aType); |
|
111 |
|
112 |
|
113 private: |
|
114 |
|
115 /** |
|
116 * C++ default constructor. |
|
117 */ |
|
118 CMIDDeviceControl(MMIDEnv& aEnv); |
|
119 |
|
120 /** |
|
121 * By default Symbian 2nd phase constructor is private. |
|
122 */ |
|
123 void ConstructL(); |
|
124 |
|
125 /** |
|
126 * Does the actual setting of lights |
|
127 */ |
|
128 void DoSetLightsL(TInt aLevel); |
|
129 |
|
130 /** |
|
131 * Checks whether lights are blinking. |
|
132 * @return ETrue if at least one supported light is blinking; else |
|
133 * EFalse is returned. |
|
134 */ |
|
135 TBool LightsBlinking(); |
|
136 |
|
137 private: // Data |
|
138 |
|
139 MMIDEnv& iEnv; |
|
140 |
|
141 // timestamp of start of flashing |
|
142 TTime* iStartTime; |
|
143 |
|
144 // remaining duration for flashing |
|
145 TInt iDuration; |
|
146 |
|
147 |
|
148 // Light Client API, owned |
|
149 CHWRMLight* iLight; |
|
150 |
|
151 // value of last setLights() call, |
|
152 // KErrNotFound if setLights() hasn't been called yet |
|
153 TInt iLightLevel; |
|
154 |
|
155 // Bitmask having information which ones of the backlights |
|
156 // are supported (primary/secondary displays and primary/secondary |
|
157 // keyboards). |
|
158 TInt iSupportedLights; |
|
159 |
|
160 }; |
|
161 |
|
162 #endif // CMIDDEVICECONTROL_H |
|
163 |
|
164 // End of File |