coreapplicationuis/SysAp/Src/sysapbatteryinfocontroller.cpp
branchRCL_3
changeset 19 924385140d98
parent 3 096dad6e50a9
child 20 c2c61fdca848
equal deleted inserted replaced
18:0818dd463d41 19:924385140d98
    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>
       
    23 #include "bsutil.h"
    22 #include "bsutil.h"
    24 #include <hwrmpowerstatesdkpskeys.h>
    23 #include <hwrmpowerstatesdkpskeys.h>
    25 #include <aknappui.h>
       
    26 #include <AknCapServerClient.h>
       
    27 #include <AknSgcc.h>
       
    28 #include "batterypopupcontrol.h"
       
    29 #include "sysapbatteryinfocontroller.h"
    24 #include "sysapbatteryinfocontroller.h"
    30 #include "SysAp.hrh"
    25 #include "SysAp.hrh"
    31 
    26 
    32 static const TInt KDefaultThreshold = 30;
    27 static const TInt KDefaultThreshold = 30;
    33 static const TInt KNotInitialized = -1;
    28 static const TInt KNotInitialized = -1;
    41 //
    36 //
    42 CSysApBatteryInfoController::CSysApBatteryInfoController( TInt aThreshold) 
    37 CSysApBatteryInfoController::CSysApBatteryInfoController( TInt aThreshold) 
    43                                                         : iBsUtil( NULL ),
    38                                                         : iBsUtil( NULL ),
    44                                                           iCurrentCapacity( KNotInitialized ),
    39                                                           iCurrentCapacity( KNotInitialized ),
    45                                                           iThresholdCapacity( aThreshold  ),
    40                                                           iThresholdCapacity( aThreshold  ),
    46                                                           iBatteryInfoState( EBatteryInfoAboveThreshold ),
    41                                                           iBatteryInfoState( EBatteryInfoAboveThreshold )
    47                                                           iBatteryPopup( NULL )
    42                                                           // iBatteryPopup( NULL )
    48     {
    43     {
    49     // sanity check, fall back to hard coded default value
    44     // sanity check, fall back to hard coded default value
    50     const TInt min(0);
    45     const TInt min(0);
    51     const TInt max(100);
    46     const TInt max(100);
    52     
    47     
    90 //
    85 //
    91 CSysApBatteryInfoController::~CSysApBatteryInfoController()
    86 CSysApBatteryInfoController::~CSysApBatteryInfoController()
    92     {
    87     {
    93     TRACES( RDebug::Print( _L("CSysApBatteryInfoController::~CSysApBatteryInfoController") ) );
    88     TRACES( RDebug::Print( _L("CSysApBatteryInfoController::~CSysApBatteryInfoController") ) );
    94     delete iBsUtil;
    89     delete iBsUtil;
    95     delete iBatteryPopup;
    90     // delete iBatteryPopup;
    96     }
    91     }
    97 
    92 
    98 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
    99 // CSysApBatteryInfoController::PowerMenuShownL
    94 // CSysApBatteryInfoController::PowerMenuShownL
   100 // ---------------------------------------------------------------------------
    95 // ---------------------------------------------------------------------------
   181 
   176 
   182 // ---------------------------------------------------------------------------
   177 // ---------------------------------------------------------------------------
   183 // CSysApBatteryInfoController::ShowBatteryPreviewPopupL
   178 // CSysApBatteryInfoController::ShowBatteryPreviewPopupL
   184 // ---------------------------------------------------------------------------
   179 // ---------------------------------------------------------------------------
   185 //
   180 //
   186 void CSysApBatteryInfoController::ShowBatteryPreviewPopupL( TInt aCapacity )
   181 void CSysApBatteryInfoController::ShowBatteryPreviewPopupL( TInt /* aCapacity */ )
   187     {
   182     {
   188     TRACES( RDebug::Print( _L("CSysApBatteryInfoController::ShowBatteryPreviewPopupL: aCapacity=%d"), aCapacity ) );
   183     // TRACES( RDebug::Print( _L("CSysApBatteryInfoController::ShowBatteryPreviewPopupL: aCapacity=%d"), aCapacity ) );
   189     
   184     
   190     delete iBatteryPopup;
   185     // delete iBatteryPopup;
   191     iBatteryPopup = NULL;
   186     // iBatteryPopup = NULL;
   192     HBufC* popupTextBuf = StringLoader::LoadLC( R_QTN_BATTERY_STATUS_POPUP, aCapacity ); 
   187     // preview battery capacity
   193     iBatteryPopup = CBatteryPopupControl::NewL( *popupTextBuf, KNullDesC );
       
   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     }
   188     }
   220 
   189 
   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         }