📄 powerresmanappui.cpp
字号:
/**
*
* Definition of CPowerResManAppUi
*
* Copyright (c) 2004 Nokia Corporation
* version 2.0
*/
// INCLUDE FILES
// Class include
#include "PowerResManAppUi.h"
#include "PowerResMan.hrh"
// System includes
#include <PowerResMan.rsg>
#include <stringloader.h>
#include <aknnotewrappers.h>
#include <sacls.h>
// User includes
#include "PowerResManContainer.h"
#include "StateVarObserver.h"
#include "PowerResManDocument.h"
#include "BackLightSwitch.h"
#include "IntegerSummation.h"
#include "IntegerSummationIdle.h"
#include "IntegerSummationThread.h"
#include "ResManagement.h"
// ================= MEMBER FUNCTIONS =======================
#define KEnableSkinFlag 0x1000
#define KLayoutAwareFlag 0x08
// Symbian OS 2nd phase constructor. Constructs and executes the application's container.
// Creates observers of the state variables which inform the container of a change in
// a state.
void CPowerResManAppUi::ConstructL()
{
#ifdef __SERIES60_3X__
BaseConstructL(EAknEnableSkin);
#else
BaseConstructL(KEnableSkinFlag | KLayoutAwareFlag);
#endif
iAppContainer = new (ELeave) CPowerResManContainer;
iAppContainer->SetMopParent( this );
iAppContainer->ConstructL( ClientRect() );
AddToStackL( iAppContainer );
#ifdef __SERIES60_3X__
iTelephony = CTelephony::NewL();
// Create observers of state variables
iBatteryStrengthVarObserver = CStateVarObserver::NewL(KUidBatteryBars,
*iAppContainer, *iTelephony);
iChargerVarObserver = CStateVarObserver::NewL(KUidChargerStatus,
*iAppContainer, *iTelephony);
iNetworkStrengthVarObserver = CStateVarObserver::NewL(KUidNetworkStrength,
*iAppContainer, *iTelephony);
#else
iBatteryStrengthVarObserver = CStateVarObserver::NewL(KUidBatteryBars,
*iAppContainer);
iChargerVarObserver = CStateVarObserver::NewL(KUidChargerStatus,
*iAppContainer);
iNetworkStrengthVarObserver = CStateVarObserver::NewL(KUidNetworkStrength,
*iAppContainer);
#endif
// Process the initial values of the state variables
iBatteryStrengthVarObserver->ProcessCurrentStateL();
iChargerVarObserver->ProcessCurrentStateL();
iNetworkStrengthVarObserver->ProcessCurrentStateL();
// Start monitoring the state variables for changes
iBatteryStrengthVarObserver->StartL();
iChargerVarObserver->StartL();
iNetworkStrengthVarObserver->StartL();
iBackLightSwitch = CBackLightSwitch::NewL();
iSum = CIntegerSummation::NewL(*this);
iSumIdle = CIntegerSummationIdle::NewL(*this);
iSumThread = CIntegerSummationThread::NewL(*this);
iResMan = CResManagement::NewL();
}
CPowerResManAppUi::~CPowerResManAppUi()
{
//observers must be deleted before iTelephony
delete iBatteryStrengthVarObserver;
delete iChargerVarObserver;
delete iNetworkStrengthVarObserver;
delete iBackLightSwitch;
delete iSum;
delete iSumIdle;
delete iSumThread;
delete iResMan;
if (iAppContainer)
{
RemoveFromStack(iAppContainer);
delete iAppContainer;
}
#ifdef __SERIES60_3X__
delete iTelephony;
#endif
}
// From CAknAppUi, takes care of command handling.
// Handles requests from the menu
void CPowerResManAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case ESystemAgentBacklightState:
iBackLightSwitch->ChangeStateL();
break;
case ESum:
iSum->StartSum();
break;
case ESumIdle:
iSumIdle->StartSumL();
break;
case ESumThread:
iSumThread->StartSum();
break;
case EScoping:
iResMan->ScopingImplementedL();
break;
case ENoScoping:
iResMan->ScopingNotImplementedL();
break;
case ETParsePtrC:
iResMan->ConstructFileNameL();
break;
case EAknSoftkeyExit:
case EEikCmdExit:
{
Exit();
break;
}
default:
break;
}
}
// Called when the summation is complete - non-leaving
void CPowerResManAppUi::SummationComplete(TInt aFinalValue)
{
// Calls (& traps) a potentially leaving function to display
// user notification that summation in complete.
TRAPD(err, SummationCompleteL(aFinalValue));
if(err)
{
// Decide the appropriate course of action
// if an error occurs
}
}
// Display the result of the summation in a note
void CPowerResManAppUi::SummationCompleteL(TInt aFinalValue) const
{
HBufC* noteText;
noteText = StringLoader::LoadLC(R_SUMMATION_TEXT);
noteText = noteText->ReAllocL(noteText->Length() + 20);
CleanupStack::Pop();
CleanupStack::PushL(noteText);
TPtr text = noteText->Des();
text.AppendNum(aFinalValue);
CAknInformationNote* note = new(ELeave)CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
void CPowerResManAppUi::HandleResourceChangeL(TInt aType)
{
CAknAppUi::HandleResourceChangeL(aType); //call to upper class
// ADDED FOR SCALABLE UI SUPPORT
// *****************************
//if ( aType == KEikDynamicLayoutVariantSwitch )
//hardcoded constant so it can be compiled with 1st edition
if ( aType == 0x101F8121 )
{
iAppContainer->SetRect( ClientRect() );
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -