|
1 // Copyright (c) 2006-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 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <ecom/ecom.h> |
|
21 #include <centralrepository.h> |
|
22 #include "HWRMPowerStatePluginHandler.h" |
|
23 #include "HWRMtrace.h" |
|
24 #include "HWRMConfiguration.h" |
|
25 #include "HWRMPrivateCRKeys.h" |
|
26 #include "HWRMPrivatePSKeys.h" |
|
27 |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 // None |
|
31 |
|
32 // EXTERNAL FUNCTION PROTOTYPES |
|
33 // None |
|
34 |
|
35 // CONSTANTS |
|
36 // None |
|
37 |
|
38 // MACROS |
|
39 // None |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 // None |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 // None |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 // None |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 // None |
|
52 |
|
53 // ============================= LOCAL FUNCTIONS =============================== |
|
54 |
|
55 // ============================ MEMBER FUNCTIONS =============================== |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CHWRMPluginHandler::CHWRMPluginHandler |
|
59 // C++ constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CHWRMPowerStatePluginHandler::CHWRMPowerStatePluginHandler(TBool aChargerBlockVibra, |
|
63 TBool aChargerBlockFeedbackVibration) |
|
64 : iPlugin(NULL), |
|
65 iChargerBlockVibra(aChargerBlockVibra), |
|
66 iChargerBlockVibraFeedback(aChargerBlockFeedbackVibration) |
|
67 { |
|
68 COMPONENT_TRACE1(_L("HWRM Server - CHWRMPowerStatePluginHandler::CHWRMPowerStatePluginHandler()") ); |
|
69 COMPONENT_TRACE1(_L("HWRM Server - CHWRMPowerStatePluginHandler::CHWRMPowerStatePluginHandler - return" ) ); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CHWRMPowerStatePluginHandler::ConstructL |
|
74 // 2nd phase constructor gets plugin instance. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CHWRMPowerStatePluginHandler::ConstructL() |
|
78 { |
|
79 COMPONENT_TRACE1(_L("HWRM Server - CHWRMPowerStatePluginHandler::ConstructL()") ); |
|
80 |
|
81 // Define and attach to the P&S values |
|
82 // Battery level |
|
83 User::LeaveIfError( RProperty::Define( KPSUidHWRMPowerState, |
|
84 KHWRMBatteryLevel, RProperty::EInt, |
|
85 KNoCapability, KHWRMSidOnlyPolicy ) ); |
|
86 User::LeaveIfError( iBattLevelProp.Attach( KPSUidHWRMPowerState, |
|
87 KHWRMBatteryLevel ) ); |
|
88 // Battery status |
|
89 User::LeaveIfError( RProperty::Define( KPSUidHWRMPowerState, |
|
90 KHWRMBatteryStatus, RProperty::EInt, |
|
91 KNoCapability, KHWRMSidOnlyPolicy ) ); |
|
92 User::LeaveIfError( iBattStatusProp.Attach( KPSUidHWRMPowerState, |
|
93 KHWRMBatteryStatus ) ); |
|
94 // Charging status |
|
95 User::LeaveIfError( RProperty::Define( KPSUidHWRMPowerState, |
|
96 KHWRMChargingStatus, RProperty::EInt, |
|
97 KNoCapability, KHWRMSidOnlyPolicy ) ); |
|
98 User::LeaveIfError( iChargingStatusProp.Attach( KPSUidHWRMPowerState, |
|
99 KHWRMChargingStatus ) ); |
|
100 |
|
101 // Get plugin instance |
|
102 iPlugin = CHWRMPowerStatePlugin::NewL( this ); |
|
103 |
|
104 COMPONENT_TRACE1(_L("HWRM Server - CHWRMPowerStatePluginHandler::ConstructL - return") ); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CHWRMPowerStatePluginHandler::NewL |
|
109 // Two-phased constructor. |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 CHWRMPowerStatePluginHandler* CHWRMPowerStatePluginHandler::NewL(TBool aChargerBlockVibra, |
|
113 TBool aChargerBlockFeedbackVibration) |
|
114 { |
|
115 COMPONENT_TRACE1(_L("HWRM Server - CHWRMPowerStatePluginHandler::NewL()") ); |
|
116 |
|
117 CHWRMPowerStatePluginHandler* self = new( ELeave ) |
|
118 CHWRMPowerStatePluginHandler(aChargerBlockVibra, aChargerBlockFeedbackVibration); |
|
119 CleanupStack::PushL( self ); |
|
120 self->ConstructL(); |
|
121 CleanupStack::Pop(); |
|
122 |
|
123 COMPONENT_TRACE2(_L("HWRM Server - CHWRMPowerStatePluginHandler::NewL - return 0x%x"), self ); |
|
124 |
|
125 return self; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // Destructor |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 CHWRMPowerStatePluginHandler::~CHWRMPowerStatePluginHandler() |
|
133 { |
|
134 COMPONENT_TRACE1(_L("HWRM Server - CHWRMPowerStatePluginHandler::~CHWRMPowerStatePluginHandler()") ); |
|
135 |
|
136 // delete the plugin |
|
137 delete iPlugin; |
|
138 |
|
139 // close the P&S properties |
|
140 iBattLevelProp.Close(); |
|
141 iBattStatusProp.Close(); |
|
142 iChargingStatusProp.Close(); |
|
143 |
|
144 COMPONENT_TRACE1(_L("HWRM Server - CHWRMPowerStatePluginHandler::~CHWRMPowerStatePluginHandler - return ") ); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CHWRMPowerStatePluginHandler::NotifyStateChange |
|
149 // Implementation of power state callback method. |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CHWRMPowerStatePluginHandler::NotifyStateChange( const TUint32 aKey, |
|
153 TInt aValue ) |
|
154 { |
|
155 COMPONENT_TRACE3(_L("HWRM Server - CHWRMPowerStatePluginHandler::NotifyStateChangeL(%d, %d)"), aKey, aValue ); |
|
156 |
|
157 // update P&S key with the new values |
|
158 switch( aKey ) |
|
159 { |
|
160 case KHWRMBatteryLevel: |
|
161 { |
|
162 COMPONENT_TRACE2(_L("HWRM Server - KHWRMBatteryLevel key value=%d"), aValue ); |
|
163 iBattLevelProp.Set( aValue ); |
|
164 break; |
|
165 } |
|
166 case KHWRMBatteryStatus: |
|
167 { |
|
168 COMPONENT_TRACE2(_L("HWRM Server - KHWRMBatteryStatus key value=%d"), aValue ); |
|
169 iBattStatusProp.Set( aValue ); |
|
170 break; |
|
171 } |
|
172 case KHWRMChargingStatus: |
|
173 { |
|
174 COMPONENT_TRACE2(_L("HWRM Server - KHWRMChargingStatus key value=%d"), aValue ); |
|
175 iChargingStatusProp.Set( aValue ); |
|
176 if ( iChargerBlockVibra || iChargerBlockVibraFeedback ) |
|
177 { |
|
178 if ( aValue == EChargingStatusCharging || |
|
179 aValue == EChargingStatusNotCharging || |
|
180 aValue == EChargingStatusAlmostComplete || |
|
181 aValue == EChargingStatusChargingComplete || |
|
182 aValue == EChargingStatusChargingContinued ) |
|
183 { |
|
184 RProperty::Set(KPSUidHWRMPrivate, KHWRMInternalVibraBlocked, ETrue); |
|
185 } |
|
186 else |
|
187 { |
|
188 RProperty::Set(KPSUidHWRMPrivate, KHWRMInternalVibraBlocked, EFalse); |
|
189 } |
|
190 } |
|
191 break; |
|
192 } |
|
193 default: |
|
194 break; |
|
195 } |
|
196 |
|
197 COMPONENT_TRACE1(_L("HWRM Server - CHWRMPowerStatePluginHandler::NotifyStateChangeL - return") ); |
|
198 } |
|
199 |
|
200 |
|
201 // End of File |