systemagentappui.cpp

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C++ 代码 · 共 107 行

CPP
107
字号
/**
* 
* @brief Definition of CSystemAgentAppUi
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "SystemAgentAppUi.h"
#include "SystemAgent.hrh"

// System includes
#include <SystemAgent.rsg>    // R_SYSTEMAGENT_DIALOG

// User includes
#include "SystemAgentDialog.h"    // CSystemAgentDialog
#include "StateVarObserver.h"
#include "SystemAgentDocument.h"

// ================= MEMBER FUNCTIONS =======================

/**
* Symbian OS 2nd phase constructor.  Constructs and executes the application's dialog.
* Creates observers of the state variables which inform the dialog of a change in 
* a state.
*/    
void CSystemAgentAppUi::ConstructL()
{
    BaseConstructL();

    // Create and initialise the dialog
    iAppDialog = new (ELeave) CSystemAgentDialog;
    iAppDialog->SetMopParent(this);
    iAppDialog->ExecuteLD(R_SYSTEMAGENT_DIALOG);
    AddToStackL(iAppDialog);

    // Create observers of state variables
    iSystemAgentVarObserver = CStateVarObserver::NewL(KUidSystemAgentStateVariable, *iAppDialog);
    iInboxVarObserver = CStateVarObserver::NewL(KUidInboxStatus, *iAppDialog);
    iChargerVarObserver = CStateVarObserver::NewL(KUidChargerStatus, *iAppDialog);
    iNetworkStrengthVarObserver = CStateVarObserver::NewL(KUidNetworkStrength, *iAppDialog);

    // Process the initial values of the state variables
    iSystemAgentVarObserver->ProcessCurrentStateL();
    iInboxVarObserver->ProcessCurrentStateL();
    iChargerVarObserver->ProcessCurrentStateL();
    iNetworkStrengthVarObserver->ProcessCurrentStateL();

    // Start monitoring the state variables for changes
    iSystemAgentVarObserver->StartL();
    iInboxVarObserver->StartL();
    iChargerVarObserver->StartL();
    iNetworkStrengthVarObserver->StartL();
}

/**
* Destructor.
* Deletes the state variable observer objects.
* Removes the application's dialog from the stack and deletes it.
*/    
CSystemAgentAppUi::~CSystemAgentAppUi()
{
    delete iSystemAgentVarObserver;
    delete iInboxVarObserver;
    delete iChargerVarObserver;
    delete iNetworkStrengthVarObserver;

    if (iAppDialog)
    {
        RemoveFromStack(iAppDialog);
        delete iAppDialog;
    }
}



/**
* From CAknAppUi, takes care of command handling.
* Handles requests to change our state variable and requests to exit
*
* @param aCommand command to be handled
*/
void CSystemAgentAppUi::HandleCommandL(TInt aCommand)
{
    switch (aCommand)
    {
        case ESystemAgentChangeSystemAgentState:
        {
            CSystemAgentDocument* doc = static_cast<CSystemAgentDocument*>(Document());
            doc->ChangeSystemAgentStateVarL();
            break;
        }
        case EEikCmdExit:
        {
            Exit();
            break;
        }
        default:
            break;
    }
}

// End of File    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?