|
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 "HWRMChargingStatusObserver.h" |
|
17 #include "HWRMtrace.h" |
|
18 #include "HWRMPower.h" |
|
19 #include <hwrmpowerstatesdkpskeys.h> |
|
20 |
|
21 // ----------------------------------------------------------------------------- |
|
22 // CHWRMChargingStatusObs::CHWRMChargingStatusObs |
|
23 // |
|
24 // ----------------------------------------------------------------------------- |
|
25 // |
|
26 |
|
27 |
|
28 CHWRMChargingStatusObs::CHWRMChargingStatusObs(MHWRMBatteryChargingStatusObserver* aChargingStatusCallback) |
|
29 :iChargingPsObserver(NULL), |
|
30 iChargingStatusObserver(aChargingStatusCallback), |
|
31 //Charging status is initialised to unknown value |
|
32 iChargingStatus(KErrUnknown) |
|
33 { |
|
34 |
|
35 } |
|
36 |
|
37 CHWRMChargingStatusObs::~CHWRMChargingStatusObs() |
|
38 { |
|
39 |
|
40 delete iChargingPsObserver; |
|
41 iChargingPsObserver = NULL; |
|
42 |
|
43 COMPONENT_TRACE1(_L( "HWRM CHWRMChargingStatusObs - ~CHWRMChargingStatusObs deleted iChargingPsObserver")); |
|
44 } |
|
45 |
|
46 |
|
47 CHWRMChargingStatusObs* CHWRMChargingStatusObs::NewL(MHWRMBatteryChargingStatusObserver* aChargingStatusCallback) |
|
48 { |
|
49 |
|
50 COMPONENT_TRACE1(_L( "HWRM CHWRMChargingStatusObs - CHWRMChargingStatusObs::NewL()")); |
|
51 |
|
52 CHWRMChargingStatusObs* chargingStatusObs = new( ELeave ) CHWRMChargingStatusObs(aChargingStatusCallback); |
|
53 |
|
54 CleanupStack::PushL( chargingStatusObs ); |
|
55 chargingStatusObs->ConstructL(); |
|
56 CleanupStack::Pop(); |
|
57 |
|
58 COMPONENT_TRACE1(_L( "HWRM CHWRMChargingStatusObs - CHWRMChargingStatusObs::NewL() - return")); |
|
59 |
|
60 return chargingStatusObs; |
|
61 } |
|
62 |
|
63 void CHWRMChargingStatusObs::ConstructL() |
|
64 { |
|
65 COMPONENT_TRACE1(_L( "HWRM CHWRMChargingStatusObs - CHWRMChargingStatusObs::ConstructL()")); |
|
66 |
|
67 iChargingPsObserver = CPsPropertyObserver::NewL(KPSUidHWRMPowerState, KHWRMChargingStatus, *this); |
|
68 |
|
69 COMPONENT_TRACE1(_L( "HWRM CHWRMChargingStatusObs - CHWRMChargingStatusObs::ConstructL() - return")); |
|
70 } |
|
71 |
|
72 |
|
73 void CHWRMChargingStatusObs::PsPropertyChanged(TInt aKey, TInt aValue, TInt aError) |
|
74 { |
|
75 if((aKey == KHWRMChargingStatus)&&(iChargingStatusObserver)&& |
|
76 (iChargingStatus != aValue)) |
|
77 { |
|
78 iChargingStatus = aValue; |
|
79 |
|
80 iChargingStatusObserver->ChargingStatusChange(aError, |
|
81 (CHWRMPower::TBatteryChargingStatus)aValue); |
|
82 } |
|
83 } |
|
84 |
|
85 TInt CHWRMChargingStatusObs::Get(TInt& val) |
|
86 { |
|
87 return iChargingPsObserver->Get(val); |
|
88 } |
|
89 |
|
90 |
|
91 // End of File |
|
92 |