|
1 /* |
|
2 * Copyright (c) 2006-2009 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 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalTechnology |
|
24 */ |
|
25 |
|
26 #ifndef HWRMLIGHTCOMMONDATA_H |
|
27 #define HWRMLIGHTCOMMONDATA_H |
|
28 |
|
29 // INCLUDES |
|
30 #include <e32base.h> |
|
31 #include <centralrepository.h> |
|
32 #include <e32property.h> |
|
33 #include "cenrepobserver.h" |
|
34 #include "HWRMLightsTimeoutObserver.h" |
|
35 #include "HWRMLight.h" |
|
36 #include "HWRMCmn.h" |
|
37 |
|
38 // CONSTANTS |
|
39 // None |
|
40 |
|
41 // MACROS |
|
42 // None |
|
43 |
|
44 // DATA TYPES |
|
45 // None |
|
46 |
|
47 // FUNCTION PROTOTYPES |
|
48 // None |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 class CHWRMLightService; |
|
52 class CHWRMPluginHandler; |
|
53 class CHWRMReservationHandler; |
|
54 class CHWRMTargetModifierPlugin; |
|
55 |
|
56 // CLASS DECLARATION |
|
57 /** |
|
58 * Container for Light data that is common for all sessions. |
|
59 * Also handles Light related cenrep and P&S data. |
|
60 * HWRM server upkeeps the instance. |
|
61 * |
|
62 */ |
|
63 class CHWRMLightCommonData : public CBase, |
|
64 public MCenRepObserver, |
|
65 public MHWRMLightsTimeoutObserver |
|
66 { |
|
67 public: // Constructors and Destructor |
|
68 |
|
69 /** |
|
70 * Two-phased constructor. |
|
71 * |
|
72 * @param aPluginHandler Pointer to plugin handler for light |
|
73 * @param aReservationHandler Pointer to reservation handler for light |
|
74 */ |
|
75 static CHWRMLightCommonData* NewL(CHWRMPluginHandler* aPluginHandler, |
|
76 CHWRMReservationHandler* aReservationHandler); |
|
77 |
|
78 /** |
|
79 * Destructor. |
|
80 */ |
|
81 virtual ~CHWRMLightCommonData(); |
|
82 |
|
83 public: // New functions |
|
84 |
|
85 /** |
|
86 * Getter for default sensor sensitivity |
|
87 * |
|
88 * @return Default sensor sensitivity |
|
89 */ |
|
90 TInt DefaultSensitivity(); |
|
91 |
|
92 /** |
|
93 * Getter for light sensor enable status |
|
94 * |
|
95 * @return Light sensor enable status |
|
96 */ |
|
97 TBool SensorEnabled(); |
|
98 |
|
99 /** |
|
100 * Getter for supported light targets |
|
101 * |
|
102 * @return Bitmask of supported lights targets. |
|
103 */ |
|
104 inline TInt SupportedTargets() const; |
|
105 |
|
106 /** |
|
107 * Getter for sensor supporting light targets |
|
108 * |
|
109 * @return Bitmask of sensor supporting lights targets. |
|
110 */ |
|
111 inline TInt SensorTargets() const; |
|
112 |
|
113 /** |
|
114 * Getter for full system light target |
|
115 * |
|
116 * @return Bitmask of full system light targets. |
|
117 */ |
|
118 inline TInt FullSystemTarget() const; |
|
119 |
|
120 /** |
|
121 * Publish Light status |
|
122 * |
|
123 * @param aTarget Light target for which the status is published. |
|
124 * @param aStatus New Light status to be published. |
|
125 */ |
|
126 void PublishLightStatus(TInt aTarget, CHWRMLight::TLightStatus aStatus); |
|
127 |
|
128 /** |
|
129 * Checks what the default state for lights should be |
|
130 * based on inactivity timer. |
|
131 * |
|
132 * @return CHWRMLight::TLightStatus indicating desired state. |
|
133 */ |
|
134 CHWRMLight::TLightStatus DefaultState() const; |
|
135 |
|
136 /** |
|
137 * Modifies target as defined in CHWRMTargetModifierPlugin |
|
138 * @see CHWRMTargetModifierPlugin::ModifyTargetL |
|
139 */ |
|
140 TInt ModifyTargetL(TInt aTarget); |
|
141 |
|
142 public: // Functions from base classes |
|
143 |
|
144 // From MCenRepObserver |
|
145 void HandleNotifyInt(TUint32 aId, TInt aNewValue); |
|
146 void HandleNotifyError(TUint32 aId, TInt error, CCenRepListener* aHandler); |
|
147 |
|
148 // From MHWRMLightsTimeoutObserver |
|
149 void LightsTimeoutChange(TInt aTimeout); |
|
150 |
|
151 private: |
|
152 |
|
153 /** |
|
154 * C++ default constructor. |
|
155 */ |
|
156 CHWRMLightCommonData(); |
|
157 |
|
158 /** |
|
159 * By default Symbian 2nd phase constructor is private. |
|
160 * |
|
161 * @param aPluginHandler Pointer to plugin handler for light |
|
162 * @param aReservationHandler Pointer to reservation handler for light |
|
163 */ |
|
164 void ConstructL(CHWRMPluginHandler* aPluginHandler, |
|
165 CHWRMReservationHandler* aReservationHandler); |
|
166 |
|
167 /** |
|
168 * Sets iDefaultIntensity within allowed limits. |
|
169 * Also updates the value to plugin. |
|
170 * @param aValue Value to set as the intensity. |
|
171 * @param aConstructCall If ETrue, method is called from ConstructL |
|
172 */ |
|
173 void SetDefaultIntensity(TInt aValue, TBool aConstructCall = EFalse); |
|
174 |
|
175 /** |
|
176 * Sets iDefaultSensitivity within allowed limits |
|
177 * Also updates the value to plugin. |
|
178 * @param aValue Value to set as the sensitivity |
|
179 * @param aConstructCall If ETrue, method is called from ConstructL |
|
180 */ |
|
181 void SetDefaultSensitivity(TInt aValue, TBool aConstructCall = EFalse); |
|
182 |
|
183 /** |
|
184 * Restarts notifications and re-reads values from cenrep. |
|
185 * Used at startup and if there is an error with notifiers. |
|
186 */ |
|
187 void ResetCenrepL(); |
|
188 |
|
189 /** |
|
190 * Cleans up central repository related parameters. |
|
191 */ |
|
192 void CleanCenrep(); |
|
193 |
|
194 /** |
|
195 * Finds item from iStatusList by target. |
|
196 */ |
|
197 static TInt FindByTarget( const TInt* aTarget, |
|
198 const THWRMStatusInfo& aItem ); |
|
199 |
|
200 private: |
|
201 |
|
202 TInt iDefaultIntensity; // Default intensity for lights |
|
203 TInt iDefaultSensitivity; // Default sensor sensitivity for lights |
|
204 TBool iSensorOn; // ETrue if sensor is enabled |
|
205 TBool iSensorSupported; // ETrue if sensor is supported by platform |
|
206 TInt iSupportedTargets; // Supported targets mask |
|
207 CRepository* iRepository; // Cenrep client |
|
208 CCenRepListener* iIntensityNotifyHandler; // Cenrep notifyhandler |
|
209 CCenRepListener* iSensitivityNotifyHandler; // Cenrep notifyhandler |
|
210 CCenRepListener* iSensorNotifyHandler; // Cenrep notifyhandler |
|
211 RProperty iLightStatusProperty; // P&S property for publishing light status |
|
212 TInt iInactivityLimit; // Cached inactivity limit |
|
213 CHWRMLightsTimeoutObserver* iLightsTimeoutObserver; // Lights timeout observer |
|
214 CHWRMLightService* iLightService; // Light service used to notify plugin about |
|
215 // default intensity and sensitivity changes |
|
216 CHWRMTargetModifierPlugin* iTargetModifier; // Target modifier plugin |
|
217 TInt iFullSystemTarget; // Full system target, obtained from TM plugin |
|
218 TInt iSensorTargets; // Targets that support sensor |
|
219 RLightStatusArray iStatusList; // Cached light status |
|
220 |
|
221 }; |
|
222 |
|
223 #include "HWRMLightCommonData.inl" |
|
224 |
|
225 #endif // HWRMLIGHTCOMMONDATA_H |
|
226 |
|
227 // End of File |