17 |
17 |
18 |
18 |
19 #include <e32debug.h> |
19 #include <e32debug.h> |
20 #include <e32property.h> |
20 #include <e32property.h> |
21 #include <StringLoader.h> |
21 #include <StringLoader.h> |
|
22 #include <SysAp.rsg> |
22 #include "bsutil.h" |
23 #include "bsutil.h" |
23 #include <hwrmpowerstatesdkpskeys.h> |
24 #include <hwrmpowerstatesdkpskeys.h> |
|
25 #include <aknappui.h> |
|
26 #include <AknCapServerClient.h> |
|
27 #include <AknSgcc.h> |
|
28 #include "batterypopupcontrol.h" |
24 #include "sysapbatteryinfocontroller.h" |
29 #include "sysapbatteryinfocontroller.h" |
25 #include "SysAp.hrh" |
30 #include "SysAp.hrh" |
26 |
31 |
27 static const TInt KDefaultThreshold = 30; |
32 static const TInt KDefaultThreshold = 30; |
28 static const TInt KNotInitialized = -1; |
33 static const TInt KNotInitialized = -1; |
36 // |
41 // |
37 CSysApBatteryInfoController::CSysApBatteryInfoController( TInt aThreshold) |
42 CSysApBatteryInfoController::CSysApBatteryInfoController( TInt aThreshold) |
38 : iBsUtil( NULL ), |
43 : iBsUtil( NULL ), |
39 iCurrentCapacity( KNotInitialized ), |
44 iCurrentCapacity( KNotInitialized ), |
40 iThresholdCapacity( aThreshold ), |
45 iThresholdCapacity( aThreshold ), |
41 iBatteryInfoState( EBatteryInfoAboveThreshold ) |
46 iBatteryInfoState( EBatteryInfoAboveThreshold ), |
42 // iBatteryPopup( NULL ) |
47 iBatteryPopup( NULL ) |
43 { |
48 { |
44 // sanity check, fall back to hard coded default value |
49 // sanity check, fall back to hard coded default value |
45 const TInt min(0); |
50 const TInt min(0); |
46 const TInt max(100); |
51 const TInt max(100); |
47 |
52 |
85 // |
90 // |
86 CSysApBatteryInfoController::~CSysApBatteryInfoController() |
91 CSysApBatteryInfoController::~CSysApBatteryInfoController() |
87 { |
92 { |
88 TRACES( RDebug::Print( _L("CSysApBatteryInfoController::~CSysApBatteryInfoController") ) ); |
93 TRACES( RDebug::Print( _L("CSysApBatteryInfoController::~CSysApBatteryInfoController") ) ); |
89 delete iBsUtil; |
94 delete iBsUtil; |
90 // delete iBatteryPopup; |
95 delete iBatteryPopup; |
91 } |
96 } |
92 |
97 |
93 // --------------------------------------------------------------------------- |
98 // --------------------------------------------------------------------------- |
94 // CSysApBatteryInfoController::PowerMenuShownL |
99 // CSysApBatteryInfoController::PowerMenuShownL |
95 // --------------------------------------------------------------------------- |
100 // --------------------------------------------------------------------------- |
176 |
181 |
177 // --------------------------------------------------------------------------- |
182 // --------------------------------------------------------------------------- |
178 // CSysApBatteryInfoController::ShowBatteryPreviewPopupL |
183 // CSysApBatteryInfoController::ShowBatteryPreviewPopupL |
179 // --------------------------------------------------------------------------- |
184 // --------------------------------------------------------------------------- |
180 // |
185 // |
181 void CSysApBatteryInfoController::ShowBatteryPreviewPopupL( TInt /* aCapacity */ ) |
186 void CSysApBatteryInfoController::ShowBatteryPreviewPopupL( TInt aCapacity ) |
182 { |
187 { |
183 // TRACES( RDebug::Print( _L("CSysApBatteryInfoController::ShowBatteryPreviewPopupL: aCapacity=%d"), aCapacity ) ); |
188 TRACES( RDebug::Print( _L("CSysApBatteryInfoController::ShowBatteryPreviewPopupL: aCapacity=%d"), aCapacity ) ); |
184 |
189 |
185 // delete iBatteryPopup; |
190 delete iBatteryPopup; |
186 // iBatteryPopup = NULL; |
191 iBatteryPopup = NULL; |
187 // preview battery capacity |
192 HBufC* popupTextBuf = StringLoader::LoadLC( R_QTN_BATTERY_STATUS_POPUP, aCapacity ); |
188 } |
193 iBatteryPopup = CBatteryPopupControl::NewL( *popupTextBuf, KNullDesC ); |
189 |
194 CleanupStack::PopAndDestroy( popupTextBuf ); |
|
195 |
|
196 // switch layout for showing the battery popup |
|
197 CAknAppUi* appUi = static_cast<CAknAppUi*>(CCoeEnv::Static()->AppUi()); |
|
198 CEikStatusPane* statusPane = appUi->StatusPane(); |
|
199 |
|
200 TInt currLayout = statusPane->CurrentLayoutResId(); |
|
201 |
|
202 RAknUiServer* aknSrv = CAknSgcClient::AknSrv(); |
|
203 if ( aknSrv ) |
|
204 { |
|
205 statusPane->SwitchLayoutL( aknSrv->StatusPaneResourceId() ); |
|
206 } |
|
207 // Trap for switching layout back to current. |
|
208 TRAPD( err, iBatteryPopup->ShowPopUpL() ); |
|
209 |
|
210 if( err ) |
|
211 { |
|
212 TRACES( RDebug::Print( _L("CSysApBatteryInfoController::ShowBatteryPreviewPopupL ShowPopUpL() leaved: %d"), err ) ); |
|
213 } |
|
214 |
|
215 // restore layout |
|
216 statusPane->SwitchLayoutL( currLayout ); |
|
217 |
|
218 User::LeaveIfError( err ); |
|
219 } |
|
220 |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CSysApBatteryInfoController::IsBatteryInfoAboveThreshold |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 TBool CSysApBatteryInfoController::IsBatteryInfoAboveThreshold() const |
|
227 { |
|
228 TInt capacity = iBsUtil->GetBatteryCapacity(); |
|
229 return ((capacity <= iThresholdCapacity ? EBatteryInfoBelowThreshold : EBatteryInfoAboveThreshold) == EBatteryInfoAboveThreshold); |
|
230 } |