|
1 // Copyright (c) 2008-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 // |
|
15 |
|
16 // INCLUDE FILES |
|
17 #include <centralrepository.h> |
|
18 #include "HWRMtrace.h" |
|
19 #include "HWRMPower.h" |
|
20 #include "HWRMPowerImpl.h" |
|
21 #include "HWRMPowerDomainCRKeys.h" |
|
22 |
|
23 |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 |
|
27 // EXTERNAL FUNCTION PROTOTYPES |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 |
|
35 // MODULE DATA STRUCTURES |
|
36 |
|
37 // LOCAL FUNCTION PROTOTYPES |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 |
|
41 // ============================= LOCAL FUNCTIONS =============================== |
|
42 |
|
43 // ============================ MEMBER FUNCTIONS =============================== |
|
44 |
|
45 /** |
|
46 * Two-phased constructor for creating a CHWRMPower client. |
|
47 */ |
|
48 EXPORT_C CHWRMPower* CHWRMPower::NewL() |
|
49 { |
|
50 CHWRMPower* power = NewLC(); |
|
51 |
|
52 CleanupStack::Pop(); |
|
53 |
|
54 return power; |
|
55 } |
|
56 |
|
57 /** |
|
58 * Two-phased constructor for creating a CHWRMPower client. |
|
59 * Leaves instance to CleanupStack. |
|
60 * |
|
61 */ |
|
62 EXPORT_C CHWRMPower* CHWRMPower::NewLC() |
|
63 { |
|
64 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::NewLC()" )); |
|
65 |
|
66 CHWRMPower* power = new( ELeave ) CHWRMPower(); |
|
67 |
|
68 CleanupStack::PushL( power ); |
|
69 power->ConstructL(); |
|
70 |
|
71 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::NewLC - return" )); |
|
72 |
|
73 return power; |
|
74 } |
|
75 |
|
76 |
|
77 /** |
|
78 * Symbian 2nd phase constructor can leave. |
|
79 * |
|
80 * @param aVoltageCallback Pointer to callback instance. |
|
81 * @param aConsumptionCallback Pointer to callback instance. |
|
82 */ |
|
83 void CHWRMPower::ConstructL() |
|
84 { |
|
85 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::Construct()" )); |
|
86 |
|
87 iPowerImpl = CHWRMPowerImpl::NewL(); |
|
88 |
|
89 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::Construct - return" )); |
|
90 } |
|
91 |
|
92 /** |
|
93 * C++ Destructor |
|
94 */ |
|
95 EXPORT_C CHWRMPower::~CHWRMPower() |
|
96 { |
|
97 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::~CHWRMPower()" )); |
|
98 |
|
99 delete iPowerImpl; |
|
100 |
|
101 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::~CHWRMPower()- return" )); |
|
102 } |
|
103 |
|
104 /** |
|
105 * Asynch |
|
106 * |
|
107 * Get the Battery Info |
|
108 * |
|
109 * @param aStatus This will be completed when the data are ready or an error occurs. |
|
110 * @param aBatteryConsumptionData The nominal battery info is returned in this parameter. Valid only when aStatus.Int() == KErrNone |
|
111 * @see CHWRMPower::TBatteryConsumptionData |
|
112 */ |
|
113 EXPORT_C void CHWRMPower::GetBatteryInfo(TRequestStatus& aStatus, TBatteryConsumptionData& aBatteryConsumptionData) |
|
114 { |
|
115 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBatteryInfo()" )); |
|
116 |
|
117 iPowerImpl->DoGetBatteryInfo(aStatus, aBatteryConsumptionData); |
|
118 |
|
119 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBatteryInfo - return" )); |
|
120 } |
|
121 |
|
122 /** |
|
123 * Asynch |
|
124 * |
|
125 * Get the Battery Voltage Info |
|
126 * |
|
127 * @param aStatus This will be completed when the data are ready or an error occurs. |
|
128 * @param aBatteryVoltageData The nominal battery info is returned in this parameter. Valid only when aStatus.Int() == KErrNone |
|
129 * @see CHWRMPower::TBatteryVoltageData |
|
130 * |
|
131 */ |
|
132 EXPORT_C void CHWRMPower::GetBatteryVoltageInfo(TRequestStatus& aStatus, TBatteryVoltageData& aBatteryVoltageData) |
|
133 { |
|
134 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBatteryVoltageInfo()" )); |
|
135 |
|
136 iPowerImpl->DoGetBatteryVoltageInfo(aStatus, aBatteryVoltageData); |
|
137 |
|
138 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBatteryVoltageInfo - return" )); |
|
139 } |
|
140 |
|
141 /** |
|
142 * |
|
143 * Get the Base Time interval used by the plugin |
|
144 * |
|
145 * @param aBaseTimeInterval The Base Time Interval is returned in this parameter. |
|
146 * |
|
147 */ |
|
148 EXPORT_C void CHWRMPower::GetBaseTimeIntervalL(TInt &aBaseTimeInterval) |
|
149 { |
|
150 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBaseTimeIntervalL()" )); |
|
151 |
|
152 CRepository* powerCenRep = CRepository::NewLC(KCRUidPowerSettings); |
|
153 |
|
154 //cache it in private member? |
|
155 |
|
156 User::LeaveIfError(powerCenRep->Get(KPowerBaseTimeInterval, aBaseTimeInterval)); |
|
157 |
|
158 CleanupStack::PopAndDestroy(powerCenRep); |
|
159 |
|
160 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBaseTimeIntervalL - return" )); |
|
161 } |
|
162 |
|
163 /** |
|
164 * |
|
165 * Post Start request to HWRM Server to start battery Power |
|
166 * measurements |
|
167 * |
|
168 * @param aStatus This will be completed when measurements start or an error occurs. |
|
169 * @param aInterval: time period multiple. |
|
170 */ |
|
171 EXPORT_C TInt CHWRMPower::StartAveragePowerReporting(TRequestStatus& aStatus, const TUint& aInterval) |
|
172 { |
|
173 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::StartAveragePowerReporting()" )); |
|
174 |
|
175 TInt err = iPowerImpl->DoStartAveragePowerReporting(aStatus, aInterval); |
|
176 |
|
177 COMPONENT_TRACE2(_L( "HWRM PowerClient - CHWRMPower::StartAveragePowerReporting( - return 0x%x" ), err ); |
|
178 |
|
179 return err; |
|
180 } |
|
181 |
|
182 /** |
|
183 * Synchronous |
|
184 * |
|
185 * Post stop request to HWRM Server to stop battery |
|
186 * power measurements |
|
187 * |
|
188 * success/failure for stopping measurements. |
|
189 */ |
|
190 EXPORT_C void CHWRMPower::StopAveragePowerReportingL() |
|
191 { |
|
192 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::StopAveragePowerReportingL()" )); |
|
193 |
|
194 iPowerImpl->DoStopAveragePowerReportingL(); |
|
195 |
|
196 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::StopAveragePowerReportingL - return" )); |
|
197 } |
|
198 |
|
199 |
|
200 EXPORT_C TInt CHWRMPower::SetPowerReportObserver(MHWRMBatteryPowerObserver* aPowerReportCallback) |
|
201 { |
|
202 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::SetPowerReportObserverL()" )); |
|
203 |
|
204 TRAPD(err,iPowerImpl->DoSetPowerReportObserverL(aPowerReportCallback)); |
|
205 |
|
206 COMPONENT_TRACE2(_L( "HWRM PowerClient - CHWRMPower::SetPowerReportObserverL err=%d- return" ), err); |
|
207 |
|
208 return err; |
|
209 |
|
210 } |
|
211 |
|
212 |
|
213 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
214 |
|
215 /** |
|
216 * Synchronous |
|
217 * Get the charger type. |
|
218 * @param aChargerType Contains the charger type if request is successful. |
|
219 * @return KErrNone if successful.Otherwise appropriate Error code |
|
220 * @see CHWRMPower::TBatteryChargerType |
|
221 * |
|
222 */ |
|
223 |
|
224 EXPORT_C TInt CHWRMPower::GetBatteryChargerType(TBatteryChargerType& aChargerType) |
|
225 { |
|
226 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBatteryChargerType()" )); |
|
227 |
|
228 aChargerType = CHWRMPower::EBatteryChargerUnKnown; |
|
229 |
|
230 TInt err = iPowerImpl->DoGetBatteryChargerType(aChargerType); |
|
231 |
|
232 COMPONENT_TRACE3(_L( "HWRM PowerClient - Charger Type = %d err = %d" ), aChargerType, err); |
|
233 |
|
234 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBatteryChargerType() - return" )); |
|
235 |
|
236 return err; |
|
237 } |
|
238 /** |
|
239 * Synchronous |
|
240 * Get the charging status. |
|
241 * @param aChargingStatus Contains the charging status if request is successful. |
|
242 * @return KErrNone if successful.Otherwise appropriate Error code |
|
243 * @see CHWRMPower::TBatteryChargingStatus |
|
244 * |
|
245 */ |
|
246 |
|
247 EXPORT_C TInt CHWRMPower::GetBatteryChargingStatus(TBatteryChargingStatus& aChargingStatus) |
|
248 { |
|
249 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBatteryChargingStatus()" )); |
|
250 |
|
251 TInt err = iPowerImpl->DoGetBatteryChargingStatus(aChargingStatus); |
|
252 |
|
253 COMPONENT_TRACE3(_L( "HWRM PowerClient - err=%d aChargingStatus=%d" ), err, aChargingStatus); |
|
254 |
|
255 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::GetBatteryChargingStatus - return" )); |
|
256 |
|
257 return err; |
|
258 } |
|
259 |
|
260 /** |
|
261 * Synchronous |
|
262 * Set callbacks for charging information. |
|
263 * |
|
264 * @param aChargingStatusCallback Pointer to callback instance. |
|
265 * @param aChrgRateCallback Pointer to callback instance. |
|
266 * @param aChrgTimeCallback Pointer to callback instance. |
|
267 */ |
|
268 |
|
269 |
|
270 EXPORT_C TInt CHWRMPower::SetBatteryChargingObserver( |
|
271 MHWRMBatteryChargingStatusObserver* aChargingStatusCallback, |
|
272 MHWRMBatteryChargingCurrentObserver* aChrgCurrentCallback, |
|
273 MHWRMBatteryFullChargingTimeObserver* aChrgTimeCallback) |
|
274 { |
|
275 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::SetBatteryChargingObserver()" )); |
|
276 |
|
277 TRAPD(err,iPowerImpl->DoSetBatteryChargingObserverL(aChargingStatusCallback, aChrgCurrentCallback, |
|
278 aChrgTimeCallback)); |
|
279 |
|
280 COMPONENT_TRACE2(_L( "HWRM PowerClient - CHWRMPower::SetBatteryChargingObserver err=%d- return" ), err); |
|
281 |
|
282 return err; |
|
283 |
|
284 } |
|
285 |
|
286 |
|
287 /** |
|
288 * |
|
289 * Post Start request to HWRM Server to start Battery Charging Current |
|
290 * measurements |
|
291 * |
|
292 * @param aStatus This will be completed when measurements start or an error occurs. |
|
293 * @param aInterval: time period multiple. |
|
294 */ |
|
295 EXPORT_C TInt CHWRMPower::NotifyAverageChargingCurrent(TRequestStatus& aStatus, const TUint& aInterval) |
|
296 { |
|
297 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::NotifyAverageChargingCurrent()" )); |
|
298 |
|
299 TInt err = iPowerImpl->DoNotifyAverageChargingCurrent(aStatus, aInterval); |
|
300 |
|
301 COMPONENT_TRACE2(_L( "HWRM PowerClient - CHWRMPower::NotifyAverageChargingCurrent( - return 0x%x" ), err ); |
|
302 |
|
303 return err; |
|
304 } |
|
305 |
|
306 /** |
|
307 * |
|
308 * Post Start request to HWRM Server to remaining charging time |
|
309 * measurements |
|
310 * |
|
311 * @param aStatus This will be completed when measurements start or an error occurs. |
|
312 */ |
|
313 EXPORT_C TInt CHWRMPower::NotifyBatteryFullChargingTime(TRequestStatus& aStatus) |
|
314 { |
|
315 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::NotifyBatteryFullChargingTime()" )); |
|
316 |
|
317 TInt err = iPowerImpl->DoNotifyBatteryFullChargingTime(aStatus); |
|
318 |
|
319 COMPONENT_TRACE2(_L( "HWRM PowerClient - CHWRMPower::NotifyBatteryFullChargingTime( - return 0x%x" ), err ); |
|
320 |
|
321 return err; |
|
322 } |
|
323 |
|
324 |
|
325 /** |
|
326 * Synchronous |
|
327 * |
|
328 * Post stop request to HWRM Server to stop average current measurements. |
|
329 * |
|
330 * success/failure for stopping measurements. |
|
331 */ |
|
332 EXPORT_C void CHWRMPower::StopChargingNotificationL(TBatteryChargingNotifier aNotifier) |
|
333 { |
|
334 COMPONENT_TRACE2(_L( "HWRM PowerClient - CHWRMPower::StopAverageVoltageReporting() aNotifier=%d" ), aNotifier); |
|
335 |
|
336 iPowerImpl->DoStopChargingNotificationL(aNotifier); |
|
337 |
|
338 COMPONENT_TRACE1(_L( "HWRM PowerClient - CHWRMPower::StopAverageVoltageReporting - return" )); |
|
339 } |
|
340 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
341 |
|
342 // End of File |